MetricNamesGenerator { public String getBytesAllocatedMetricName(boolean forBackground) { return MetricRegistry.name( appendCrossMetricInfo(MEMORY + SEPARATOR + BYTES_ALLOCATED, forBackground)); } MetricNamesGenerator(App app, Device device, Time time); String getFrameTimeMetricName(Activity activity); String getOnActivityCreatedMetricName(Activity activity); String getOnActivityStartedMetricName(Activity activity); String getOnActivityResumedMetricName(Activity activity); String getActivityVisibleMetricName(Activity activity); String getOnActivityPausedMetricName(Activity activity); String getOnActivityStoppedMetricName(Activity activity); String getOnActivityDestroyedMetricName(Activity activity); String getBytesDownloadedMetricName(boolean isInBackground); String getBytesUploadedMetricName(boolean isInBackground); String getCPUUsageMetricName(boolean isInBackground); String getMemoryUsageMetricName(boolean forBackground); String getBytesAllocatedMetricName(boolean forBackground); String getInternalStorageWrittenBytes(boolean isInBackground); String getSharedPreferencesWrittenBytes(boolean isInBackground);  }
@Test public void doesNotIdentifyABytesAllocatedMetricAsMemoryUsage() { String bytesAllocated = generator.getBytesAllocatedMetricName(ANY_IN_IN_BACKGROUND_VALUE); assertFalse(extractor.isMemoryUsageMetric(bytesAllocated)); }
@Test public void bytesAllocatedMetricNameShouldContainExactly11FieldsSeparatedByDots() { String bytesAllocated = generator.getBytesAllocatedMetricName(ANY_IN_IN_BACKGROUND_VALUE); assertEquals(12, MetricNameUtils.split(bytesAllocated).length); }
@Test public void bytesAllocatedUsageUsageMetricNameShouldContainTheCrossMetricInfoName() { String bytesAllocated = generator.getBytesAllocatedMetricName(ANY_IN_IN_BACKGROUND_VALUE); assertContainsCrossMetricInfoName(bytesAllocated); }
@Test public void bytesAllocatedUsageContainsTheMetricNameInTheCorrectPosition() { String bytesAllocated = generator.getBytesAllocatedMetricName(ANY_IN_IN_BACKGROUND_VALUE); String[] parts = MetricNameUtils.split(bytesAllocated); assertEquals("bytesAllocated", parts[11]); }
@Test public void identifiesABytesAllocatedMetricProperly() { String bytesAllocated = generator.getBytesAllocatedMetricName(ANY_IN_IN_BACKGROUND_VALUE); assertTrue(extractor.isBytesAllocatedMetric(bytesAllocated)); }