### Question:
PowerTracker { public boolean isInPowerSave() { return mPowerManager.isPowerSaveMode(); } PowerTracker(Context context, PowerManager powerManager); void onBootCompleted(); void addListener(Listener listener); boolean isInPowerSave(); boolean isCharging(); boolean isDeviceIdle(); void dump(IndentingPrintWriter ipw);  }### Answer:
@Test public void testPowerSaveMode() { when(mockPowerManager.isPowerSaveMode()).thenReturn(true); shadowApplication.sendBroadcast(new Intent(PowerManager.ACTION_POWER_SAVE_MODE_CHANGED)); Assert.assertTrue(powerTracker.isInPowerSave()); verify(mockListener).onPowerSaveModeChanged(); reset(mockListener); when(mockPowerManager.isPowerSaveMode()).thenReturn(false); shadowApplication.sendBroadcast(new Intent(PowerManager.ACTION_POWER_SAVE_MODE_CHANGED)); Assert.assertFalse(powerTracker.isInPowerSave()); verify(mockListener).onPowerSaveModeChanged(); }
@Test public void testPowerSaveMode() { when(mockPowerManager.isPowerSaveMode()).thenReturn(true); context.sendBroadcast(new Intent(PowerManager.ACTION_POWER_SAVE_MODE_CHANGED)); assertTrue(powerTracker.isInPowerSave()); verify(mockListener).onPowerSaveModeChanged(); reset(mockListener); when(mockPowerManager.isPowerSaveMode()).thenReturn(false); context.sendBroadcast(new Intent(PowerManager.ACTION_POWER_SAVE_MODE_CHANGED)); assertFalse(powerTracker.isInPowerSave()); verify(mockListener).onPowerSaveModeChanged(); }