### Question:
TimeOnlyMode implements PowerTracker.Listener { @Override public void onPowerSaveModeChanged() { if (isFeatureSupported()) { for (Listener listener : mListeners) { listener.onTimeOnlyModeChanged(isInTimeOnlyMode()); } } } TimeOnlyMode(Context context);  TimeOnlyMode(ContentResolver contentResolver, PowerTracker powerTracker); void addListener(Listener listener); @Override void onPowerSaveModeChanged(); @Override void onChargingStateChanged(); boolean isInTimeOnlyMode(); boolean isHomeDisabled(); boolean isTiltToWakeDisabled(); boolean isTouchToWakeDisabled(); void registerContentObserver(ContentObserver contentObserver); void unregisterContentObserver(ContentObserver contentObserver);  }### Answer:
@Test public void testTimeOnlyModeListenersGetNotified() { Settings.Global.putString(cr, Settings.Global.TIME_ONLY_MODE_CONSTANTS, timeOnlyModeSettingsString(true, true, true)); when(mockPowerTracker.isInPowerSave()).thenReturn(false); timeOnlyMode.onPowerSaveModeChanged(); verify(mockListener).onTimeOnlyModeChanged(false); reset(mockListener); when(mockPowerTracker.isInPowerSave()).thenReturn(true); timeOnlyMode.onPowerSaveModeChanged(); verify(mockListener).onTimeOnlyModeChanged(true); reset(mockListener); Settings.Global.putString(cr, Settings.Global.TIME_ONLY_MODE_CONSTANTS, timeOnlyModeSettingsString(false, false, false)); when(mockPowerTracker.isInPowerSave()).thenReturn(false); timeOnlyMode.onPowerSaveModeChanged(); when(mockPowerTracker.isInPowerSave()).thenReturn(true); timeOnlyMode.onPowerSaveModeChanged(); verifyNoMoreInteractions(mockListener); }