ScreenTrackingEvent extends Event { @NonNull @Override @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) public final JsonMap getEventData() { return JsonMap.newBuilder() .put(SCREEN_KEY, screen) .put(START_TIME_KEY, Event.millisecondsToSecondsString(startTime)) .put(STOP_TIME_KEY, Event.millisecondsToSecondsString(stopTime)) .put(DURATION_KEY, Event.millisecondsToSecondsString(stopTime - startTime)) .put(PREVIOUS_SCREEN_KEY, previousScreen) .build(); } ScreenTrackingEvent(@NonNull String screen, @Nullable String previousScreen, long startTime, long stopTime); @Override boolean isValid(); @NonNull @Override String getType(); @NonNull @Override @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) final JsonMap getEventData();  }
@Test public void testScreenTrackingEventData() throws JsonException { String screen = "test_screen"; ScreenTrackingEvent event = new ScreenTrackingEvent(screen, "previous_screen", 0, 1); JsonValue expected = JsonValue.parseString("{\"screen\":\"test_screen\",\"duration\":\"0.001\",\"exited_time\"" + ":\"0.001\",\"previous_screen\":\"previous_screen\",\"entered_time\":\"0.000\"}"); Assert.assertEquals(expected.getMap(), event.getEventData()); }