MetricNamesGenerator { public String getBytesUploadedMetricName(boolean isInBackground) { return MetricRegistry.name( appendCrossMetricInfo(NETWORK + SEPARATOR + BYTES_UPLOADED, 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 bytesUploadedMetricShouldContainExactly11FieldsSeparatedByDots() { String bytesUploaded = generator.getBytesUploadedMetricName(ANY_IN_IN_BACKGROUND_VALUE); assertEquals(12, MetricNameUtils.split(bytesUploaded).length); }
@Test public void bytesUploadedShouldContainTheCrossMetricInfoInTheName() { String bytesUploaded = generator.getBytesUploadedMetricName(ANY_IN_IN_BACKGROUND_VALUE); assertContainsCrossMetricInfoName(bytesUploaded); }
@Test public void bytesUploadedContainsTheMetricNameInTheCorrectPosition() { String bytesUploaded = generator.getBytesUploadedMetricName(ANY_IN_IN_BACKGROUND_VALUE); String[] parts = MetricNameUtils.split(bytesUploaded); assertEquals("network", parts[10]); assertEquals("bytesUploaded", parts[11]); }
@Test public void identifiesABytesUploadedMetricProperly() { String bytesUploaded = generator.getBytesUploadedMetricName(ANY_IN_IN_BACKGROUND_VALUE); assertTrue(extractor.isBytesUploadedMetric(bytesUploaded)); }
@Test public void doesNotIdentifyABytesUploadedMetricAsABytesDownloaded() { String bytesUploaded = generator.getBytesUploadedMetricName(ANY_IN_IN_BACKGROUND_VALUE); assertFalse(extractor.isBytesDownloadedMetric(bytesUploaded)); }