@Test public void testNotifyListeners() { WearWifiMediatorSettings.SettingsObserver obs = mWifiSettings.getSettingsObserver(); Settings.System.putInt(cr, ENABLE_WIFI_WHEN_CHARGING_KEY, 0); obs.onChange(false, Settings.System.getUriFor(ENABLE_WIFI_WHEN_CHARGING_KEY)); verify(mockListener).onEnableWifiWhileChargingChanged(false); reset(mockListener); Settings.Global.putInt(cr, DISABLE_WIFI_MEDIATOR_KEY, 1); obs.onChange(false, Settings.Global.getUriFor(DISABLE_WIFI_MEDIATOR_KEY)); verify(mockListener).onDisableWifiMediatorChanged(true); reset(mockListener); Settings.System.putInt(cr, IN_WIFI_SETTINGS_KEY, 1); obs.onChange(false, Settings.System.getUriFor(IN_WIFI_SETTINGS_KEY)); verify(mockListener).onInWifiSettingsMenuChanged(true); reset(mockListener); Settings.System.putString(cr, WIFI_SETTING_KEY, WIFI_SETTING_OFF); obs.onChange(false, Settings.System.getUriFor(WIFI_SETTING_KEY)); verify(mockListener).onWifiSettingChanged(WIFI_SETTING_OFF); reset(mockListener); Settings.Global.putInt(cr, HW_LOW_POWER_MODE_KEY, 1); obs.onChange(false, Settings.Global.getUriFor(HW_LOW_POWER_MODE_KEY)); verify(mockListener).onHardwareLowPowerModeChanged(true); reset(mockListener); Settings.Global.putInt(cr, Settings.Global.WIFI_ON_WHEN_PROXY_DISCONNECTED, 0); obs.onChange(false, Settings.Global.getUriFor( Settings.Global.WIFI_ON_WHEN_PROXY_DISCONNECTED)); verify(mockListener).onWifiOnWhenProxyDisconnectedChanged(false); reset(mockListener); }
@VisibleForTesting SettingsObserver getSettingsObserver() { return mSettingsObserver; }
WearWifiMediatorSettings { @VisibleForTesting SettingsObserver getSettingsObserver() { return mSettingsObserver; } }
WearWifiMediatorSettings { @VisibleForTesting SettingsObserver getSettingsObserver() { return mSettingsObserver; } WearWifiMediatorSettings(ContentResolver contentResolver); }
WearWifiMediatorSettings { @VisibleForTesting SettingsObserver getSettingsObserver() { return mSettingsObserver; } WearWifiMediatorSettings(ContentResolver contentResolver); void addListener(Listener listener); boolean getWifiOnWhenProxyDisconnected(); boolean getIsInAirplaneMode(); String getWifiSetting(); void putWifiSetting(String wifiSetting); boolean getInWifiSettings(); boolean getEnableWifiWhileCharging(); boolean getDisableWifiMediator(); boolean getHardwareLowPowerMode(); String updateWifiSettingOnAirplaneModeChange(String currentWifiSetting, boolean airplaneModeOn); }
WearWifiMediatorSettings { @VisibleForTesting SettingsObserver getSettingsObserver() { return mSettingsObserver; } WearWifiMediatorSettings(ContentResolver contentResolver); void addListener(Listener listener); boolean getWifiOnWhenProxyDisconnected(); boolean getIsInAirplaneMode(); String getWifiSetting(); void putWifiSetting(String wifiSetting); boolean getInWifiSettings(); boolean getEnableWifiWhileCharging(); boolean getDisableWifiMediator(); boolean getHardwareLowPowerMode(); String updateWifiSettingOnAirplaneModeChange(String currentWifiSetting, boolean airplaneModeOn);  }