Loading src/com/android/settings/network/NetworkProviderSettings.java +3 −1 Original line number Diff line number Diff line Loading @@ -566,7 +566,9 @@ public class NetworkProviderSettings extends RestrictedSettingsFragment } if (mSelectedWifiEntry.canDisconnect()) { if (mSelectedWifiEntry.canShare()) { menu.add(Menu.NONE, MENU_ID_SHARE, 0 /* order */, R.string.share); } menu.add(Menu.NONE, MENU_ID_DISCONNECT, 1 /* order */, R.string.wifi_disconnect_button_text); } Loading tests/robotests/src/com/android/settings/network/NetworkProviderSettingsTest.java +49 −0 Original line number Diff line number Diff line Loading @@ -328,6 +328,55 @@ public class NetworkProviderSettingsTest { anyInt()); } @Test public void onCreateContextMenu_canShare_shouldHaveShareMenuForConnectedWifiEntry() { final FragmentActivity activity = mock(FragmentActivity.class); when(activity.getApplicationContext()).thenReturn(mContext); when(mNetworkProviderSettings.getActivity()).thenReturn(activity); final WifiEntry wifiEntry = mock(WifiEntry.class); when(wifiEntry.canDisconnect()).thenReturn(true); when(wifiEntry.canShare()).thenReturn(true); when(wifiEntry.canForget()).thenReturn(true); when(wifiEntry.isSaved()).thenReturn(true); when(wifiEntry.getConnectedState()).thenReturn(WifiEntry.CONNECTED_STATE_CONNECTED); final LongPressWifiEntryPreference connectedWifiEntryPreference = mNetworkProviderSettings.createLongPressWifiEntryPreference(wifiEntry); final View view = mock(View.class); when(view.getTag()).thenReturn(connectedWifiEntryPreference); final ContextMenu menu = mock(ContextMenu.class); mNetworkProviderSettings.onCreateContextMenu(menu, view, null /* info */); verify(menu).add(anyInt(), eq(NetworkProviderSettings.MENU_ID_SHARE), anyInt(), anyInt()); } @Test public void onCreateContextMenu_canNotShare_shouldDisappearShareMenuForConnectedWifiEntry() { final FragmentActivity activity = mock(FragmentActivity.class); when(activity.getApplicationContext()).thenReturn(mContext); when(mNetworkProviderSettings.getActivity()).thenReturn(activity); final WifiEntry wifiEntry = mock(WifiEntry.class); when(wifiEntry.canDisconnect()).thenReturn(true); when(wifiEntry.canShare()).thenReturn(false); when(wifiEntry.canForget()).thenReturn(true); when(wifiEntry.isSaved()).thenReturn(true); when(wifiEntry.getConnectedState()).thenReturn(WifiEntry.CONNECTED_STATE_CONNECTED); final LongPressWifiEntryPreference connectedWifiEntryPreference = mNetworkProviderSettings.createLongPressWifiEntryPreference(wifiEntry); final View view = mock(View.class); when(view.getTag()).thenReturn(connectedWifiEntryPreference); final ContextMenu menu = mock(ContextMenu.class); mNetworkProviderSettings.onCreateContextMenu(menu, view, null /* info */); verify(menu, never()) .add(anyInt(), eq(NetworkProviderSettings.MENU_ID_SHARE), anyInt(), anyInt()); } @Test public void onWifiEntriesChanged_shouldChangeNextButtonState() { mNetworkProviderSettings.onWifiEntriesChanged(); Loading Loading
src/com/android/settings/network/NetworkProviderSettings.java +3 −1 Original line number Diff line number Diff line Loading @@ -566,7 +566,9 @@ public class NetworkProviderSettings extends RestrictedSettingsFragment } if (mSelectedWifiEntry.canDisconnect()) { if (mSelectedWifiEntry.canShare()) { menu.add(Menu.NONE, MENU_ID_SHARE, 0 /* order */, R.string.share); } menu.add(Menu.NONE, MENU_ID_DISCONNECT, 1 /* order */, R.string.wifi_disconnect_button_text); } Loading
tests/robotests/src/com/android/settings/network/NetworkProviderSettingsTest.java +49 −0 Original line number Diff line number Diff line Loading @@ -328,6 +328,55 @@ public class NetworkProviderSettingsTest { anyInt()); } @Test public void onCreateContextMenu_canShare_shouldHaveShareMenuForConnectedWifiEntry() { final FragmentActivity activity = mock(FragmentActivity.class); when(activity.getApplicationContext()).thenReturn(mContext); when(mNetworkProviderSettings.getActivity()).thenReturn(activity); final WifiEntry wifiEntry = mock(WifiEntry.class); when(wifiEntry.canDisconnect()).thenReturn(true); when(wifiEntry.canShare()).thenReturn(true); when(wifiEntry.canForget()).thenReturn(true); when(wifiEntry.isSaved()).thenReturn(true); when(wifiEntry.getConnectedState()).thenReturn(WifiEntry.CONNECTED_STATE_CONNECTED); final LongPressWifiEntryPreference connectedWifiEntryPreference = mNetworkProviderSettings.createLongPressWifiEntryPreference(wifiEntry); final View view = mock(View.class); when(view.getTag()).thenReturn(connectedWifiEntryPreference); final ContextMenu menu = mock(ContextMenu.class); mNetworkProviderSettings.onCreateContextMenu(menu, view, null /* info */); verify(menu).add(anyInt(), eq(NetworkProviderSettings.MENU_ID_SHARE), anyInt(), anyInt()); } @Test public void onCreateContextMenu_canNotShare_shouldDisappearShareMenuForConnectedWifiEntry() { final FragmentActivity activity = mock(FragmentActivity.class); when(activity.getApplicationContext()).thenReturn(mContext); when(mNetworkProviderSettings.getActivity()).thenReturn(activity); final WifiEntry wifiEntry = mock(WifiEntry.class); when(wifiEntry.canDisconnect()).thenReturn(true); when(wifiEntry.canShare()).thenReturn(false); when(wifiEntry.canForget()).thenReturn(true); when(wifiEntry.isSaved()).thenReturn(true); when(wifiEntry.getConnectedState()).thenReturn(WifiEntry.CONNECTED_STATE_CONNECTED); final LongPressWifiEntryPreference connectedWifiEntryPreference = mNetworkProviderSettings.createLongPressWifiEntryPreference(wifiEntry); final View view = mock(View.class); when(view.getTag()).thenReturn(connectedWifiEntryPreference); final ContextMenu menu = mock(ContextMenu.class); mNetworkProviderSettings.onCreateContextMenu(menu, view, null /* info */); verify(menu, never()) .add(anyInt(), eq(NetworkProviderSettings.MENU_ID_SHARE), anyInt(), anyInt()); } @Test public void onWifiEntriesChanged_shouldChangeNextButtonState() { mNetworkProviderSettings.onWifiEntriesChanged(); Loading