[Provider Model] Internet Panel - Airplane mode is on
- Add "Airplane mode is on" to sub-title
- Set the header layout to CENTER_HORIZONTAL if it's no icon
- Hide "Settings" button
- Screenshot
https://screenshot.googleplex.com/6m5dFVZu7ar4nKW
Bug: 178717651
Test: manual test
atest InternetConnectivityPanelTest \
PanelFragmentTest \
ProviderModelSliceTest
Change-Id: I899a817fd99415e9cad608aa4deac1e45365696a
diff --git a/res/layout/panel_layout.xml b/res/layout/panel_layout.xml
index 5f33c32..ac7a72b 100644
--- a/res/layout/panel_layout.xml
+++ b/res/layout/panel_layout.xml
@@ -48,11 +48,13 @@
</LinearLayout>
<LinearLayout
+ android:id="@+id/header_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:orientation="vertical">
+
<TextView
android:id="@+id/header_title"
android:layout_width="wrap_content"
@@ -67,8 +69,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
- android:maxLines="1" />
-
+ android:maxLines="1"/>
</LinearLayout>
</LinearLayout>
diff --git a/src/com/android/settings/network/ProviderModelSlice.java b/src/com/android/settings/network/ProviderModelSlice.java
index 288fe63..24077dd 100644
--- a/src/com/android/settings/network/ProviderModelSlice.java
+++ b/src/com/android/settings/network/ProviderModelSlice.java
@@ -26,7 +26,6 @@
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.net.Uri;
-import android.provider.Settings;
import android.telephony.SubscriptionManager;
import android.util.Log;
@@ -87,9 +86,6 @@
final ListBuilder listBuilder = mHelper.createListBuilder(getUri());
if (mHelper.isAirplaneModeEnabled() && !mWifiManager.isWifiEnabled()) {
log("Airplane mode is enabled.");
- listBuilder.setHeader(mHelper.createHeader(Settings.ACTION_AIRPLANE_MODE_SETTINGS));
- listBuilder.addGridRow(mHelper.createMessageGridRow(R.string.condition_airplane_title,
- Settings.ACTION_AIRPLANE_MODE_SETTINGS));
return listBuilder.build();
}
@@ -195,10 +191,14 @@
MobileNetworkUtils.setMobileDataEnabled(mContext, defaultSubId, newState,
false /* disableOtherSubscriptions */);
}
- doCarrierNetworkAction(isToggleAction, newState);
+
+ final boolean isDataEnabled =
+ isToggleAction ? newState : MobileNetworkUtils.isMobileDataEnabled(mContext);
+ doCarrierNetworkAction(isToggleAction, isDataEnabled);
}
- private void doCarrierNetworkAction(boolean isToggleAction, boolean isDataEnabled) {
+ @VisibleForTesting
+ void doCarrierNetworkAction(boolean isToggleAction, boolean isDataEnabled) {
final NetworkProviderWorker worker = getWorker();
if (worker == null) {
return;
@@ -209,7 +209,7 @@
return;
}
- if (MobileNetworkUtils.isMobileDataEnabled(mContext)) {
+ if (isDataEnabled) {
worker.connectCarrierNetwork();
}
}
diff --git a/src/com/android/settings/panel/InternetConnectivityPanel.java b/src/com/android/settings/panel/InternetConnectivityPanel.java
index 7bafe97..c90d22b 100644
--- a/src/com/android/settings/panel/InternetConnectivityPanel.java
+++ b/src/com/android/settings/panel/InternetConnectivityPanel.java
@@ -19,6 +19,7 @@
import static androidx.lifecycle.Lifecycle.Event.ON_PAUSE;
import static androidx.lifecycle.Lifecycle.Event.ON_RESUME;
+import static com.android.settings.network.InternetUpdater.INTERNET_APM;
import static com.android.settings.network.InternetUpdater.INTERNET_APM_NETWORKS;
import static com.android.settings.network.NetworkProviderSettings.ACTION_NETWORK_PROVIDER_SETTINGS;
@@ -83,6 +84,9 @@
mInternetUpdater.onPause();
}
+ /**
+ * @return a string for the title of the Panel.
+ */
@Override
public CharSequence getTitle() {
if (mIsProviderModelEnabled) {
@@ -93,10 +97,21 @@
return mContext.getText(R.string.internet_connectivity_panel_title);
}
+ /**
+ * @return a string for the subtitle of the Panel.
+ */
+ @Override
+ public CharSequence getSubTitle() {
+ if (mIsProviderModelEnabled && mInternetType == INTERNET_APM) {
+ return mContext.getText(R.string.condition_airplane_title);
+ }
+ return null;
+ }
+
@Override
public List<Uri> getSlices() {
final List<Uri> uris = new ArrayList<>();
- if (Utils.isProviderModelEnabled(mContext)) {
+ if (mIsProviderModelEnabled) {
uris.add(CustomSliceRegistry.PROVIDER_MODEL_SLICE_URI);
uris.add(CustomSliceRegistry.AIRPLANE_SAFE_NETWORKS_SLICE_URI);
} else {
@@ -109,18 +124,21 @@
@Override
public Intent getSeeMoreIntent() {
- return new Intent(Utils.isProviderModelEnabled(mContext)
+ return new Intent(mIsProviderModelEnabled
? ACTION_NETWORK_PROVIDER_SETTINGS : Settings.ACTION_WIRELESS_SETTINGS)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}
@Override
public boolean isCustomizedButtonUsed() {
- return Utils.isProviderModelEnabled(mContext);
+ return mIsProviderModelEnabled;
}
@Override
public CharSequence getCustomizedButtonTitle() {
+ if (mInternetType == INTERNET_APM) {
+ return null;
+ }
return mContext.getText(R.string.settings_button);
}
@@ -145,18 +163,35 @@
* @param internetType the internet type
*/
public void onInternetTypeChanged(@InternetUpdater.InternetType int internetType) {
- final boolean needRefresh = internetType != mInternetType
- && (internetType == INTERNET_APM_NETWORKS
- || mInternetType == INTERNET_APM_NETWORKS);
- mInternetType = internetType;
- if (needRefresh) {
- refresh();
+ if (internetType == mInternetType) {
+ return;
}
- }
- private void refresh() {
+ final boolean changeToApm = (internetType == INTERNET_APM);
+ final boolean changeFromApm = (mInternetType == INTERNET_APM);
+ final boolean changeWithApmNetworks =
+ (internetType == INTERNET_APM_NETWORKS || mInternetType == INTERNET_APM_NETWORKS);
+ mInternetType = internetType;
+
if (mCallback != null) {
- mCallback.onTitleChanged();
+ if (changeToApm) {
+ // The internet type is changed to the airplane mode.
+ // Title: Internet
+ // Sub-Title: Airplane mode is on
+ // Settings button: Hide
+ mCallback.onHeaderChanged();
+ mCallback.onCustomizedButtonStateChanged();
+ } else if (changeFromApm) {
+ // The internet type is changed from the airplane mode.
+ // Title: Internet
+ // Settings button: Show
+ mCallback.onTitleChanged();
+ mCallback.onCustomizedButtonStateChanged();
+ } else if (changeWithApmNetworks) {
+ // The internet type is changed with the airplane mode networks.
+ // Title: Airplane mode networks / Internet
+ mCallback.onTitleChanged();
+ }
}
}
}
diff --git a/src/com/android/settings/panel/PanelFragment.java b/src/com/android/settings/panel/PanelFragment.java
index 503b34a..e7c1bef 100644
--- a/src/com/android/settings/panel/PanelFragment.java
+++ b/src/com/android/settings/panel/PanelFragment.java
@@ -26,6 +26,7 @@
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
+import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -94,6 +95,7 @@
private LinearLayout mPanelHeader;
private ImageView mTitleIcon;
private LinearLayout mTitleGroup;
+ private LinearLayout mHeaderLayout;
private TextView mHeaderTitle;
private TextView mHeaderSubtitle;
private int mMaxHeight;
@@ -202,6 +204,7 @@
mPanelHeader = mLayoutView.findViewById(R.id.panel_header);
mTitleIcon = mLayoutView.findViewById(R.id.title_icon);
mTitleGroup = mLayoutView.findViewById(R.id.title_group);
+ mHeaderLayout = mLayoutView.findViewById(R.id.header_layout);
mHeaderTitle = mLayoutView.findViewById(R.id.header_title);
mHeaderSubtitle = mLayoutView.findViewById(R.id.header_subtitle);
mFooterDivider = mLayoutView.findViewById(R.id.footer_divider);
@@ -239,13 +242,12 @@
final IconCompat icon = mPanel.getIcon();
final CharSequence title = mPanel.getTitle();
+ final CharSequence subtitle = mPanel.getSubTitle();
- if (icon != null) {
- enablePanelHeader(icon, title);
+ if (icon != null || (subtitle != null && subtitle.length() > 0)) {
+ enablePanelHeader(icon, title, subtitle);
} else {
- mTitleView.setVisibility(View.VISIBLE);
- mPanelHeader.setVisibility(View.GONE);
- mTitleView.setText(title);
+ enableTitle(title);
}
mFooterDivider.setVisibility(View.GONE);
@@ -254,13 +256,7 @@
mDoneButton.setOnClickListener(getCloseListener());
if (mPanel.isCustomizedButtonUsed()) {
- final CharSequence customTitle = mPanel.getCustomizedButtonTitle();
- if (TextUtils.isEmpty(customTitle)) {
- mSeeMoreButton.setVisibility(View.GONE);
- } else {
- mSeeMoreButton.setVisibility(View.VISIBLE);
- mSeeMoreButton.setText(customTitle);
- }
+ enableCustomizedButton();
} else if (mPanel.getSeeMoreIntent() == null) {
// If getSeeMoreIntent() is null hide the mSeeMoreButton.
mSeeMoreButton.setVisibility(View.GONE);
@@ -275,14 +271,16 @@
0 /* value */);
}
- private void enablePanelHeader(IconCompat icon, CharSequence title) {
+ private void enablePanelHeader(IconCompat icon, CharSequence title, CharSequence subtitle) {
mTitleView.setVisibility(View.GONE);
mPanelHeader.setVisibility(View.VISIBLE);
mPanelHeader.setAccessibilityPaneTitle(title);
mHeaderTitle.setText(title);
- mHeaderSubtitle.setText(mPanel.getSubTitle());
+ mHeaderSubtitle.setText(subtitle);
+ mHeaderSubtitle.setAccessibilityPaneTitle(subtitle);
if (icon != null) {
mTitleGroup.setVisibility(View.VISIBLE);
+ mHeaderLayout.setGravity(Gravity.LEFT);
mTitleIcon.setImageIcon(icon.toIcon(getContext()));
if (mPanel.getHeaderIconIntent() != null) {
mTitleIcon.setOnClickListener(getHeaderIconListener());
@@ -295,6 +293,24 @@
}
} else {
mTitleGroup.setVisibility(View.GONE);
+ mHeaderLayout.setGravity(Gravity.CENTER_HORIZONTAL);
+ }
+ }
+
+ private void enableTitle(CharSequence title) {
+ mPanelHeader.setVisibility(View.GONE);
+ mTitleView.setVisibility(View.VISIBLE);
+ mTitleView.setAccessibilityPaneTitle(title);
+ mTitleView.setText(title);
+ }
+
+ private void enableCustomizedButton() {
+ final CharSequence customTitle = mPanel.getCustomizedButtonTitle();
+ if (TextUtils.isEmpty(customTitle)) {
+ mSeeMoreButton.setVisibility(View.GONE);
+ } else {
+ mSeeMoreButton.setVisibility(View.VISIBLE);
+ mSeeMoreButton.setText(customTitle);
}
}
@@ -487,24 +503,14 @@
@Override
public void onCustomizedButtonStateChanged() {
ThreadUtils.postOnMainThread(() -> {
- mSeeMoreButton.setVisibility(
- mPanel.isCustomizedButtonUsed() ? View.VISIBLE : View.GONE);
- mSeeMoreButton.setText(mPanel.getCustomizedButtonTitle());
+ enableCustomizedButton();
});
}
@Override
public void onHeaderChanged() {
ThreadUtils.postOnMainThread(() -> {
- final IconCompat icon = mPanel.getIcon();
- if (icon != null) {
- mTitleIcon.setImageIcon(icon.toIcon(getContext()));
- mTitleGroup.setVisibility(View.VISIBLE);
- } else {
- mTitleGroup.setVisibility(View.GONE);
- }
- mHeaderTitle.setText(mPanel.getTitle());
- mHeaderSubtitle.setText(mPanel.getSubTitle());
+ enablePanelHeader(mPanel.getIcon(), mPanel.getTitle(), mPanel.getSubTitle());
});
}
@@ -517,7 +523,7 @@
@Override
public void onTitleChanged() {
ThreadUtils.postOnMainThread(() -> {
- mTitleView.setText(mPanel.getTitle());
+ enableTitle(mPanel.getTitle());
});
}
diff --git a/tests/robotests/src/com/android/settings/panel/InternetConnectivityPanelTest.java b/tests/robotests/src/com/android/settings/panel/InternetConnectivityPanelTest.java
deleted file mode 100644
index eb82d31..0000000
--- a/tests/robotests/src/com/android/settings/panel/InternetConnectivityPanelTest.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.android.settings.panel;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import android.net.Uri;
-import android.os.SystemProperties;
-
-import com.android.settings.network.AirplaneModePreferenceController;
-import com.android.settings.slices.CustomSliceRegistry;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
-
-import java.util.List;
-
-@RunWith(RobolectricTestRunner.class)
-
-public class InternetConnectivityPanelTest {
-
- private InternetConnectivityPanel mPanel;
- private static final String SETTINGS_PROVIDER_MODEL =
- "persist.sys.fflag.override.settings_provider_model";
- private boolean mSettingsProviderModelState;
-
- @Before
- public void setUp() {
- mPanel = InternetConnectivityPanel.create(RuntimeEnvironment.application);
- mSettingsProviderModelState = SystemProperties.getBoolean(SETTINGS_PROVIDER_MODEL, false);
- }
-
- @After
- public void tearDown() {
- SystemProperties.set(SETTINGS_PROVIDER_MODEL,
- mSettingsProviderModelState ? "true" : "false");
- }
-
- @Test
- public void getSlices_providerModelDisabled_containsNecessarySlices() {
- SystemProperties.set(SETTINGS_PROVIDER_MODEL, "false");
- final List<Uri> uris = mPanel.getSlices();
-
- assertThat(uris).containsExactly(
- AirplaneModePreferenceController.SLICE_URI,
- CustomSliceRegistry.MOBILE_DATA_SLICE_URI,
- CustomSliceRegistry.WIFI_SLICE_URI);
- }
-
- @Test
- public void getSlices_providerModelEnabled_containsNecessarySlices() {
- SystemProperties.set(SETTINGS_PROVIDER_MODEL, "true");
- final List<Uri> uris = mPanel.getSlices();
-
- assertThat(uris).containsExactly(
- CustomSliceRegistry.PROVIDER_MODEL_SLICE_URI,
- CustomSliceRegistry.AIRPLANE_SAFE_NETWORKS_SLICE_URI);
- }
-
- @Test
- public void getSeeMoreIntent_notNull() {
- assertThat(mPanel.getSeeMoreIntent()).isNotNull();
- }
-}
diff --git a/tests/unit/src/com/android/settings/network/ProviderModelSliceTest.java b/tests/unit/src/com/android/settings/network/ProviderModelSliceTest.java
index 8f998a4..476d854 100644
--- a/tests/unit/src/com/android/settings/network/ProviderModelSliceTest.java
+++ b/tests/unit/src/com/android/settings/network/ProviderModelSliceTest.java
@@ -16,8 +16,6 @@
package com.android.settings.network;
-import static android.app.slice.Slice.EXTRA_TOGGLE_STATE;
-
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
@@ -25,6 +23,7 @@
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.eq;
+import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -387,35 +386,34 @@
}
@Test
- public void onNotifyChange_intentToggleActionOn_shouldSetCarrierNetworkEnabledTrue() {
- when(mMockProviderModelSlice.defaultSubscriptionIsUsable(anyInt())).thenReturn(true);
- Intent intent = mMockProviderModelSlice.getBroadcastIntent(mContext).getIntent();
- intent.putExtra(EXTRA_TOGGLE_STATE, true);
-
- mMockProviderModelSlice.onNotifyChange(intent);
+ public void doCarrierNetworkAction_toggleActionSetDataEnabled_setCarrierNetworkEnabledTrue() {
+ mMockProviderModelSlice.doCarrierNetworkAction(true /* isToggleAction */,
+ true /* isDataEnabled */);
verify(mMockNetworkProviderWorker).setCarrierNetworkEnabled(true);
}
@Test
- public void onNotifyChange_intentToggleActionOff_shouldSetCarrierNetworkEnabledFalse() {
- when(mMockProviderModelSlice.defaultSubscriptionIsUsable(anyInt())).thenReturn(true);
- Intent intent = mMockProviderModelSlice.getBroadcastIntent(mContext).getIntent();
- intent.putExtra(EXTRA_TOGGLE_STATE, false);
-
- mMockProviderModelSlice.onNotifyChange(intent);
+ public void doCarrierNetworkAction_toggleActionSetDataDisabled_setCarrierNetworkEnabledFalse() {
+ mMockProviderModelSlice.doCarrierNetworkAction(true /* isToggleAction */,
+ false /* isDataEnabled */);
verify(mMockNetworkProviderWorker).setCarrierNetworkEnabled(false);
}
@Test
- public void onNotifyChange_intentPrimaryAction_shouldConnectCarrierNetwork() {
- when(mMockProviderModelSlice.defaultSubscriptionIsUsable(anyInt())).thenReturn(true);
- when(mTelephonyManager.isDataEnabled()).thenReturn(true);
- Intent intent = mMockProviderModelSlice.getBroadcastIntent(mContext).getIntent();
-
- mMockProviderModelSlice.onNotifyChange(intent);
+ public void doCarrierNetworkAction_primaryActionAndDataEnabled_connectCarrierNetwork() {
+ mMockProviderModelSlice.doCarrierNetworkAction(false /* isToggleAction */,
+ true /* isDataEnabled */);
verify(mMockNetworkProviderWorker).connectCarrierNetwork();
}
+
+ @Test
+ public void doCarrierNetworkAction_primaryActionAndDataDisabled_notConnectCarrierNetwork() {
+ mMockProviderModelSlice.doCarrierNetworkAction(false /* isToggleAction */,
+ false /* isDataEnabled */);
+
+ verify(mMockNetworkProviderWorker, never()).connectCarrierNetwork();
+ }
}
diff --git a/tests/unit/src/com/android/settings/panel/InternetConnectivityPanelTest.java b/tests/unit/src/com/android/settings/panel/InternetConnectivityPanelTest.java
index e8f694b..a4d4ad1 100644
--- a/tests/unit/src/com/android/settings/panel/InternetConnectivityPanelTest.java
+++ b/tests/unit/src/com/android/settings/panel/InternetConnectivityPanelTest.java
@@ -18,6 +18,9 @@
import static com.android.settings.network.InternetUpdater.INTERNET_APM;
import static com.android.settings.network.InternetUpdater.INTERNET_APM_NETWORKS;
+import static com.android.settings.network.InternetUpdater.INTERNET_CELLULAR;
+import static com.android.settings.network.InternetUpdater.INTERNET_ETHERNET;
+import static com.android.settings.network.InternetUpdater.INTERNET_WIFI;
import static com.google.common.truth.Truth.assertThat;
@@ -26,10 +29,13 @@
import static org.mockito.Mockito.verify;
import android.content.Context;
+import android.net.Uri;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
+import com.android.settings.network.AirplaneModePreferenceController;
+import com.android.settings.slices.CustomSliceRegistry;
import com.android.settings.testutils.ResourcesUtils;
import org.junit.Before;
@@ -40,6 +46,8 @@
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
+import java.util.List;
+
@RunWith(AndroidJUnit4.class)
public class InternetConnectivityPanelTest {
@@ -47,6 +55,10 @@
ApplicationProvider.getApplicationContext(), "provider_internet_settings");
public static final String TITLE_APM_NETWORKS = ResourcesUtils.getResourcesString(
ApplicationProvider.getApplicationContext(), "airplane_mode_network_panel_title");
+ public static final String SUBTITLE_APM_IS_ON = ResourcesUtils.getResourcesString(
+ ApplicationProvider.getApplicationContext(), "condition_airplane_title");
+ public static final String BUTTON_SETTINGS = ResourcesUtils.getResourcesString(
+ ApplicationProvider.getApplicationContext(), "settings_button");
@Rule
public final MockitoRule mMocks = MockitoJUnit.rule();
@@ -66,30 +78,147 @@
}
@Test
- public void getTitle_internetTypeChangedFromApmToApmNetworks_verifyTitleChanged() {
+ public void getTitle_internetApmNetworks_shouldBeApmNetworks() {
+ mPanel.onInternetTypeChanged(INTERNET_APM_NETWORKS);
+
+ assertThat(mPanel.getTitle()).isEqualTo(TITLE_APM_NETWORKS);
+ }
+
+ @Test
+ public void getTitle_notInternetApmNetworks_shouldBeInternet() {
mPanel.onInternetTypeChanged(INTERNET_APM);
assertThat(mPanel.getTitle()).isEqualTo(TITLE_INTERNET);
+ mPanel.onInternetTypeChanged(INTERNET_WIFI);
+
+ assertThat(mPanel.getTitle()).isEqualTo(TITLE_INTERNET);
+
+ mPanel.onInternetTypeChanged(INTERNET_CELLULAR);
+
+ assertThat(mPanel.getTitle()).isEqualTo(TITLE_INTERNET);
+
+ mPanel.onInternetTypeChanged(INTERNET_ETHERNET);
+
+ assertThat(mPanel.getTitle()).isEqualTo(TITLE_INTERNET);
+ }
+
+ @Test
+ public void getSubTitle_internetApm_shouldBeApmIsOn() {
+ mPanel.onInternetTypeChanged(INTERNET_APM);
+
+ assertThat(mPanel.getSubTitle()).isEqualTo(SUBTITLE_APM_IS_ON);
+ }
+
+ @Test
+ public void getSubTitle_notinternetApm_shouldBeNull() {
+ mPanel.onInternetTypeChanged(INTERNET_APM_NETWORKS);
+
+ assertThat(mPanel.getSubTitle()).isNull();
+
+ mPanel.onInternetTypeChanged(INTERNET_WIFI);
+
+ assertThat(mPanel.getSubTitle()).isNull();
+
+ mPanel.onInternetTypeChanged(INTERNET_CELLULAR);
+
+ assertThat(mPanel.getSubTitle()).isNull();
+
+ mPanel.onInternetTypeChanged(INTERNET_ETHERNET);
+
+ assertThat(mPanel.getSubTitle()).isNull();
+ }
+
+ @Test
+ public void getCustomizedButtonTitle_internetApm_shouldBeNull() {
+ mPanel.onInternetTypeChanged(INTERNET_APM);
+
+ assertThat(mPanel.getCustomizedButtonTitle()).isNull();
+ }
+
+ @Test
+ public void getCustomizedButtonTitle_notInternetApm_shouldBeSettings() {
+ mPanel.onInternetTypeChanged(INTERNET_APM_NETWORKS);
+
+ assertThat(mPanel.getCustomizedButtonTitle()).isEqualTo(BUTTON_SETTINGS);
+
+ mPanel.onInternetTypeChanged(INTERNET_WIFI);
+
+ assertThat(mPanel.getCustomizedButtonTitle()).isEqualTo(BUTTON_SETTINGS);
+
+ mPanel.onInternetTypeChanged(INTERNET_CELLULAR);
+
+ assertThat(mPanel.getCustomizedButtonTitle()).isEqualTo(BUTTON_SETTINGS);
+
+ mPanel.onInternetTypeChanged(INTERNET_ETHERNET);
+
+ assertThat(mPanel.getCustomizedButtonTitle()).isEqualTo(BUTTON_SETTINGS);
+ }
+
+ @Test
+ public void getSlices_providerModelDisabled_containsNecessarySlices() {
+ mPanel.mIsProviderModelEnabled = false;
+ final List<Uri> uris = mPanel.getSlices();
+
+ assertThat(uris).containsExactly(
+ AirplaneModePreferenceController.SLICE_URI,
+ CustomSliceRegistry.MOBILE_DATA_SLICE_URI,
+ CustomSliceRegistry.WIFI_SLICE_URI);
+ }
+
+ @Test
+ public void getSlices_providerModelEnabled_containsNecessarySlices() {
+ final List<Uri> uris = mPanel.getSlices();
+
+ assertThat(uris).containsExactly(
+ CustomSliceRegistry.PROVIDER_MODEL_SLICE_URI,
+ CustomSliceRegistry.AIRPLANE_SAFE_NETWORKS_SLICE_URI);
+ }
+
+ @Test
+ public void getSeeMoreIntent_notNull() {
+ assertThat(mPanel.getSeeMoreIntent()).isNotNull();
+ }
+
+ @Test
+ public void onInternetTypeChanged_internetTypeChangedToApm_changeHeaderAndHideSettings() {
+ mPanel.onInternetTypeChanged(INTERNET_APM_NETWORKS);
+ clearInvocations(mPanelContentCallback);
+
+ mPanel.onInternetTypeChanged(INTERNET_APM);
+
+ verify(mPanelContentCallback).onHeaderChanged();
+ verify(mPanelContentCallback).onCustomizedButtonStateChanged();
+ }
+
+ @Test
+ public void onInternetTypeChanged_internetTypeChangedFomApm_changeTitleAndShowSettings() {
+ mPanel.onInternetTypeChanged(INTERNET_APM);
clearInvocations(mPanelContentCallback);
mPanel.onInternetTypeChanged(INTERNET_APM_NETWORKS);
- assertThat(mPanel.getTitle()).isEqualTo(TITLE_APM_NETWORKS);
+ verify(mPanelContentCallback).onTitleChanged();
+ verify(mPanelContentCallback).onCustomizedButtonStateChanged();
+ }
+
+ @Test
+ public void onInternetTypeChanged_internetTypeChangedToApmNetworks_changeTitle() {
+ mPanel.onInternetTypeChanged(INTERNET_WIFI);
+ clearInvocations(mPanelContentCallback);
+
+ mPanel.onInternetTypeChanged(INTERNET_APM_NETWORKS);
+
verify(mPanelContentCallback).onTitleChanged();
}
@Test
- public void getTitle_internetTypeChangedFromApmNetworksToApm_verifyTitleChanged() {
+ public void onInternetTypeChanged_internetTypeChangedFromApmNetworks_changeTitle() {
mPanel.onInternetTypeChanged(INTERNET_APM_NETWORKS);
-
- assertThat(mPanel.getTitle()).isEqualTo(TITLE_APM_NETWORKS);
-
clearInvocations(mPanelContentCallback);
- mPanel.onInternetTypeChanged(INTERNET_APM);
+ mPanel.onInternetTypeChanged(INTERNET_WIFI);
- assertThat(mPanel.getTitle()).isEqualTo(TITLE_INTERNET);
verify(mPanelContentCallback).onTitleChanged();
}
}