Merge Android R (rvc-dev-plus-aosp-without-vendor@6692709)
Bug: 166295507 Merged-In: Ie9d2c4d6d4618a167af1c5627d5d7918a404f398 Change-Id: I2ae428e37fd96226ce4e06032e2c0beaacbd0301
This commit is contained in:
@@ -1,73 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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;
|
||||
|
||||
import static junit.framework.Assert.fail;
|
||||
|
||||
import android.app.Instrumentation;
|
||||
import android.app.UiAutomation;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ResolveInfo;
|
||||
|
||||
import androidx.test.InstrumentationRegistry;
|
||||
import androidx.test.filters.SmallTest;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@SmallTest
|
||||
public class RegulatoryInfoDisplayActivityTest {
|
||||
private static final String TAG = "RegulatoryInfoTest";
|
||||
|
||||
private Instrumentation mInstrumentation;
|
||||
private Intent mRegulatoryInfoIntent;
|
||||
private UiAutomation mUiAutomation;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mInstrumentation = InstrumentationRegistry.getInstrumentation();
|
||||
mUiAutomation = InstrumentationRegistry.getInstrumentation().getUiAutomation();
|
||||
mRegulatoryInfoIntent = new Intent("android.settings.SHOW_REGULATORY_INFO")
|
||||
.addCategory(Intent.CATEGORY_DEFAULT)
|
||||
.setPackage(mInstrumentation.getTargetContext().getPackageName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resolveRegulatoryInfoIntent_intentShouldMatchConfig() {
|
||||
// Load intent from PackageManager and load config from Settings app
|
||||
final Context context = mInstrumentation.getTargetContext();
|
||||
|
||||
final boolean hasRegulatoryInfo = context.getResources()
|
||||
.getBoolean(R.bool.config_show_regulatory_info);
|
||||
final ResolveInfo resolveInfo = mInstrumentation.getTargetContext().getPackageManager()
|
||||
.resolveActivity(mRegulatoryInfoIntent, 0 /* flags */);
|
||||
|
||||
// Check config and intent both enable or both disabled.
|
||||
if (hasRegulatoryInfo && resolveInfo == null) {
|
||||
fail("Config enables regulatory info but there is no handling intent");
|
||||
return;
|
||||
}
|
||||
if (!hasRegulatoryInfo && resolveInfo != null) {
|
||||
fail("Config disables regulatory info but there is at least one handling intent");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,124 +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.accessibility;
|
||||
|
||||
import static androidx.test.espresso.Espresso.onView;
|
||||
import static androidx.test.espresso.assertion.ViewAssertions.matches;
|
||||
import static androidx.test.espresso.matcher.ViewMatchers.hasDescendant;
|
||||
import static androidx.test.espresso.matcher.ViewMatchers.isChecked;
|
||||
import static androidx.test.espresso.matcher.ViewMatchers.isNotChecked;
|
||||
import static androidx.test.espresso.matcher.ViewMatchers.withParent;
|
||||
import static androidx.test.espresso.matcher.ViewMatchers.withText;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.instanceOf;
|
||||
import static org.hamcrest.CoreMatchers.not;
|
||||
import static org.hamcrest.Matchers.allOf;
|
||||
|
||||
import android.app.Instrumentation;
|
||||
import android.os.Bundle;
|
||||
|
||||
import android.provider.Settings;
|
||||
import android.widget.CompoundButton;
|
||||
|
||||
import androidx.test.InstrumentationRegistry;
|
||||
import androidx.test.rule.ActivityTestRule;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Settings.AccessibilitySettingsActivity;
|
||||
import com.android.settings.core.InstrumentedPreferenceFragment;
|
||||
import com.android.settings.core.SubSettingLauncher;
|
||||
|
||||
import org.hamcrest.Matcher;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class AccessibilityShortcutPreferenceFragmentTest {
|
||||
@Rule
|
||||
public final ActivityTestRule<AccessibilitySettingsActivity> mActivityRule =
|
||||
new ActivityTestRule<>(AccessibilitySettingsActivity.class, true);
|
||||
|
||||
private final Instrumentation mInstrumentation = InstrumentationRegistry.getInstrumentation();
|
||||
private AccessibilityShortcutPreferenceFragment mAccessibilityShortcutPreferenceFragment;
|
||||
private AccessibilitySettingsActivity mActivity;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mActivity = mActivityRule.getActivity();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void lockScreenPreference_setOnBeforeDialogShown_isOn() {
|
||||
setDialogShown(false);
|
||||
setOnLockscreen(true);
|
||||
startFragment();
|
||||
assertLockscreenSwitchIsCheckedIs(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void lockScreenPreference_defaultAfterDialogShown_isOn() {
|
||||
setDialogShown(true);
|
||||
setOnLockscreen(null);
|
||||
startFragment();
|
||||
assertLockscreenSwitchIsCheckedIs(true);
|
||||
}
|
||||
|
||||
private void startFragment() {
|
||||
mInstrumentation.runOnMainSync(() -> {
|
||||
new SubSettingLauncher(mActivity)
|
||||
.setDestination(AccessibilityShortcutPreferenceFragment.class.getName())
|
||||
.setArguments(new Bundle())
|
||||
.setSourceMetricsCategory(
|
||||
InstrumentedPreferenceFragment.METRICS_CATEGORY_UNKNOWN)
|
||||
.launch();
|
||||
});
|
||||
}
|
||||
|
||||
private void setDialogShown(boolean shown) {
|
||||
Settings.Secure.putInt(mActivity.getContentResolver(),
|
||||
Settings.Secure.ACCESSIBILITY_SHORTCUT_DIALOG_SHOWN, shown ? 1 : 0);
|
||||
}
|
||||
|
||||
private void setOnLockscreen(Boolean onLockscreen) {
|
||||
if (onLockscreen == null) {
|
||||
Settings.Secure.putString(mActivity.getContentResolver(),
|
||||
Settings.Secure.ACCESSIBILITY_SHORTCUT_ON_LOCK_SCREEN, null);
|
||||
} else {
|
||||
Settings.Secure.putInt(mActivity.getContentResolver(),
|
||||
Settings.Secure.ACCESSIBILITY_SHORTCUT_ON_LOCK_SCREEN, onLockscreen ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
private void assertLockscreenSwitchIsCheckedIs(boolean isChecked) {
|
||||
// Identify the switch by looking for a grandparent that has a descendent with the
|
||||
// switch label. To disambiguate, make sure that grandparent doesn't also have a descendant
|
||||
// with the title of the main switch
|
||||
final String lockScreenSwitchTitle =
|
||||
mActivity.getString(R.string.accessibility_shortcut_service_on_lock_screen_title);
|
||||
final String mainSwitchTitle =
|
||||
mActivity.getString(R.string.accessibility_service_master_switch_title);
|
||||
Matcher isCheckedMatcher = (isChecked) ? isChecked() : isNotChecked();
|
||||
Matcher hasLockScreenTitleDescendant = hasDescendant(withText(lockScreenSwitchTitle));
|
||||
Matcher noMainSwitchTitleDescendant = not(hasDescendant(withText(mainSwitchTitle)));
|
||||
onView(allOf(withParent(withParent(allOf(
|
||||
hasLockScreenTitleDescendant, noMainSwitchTitleDescendant))),
|
||||
instanceOf(CompoundButton.class))).check(matches(isCheckedMatcher));
|
||||
}
|
||||
}
|
@@ -86,5 +86,10 @@ public class ToggleFeaturePreferenceFragmentTest {
|
||||
public int getMetricsCategory() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
int getUserShortcutTypes() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
@@ -36,6 +36,7 @@ import com.android.settings.development.featureflags.FeatureFlagsDashboard;
|
||||
import com.android.settingslib.core.instrumentation.Instrumentable;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@@ -60,6 +61,7 @@ public class LifecycleEventHandlingTest {
|
||||
|
||||
@Test
|
||||
@Presubmit
|
||||
@Ignore("b/133334887")
|
||||
public void launchDashboard_shouldSeeFooter() {
|
||||
new SubSettingLauncher(mContext)
|
||||
.setDestination(FeatureFlagsDashboard.class.getName())
|
||||
|
@@ -28,9 +28,9 @@ import androidx.test.filters.MediumTest;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.search.DatabaseIndexingUtils;
|
||||
import com.android.settings.search.Indexable;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
import com.android.settingslib.search.SearchIndexableData;
|
||||
import com.android.settingslib.search.SearchIndexableResources;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -60,10 +60,10 @@ public class PreferenceControllerContractTest {
|
||||
final SearchIndexableResources resources =
|
||||
FeatureFactory.getFactory(mContext).getSearchFeatureProvider()
|
||||
.getSearchIndexableResources();
|
||||
for (Class<?> clazz : resources.getProviderValues()) {
|
||||
for (SearchIndexableData bundle : resources.getProviderValues()) {
|
||||
|
||||
final Indexable.SearchIndexProvider provider =
|
||||
DatabaseIndexingUtils.getSearchIndexProvider(clazz);
|
||||
final BaseSearchIndexProvider provider =
|
||||
(BaseSearchIndexProvider) bundle.getSearchIndexProvider();
|
||||
if (provider == null) {
|
||||
continue;
|
||||
}
|
||||
|
@@ -32,9 +32,9 @@ import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.android.settings.core.PreferenceXmlParserUtils.MetadataFlag;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.search.DatabaseIndexingUtils;
|
||||
import com.android.settings.search.Indexable;
|
||||
import com.android.settings.search.SearchIndexableRaw;
|
||||
import com.android.settingslib.search.Indexable;
|
||||
import com.android.settingslib.search.SearchIndexableData;
|
||||
import com.android.settingslib.search.SearchIndexableRaw;
|
||||
import com.android.settingslib.search.SearchIndexableResources;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -120,8 +120,8 @@ public class UniquePreferenceTest {
|
||||
final SearchIndexableResources resources =
|
||||
FeatureFactory.getFactory(mContext).getSearchFeatureProvider()
|
||||
.getSearchIndexableResources();
|
||||
for (Class<?> clazz : resources.getProviderValues()) {
|
||||
verifyPreferenceKeys(uniqueKeys, duplicatedKeys, nullKeyClasses, clazz);
|
||||
for (SearchIndexableData SearchIndexableData : resources.getProviderValues()) {
|
||||
verifyPreferenceKeys(uniqueKeys, duplicatedKeys, nullKeyClasses, SearchIndexableData);
|
||||
}
|
||||
|
||||
if (!nullKeyClasses.isEmpty()) {
|
||||
@@ -145,14 +145,12 @@ public class UniquePreferenceTest {
|
||||
}
|
||||
|
||||
private void verifyPreferenceKeys(Set<String> uniqueKeys, Set<String> duplicatedKeys,
|
||||
Set<String> nullKeyClasses, Class<?> clazz)
|
||||
Set<String> nullKeyClasses, SearchIndexableData searchIndexableData)
|
||||
throws IOException, XmlPullParserException, Resources.NotFoundException {
|
||||
if (clazz == null) {
|
||||
return;
|
||||
}
|
||||
final String className = clazz.getName();
|
||||
|
||||
final String className = searchIndexableData.getTargetClass().getName();
|
||||
final Indexable.SearchIndexProvider provider =
|
||||
DatabaseIndexingUtils.getSearchIndexProvider(clazz);
|
||||
searchIndexableData.getSearchIndexProvider();
|
||||
final List<SearchIndexableRaw> rawsToIndex = provider.getRawDataToIndex(mContext, true);
|
||||
final List<SearchIndexableResource> resourcesToIndex =
|
||||
provider.getXmlResourcesToIndex(mContext, true);
|
||||
|
@@ -33,8 +33,8 @@ import androidx.test.filters.MediumTest;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.search.DatabaseIndexingUtils;
|
||||
import com.android.settings.search.Indexable;
|
||||
import com.android.settingslib.search.Indexable;
|
||||
import com.android.settingslib.search.SearchIndexableData;
|
||||
import com.android.settingslib.search.SearchIndexableResources;
|
||||
|
||||
import com.google.android.collect.Sets;
|
||||
@@ -84,22 +84,21 @@ public class UserRestrictionTest {
|
||||
final SearchIndexableResources resources =
|
||||
FeatureFactory.getFactory(mContext).getSearchFeatureProvider()
|
||||
.getSearchIndexableResources();
|
||||
for (Class<?> clazz : resources.getProviderValues()) {
|
||||
verifyUserRestriction(clazz);
|
||||
for (SearchIndexableData bundle : resources.getProviderValues()) {
|
||||
verifyUserRestriction(bundle);
|
||||
}
|
||||
}
|
||||
|
||||
private void verifyUserRestriction(Class<?> clazz)
|
||||
private void verifyUserRestriction(SearchIndexableData searchIndexableData)
|
||||
throws IOException, XmlPullParserException, Resources.NotFoundException {
|
||||
if (clazz == null) {
|
||||
return;
|
||||
}
|
||||
final String className = clazz.getName();
|
||||
|
||||
final Indexable.SearchIndexProvider provider =
|
||||
DatabaseIndexingUtils.getSearchIndexProvider(clazz);
|
||||
searchIndexableData.getSearchIndexProvider();
|
||||
final List<SearchIndexableResource> resourcesToIndex =
|
||||
provider.getXmlResourcesToIndex(mContext, true);
|
||||
|
||||
final String className = searchIndexableData.getTargetClass().getName();
|
||||
|
||||
if (resourcesToIndex == null) {
|
||||
Log.d(TAG, className + "is not providing SearchIndexableResource, skipping");
|
||||
return;
|
||||
|
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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.fuelgauge;
|
||||
|
||||
import static androidx.test.espresso.Espresso.onView;
|
||||
import static androidx.test.espresso.action.ViewActions.click;
|
||||
import static androidx.test.espresso.matcher.ViewMatchers.withText;
|
||||
|
||||
import android.app.Instrumentation;
|
||||
import android.content.Intent;
|
||||
|
||||
import androidx.test.InstrumentationRegistry;
|
||||
import androidx.test.filters.SmallTest;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.android.settings.R;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@SmallTest
|
||||
public class PowerUsageSummaryTest {
|
||||
private static final String BATTERY_INTENT = "android.intent.action.POWER_USAGE_SUMMARY";
|
||||
|
||||
@Before
|
||||
public void SetUp() {
|
||||
Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
|
||||
instrumentation.startActivitySync(new Intent(BATTERY_INTENT));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClickLastFullCharge_shouldNotCrash() {
|
||||
onView(withText(R.string.battery_last_full_charge)).perform(click());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClickScreenUsage_shouldNotCrash() {
|
||||
onView(withText(R.string.device_screen_usage)).perform(click());
|
||||
}
|
||||
|
||||
}
|
@@ -27,6 +27,7 @@ import android.app.Instrumentation;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.support.test.uiautomator.UiDevice;
|
||||
|
||||
import androidx.test.InstrumentationRegistry;
|
||||
import androidx.test.filters.SmallTest;
|
||||
@@ -42,6 +43,7 @@ import java.util.concurrent.TimeUnit;
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@SmallTest
|
||||
public class RestrictAppTest {
|
||||
private static final String WM_DISMISS_KEYGUARD_COMMAND = "wm dismiss-keyguard";
|
||||
private static final String BATTERY_INTENT = "android.intent.action.POWER_USAGE_SUMMARY";
|
||||
private static final String PACKAGE_SETTINGS = "com.android.settings";
|
||||
private static final String PACKAGE_SYSTEM_UI = "com.android.systemui";
|
||||
@@ -50,10 +52,16 @@ public class RestrictAppTest {
|
||||
|
||||
private BatteryDatabaseManager mBatteryDatabaseManager;
|
||||
private PackageManager mPackageManager;
|
||||
private UiDevice mUiDevice;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
public void setUp() throws Exception {
|
||||
final Context context = InstrumentationRegistry.getTargetContext();
|
||||
|
||||
mUiDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
|
||||
mUiDevice.wakeUp();
|
||||
mUiDevice.executeShellCommand(WM_DISMISS_KEYGUARD_COMMAND);
|
||||
|
||||
mPackageManager = context.getPackageManager();
|
||||
mBatteryDatabaseManager = BatteryDatabaseManager.getInstance(context);
|
||||
mBatteryDatabaseManager.deleteAllAnomaliesBeforeTimeStamp(System.currentTimeMillis() +
|
||||
@@ -68,7 +76,7 @@ public class RestrictAppTest {
|
||||
AnomalyDatabaseHelper.State.NEW, System.currentTimeMillis());
|
||||
|
||||
Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
|
||||
instrumentation.startActivitySync(new Intent(BATTERY_INTENT));
|
||||
instrumentation.startActivitySync(createBatteryIntent());
|
||||
onView(withText("Restrict 1 app")).check(matches(isDisplayed()));
|
||||
}
|
||||
|
||||
@@ -83,25 +91,10 @@ public class RestrictAppTest {
|
||||
AnomalyDatabaseHelper.State.NEW, System.currentTimeMillis());
|
||||
|
||||
Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
|
||||
instrumentation.startActivitySync(new Intent(BATTERY_INTENT));
|
||||
instrumentation.startActivitySync(createBatteryIntent());
|
||||
onView(withText("Restrict 2 apps")).check(matches(isDisplayed()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void batterySettings_hasAutoHandledAnomalies_showAutoHandled() throws
|
||||
PackageManager.NameNotFoundException {
|
||||
mBatteryDatabaseManager.insertAnomaly(mPackageManager.getPackageUid(PACKAGE_SETTINGS, 0),
|
||||
PACKAGE_SETTINGS, 1,
|
||||
AnomalyDatabaseHelper.State.AUTO_HANDLED, System.currentTimeMillis());
|
||||
mBatteryDatabaseManager.insertAnomaly(mPackageManager.getPackageUid(PACKAGE_SYSTEM_UI, 0),
|
||||
PACKAGE_SYSTEM_UI, 1,
|
||||
AnomalyDatabaseHelper.State.AUTO_HANDLED, System.currentTimeMillis());
|
||||
|
||||
Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
|
||||
instrumentation.startActivitySync(new Intent(BATTERY_INTENT));
|
||||
onView(withText("2 apps recently restricted")).check(matches(isDisplayed()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void insertDuplicateAnomalies_onlyInsertOnce() throws
|
||||
PackageManager.NameNotFoundException {
|
||||
@@ -123,4 +116,11 @@ public class RestrictAppTest {
|
||||
.addAnomalyType(ANOMALY_TYPE)
|
||||
.build());
|
||||
}
|
||||
|
||||
private Intent createBatteryIntent() {
|
||||
final Intent intent = new Intent(BATTERY_INTENT);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
|
||||
return intent;
|
||||
}
|
||||
}
|
||||
|
@@ -75,7 +75,7 @@ public class TetherProvisioningActivityTest {
|
||||
.putExtra(EXTRA_PROVISION_CALLBACK, receiver)
|
||||
.putExtra(TetherProvisioningActivity.EXTRA_TETHER_SUBID, 10000))) {
|
||||
assertEquals(TetheringManager.TETHER_ERROR_PROVISIONING_FAILED, receiver.get());
|
||||
//assertEquals(Lifecycle.State.DESTROYED, scenario.getState());
|
||||
assertEquals(Lifecycle.State.DESTROYED, scenario.getState());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (C) 2020 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.notification;
|
||||
|
||||
import static androidx.test.espresso.Espresso.onView;
|
||||
import static androidx.test.espresso.assertion.ViewAssertions.matches;
|
||||
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
|
||||
import static androidx.test.espresso.matcher.ViewMatchers.withText;
|
||||
|
||||
import static org.hamcrest.Matchers.allOf;
|
||||
|
||||
import android.app.Instrumentation;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.provider.Settings;
|
||||
import android.support.test.uiautomator.UiDevice;
|
||||
|
||||
import androidx.test.InstrumentationRegistry;
|
||||
import androidx.test.filters.SmallTest;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@SmallTest
|
||||
public class AppBubbleNotificationSettingsTest {
|
||||
|
||||
private static final String WM_DISMISS_KEYGUARD_COMMAND = "wm dismiss-keyguard";
|
||||
|
||||
private UiDevice mUiDevice;
|
||||
private Context mTargetContext;
|
||||
private Instrumentation mInstrumentation;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
mInstrumentation = InstrumentationRegistry.getInstrumentation();
|
||||
mTargetContext = mInstrumentation.getTargetContext();
|
||||
|
||||
mUiDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
|
||||
mUiDevice.wakeUp();
|
||||
mUiDevice.executeShellCommand(WM_DISMISS_KEYGUARD_COMMAND);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void launchBubbleNotificationSetting_shouldNotCrash() {
|
||||
final Intent intent = new Intent(Settings.ACTION_APP_NOTIFICATION_BUBBLE_SETTINGS)
|
||||
.putExtra(Settings.EXTRA_APP_PACKAGE, mTargetContext.getPackageName())
|
||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
|
||||
mInstrumentation.startActivitySync(intent);
|
||||
|
||||
CharSequence name = mTargetContext.getApplicationInfo().loadLabel(
|
||||
mTargetContext.getPackageManager());
|
||||
onView(allOf(withText(name.toString()))).check(matches(isDisplayed()));
|
||||
}
|
||||
}
|
@@ -43,6 +43,7 @@ import androidx.test.runner.lifecycle.ActivityLifecycleMonitorRegistry;
|
||||
import androidx.test.runner.lifecycle.Stage;
|
||||
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
import com.android.internal.widget.LockscreenCredential;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
@@ -150,7 +151,7 @@ public class ChooseLockGenericTest {
|
||||
.putExtra(LockPatternUtils.PASSWORD_TYPE_KEY,
|
||||
DevicePolicyManager.PASSWORD_QUALITY_NUMERIC)
|
||||
.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD,
|
||||
"12345")
|
||||
LockscreenCredential.createPin("12345"))
|
||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
getInstrumentation().getContext().startActivity(newPasswordIntent);
|
||||
mDevice.waitForIdle();
|
||||
|
@@ -31,8 +31,8 @@ import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.android.settings.core.PreferenceXmlParserUtils;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.search.DatabaseIndexingUtils;
|
||||
import com.android.settings.search.Indexable;
|
||||
import com.android.settingslib.search.Indexable;
|
||||
import com.android.settingslib.search.SearchIndexableData;
|
||||
import com.android.settingslib.search.SearchIndexableResources;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -67,8 +67,8 @@ public class SliceDataContractTest {
|
||||
FeatureFactory.getFactory(mContext).getSearchFeatureProvider()
|
||||
.getSearchIndexableResources();
|
||||
|
||||
for (Class<?> clazz : resources.getProviderValues()) {
|
||||
verifyPreferenceTitle(nullTitleFragments, clazz);
|
||||
for (SearchIndexableData SearchIndexableData : resources.getProviderValues()) {
|
||||
verifyPreferenceTitle(nullTitleFragments, SearchIndexableData);
|
||||
}
|
||||
|
||||
if (!nullTitleFragments.isEmpty()) {
|
||||
@@ -82,14 +82,13 @@ public class SliceDataContractTest {
|
||||
}
|
||||
}
|
||||
|
||||
private void verifyPreferenceTitle(Set<String> nullTitleFragments, Class<?> clazz)
|
||||
private void verifyPreferenceTitle(Set<String> nullTitleFragments,
|
||||
SearchIndexableData searchIndexableData)
|
||||
throws IOException, XmlPullParserException {
|
||||
if (clazz == null) {
|
||||
return;
|
||||
}
|
||||
final String className = clazz.getName();
|
||||
|
||||
final String className = searchIndexableData.getTargetClass().getName();
|
||||
final Indexable.SearchIndexProvider provider =
|
||||
DatabaseIndexingUtils.getSearchIndexProvider(clazz);
|
||||
searchIndexableData.getSearchIndexProvider();
|
||||
|
||||
final List<SearchIndexableResource> resourcesToIndex =
|
||||
provider.getXmlResourcesToIndex(mContext, true);
|
||||
|
@@ -28,7 +28,6 @@ import static org.hamcrest.CoreMatchers.allOf;
|
||||
import static org.hamcrest.CoreMatchers.anything;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.matchers.JUnitMatchers.containsString;
|
||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.nullable;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
@@ -39,13 +38,13 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.support.test.uiautomator.UiDevice;
|
||||
import android.telephony.SubscriptionInfo;
|
||||
import android.telephony.ims.ImsMmTelManager;
|
||||
|
||||
import androidx.test.InstrumentationRegistry;
|
||||
import androidx.test.espresso.NoMatchingViewException;
|
||||
import androidx.test.espresso.ViewInteraction;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.android.ims.ImsConfig;
|
||||
import com.android.ims.ImsManager;
|
||||
import com.android.internal.telephony.SubscriptionController;
|
||||
import com.android.settings.testutils.MockedServiceManager;
|
||||
@@ -88,6 +87,10 @@ public class WifiCallingSettingUiTest {
|
||||
ImsManager mImsManager0;
|
||||
@Mock
|
||||
ImsManager mImsManager1;
|
||||
@Mock
|
||||
ImsMmTelManager mImsMmTelManager0;
|
||||
@Mock
|
||||
ImsMmTelManager mImsMmTelManager1;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
@@ -136,10 +139,10 @@ public class WifiCallingSettingUiTest {
|
||||
public void testSingleSimUi() throws InterruptedException {
|
||||
configureSingleSim();
|
||||
doReturn(true).when(mImsManager0).isWfcEnabledByUser();
|
||||
doReturn(ImsConfig.WfcModeFeatureValueConstants.WIFI_PREFERRED)
|
||||
.when(mImsManager0).getWfcMode();
|
||||
doReturn(ImsConfig.WfcModeFeatureValueConstants.WIFI_PREFERRED)
|
||||
.when(mImsManager0).getWfcMode(anyBoolean());
|
||||
doReturn(ImsMmTelManager.WIFI_MODE_WIFI_PREFERRED)
|
||||
.when(mImsMmTelManager0).getVoWiFiModeSetting();
|
||||
doReturn(ImsMmTelManager.WIFI_MODE_WIFI_PREFERRED)
|
||||
.when(mImsMmTelManager0).getVoWiFiRoamingModeSetting();
|
||||
|
||||
mInstrumentation.startActivitySync(createActivityIntent());
|
||||
|
||||
@@ -181,10 +184,10 @@ public class WifiCallingSettingUiTest {
|
||||
doReturn(false).when(mImsManager1).isWfcEnabledByPlatform();
|
||||
doReturn(false).when(mImsManager1).isNonTtyOrTtyOnVolteEnabled();
|
||||
doReturn(false).when(mImsManager0).isWfcEnabledByUser();
|
||||
doReturn(ImsConfig.WfcModeFeatureValueConstants.WIFI_PREFERRED)
|
||||
.when(mImsManager0).getWfcMode();
|
||||
doReturn(ImsConfig.WfcModeFeatureValueConstants.WIFI_PREFERRED)
|
||||
.when(mImsManager0).getWfcMode(anyBoolean());
|
||||
doReturn(ImsMmTelManager.WIFI_MODE_WIFI_PREFERRED)
|
||||
.when(mImsMmTelManager0).getVoWiFiModeSetting();
|
||||
doReturn(ImsMmTelManager.WIFI_MODE_WIFI_PREFERRED)
|
||||
.when(mImsMmTelManager0).getVoWiFiRoamingModeSetting();
|
||||
|
||||
Activity activity = mInstrumentation.startActivitySync(createActivityIntent());
|
||||
|
||||
@@ -200,10 +203,10 @@ public class WifiCallingSettingUiTest {
|
||||
public void testWfcDisabled() throws InterruptedException {
|
||||
configureSingleSim();
|
||||
doReturn(false).when(mImsManager0).isWfcEnabledByUser();
|
||||
doReturn(ImsConfig.WfcModeFeatureValueConstants.WIFI_PREFERRED)
|
||||
.when(mImsManager0).getWfcMode();
|
||||
doReturn(ImsConfig.WfcModeFeatureValueConstants.WIFI_PREFERRED)
|
||||
.when(mImsManager0).getWfcMode(anyBoolean());
|
||||
doReturn(ImsMmTelManager.WIFI_MODE_WIFI_PREFERRED)
|
||||
.when(mImsMmTelManager0).getVoWiFiModeSetting();
|
||||
doReturn(ImsMmTelManager.WIFI_MODE_WIFI_PREFERRED)
|
||||
.when(mImsMmTelManager0).getVoWiFiRoamingModeSetting();
|
||||
|
||||
Activity activity = mInstrumentation.startActivitySync(createActivityIntent());
|
||||
|
||||
@@ -220,10 +223,10 @@ public class WifiCallingSettingUiTest {
|
||||
configureDualSim();
|
||||
doReturn(true).when(mImsManager0).isWfcEnabledByUser();
|
||||
doReturn(false).when(mImsManager1).isWfcEnabledByUser();
|
||||
doReturn(ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED)
|
||||
.when(mImsManager0).getWfcMode();
|
||||
doReturn(ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED)
|
||||
.when(mImsManager0).getWfcMode(anyBoolean());
|
||||
doReturn(ImsMmTelManager.WIFI_MODE_CELLULAR_PREFERRED)
|
||||
.when(mImsMmTelManager0).getVoWiFiModeSetting();
|
||||
doReturn(ImsMmTelManager.WIFI_MODE_CELLULAR_PREFERRED)
|
||||
.when(mImsMmTelManager0).getVoWiFiRoamingModeSetting();
|
||||
|
||||
mInstrumentation.startActivitySync(createActivityIntent());
|
||||
|
||||
@@ -258,6 +261,7 @@ public class WifiCallingSettingUiTest {
|
||||
com.android.settings.Settings.WifiCallingSettingsActivity.class);
|
||||
intent.setPackage("com.android.settings");
|
||||
intent.setAction("android.intent.action.MAIN");
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
return intent;
|
||||
}
|
||||
|
||||
|
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package com.android.settings.wifi;
|
||||
|
||||
import static androidx.test.InstrumentationRegistry.getInstrumentation;
|
||||
import static androidx.test.espresso.Espresso.onView;
|
||||
import static androidx.test.espresso.assertion.ViewAssertions.doesNotExist;
|
||||
import static androidx.test.espresso.assertion.ViewAssertions.matches;
|
||||
@@ -28,9 +27,7 @@ import static androidx.test.espresso.matcher.ViewMatchers.withText;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.hamcrest.Matchers.allOf;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.hamcrest.Matchers.startsWith;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@@ -39,9 +36,9 @@ import android.content.Intent;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.net.wifi.WifiConfiguration;
|
||||
import android.net.wifi.WifiConfiguration.NetworkSelectionStatus;
|
||||
import android.net.wifi.WifiInfo;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.net.wifi.WifiSsid;
|
||||
import android.provider.Settings;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
@@ -60,13 +57,13 @@ import com.android.settingslib.wifi.WifiTrackerFactory;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@@ -129,11 +126,12 @@ public class WifiSettingsUiTest {
|
||||
config.SSID = TEST_SSID;
|
||||
config.BSSID = TEST_BSSID;
|
||||
config.networkId = TEST_NETWORK_ID;
|
||||
WifiInfo wifiInfo = new WifiInfo();
|
||||
wifiInfo.setSSID(WifiSsid.createFromAsciiEncoded(TEST_UNQUOTED_SSID));
|
||||
wifiInfo.setBSSID(TEST_BSSID);
|
||||
wifiInfo.setRssi(TEST_RSSI);
|
||||
wifiInfo.setNetworkId(TEST_NETWORK_ID);
|
||||
WifiInfo wifiInfo = new WifiInfo.Builder()
|
||||
.setSsid(TEST_UNQUOTED_SSID.getBytes(StandardCharsets.UTF_8))
|
||||
.setBssid(TEST_BSSID)
|
||||
.setRssi(TEST_RSSI)
|
||||
.setNetworkId(TEST_NETWORK_ID)
|
||||
.build();
|
||||
NetworkInfo networkInfo = new NetworkInfo(ConnectivityManager.TYPE_WIFI, 0, null, null);
|
||||
networkInfo.setDetailedState(NetworkInfo.DetailedState.CONNECTED, null, null);
|
||||
AccessPoint accessPoint = new AccessPoint(mContext, config);
|
||||
@@ -294,19 +292,20 @@ public class WifiSettingsUiTest {
|
||||
config.networkId = TEST_NETWORK_ID;
|
||||
config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
|
||||
|
||||
WifiConfiguration.NetworkSelectionStatus selectionStatus =
|
||||
new WifiConfiguration.NetworkSelectionStatus();
|
||||
selectionStatus.setNetworkSelectionDisableReason(
|
||||
WifiConfiguration.NetworkSelectionStatus.DISABLED_BY_WRONG_PASSWORD);
|
||||
selectionStatus.setNetworkSelectionStatus(
|
||||
WifiConfiguration.NetworkSelectionStatus.NETWORK_SELECTION_TEMPORARY_DISABLED);
|
||||
NetworkSelectionStatus selectionStatus = new NetworkSelectionStatus.Builder()
|
||||
.setNetworkSelectionDisableReason(
|
||||
NetworkSelectionStatus.DISABLED_BY_WRONG_PASSWORD)
|
||||
.setNetworkSelectionStatus(
|
||||
NetworkSelectionStatus.NETWORK_SELECTION_TEMPORARY_DISABLED)
|
||||
.build();
|
||||
config.setNetworkSelectionStatus(selectionStatus);
|
||||
|
||||
WifiInfo wifiInfo = new WifiInfo();
|
||||
wifiInfo.setSSID(WifiSsid.createFromAsciiEncoded(TEST_UNQUOTED_SSID));
|
||||
wifiInfo.setBSSID(TEST_BSSID);
|
||||
wifiInfo.setRssi(TEST_RSSI);
|
||||
wifiInfo.setNetworkId(TEST_NETWORK_ID);
|
||||
WifiInfo wifiInfo = new WifiInfo.Builder()
|
||||
.setSsid(TEST_UNQUOTED_SSID.getBytes(StandardCharsets.UTF_8))
|
||||
.setBssid(TEST_BSSID)
|
||||
.setRssi(TEST_RSSI)
|
||||
.setNetworkId(TEST_NETWORK_ID)
|
||||
.build();
|
||||
AccessPoint accessPoint = new AccessPoint(mContext, config);
|
||||
accessPoint.update(config, wifiInfo, null);
|
||||
|
||||
@@ -315,12 +314,12 @@ public class WifiSettingsUiTest {
|
||||
assertThat(accessPoint.getBssid()).isEqualTo(TEST_BSSID);
|
||||
assertThat(accessPoint.isActive()).isFalse();
|
||||
assertThat(accessPoint.getConfig()).isNotNull();
|
||||
WifiConfiguration.NetworkSelectionStatus networkStatus =
|
||||
accessPoint.getConfig().getNetworkSelectionStatus();
|
||||
NetworkSelectionStatus networkStatus = accessPoint.getConfig().getNetworkSelectionStatus();
|
||||
assertThat(networkStatus).isNotNull();
|
||||
assertThat(networkStatus.isNetworkEnabled()).isFalse();
|
||||
assertThat(networkStatus.getNetworkSelectionStatus())
|
||||
.isEqualTo(NetworkSelectionStatus.NETWORK_SELECTION_TEMPORARY_DISABLED);
|
||||
assertThat(networkStatus.getNetworkSelectionDisableReason()).isEqualTo(
|
||||
WifiConfiguration.NetworkSelectionStatus.DISABLED_BY_WRONG_PASSWORD);
|
||||
NetworkSelectionStatus.DISABLED_BY_WRONG_PASSWORD);
|
||||
|
||||
when(mWifiTracker.getAccessPoints()).thenReturn(Lists.newArrayList(accessPoint));
|
||||
launchActivity(WifiSettings.EXTRA_START_CONNECT_SSID, accessPoint.getSsidStr());
|
||||
|
@@ -26,10 +26,13 @@ import android.os.RemoteException;
|
||||
import android.provider.Settings;
|
||||
import android.support.test.uiautomator.UiDevice;
|
||||
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.test.InstrumentationRegistry;
|
||||
import androidx.test.rule.ActivityTestRule;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.google.android.setupdesign.GlifLayout;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -60,8 +63,13 @@ public class WifiDppConfiguratorActivityTest {
|
||||
intent.putExtra(WifiDppUtils.EXTRA_WIFI_PRE_SHARED_KEY, "password");
|
||||
|
||||
mActivityRule.launchActivity(intent);
|
||||
FragmentManager fragmentManager = mActivityRule.getActivity().getSupportFragmentManager();
|
||||
WifiDppQrCodeScannerFragment fragment =
|
||||
(WifiDppQrCodeScannerFragment) fragmentManager.findFragmentByTag(
|
||||
WifiDppUtils.TAG_FRAGMENT_QR_CODE_SCANNER);
|
||||
|
||||
assertThat(mActivityRule.getActivity().isFinishing()).isEqualTo(false);
|
||||
assertThat(fragment.getView() instanceof GlifLayout).isTrue();
|
||||
assertThat(mActivityRule.getActivity().isFinishing()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -73,8 +81,13 @@ public class WifiDppConfiguratorActivityTest {
|
||||
intent.putExtra(WifiDppUtils.EXTRA_WIFI_PRE_SHARED_KEY, "password");
|
||||
|
||||
mActivityRule.launchActivity(intent);
|
||||
FragmentManager fragmentManager = mActivityRule.getActivity().getSupportFragmentManager();
|
||||
WifiDppQrCodeGeneratorFragment fragment =
|
||||
(WifiDppQrCodeGeneratorFragment) fragmentManager.findFragmentByTag(
|
||||
WifiDppUtils.TAG_FRAGMENT_QR_CODE_GENERATOR);
|
||||
|
||||
assertThat(mActivityRule.getActivity().isFinishing()).isEqualTo(false);
|
||||
assertThat(fragment.getView() instanceof GlifLayout).isTrue();
|
||||
assertThat(mActivityRule.getActivity().isFinishing()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -84,22 +97,14 @@ public class WifiDppConfiguratorActivityTest {
|
||||
|
||||
mActivityRule.launchActivity(intent);
|
||||
|
||||
assertThat(mActivityRule.getActivity().isFinishing()).isEqualTo(false);
|
||||
assertThat(mActivityRule.getActivity().isFinishing()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testActivity_shouldImplementsWifiNetworkConfigRetriever() {
|
||||
WifiDppConfiguratorActivity activity = mActivityRule.getActivity();
|
||||
|
||||
assertThat(activity instanceof WifiNetworkConfig.Retriever).isEqualTo(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testActivity_shouldImplementsQrCodeGeneratorFragmentCallback() {
|
||||
WifiDppConfiguratorActivity activity = mActivityRule.getActivity();
|
||||
|
||||
assertThat(activity instanceof WifiDppQrCodeGeneratorFragment
|
||||
.OnQrCodeGeneratorFragmentAddButtonClickedListener).isEqualTo(true);
|
||||
assertThat(activity instanceof WifiNetworkConfig.Retriever).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -107,7 +112,7 @@ public class WifiDppConfiguratorActivityTest {
|
||||
WifiDppConfiguratorActivity activity = mActivityRule.getActivity();
|
||||
|
||||
assertThat(activity instanceof WifiDppQrCodeScannerFragment
|
||||
.OnScanWifiDppSuccessListener).isEqualTo(true);
|
||||
.OnScanWifiDppSuccessListener).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -115,7 +120,7 @@ public class WifiDppConfiguratorActivityTest {
|
||||
WifiDppConfiguratorActivity activity = mActivityRule.getActivity();
|
||||
|
||||
assertThat(activity instanceof WifiDppAddDeviceFragment
|
||||
.OnClickChooseDifferentNetworkListener).isEqualTo(true);
|
||||
.OnClickChooseDifferentNetworkListener).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -175,40 +180,4 @@ public class WifiDppConfiguratorActivityTest {
|
||||
assertThat(restoredWifiNetworkConfig.getNetworkId()).isEqualTo(0);
|
||||
assertThat(restoredWifiNetworkConfig.isHotspot()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void launchScanner_onNavigateUp_shouldFinish() {
|
||||
Intent intent = new Intent(WifiDppConfiguratorActivity.ACTION_CONFIGURATOR_QR_CODE_SCANNER);
|
||||
intent.putExtra(WifiDppUtils.EXTRA_WIFI_SECURITY, "WEP");
|
||||
intent.putExtra(WifiDppUtils.EXTRA_WIFI_SSID, "GoogleGuest");
|
||||
intent.putExtra(WifiDppUtils.EXTRA_WIFI_PRE_SHARED_KEY, "password");
|
||||
final Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
|
||||
|
||||
mActivityRule.launchActivity(intent);
|
||||
|
||||
instrumentation.runOnMainSync(() -> {
|
||||
mActivityRule.getActivity().onNavigateUp();
|
||||
|
||||
assertThat(mActivityRule.getActivity().isFinishing()).isEqualTo(true);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void launchGenerator_onNavigateUp_shouldFinish() {
|
||||
Intent intent = new Intent(
|
||||
WifiDppConfiguratorActivity.ACTION_CONFIGURATOR_QR_CODE_GENERATOR);
|
||||
intent.putExtra(WifiDppUtils.EXTRA_WIFI_SECURITY, "WEP");
|
||||
intent.putExtra(WifiDppUtils.EXTRA_WIFI_SSID, "GoogleGuest");
|
||||
intent.putExtra(WifiDppUtils.EXTRA_WIFI_PRE_SHARED_KEY, "password");
|
||||
final Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
|
||||
|
||||
mActivityRule.launchActivity(intent);
|
||||
|
||||
instrumentation.runOnMainSync(() -> {
|
||||
mActivityRule.getActivity().onNavigateUp();
|
||||
|
||||
assertThat(mActivityRule.getActivity().isFinishing()).isEqualTo(true);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -23,9 +23,7 @@ import static androidx.test.espresso.matcher.ViewMatchers.withText;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Mockito.any;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -35,7 +33,6 @@ import android.net.Uri;
|
||||
import android.net.wifi.WifiConfiguration;
|
||||
import android.net.wifi.WifiInfo;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.net.wifi.WifiSsid;
|
||||
import android.provider.Settings;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
@@ -45,19 +42,18 @@ import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.android.settingslib.wifi.AccessPoint;
|
||||
import com.android.settingslib.wifi.WifiTracker;
|
||||
import com.android.settingslib.wifi.WifiTracker.WifiListener;
|
||||
import com.android.settingslib.wifi.WifiTrackerFactory;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@@ -107,8 +103,6 @@ public class WifiNetworkListFragmentTest {
|
||||
intent.setData(Uri.parse(uriString));
|
||||
mActivityRule.launchActivity(intent);
|
||||
|
||||
verify(mWifiTracker).getManager();
|
||||
|
||||
List<Fragment> fragments =
|
||||
mActivityRule.getActivity().getSupportFragmentManager().getFragments();
|
||||
assertThat(fragments.size()).isEqualTo(1);
|
||||
@@ -138,11 +132,12 @@ public class WifiNetworkListFragmentTest {
|
||||
config.BSSID = TEST_BSSID;
|
||||
config.networkId = TEST_NETWORK_ID;
|
||||
config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
|
||||
final WifiInfo wifiInfo = new WifiInfo();
|
||||
wifiInfo.setSSID(WifiSsid.createFromAsciiEncoded(TEST_UNQUOTED_SSID));
|
||||
wifiInfo.setBSSID(TEST_BSSID);
|
||||
wifiInfo.setRssi(TEST_RSSI);
|
||||
wifiInfo.setNetworkId(TEST_NETWORK_ID);
|
||||
final WifiInfo wifiInfo = new WifiInfo.Builder()
|
||||
.setSsid(TEST_UNQUOTED_SSID.getBytes(StandardCharsets.UTF_8))
|
||||
.setBssid(TEST_BSSID)
|
||||
.setRssi(TEST_RSSI)
|
||||
.setNetworkId(TEST_NETWORK_ID)
|
||||
.build();
|
||||
final NetworkInfo networkInfo = new NetworkInfo(ConnectivityManager.TYPE_WIFI, 0, null, null);
|
||||
networkInfo.setDetailedState(NetworkInfo.DetailedState.CONNECTED, null, null);
|
||||
final AccessPoint accessPoint = new AccessPoint(mContext, config);
|
||||
|
Reference in New Issue
Block a user