@Test @Override public void testSum() throws Exception { AppWakeupMetrics a = getAppWakeupMetrics(4, 0); AppWakeupMetrics b = getAppWakeupMetrics(7, 10); AppWakeupMetrics output = new AppWakeupMetrics(); a.sum(b, output); assertThat(output.appWakeups.size()).isEqualTo(7); verifyKeyAndReason(output.appWakeups); verifyWakeupDetails(output.appWakeups.valueAt(0), 10, 12); verifyWakeupDetails(output.appWakeups.valueAt(1), 12, 14); verifyWakeupDetails(output.appWakeups.valueAt(2), 14, 16); verifyWakeupDetails(output.appWakeups.valueAt(3), 16, 18); verifyWakeupDetails(output.appWakeups.valueAt(4), 14, 15); verifyWakeupDetails(output.appWakeups.valueAt(5), 15, 16); verifyWakeupDetails(output.appWakeups.valueAt(6), 16, 17); }
@Override public AppWakeupMetrics sum(@Nullable AppWakeupMetrics b, @Nullable AppWakeupMetrics output) { if (output == null) { output = new AppWakeupMetrics(); } if (b == null) { output.set(this); } else { output.appWakeups.clear(); for (int i = 0; i < appWakeups.size(); i++) { String tag = appWakeups.keyAt(i); output.appWakeups.put(tag, new WakeupDetails(appWakeups.valueAt(i).reason)); appWakeups.valueAt(i).sum(b.appWakeups.get(tag), output.appWakeups.get(tag)); } for (int i = 0; i < b.appWakeups.size(); i++) { String tag = b.appWakeups.keyAt(i); if (!output.appWakeups.containsKey(tag)) { output.appWakeups.put(tag, b.appWakeups.valueAt(i)); } } } return output; }
AppWakeupMetrics extends SystemMetrics<AppWakeupMetrics> { @Override public AppWakeupMetrics sum(@Nullable AppWakeupMetrics b, @Nullable AppWakeupMetrics output) { if (output == null) { output = new AppWakeupMetrics(); } if (b == null) { output.set(this); } else { output.appWakeups.clear(); for (int i = 0; i < appWakeups.size(); i++) { String tag = appWakeups.keyAt(i); output.appWakeups.put(tag, new WakeupDetails(appWakeups.valueAt(i).reason)); appWakeups.valueAt(i).sum(b.appWakeups.get(tag), output.appWakeups.get(tag)); } for (int i = 0; i < b.appWakeups.size(); i++) { String tag = b.appWakeups.keyAt(i); if (!output.appWakeups.containsKey(tag)) { output.appWakeups.put(tag, b.appWakeups.valueAt(i)); } } } return output; } }
AppWakeupMetrics extends SystemMetrics<AppWakeupMetrics> { @Override public AppWakeupMetrics sum(@Nullable AppWakeupMetrics b, @Nullable AppWakeupMetrics output) { if (output == null) { output = new AppWakeupMetrics(); } if (b == null) { output.set(this); } else { output.appWakeups.clear(); for (int i = 0; i < appWakeups.size(); i++) { String tag = appWakeups.keyAt(i); output.appWakeups.put(tag, new WakeupDetails(appWakeups.valueAt(i).reason)); appWakeups.valueAt(i).sum(b.appWakeups.get(tag), output.appWakeups.get(tag)); } for (int i = 0; i < b.appWakeups.size(); i++) { String tag = b.appWakeups.keyAt(i); if (!output.appWakeups.containsKey(tag)) { output.appWakeups.put(tag, b.appWakeups.valueAt(i)); } } } return output; }  }
AppWakeupMetrics extends SystemMetrics<AppWakeupMetrics> { @Override public AppWakeupMetrics sum(@Nullable AppWakeupMetrics b, @Nullable AppWakeupMetrics output) { if (output == null) { output = new AppWakeupMetrics(); } if (b == null) { output.set(this); } else { output.appWakeups.clear(); for (int i = 0; i < appWakeups.size(); i++) { String tag = appWakeups.keyAt(i); output.appWakeups.put(tag, new WakeupDetails(appWakeups.valueAt(i).reason)); appWakeups.valueAt(i).sum(b.appWakeups.get(tag), output.appWakeups.get(tag)); } for (int i = 0; i < b.appWakeups.size(); i++) { String tag = b.appWakeups.keyAt(i); if (!output.appWakeups.containsKey(tag)) { output.appWakeups.put(tag, b.appWakeups.valueAt(i)); } } } return output; }  @Override AppWakeupMetrics set(AppWakeupMetrics metrics); @Override AppWakeupMetrics sum(@Nullable AppWakeupMetrics b, @Nullable AppWakeupMetrics output); @Override AppWakeupMetrics diff(@Nullable AppWakeupMetrics b, @Nullable AppWakeupMetrics output); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); JSONArray toJSON(); }
AppWakeupMetrics extends SystemMetrics<AppWakeupMetrics> { @Override public AppWakeupMetrics sum(@Nullable AppWakeupMetrics b, @Nullable AppWakeupMetrics output) { if (output == null) { output = new AppWakeupMetrics(); } if (b == null) { output.set(this); } else { output.appWakeups.clear(); for (int i = 0; i < appWakeups.size(); i++) { String tag = appWakeups.keyAt(i); output.appWakeups.put(tag, new WakeupDetails(appWakeups.valueAt(i).reason)); appWakeups.valueAt(i).sum(b.appWakeups.get(tag), output.appWakeups.get(tag)); } for (int i = 0; i < b.appWakeups.size(); i++) { String tag = b.appWakeups.keyAt(i); if (!output.appWakeups.containsKey(tag)) { output.appWakeups.put(tag, b.appWakeups.valueAt(i)); } } } return output; }  @Override AppWakeupMetrics set(AppWakeupMetrics metrics); @Override AppWakeupMetrics sum(@Nullable AppWakeupMetrics b, @Nullable AppWakeupMetrics output); @Override AppWakeupMetrics diff(@Nullable AppWakeupMetrics b, @Nullable AppWakeupMetrics output); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); JSONArray toJSON(); public SimpleArrayMap<String, WakeupDetails> appWakeups; }