MetricNamesGenerator { public String getInternalStorageWrittenBytes(boolean isInBackground) { return MetricRegistry.name( appendCrossMetricInfo(DISK + SEPARATOR + INTERNAL_STORAGE_WRITTEN_BYTES, isInBackground)); } 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 internalStorageWrittenBytesMetricNameShouldContainExactly11FieldsSeparatedByDots() { String writtenBytes = generator.getInternalStorageWrittenBytes(ANY_IN_IN_BACKGROUND_VALUE); assertEquals(12, MetricNameUtils.split(writtenBytes).length); }
@Test public void internalStorageWrittenBytesMetricNameShouldContainTheCrossMetricInfoName() { String writtenBytes = generator.getInternalStorageWrittenBytes(ANY_IN_IN_BACKGROUND_VALUE); assertContainsCrossMetricInfoName(writtenBytes); }
@Test public void internalStorageWrittenBytesContainsTheMetricNameInTheCorrectPosition() { String writtenBytes = generator.getInternalStorageWrittenBytes(ANY_IN_IN_BACKGROUND_VALUE); String[] parts = MetricNameUtils.split(writtenBytes); assertEquals("internalStorageWrittenBytes", parts[11]); }
@Test public void identifiesAInternalStorageWrittenBytesMetricProperly() { String writtenBytes = generator.getInternalStorageWrittenBytes(ANY_IN_IN_BACKGROUND_VALUE); assertTrue(extractor.isInternalStorageAllocatedBytesMetric(writtenBytes)); }