### Question:
DefaultPerformanceTiming implements PerformanceTiming { @Override public long getEventValue(PerformanceTimingEvent event) { checkArgument(event, "The event should not be null."); return timePassedUntil(execute(scriptFor(event))); } DefaultPerformanceTiming(WebDriver driver); @Override long getEventValue(PerformanceTimingEvent event); @Override Object secureConnectionStart(); @Override PerformanceTimingMetrics getMetrics();  }### Answer:
@Test public void shouldGetEventValue() { when(((JavascriptExecutor) driver).executeScript(LOAD_EVENT_END_SCRIPT)).thenReturn(45L); when(((JavascriptExecutor) driver).executeScript(NAVIGATION_START_SCRIPT)).thenReturn(28L); assertThat(performanceTiming.getEventValue(PerformanceTimingEvent.LOAD_EVENT_END)).isEqualTo(17L); verify(((JavascriptExecutor) driver)).executeScript(LOAD_EVENT_END_SCRIPT); verify(((JavascriptExecutor) driver)).executeScript(NAVIGATION_START_SCRIPT); verifyNoMoreInteractions(driver); }
@Test public void shouldReturnNegativeValueIfEventHasNotBeenRegistered() { when(((JavascriptExecutor) driver).executeScript(LOAD_EVENT_END_SCRIPT)).thenReturn(0L); when(((JavascriptExecutor) driver).executeScript(NAVIGATION_START_SCRIPT)).thenReturn(28L); assertThat(performanceTiming.getEventValue(PerformanceTimingEvent.LOAD_EVENT_END)).isEqualTo(-28L); verify(((JavascriptExecutor) driver)).executeScript(LOAD_EVENT_END_SCRIPT); verify(((JavascriptExecutor) driver)).executeScript(NAVIGATION_START_SCRIPT); verifyNoMoreInteractions(driver); }
@Test public void shouldGetEventValueInTimeUnit() { when(((JavascriptExecutor) driver).executeScript(LOAD_EVENT_END_SCRIPT)).thenReturn(60000L); when(((JavascriptExecutor) driver).executeScript(NAVIGATION_START_SCRIPT)).thenReturn(45900L); assertThat(performanceTiming.getEventValue(PerformanceTimingEvent.LOAD_EVENT_END, TimeUnit.MILLISECONDS)) .isEqualTo(14100L); assertThat(performanceTiming.getEventValue(PerformanceTimingEvent.LOAD_EVENT_END, TimeUnit.SECONDS)) .isEqualTo(14L); verify((JavascriptExecutor) driver, times(2)).executeScript(LOAD_EVENT_END_SCRIPT); verify((JavascriptExecutor) driver, times(2)).executeScript(NAVIGATION_START_SCRIPT); verifyNoMoreInteractions(driver); }
@Test public void shouldThrowExceptionForNullEvent() { assertThatIllegalArgumentException().isThrownBy(() -> performanceTiming.getEventValue(null)) .withMessage("The event should not be null."); }