[Provider Model] Should not show Wi-Fi entries under lockscreen
- If the Internet Panel is showing under lockscreen
- Show "Unlock to view networks" subtitle
- Highlight Wi-Fi toggle if the default network is Wi-Fi
- Hide Wi-Fi entries
- Hide "See all" item
- If the Wi-Fi entries is empty
- Hide Wi-Fi entries
- Hide "See all" item
Bug: 194872708
Bug: 194873442
Bug: 195088254
Test: manual test
atest -c InternetDialogControllerTest \
InternetDialogTest
Change-Id: I40ff3ed0b38d590c0171c654ceaa433ceb0fac59
Merged-In: I40ff3ed0b38d590c0171c654ceaa433ceb0fac59
(cherry picked from commit 08c3dbec32)
This commit is contained in:
@@ -3021,6 +3021,8 @@
|
|||||||
<string name="pref_title_network_details" msgid="7329759534269363308">"Network details"</string>
|
<string name="pref_title_network_details" msgid="7329759534269363308">"Network details"</string>
|
||||||
<!-- Provider Model: Panel subtitle for tapping a network to connect to internet. [CHAR LIMIT=60] -->
|
<!-- Provider Model: Panel subtitle for tapping a network to connect to internet. [CHAR LIMIT=60] -->
|
||||||
<string name="tap_a_network_to_connect">Tap a network to connect</string>
|
<string name="tap_a_network_to_connect">Tap a network to connect</string>
|
||||||
|
<!-- Provider Model: Panel subtitle for unlocking screen to view networks. [CHAR LIMIT=60] -->
|
||||||
|
<string name="unlock_to_view_networks">Unlock to view networks</string>
|
||||||
<!-- Provider Model: Wi-Fi settings. text displayed when Wi-Fi is on and network list is empty [CHAR LIMIT=50]-->
|
<!-- Provider Model: Wi-Fi settings. text displayed when Wi-Fi is on and network list is empty [CHAR LIMIT=50]-->
|
||||||
<string name="wifi_empty_list_wifi_on">Searching for networks\u2026</string>
|
<string name="wifi_empty_list_wifi_on">Searching for networks\u2026</string>
|
||||||
<!-- Provider Model: Failure notification for connect -->
|
<!-- Provider Model: Failure notification for connect -->
|
||||||
|
|||||||
@@ -287,14 +287,22 @@ public class InternetDialog extends SystemUIDialog implements
|
|||||||
}
|
}
|
||||||
showProgressBar();
|
showProgressBar();
|
||||||
setMobileDataLayout(mInternetDialogController.activeNetworkIsCellular());
|
setMobileDataLayout(mInternetDialogController.activeNetworkIsCellular());
|
||||||
setConnectedWifiLayout();
|
|
||||||
boolean isWifiEnabled = mWifiManager.isWifiEnabled();
|
final boolean isDeviceLocked = mInternetDialogController.isDeviceLocked();
|
||||||
mWiFiToggle.setChecked(isWifiEnabled);
|
final boolean isWifiEnabled = mWifiManager.isWifiEnabled();
|
||||||
int visible = isWifiEnabled ? View.VISIBLE : View.GONE;
|
updateWifiToggle(isWifiEnabled, isDeviceLocked);
|
||||||
mWifiRecyclerView.setVisibility(visible);
|
updateConnectedWifi(isWifiEnabled, isDeviceLocked);
|
||||||
mAdapter.notifyDataSetChanged();
|
|
||||||
mSeeAllLayout.setVisibility(visible);
|
List<WifiEntry> wifiEntryList = mInternetDialogController.getWifiEntryList();
|
||||||
mSpace.setVisibility(isWifiEnabled ? View.GONE : View.VISIBLE);
|
final int wifiListVisibility =
|
||||||
|
(isDeviceLocked || wifiEntryList == null || wifiEntryList.size() <= 0)
|
||||||
|
? View.GONE : View.VISIBLE;
|
||||||
|
mWifiRecyclerView.setVisibility(wifiListVisibility);
|
||||||
|
if (wifiListVisibility == View.VISIBLE) {
|
||||||
|
mAdapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
mSeeAllLayout.setVisibility(wifiListVisibility);
|
||||||
|
mSpace.setVisibility(wifiListVisibility == View.VISIBLE ? View.GONE : View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setOnClickListener() {
|
private void setOnClickListener() {
|
||||||
@@ -358,8 +366,14 @@ public class InternetDialog extends SystemUIDialog implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setConnectedWifiLayout() {
|
private void updateWifiToggle(boolean isWifiEnabled, boolean isDeviceLocked) {
|
||||||
if (!mWifiManager.isWifiEnabled() || mConnectedWifiEntry == null) {
|
mWiFiToggle.setChecked(isWifiEnabled);
|
||||||
|
mTurnWifiOnLayout.setBackground(
|
||||||
|
(isDeviceLocked && mConnectedWifiEntry != null) ? mBackgroundOn : null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateConnectedWifi(boolean isWifiEnabled, boolean isDeviceLocked) {
|
||||||
|
if (!isWifiEnabled || mConnectedWifiEntry == null || isDeviceLocked) {
|
||||||
mConnectedWifListLayout.setBackground(null);
|
mConnectedWifListLayout.setBackground(null);
|
||||||
mConnectedWifListLayout.setVisibility(View.GONE);
|
mConnectedWifListLayout.setVisibility(View.GONE);
|
||||||
return;
|
return;
|
||||||
@@ -418,7 +432,8 @@ public class InternetDialog extends SystemUIDialog implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void showProgressBar() {
|
protected void showProgressBar() {
|
||||||
if (mWifiManager == null || !mWifiManager.isWifiEnabled()) {
|
if (mWifiManager == null || !mWifiManager.isWifiEnabled()
|
||||||
|
|| mInternetDialogController.isDeviceLocked()) {
|
||||||
setProgressBarVisible(false);
|
setProgressBarVisible(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ import com.android.systemui.R;
|
|||||||
import com.android.systemui.broadcast.BroadcastDispatcher;
|
import com.android.systemui.broadcast.BroadcastDispatcher;
|
||||||
import com.android.systemui.dagger.qualifiers.Main;
|
import com.android.systemui.dagger.qualifiers.Main;
|
||||||
import com.android.systemui.plugins.ActivityStarter;
|
import com.android.systemui.plugins.ActivityStarter;
|
||||||
|
import com.android.systemui.statusbar.policy.KeyguardStateController;
|
||||||
import com.android.systemui.statusbar.policy.NetworkController;
|
import com.android.systemui.statusbar.policy.NetworkController;
|
||||||
import com.android.systemui.statusbar.policy.NetworkController.AccessPointController;
|
import com.android.systemui.statusbar.policy.NetworkController.AccessPointController;
|
||||||
import com.android.systemui.util.settings.GlobalSettings;
|
import com.android.systemui.util.settings.GlobalSettings;
|
||||||
@@ -97,6 +98,8 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
|||||||
private static final int SUBTITLE_TEXT_WIFI_IS_OFF = R.string.wifi_is_off;
|
private static final int SUBTITLE_TEXT_WIFI_IS_OFF = R.string.wifi_is_off;
|
||||||
private static final int SUBTITLE_TEXT_TAP_A_NETWORK_TO_CONNECT =
|
private static final int SUBTITLE_TEXT_TAP_A_NETWORK_TO_CONNECT =
|
||||||
R.string.tap_a_network_to_connect;
|
R.string.tap_a_network_to_connect;
|
||||||
|
private static final int SUBTITLE_TEXT_UNLOCK_TO_VIEW_NETWORKS =
|
||||||
|
R.string.unlock_to_view_networks;
|
||||||
private static final int SUBTITLE_TEXT_SEARCHING_FOR_NETWORKS =
|
private static final int SUBTITLE_TEXT_SEARCHING_FOR_NETWORKS =
|
||||||
R.string.wifi_empty_list_wifi_on;
|
R.string.wifi_empty_list_wifi_on;
|
||||||
private static final int SUBTITLE_TEXT_NON_CARRIER_NETWORK_UNAVAILABLE =
|
private static final int SUBTITLE_TEXT_NON_CARRIER_NETWORK_UNAVAILABLE =
|
||||||
@@ -137,6 +140,9 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
|||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
protected WifiUtils.InternetIconInjector mWifiIconInjector;
|
protected WifiUtils.InternetIconInjector mWifiIconInjector;
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
KeyguardStateController mKeyguardStateController;
|
||||||
|
|
||||||
private final KeyguardUpdateMonitorCallback mKeyguardUpdateCallback =
|
private final KeyguardUpdateMonitorCallback mKeyguardUpdateCallback =
|
||||||
new KeyguardUpdateMonitorCallback() {
|
new KeyguardUpdateMonitorCallback() {
|
||||||
@Override
|
@Override
|
||||||
@@ -161,7 +167,7 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
|||||||
@Nullable WifiManager wifiManager, ConnectivityManager connectivityManager,
|
@Nullable WifiManager wifiManager, ConnectivityManager connectivityManager,
|
||||||
@Main Handler handler, @Main Executor mainExecutor,
|
@Main Handler handler, @Main Executor mainExecutor,
|
||||||
BroadcastDispatcher broadcastDispatcher, KeyguardUpdateMonitor keyguardUpdateMonitor,
|
BroadcastDispatcher broadcastDispatcher, KeyguardUpdateMonitor keyguardUpdateMonitor,
|
||||||
GlobalSettings globalSettings) {
|
GlobalSettings globalSettings, KeyguardStateController keyguardStateController) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Log.d(TAG, "Init InternetDialogController");
|
Log.d(TAG, "Init InternetDialogController");
|
||||||
}
|
}
|
||||||
@@ -175,6 +181,7 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
|||||||
mSubscriptionManager = subscriptionManager;
|
mSubscriptionManager = subscriptionManager;
|
||||||
mBroadcastDispatcher = broadcastDispatcher;
|
mBroadcastDispatcher = broadcastDispatcher;
|
||||||
mKeyguardUpdateMonitor = keyguardUpdateMonitor;
|
mKeyguardUpdateMonitor = keyguardUpdateMonitor;
|
||||||
|
mKeyguardStateController = keyguardStateController;
|
||||||
mConnectionStateFilter = new IntentFilter();
|
mConnectionStateFilter = new IntentFilter();
|
||||||
mConnectionStateFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
|
mConnectionStateFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
|
||||||
mConnectionStateFilter.addAction(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION);
|
mConnectionStateFilter.addAction(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION);
|
||||||
@@ -272,6 +279,15 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
|||||||
return mContext.getText(SUBTITLE_TEXT_WIFI_IS_OFF);
|
return mContext.getText(SUBTITLE_TEXT_WIFI_IS_OFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isDeviceLocked()) {
|
||||||
|
// When the device is locked.
|
||||||
|
// Sub-Title: Unlock to view networks
|
||||||
|
if (DEBUG) {
|
||||||
|
Log.d(TAG, "The device is locked.");
|
||||||
|
}
|
||||||
|
return mContext.getText(SUBTITLE_TEXT_UNLOCK_TO_VIEW_NETWORKS);
|
||||||
|
}
|
||||||
|
|
||||||
final List<ScanResult> wifiList = mWifiManager.getScanResults();
|
final List<ScanResult> wifiList = mWifiManager.getScanResults();
|
||||||
if (wifiList != null && wifiList.size() != 0) {
|
if (wifiList != null && wifiList.size() != 0) {
|
||||||
return mContext.getText(SUBTITLE_TEXT_TAP_A_NETWORK_TO_CONNECT);
|
return mContext.getText(SUBTITLE_TEXT_TAP_A_NETWORK_TO_CONNECT);
|
||||||
@@ -683,6 +699,10 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
|||||||
&& serviceState.getState() == serviceState.STATE_IN_SERVICE;
|
&& serviceState.getState() == serviceState.STATE_IN_SERVICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isDeviceLocked() {
|
||||||
|
return !mKeyguardStateController.isUnlocked();
|
||||||
|
}
|
||||||
|
|
||||||
boolean activeNetworkIsCellular() {
|
boolean activeNetworkIsCellular() {
|
||||||
if (mConnectivityManager == null) {
|
if (mConnectivityManager == null) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
|
|||||||
@@ -33,13 +33,13 @@ import androidx.test.filters.SmallTest;
|
|||||||
|
|
||||||
import com.android.internal.logging.UiEventLogger;
|
import com.android.internal.logging.UiEventLogger;
|
||||||
import com.android.keyguard.KeyguardUpdateMonitor;
|
import com.android.keyguard.KeyguardUpdateMonitor;
|
||||||
import com.android.settingslib.Utils;
|
|
||||||
import com.android.settingslib.wifi.WifiUtils;
|
import com.android.settingslib.wifi.WifiUtils;
|
||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
import com.android.systemui.SysuiTestCase;
|
import com.android.systemui.SysuiTestCase;
|
||||||
import com.android.systemui.broadcast.BroadcastDispatcher;
|
import com.android.systemui.broadcast.BroadcastDispatcher;
|
||||||
import com.android.systemui.dagger.qualifiers.Main;
|
import com.android.systemui.dagger.qualifiers.Main;
|
||||||
import com.android.systemui.plugins.ActivityStarter;
|
import com.android.systemui.plugins.ActivityStarter;
|
||||||
|
import com.android.systemui.statusbar.policy.KeyguardStateController;
|
||||||
import com.android.systemui.statusbar.policy.NetworkController;
|
import com.android.systemui.statusbar.policy.NetworkController;
|
||||||
import com.android.systemui.statusbar.policy.NetworkController.AccessPointController;
|
import com.android.systemui.statusbar.policy.NetworkController.AccessPointController;
|
||||||
import com.android.systemui.util.concurrency.FakeExecutor;
|
import com.android.systemui.util.concurrency.FakeExecutor;
|
||||||
@@ -79,7 +79,7 @@ public class InternetDialogControllerTest extends SysuiTestCase {
|
|||||||
@Mock
|
@Mock
|
||||||
private GlobalSettings mGlobalSettings;
|
private GlobalSettings mGlobalSettings;
|
||||||
@Mock
|
@Mock
|
||||||
private KeyguardUpdateMonitor mKeyguardUpdateMonitor;
|
private KeyguardStateController mKeyguardStateController;
|
||||||
@Mock
|
@Mock
|
||||||
private NetworkController.AccessPointController mAccessPointController;
|
private NetworkController.AccessPointController mAccessPointController;
|
||||||
@Mock
|
@Mock
|
||||||
@@ -99,15 +99,16 @@ public class InternetDialogControllerTest extends SysuiTestCase {
|
|||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
doReturn(mTelephonyManager).when(mTelephonyManager).createForSubscriptionId(SUB_ID);
|
doReturn(mTelephonyManager).when(mTelephonyManager).createForSubscriptionId(anyInt());
|
||||||
when(mWifiManager.getConnectionInfo()).thenReturn(mWifiInfo);
|
when(mWifiManager.getConnectionInfo()).thenReturn(mWifiInfo);
|
||||||
|
when(mKeyguardStateController.isUnlocked()).thenReturn(true);
|
||||||
when(mConnectedEntry.isDefaultNetwork()).thenReturn(true);
|
when(mConnectedEntry.isDefaultNetwork()).thenReturn(true);
|
||||||
|
|
||||||
mInternetDialogController = new MockInternetDialogController(mContext,
|
mInternetDialogController = new MockInternetDialogController(mContext,
|
||||||
mock(UiEventLogger.class), mock(ActivityStarter.class), mAccessPointController,
|
mock(UiEventLogger.class), mock(ActivityStarter.class), mAccessPointController,
|
||||||
mSubscriptionManager, mTelephonyManager, mWifiManager,
|
mSubscriptionManager, mTelephonyManager, mWifiManager,
|
||||||
mock(ConnectivityManager.class), mHandler, mExecutor, mBroadcastDispatcher,
|
mock(ConnectivityManager.class), mHandler, mExecutor, mBroadcastDispatcher,
|
||||||
mKeyguardUpdateMonitor, mGlobalSettings);
|
mock(KeyguardUpdateMonitor.class), mGlobalSettings, mKeyguardStateController);
|
||||||
mSubscriptionManager.addOnSubscriptionsChangedListener(mExecutor,
|
mSubscriptionManager.addOnSubscriptionsChangedListener(mExecutor,
|
||||||
mInternetDialogController.mOnSubscriptionsChangedListener);
|
mInternetDialogController.mOnSubscriptionsChangedListener);
|
||||||
mInternetDialogController.onStart(
|
mInternetDialogController.onStart(
|
||||||
@@ -173,6 +174,16 @@ public class InternetDialogControllerTest extends SysuiTestCase {
|
|||||||
getResourcesString("tap_a_network_to_connect")));
|
getResourcesString("tap_a_network_to_connect")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getSubtitleText_deviceLockedWithWifiOn_returnUnlockToViewNetworks() {
|
||||||
|
mInternetDialogController.setAirplaneModeEnabled(false);
|
||||||
|
when(mWifiManager.isWifiEnabled()).thenReturn(true);
|
||||||
|
when(mKeyguardStateController.isUnlocked()).thenReturn(false);
|
||||||
|
|
||||||
|
assertTrue(TextUtils.equals(mInternetDialogController.getSubtitleText(false),
|
||||||
|
getResourcesString("unlock_to_view_networks")));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getSubtitleText_withNoService_returnNoNetworksAvailable() {
|
public void getSubtitleText_withNoService_returnNoNetworksAvailable() {
|
||||||
mInternetDialogController.setAirplaneModeEnabled(false);
|
mInternetDialogController.setAirplaneModeEnabled(false);
|
||||||
@@ -311,6 +322,20 @@ public class InternetDialogControllerTest extends SysuiTestCase {
|
|||||||
verify(mActivityStarter).postStartActivityDismissingKeyguard(any(Intent.class), anyInt());
|
verify(mActivityStarter).postStartActivityDismissingKeyguard(any(Intent.class), anyInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isDeviceLocked_keyguardIsUnlocked_returnFalse() {
|
||||||
|
when(mKeyguardStateController.isUnlocked()).thenReturn(true);
|
||||||
|
|
||||||
|
assertThat(mInternetDialogController.isDeviceLocked()).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isDeviceLocked_keyguardIsLocked_returnTrue() {
|
||||||
|
when(mKeyguardStateController.isUnlocked()).thenReturn(false);
|
||||||
|
|
||||||
|
assertThat(mInternetDialogController.isDeviceLocked()).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
private String getResourcesString(String name) {
|
private String getResourcesString(String name) {
|
||||||
return mContext.getResources().getString(getResourcesId(name));
|
return mContext.getResources().getString(getResourcesId(name));
|
||||||
}
|
}
|
||||||
@@ -331,10 +356,12 @@ public class InternetDialogControllerTest extends SysuiTestCase {
|
|||||||
@Nullable WifiManager wifiManager, ConnectivityManager connectivityManager,
|
@Nullable WifiManager wifiManager, ConnectivityManager connectivityManager,
|
||||||
@Main Handler handler, @Main Executor mainExecutor,
|
@Main Handler handler, @Main Executor mainExecutor,
|
||||||
BroadcastDispatcher broadcastDispatcher,
|
BroadcastDispatcher broadcastDispatcher,
|
||||||
KeyguardUpdateMonitor keyguardUpdateMonitor, GlobalSettings globalSettings) {
|
KeyguardUpdateMonitor keyguardUpdateMonitor, GlobalSettings globalSettings,
|
||||||
|
KeyguardStateController keyguardStateController) {
|
||||||
super(context, uiEventLogger, starter, accessPointController, subscriptionManager,
|
super(context, uiEventLogger, starter, accessPointController, subscriptionManager,
|
||||||
telephonyManager, wifiManager, connectivityManager, handler, mainExecutor,
|
telephonyManager, wifiManager, connectivityManager, handler, mainExecutor,
|
||||||
broadcastDispatcher, keyguardUpdateMonitor, globalSettings);
|
broadcastDispatcher, keyguardUpdateMonitor, globalSettings,
|
||||||
|
keyguardStateController);
|
||||||
mGlobalSettings = globalSettings;
|
mGlobalSettings = globalSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -59,24 +59,31 @@ public class InternetDialogTest extends SysuiTestCase {
|
|||||||
private static final String WIFI_TITLE = "Connected Wi-Fi Title";
|
private static final String WIFI_TITLE = "Connected Wi-Fi Title";
|
||||||
private static final String WIFI_SUMMARY = "Connected Wi-Fi Summary";
|
private static final String WIFI_SUMMARY = "Connected Wi-Fi Summary";
|
||||||
|
|
||||||
private final UiEventLogger mUiEventLogger = mock(UiEventLogger.class);
|
|
||||||
|
|
||||||
private InternetDialogFactory mInternetDialogFactory = mock(InternetDialogFactory.class);
|
|
||||||
private InternetAdapter mInternetAdapter = mock(InternetAdapter.class);
|
|
||||||
private InternetDialogController mInternetDialogController = mock(
|
|
||||||
InternetDialogController.class);
|
|
||||||
private InternetDialogController.InternetDialogCallback mCallback =
|
|
||||||
mock(InternetDialogController.InternetDialogCallback.class);
|
|
||||||
private MockInternetDialog mInternetDialog;
|
|
||||||
private WifiReceiver mWifiReceiver = null;
|
|
||||||
private WifiManager mMockWifiManager = mock(WifiManager.class);
|
|
||||||
private TelephonyManager mTelephonyManager = mock(TelephonyManager.class);
|
|
||||||
@Mock
|
@Mock
|
||||||
private WifiEntry mWifiEntry = mock(WifiEntry.class);
|
private InternetDialogFactory mInternetDialogFactory;
|
||||||
@Mock
|
@Mock
|
||||||
private WifiInfo mWifiInfo;
|
private InternetDialogController mInternetDialogController;
|
||||||
|
@Mock
|
||||||
|
private UiEventLogger mUiEventLogger;
|
||||||
@Mock
|
@Mock
|
||||||
private Handler mHandler;
|
private Handler mHandler;
|
||||||
|
@Mock
|
||||||
|
private TelephonyManager mTelephonyManager;
|
||||||
|
@Mock
|
||||||
|
private InternetAdapter mInternetAdapter;
|
||||||
|
@Mock
|
||||||
|
private WifiManager mMockWifiManager;
|
||||||
|
@Mock
|
||||||
|
private WifiEntry mWifiEntry;
|
||||||
|
@Mock
|
||||||
|
private WifiInfo mWifiInfo;
|
||||||
|
|
||||||
|
private MockInternetDialog mInternetDialog;
|
||||||
|
private WifiReceiver mWifiReceiver;
|
||||||
|
private LinearLayout mWifiToggle;
|
||||||
|
private LinearLayout mConnectedWifi;
|
||||||
|
private RecyclerView mWifiList;
|
||||||
|
private LinearLayout mSeeAll;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
@@ -99,6 +106,10 @@ public class InternetDialogTest extends SysuiTestCase {
|
|||||||
when(mWifiEntry.getTitle()).thenReturn(WIFI_TITLE);
|
when(mWifiEntry.getTitle()).thenReturn(WIFI_TITLE);
|
||||||
when(mWifiEntry.getSummary(false)).thenReturn(WIFI_SUMMARY);
|
when(mWifiEntry.getSummary(false)).thenReturn(WIFI_SUMMARY);
|
||||||
when(mInternetDialogController.getWifiEntryList()).thenReturn(Arrays.asList(mWifiEntry));
|
when(mInternetDialogController.getWifiEntryList()).thenReturn(Arrays.asList(mWifiEntry));
|
||||||
|
mWifiToggle = mInternetDialog.mDialogView.requireViewById(R.id.turn_on_wifi_layout);
|
||||||
|
mConnectedWifi = mInternetDialog.mDialogView.requireViewById(R.id.wifi_connected_layout);
|
||||||
|
mWifiList = mInternetDialog.mDialogView.requireViewById(R.id.wifi_list_layout);
|
||||||
|
mSeeAll = mInternetDialog.mDialogView.requireViewById(R.id.see_all_layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
@@ -137,7 +148,7 @@ public class InternetDialogTest extends SysuiTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateDialog_withWifiOnAndHasConnectedWifi_connectedWifiLayoutVisible() {
|
public void updateDialog_wifiOnAndHasConnectedWifi_showConnectedWifi() {
|
||||||
doReturn(false).when(mInternetDialogController).activeNetworkIsCellular();
|
doReturn(false).when(mInternetDialogController).activeNetworkIsCellular();
|
||||||
when(mWifiEntry.getTitle()).thenReturn(WIFI_TITLE);
|
when(mWifiEntry.getTitle()).thenReturn(WIFI_TITLE);
|
||||||
when(mWifiEntry.getSummary(false)).thenReturn(WIFI_SUMMARY);
|
when(mWifiEntry.getSummary(false)).thenReturn(WIFI_SUMMARY);
|
||||||
@@ -147,36 +158,85 @@ public class InternetDialogTest extends SysuiTestCase {
|
|||||||
|
|
||||||
mInternetDialog.updateDialog();
|
mInternetDialog.updateDialog();
|
||||||
|
|
||||||
final LinearLayout linearLayout = mInternetDialog.mDialogView.requireViewById(
|
assertThat(mConnectedWifi.getVisibility()).isEqualTo(View.VISIBLE);
|
||||||
R.id.wifi_connected_layout);
|
|
||||||
assertThat(linearLayout.getVisibility()).isEqualTo(View.VISIBLE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateDialog_withWifiOnAndNoConnectedWifi_connectedWifiLayoutGone() {
|
public void updateDialog_wifiOnAndNoConnectedWifi_hideConnectedWifi() {
|
||||||
doReturn(false).when(mInternetDialogController).activeNetworkIsCellular();
|
doReturn(false).when(mInternetDialogController).activeNetworkIsCellular();
|
||||||
mInternetDialog.updateDialog();
|
|
||||||
final LinearLayout linearLayout = mInternetDialog.mDialogView.requireViewById(
|
|
||||||
R.id.wifi_connected_layout);
|
|
||||||
|
|
||||||
assertThat(linearLayout.getVisibility()).isEqualTo(View.GONE);
|
mInternetDialog.updateDialog();
|
||||||
|
|
||||||
|
assertThat(mConnectedWifi.getVisibility()).isEqualTo(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateDialog_withWifiOff_WifiRecycleViewGone() {
|
public void updateDialog_wifiOnAndNoWifiList_hideWifiListAndSeeAll() {
|
||||||
when(mMockWifiManager.isWifiEnabled()).thenReturn(false);
|
when(mInternetDialogController.getWifiEntryList()).thenReturn(null);
|
||||||
mInternetDialog.updateDialog();
|
|
||||||
final RecyclerView view = mInternetDialog.mDialogView.requireViewById(
|
|
||||||
R.id.wifi_list_layout);
|
|
||||||
|
|
||||||
assertThat(view.getVisibility()).isEqualTo(View.GONE);
|
mInternetDialog.updateDialog();
|
||||||
|
|
||||||
|
assertThat(mWifiList.getVisibility()).isEqualTo(View.GONE);
|
||||||
|
assertThat(mSeeAll.getVisibility()).isEqualTo(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onClickSeeMoreButton_clickSeeMore_verifyLaunchNetworkSetting() {
|
public void updateDialog_wifiOnAndHasWifiList_showWifiListAndSeeAll() {
|
||||||
final LinearLayout seeAllLayout = mInternetDialog.mDialogView.requireViewById(
|
List<WifiEntry> wifiEntries = new ArrayList<WifiEntry>();
|
||||||
R.id.see_all_layout);
|
wifiEntries.add(mWifiEntry);
|
||||||
seeAllLayout.performClick();
|
when(mInternetDialogController.getWifiEntryList()).thenReturn(wifiEntries);
|
||||||
|
|
||||||
|
mInternetDialog.updateDialog();
|
||||||
|
|
||||||
|
assertThat(mWifiList.getVisibility()).isEqualTo(View.VISIBLE);
|
||||||
|
assertThat(mSeeAll.getVisibility()).isEqualTo(View.VISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateDialog_deviceLockedAndHasConnectedWifi_showHighlightWifiToggle() {
|
||||||
|
when(mInternetDialogController.isDeviceLocked()).thenReturn(true);
|
||||||
|
when(mWifiEntry.getTitle()).thenReturn(WIFI_TITLE);
|
||||||
|
when(mWifiEntry.getSummary(false)).thenReturn(WIFI_SUMMARY);
|
||||||
|
when(mWifiEntry.getConnectedState()).thenReturn(WifiEntry.CONNECTED_STATE_CONNECTED);
|
||||||
|
when(mWifiEntry.isDefaultNetwork()).thenReturn(true);
|
||||||
|
mInternetDialog.mConnectedWifiEntry = mWifiEntry;
|
||||||
|
|
||||||
|
mInternetDialog.updateDialog();
|
||||||
|
|
||||||
|
assertThat(mWifiToggle.getVisibility()).isEqualTo(View.VISIBLE);
|
||||||
|
assertThat(mWifiToggle.getBackground()).isNotNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateDialog_deviceLockedAndHasConnectedWifi_hideConnectedWifi() {
|
||||||
|
when(mInternetDialogController.isDeviceLocked()).thenReturn(true);
|
||||||
|
when(mWifiEntry.getTitle()).thenReturn(WIFI_TITLE);
|
||||||
|
when(mWifiEntry.getSummary(false)).thenReturn(WIFI_SUMMARY);
|
||||||
|
when(mWifiEntry.getConnectedState()).thenReturn(WifiEntry.CONNECTED_STATE_CONNECTED);
|
||||||
|
when(mWifiEntry.isDefaultNetwork()).thenReturn(true);
|
||||||
|
mInternetDialog.mConnectedWifiEntry = mWifiEntry;
|
||||||
|
|
||||||
|
mInternetDialog.updateDialog();
|
||||||
|
|
||||||
|
assertThat(mConnectedWifi.getVisibility()).isEqualTo(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateDialog_deviceLockedAndHasWifiList_hideWifiListAndSeeAll() {
|
||||||
|
when(mInternetDialogController.isDeviceLocked()).thenReturn(true);
|
||||||
|
List<WifiEntry> wifiEntries = new ArrayList<WifiEntry>();
|
||||||
|
wifiEntries.add(mWifiEntry);
|
||||||
|
when(mInternetDialogController.getWifiEntryList()).thenReturn(wifiEntries);
|
||||||
|
|
||||||
|
mInternetDialog.updateDialog();
|
||||||
|
|
||||||
|
assertThat(mWifiList.getVisibility()).isEqualTo(View.GONE);
|
||||||
|
assertThat(mSeeAll.getVisibility()).isEqualTo(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onClickSeeMoreButton_clickSeeAll_verifyLaunchNetworkSetting() {
|
||||||
|
mSeeAll.performClick();
|
||||||
|
|
||||||
verify(mInternetDialogController).launchNetworkSetting();
|
verify(mInternetDialogController).launchNetworkSetting();
|
||||||
}
|
}
|
||||||
@@ -192,6 +252,17 @@ public class InternetDialogTest extends SysuiTestCase {
|
|||||||
verify(mHandler, never()).postDelayed(any(Runnable.class), anyLong());
|
verify(mHandler, never()).postDelayed(any(Runnable.class), anyLong());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void showProgressBar_deviceLocked_hideProgressBar() {
|
||||||
|
Mockito.reset(mHandler);
|
||||||
|
when(mInternetDialogController.isDeviceLocked()).thenReturn(true);
|
||||||
|
|
||||||
|
mInternetDialog.showProgressBar();
|
||||||
|
|
||||||
|
assertThat(mInternetDialog.mIsProgressBarVisible).isFalse();
|
||||||
|
verify(mHandler, never()).postDelayed(any(Runnable.class), anyLong());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void showProgressBar_wifiEnabledWithWifiEntry_showProgressBarThenHide() {
|
public void showProgressBar_wifiEnabledWithWifiEntry_showProgressBarThenHide() {
|
||||||
Mockito.reset(mHandler);
|
Mockito.reset(mHandler);
|
||||||
|
|||||||
Reference in New Issue
Block a user