MetricNamesGenerator { public String getFrameTimeMetricName(Activity activity) { String activityName = getActivityName(activity); return MetricRegistry.name(appendCrossMetricInfo( UI + SEPARATOR + FRAME_TIME + SEPARATOR + activityName + SEPARATOR + time.now())); } 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 frameTimeMetricNameShouldContainActivityNameAsScreenName() { String frameTime = generator.getFrameTimeMetricName(activity); String activityName = extractor.getScreenName(frameTime); assertEquals(activityName, activity.getClass().getSimpleName()); }
@Test public void frameTimeMetricNameShouldContainTheGenerationTime() { givenNowIs(ANY_TIMESTAMP); String frameTime = generator.getFrameTimeMetricName(activity); long timestamp = extractor.getTimestamp(frameTime); assertEquals(ANY_TIMESTAMP, timestamp); }
@Test public void frameTimeContainsTheMetricNameInTheCorrectPosition() { String frameTime = generator.getFrameTimeMetricName(activity); String[] parts = MetricNameUtils.split(frameTime); assertEquals("ui", parts[10]); assertEquals("frameTime", parts[11]); }
@Test public void identifiesAFrameTimeMetricProperly() { String frameTime = generator.getFrameTimeMetricName(activity); assertTrue(extractor.isFrameTimeMetric(frameTime)); }
@Test public void frameTimeMetricNameShouldContainExactly13FieldsSeparatedByDots() { String frameTime = generator.getFrameTimeMetricName(activity); assertEquals(14, MetricNameUtils.split(frameTime).length); }
@Test public void frameTimeMetricNameShouldContainTheCrossMetricInfoName() { String frameTime = generator.getFrameTimeMetricName(activity); assertContainsCrossMetricInfoName(frameTime); }