use of androidx.test.annotation.UiThreadTest in project android_packages_apps_Settings by omnirom.
the class ProviderModelSliceTest method setUp.
@Before
@UiThreadTest
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = spy(ApplicationProvider.getApplicationContext());
mFeatureFactory = FakeFeatureFactory.setupForTest();
when(mFeatureFactory.wifiTrackerLibProvider.createWifiPickerTracker(any(), any(), any(), any(), any(), anyLong(), anyLong(), any())).thenReturn(mWifiPickerTracker);
when(mContext.getSystemService(SubscriptionManager.class)).thenReturn(mSubscriptionManager);
when(mContext.getSystemService(ConnectivityManager.class)).thenReturn(mConnectivityManager);
when(mContext.getSystemService(TelephonyManager.class)).thenReturn(mTelephonyManager);
when(mTelephonyManager.createForSubscriptionId(anyInt())).thenReturn(mTelephonyManager);
when(mContext.getSystemService(WifiManager.class)).thenReturn(mWifiManager);
when(mWifiManager.isWifiEnabled()).thenReturn(true);
// Set-up specs for SliceMetadata.
SliceProvider.setSpecs(SliceLiveData.SUPPORTED_SPECS);
mMockNetworkProviderWorker = spy(new MockNetworkProviderWorker(mContext, PROVIDER_MODEL_SLICE_URI));
mMockProviderModelSlice = spy(new MockProviderModelSlice(mContext, mMockNetworkProviderWorker));
mMockAlertDialog = new AlertDialog.Builder(mContext).setTitle("").create();
mMockAlertDialog = spy(mMockAlertDialog);
mMockProviderModelSlice.setMobileDataDisableDialog(mMockAlertDialog);
mListBuilder = spy(new ListBuilder(mContext, PROVIDER_MODEL_SLICE_URI, ListBuilder.INFINITY).setAccentColor(-1));
when(mProviderModelSliceHelper.createListBuilder(PROVIDER_MODEL_SLICE_URI)).thenReturn(mListBuilder);
when(mProviderModelSliceHelper.getSubscriptionManager()).thenReturn(mSubscriptionManager);
mWifiList = new ArrayList<>();
mMockNetworkProviderWorker.updateSelfResults(mWifiList);
mockBuilder();
}
use of androidx.test.annotation.UiThreadTest in project android_packages_apps_Settings by omnirom.
the class ProviderModelSliceTest method getSlice_haveEthernetAndCarrierAndConnectedWifiAndDisconnectedWifi_getSixRow.
@Test
@UiThreadTest
public void getSlice_haveEthernetAndCarrierAndConnectedWifiAndDisconnectedWifi_getSixRow() {
mWifiList.clear();
mockWifiItemCondition(mMockWifiSliceItem1, "wifi1", "wifi1", WifiEntry.CONNECTED_STATE_CONNECTED, "wifi1_key", true);
mWifiList.add(mMockWifiSliceItem1);
mockWifiItemCondition(mMockWifiSliceItem2, "wifi2", "wifi2", WifiEntry.CONNECTED_STATE_DISCONNECTED, "wifi2_key", true);
mWifiList.add(mMockWifiSliceItem2);
mMockNetworkProviderWorker.updateSelfResults(mWifiList);
mockHelperCondition(false, true, true, mWifiList.get(0));
when(mMockNetworkProviderWorker.getInternetType()).thenReturn(InternetUpdater.INTERNET_ETHERNET);
final Slice slice = mMockProviderModelSlice.getSlice();
assertThat(slice).isNotNull();
assertThat(mMockProviderModelSlice.hasCreateEthernetRow()).isTrue();
verify(mListBuilder, times(1)).addRow(mMockCarrierRowBuild);
verify(mListBuilder, times(6)).addRow(any(ListBuilder.RowBuilder.class));
assertThat(mMockProviderModelSlice.hasSeeAllRow()).isTrue();
}
use of androidx.test.annotation.UiThreadTest in project android_packages_apps_Settings by omnirom.
the class ProviderModelSliceTest method getSlice_noWifiAndNoCarrier_oneCarrier.
@Test
@UiThreadTest
public void getSlice_noWifiAndNoCarrier_oneCarrier() {
mWifiList.clear();
mMockProviderModelSlice = new MockProviderModelSlice(mContext, null);
mockHelperCondition(false, true, true, null);
final Slice slice = mMockProviderModelSlice.getSlice();
assertThat(slice).isNotNull();
verify(mListBuilder, times(1)).addRow(mMockCarrierRowBuild);
assertThat(mMockProviderModelSlice.hasSeeAllRow()).isFalse();
}
use of androidx.test.annotation.UiThreadTest in project android_packages_apps_Settings by omnirom.
the class ProviderModelSliceTest method getSlice_noWifiAndHasCarrierNoData_oneCarrier.
@Test
@UiThreadTest
public void getSlice_noWifiAndHasCarrierNoData_oneCarrier() {
mWifiList.clear();
mMockNetworkProviderWorker.updateSelfResults(null);
mockHelperCondition(false, true, false, null);
final Slice slice = mMockProviderModelSlice.getSlice();
assertThat(slice).isNotNull();
verify(mListBuilder, times(1)).addRow(mMockCarrierRowBuild);
assertThat(mMockProviderModelSlice.hasSeeAllRow()).isFalse();
}
use of androidx.test.annotation.UiThreadTest in project android_packages_apps_Settings by omnirom.
the class ProviderModelSliceTest method onNotifyChange_FirstTimeDisableToggleState_showDialog.
@Test
@UiThreadTest
public void onNotifyChange_FirstTimeDisableToggleState_showDialog() {
final Intent intent = new Intent();
intent.putExtra(EXTRA_TOGGLE_STATE, false);
SharedPreferences sharedPref = mMockProviderModelSlice.getSharedPreference();
when(mProviderModelSliceHelper.getMobileTitle()).thenReturn("mockRow");
if (sharedPref != null) {
SharedPreferences.Editor editor = sharedPref.edit();
editor.putBoolean(PREF_HAS_TURNED_OFF_MOBILE_DATA, true);
editor.apply();
}
mMockProviderModelSlice.onNotifyChange(intent);
verify(mMockAlertDialog).show();
}
Aggregations