summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRex Hoffman <rexhoffman@google.com>2024-01-05 06:18:44 +0000
committerRex Hoffman <rexhoffman@google.com>2024-01-05 06:20:00 +0000
commitf1bb755052111fc5df8b873428bbe4448b0dfff7 (patch)
tree3cf9f7602c1a99223bdf13aee8ae280e962b5e8c
parent76f865f2511840c8afc2b33ec3bda1dccb518fce (diff)
downloadSettings-f1bb755052111fc5df8b873428bbe4448b0dfff7.tar.gz
Uptesting is moving folks to /external/robolectric from /external/robolectric-shadows
We maintain /external/robolectric (keep it in sync with github/google3) and are getting ready to delete /external/robolectric-shadows Need to update Shadows to compile against external/robolectric after dependency cleanups Bug: 314757990 Test: CI (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:2db8ea218810ecae17e8e95379be1d937adc566e) Merged-In: Ib76a5188a8a4154b304b25316d67cba8d494bc96 Change-Id: Ib76a5188a8a4154b304b25316d67cba8d494bc96
-rw-r--r--Android.bp1
-rw-r--r--tests/robotests/Android.bp1
-rw-r--r--tests/robotests/config/robolectric.properties1
-rw-r--r--tests/robotests/src/com/android/car/settings/profiles/ProfileHelperTest.java7
-rw-r--r--tests/robotests/src/com/android/car/settings/testutils/ShadowNotificationManager.java83
-rw-r--r--tests/robotests/src/com/android/car/settings/testutils/ShadowTelephonyManager.java4
-rw-r--r--tests/robotests/src/com/android/car/settings/testutils/ShadowTypeface.java2
-rw-r--r--tests/robotests/src/com/android/car/settings/testutils/ShadowUserManager.java10
8 files changed, 7 insertions, 102 deletions
diff --git a/Android.bp b/Android.bp
index e85a0473e..1271fe6db 100644
--- a/Android.bp
+++ b/Android.bp
@@ -166,7 +166,6 @@ android_library {
"SettingsLib-search",
"androidx-constraintlayout_constraintlayout-solver",
"jsr305",
- "car-ui-lib-testing-support",
"car-admin-ui-lib",
"car-helper-lib",
"car-qc-lib",
diff --git a/tests/robotests/Android.bp b/tests/robotests/Android.bp
index 1b9353eb6..ed801b29b 100644
--- a/tests/robotests/Android.bp
+++ b/tests/robotests/Android.bp
@@ -25,7 +25,6 @@ android_robolectric_test {
libs: [
"Settings-robo-testutils",
- "robolectric_android-all-stub",
"truth",
"testng",
"android.car",
diff --git a/tests/robotests/config/robolectric.properties b/tests/robotests/config/robolectric.properties
index 1100ea2fe..b06644334 100644
--- a/tests/robotests/config/robolectric.properties
+++ b/tests/robotests/config/robolectric.properties
@@ -17,3 +17,4 @@ sdk=NEWEST_SDK
shadows=\
com.android.car.settings.testutils.ShadowCar, \
com.android.car.settings.testutils.ShadowTypeface
+looperMode=LEGACY
diff --git a/tests/robotests/src/com/android/car/settings/profiles/ProfileHelperTest.java b/tests/robotests/src/com/android/car/settings/profiles/ProfileHelperTest.java
index 8db2002cc..1462886ca 100644
--- a/tests/robotests/src/com/android/car/settings/profiles/ProfileHelperTest.java
+++ b/tests/robotests/src/com/android/car/settings/profiles/ProfileHelperTest.java
@@ -56,8 +56,7 @@ import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowProcess;
@RunWith(RobolectricTestRunner.class)
-@Config(shadows = {ShadowActivityManager.class, ShadowUserManager.class,
- ShadowUserIconProvider.class})
+@Config(shadows = {ShadowUserManager.class, ShadowUserIconProvider.class})
public class ProfileHelperTest {
private static final String DEFAULT_ADMIN_NAME = "default_admin";
@@ -416,7 +415,7 @@ public class ProfileHelperTest {
@Test
public void testGetMaxSupportedRealUsers_isHeadless() {
ShadowUserManager.setIsHeadlessSystemUserMode(true);
- ShadowUserManager.setMaxSupportedUsers(7);
+ when(mMockUserManager.getMaxSupportedUsers()).thenReturn(7);
// Create System user, two managed profiles, and two normal users.
UserInfo user0 = createAdminUser(0);
@@ -434,7 +433,7 @@ public class ProfileHelperTest {
@Test
public void testGetMaxSupportedRealUsers_isNotHeadless() {
ShadowUserManager.setIsHeadlessSystemUserMode(false);
- ShadowUserManager.setMaxSupportedUsers(7);
+ when(mMockUserManager.getMaxSupportedUsers()).thenReturn(7);
// Create System user, two managed profiles, and two normal users.
UserInfo user0 = createAdminUser(0);
diff --git a/tests/robotests/src/com/android/car/settings/testutils/ShadowNotificationManager.java b/tests/robotests/src/com/android/car/settings/testutils/ShadowNotificationManager.java
deleted file mode 100644
index 3aab74f0f..000000000
--- a/tests/robotests/src/com/android/car/settings/testutils/ShadowNotificationManager.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright 2019 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.car.settings.testutils;
-
-import android.app.AutomaticZenRule;
-import android.app.NotificationManager;
-import android.content.ComponentName;
-import android.util.ArrayMap;
-import android.util.ArraySet;
-
-import org.robolectric.annotation.Implementation;
-import org.robolectric.annotation.Implements;
-
-import java.util.Map;
-import java.util.Set;
-
-@Implements(NotificationManager.class)
-public class ShadowNotificationManager extends org.robolectric.shadows.ShadowNotificationManager {
-
- private Set<String> mNotificationPolicyGrantedPackages = new ArraySet<>();
- private Set<ComponentName> mNotificationListenerAccessGrantedComponents = new ArraySet<>();
- private Map<String, AutomaticZenRule> mAutomaticZenRules = new ArrayMap<>();
- private int mZenRuleIdCounter = 0;
-
- @Implementation
- public void setNotificationPolicyAccessGranted(String pkg, boolean granted) {
- if (granted) {
- mNotificationPolicyGrantedPackages.add(pkg);
- } else {
- mNotificationPolicyGrantedPackages.remove(pkg);
- }
- }
-
- @Implementation
- protected boolean isNotificationPolicyAccessGrantedForPackage(String pkg) {
- return mNotificationPolicyGrantedPackages.contains(pkg);
- }
-
- @Implementation
- protected boolean isNotificationListenerAccessGranted(ComponentName listener) {
- return mNotificationListenerAccessGrantedComponents.contains(listener);
- }
-
- @Implementation
- protected void setNotificationListenerAccessGranted(ComponentName listener, boolean granted) {
- if (granted) {
- mNotificationListenerAccessGrantedComponents.add(listener);
- } else {
- mNotificationListenerAccessGrantedComponents.remove(listener);
- }
- }
-
- @Implementation
- protected Map<String, AutomaticZenRule> getAutomaticZenRules() {
- return mAutomaticZenRules;
- }
-
- @Implementation
- protected String addAutomaticZenRule(AutomaticZenRule automaticZenRule) {
- String id = String.valueOf(mZenRuleIdCounter++);
- mAutomaticZenRules.put(id, automaticZenRule);
- return id;
- }
-
- @Implementation
- protected void removeAutomaticZenRules(String packageName) {
- mAutomaticZenRules.clear();
- }
-}
diff --git a/tests/robotests/src/com/android/car/settings/testutils/ShadowTelephonyManager.java b/tests/robotests/src/com/android/car/settings/testutils/ShadowTelephonyManager.java
index 9c464f76d..17becb16a 100644
--- a/tests/robotests/src/com/android/car/settings/testutils/ShadowTelephonyManager.java
+++ b/tests/robotests/src/com/android/car/settings/testutils/ShadowTelephonyManager.java
@@ -68,12 +68,12 @@ public class ShadowTelephonyManager extends org.robolectric.shadows.ShadowTeleph
}
@Implementation
- protected void setDataEnabled(boolean enable) {
+ public void setDataEnabled(boolean enable) {
mIsDataEnabled = enable;
}
@Implementation
- protected boolean isDataEnabled() {
+ public boolean isDataEnabled() {
return mIsDataEnabled;
}
diff --git a/tests/robotests/src/com/android/car/settings/testutils/ShadowTypeface.java b/tests/robotests/src/com/android/car/settings/testutils/ShadowTypeface.java
index 23fa99252..52a46b6a8 100644
--- a/tests/robotests/src/com/android/car/settings/testutils/ShadowTypeface.java
+++ b/tests/robotests/src/com/android/car/settings/testutils/ShadowTypeface.java
@@ -24,7 +24,7 @@ import org.robolectric.annotation.Implements;
* This is to shadow an extra function that old versions of Robolectric don't cover.
*/
@Implements(value = Typeface.class)
-public class ShadowTypeface extends org.robolectric.shadows.ShadowTypeface {
+public class ShadowTypeface extends org.robolectric.shadows.ShadowLegacyTypeface {
@Implementation
public static Typeface create(Typeface family, int weight, boolean italic) {
diff --git a/tests/robotests/src/com/android/car/settings/testutils/ShadowUserManager.java b/tests/robotests/src/com/android/car/settings/testutils/ShadowUserManager.java
index e9fcf2b45..ce616b277 100644
--- a/tests/robotests/src/com/android/car/settings/testutils/ShadowUserManager.java
+++ b/tests/robotests/src/com/android/car/settings/testutils/ShadowUserManager.java
@@ -39,7 +39,6 @@ public class ShadowUserManager extends org.robolectric.shadows.ShadowUserManager
private static boolean sCanAddMoreUsers = true;
private static Map<Integer, List<UserInfo>> sProfiles = new ArrayMap<>();
private static Map<Integer, Bitmap> sUserIcons = new ArrayMap<>();
- private static int sMaxSupportedUsers = 10;
@Implementation
protected int[] getProfileIdsWithDisabled(int userId) {
@@ -101,15 +100,6 @@ public class ShadowUserManager extends org.robolectric.shadows.ShadowUserManager
sUserIcons.put(userId, icon);
}
- @Implementation
- public static int getMaxSupportedUsers() {
- return sMaxSupportedUsers;
- }
-
- public static void setMaxSupportedUsers(int maxSupportedUsers) {
- sMaxSupportedUsers = maxSupportedUsers;
- }
-
@Resetter
public static void reset() {
org.robolectric.shadows.ShadowUserManager.reset();