diff options
author | Bernardo Rufino <brufino@google.com> | 2019-08-12 15:40:49 +0100 |
---|---|---|
committer | Bernardo Rufino <brufino@google.com> | 2019-08-13 18:36:24 +0100 |
commit | 9b55bfbd17b6b6e44aea328a83dce7a32aee18fb (patch) | |
tree | 0239b94f2830d5efbf86ef60339c07b6c854e90f /services/robotests/src | |
parent | ac81c6a08f46623b355dcbb48f91a75f6c049c4f (diff) |
Move start and stop of sub-systems to Trampoline
From BMS. Moved mUserServices list creation from BMS to Trampoline.
BMS still uses it but the plan is to move gradually in multiple
CLs to eventually delete it. Both are dealing with the same instance
because of this. Start and stop of sub-system (uBMS) is now handled in
Trampoline. getUserServices() was also moved. BMS robolectric tests were moved
to Trampoline *robolectric* tests to simplify this CL. After we merge BMS and
Trampoline, we can look into moving tests away from Robolectric.
Test: atest BackupManagerServiceTest TrampolineRoboTest TrampolineTest
Bug: 135661048
Change-Id: I4e612d06fe006c12f215a94f210450a5e6316b75
Diffstat (limited to 'services/robotests/src')
-rw-r--r-- | services/robotests/src/com/android/server/testing/shadows/ShadowEnvironment.java | 50 | ||||
-rw-r--r-- | services/robotests/src/com/android/server/testing/shadows/ShadowUserManager.java | 33 |
2 files changed, 83 insertions, 0 deletions
diff --git a/services/robotests/src/com/android/server/testing/shadows/ShadowEnvironment.java b/services/robotests/src/com/android/server/testing/shadows/ShadowEnvironment.java new file mode 100644 index 000000000000..577b0824e775 --- /dev/null +++ b/services/robotests/src/com/android/server/testing/shadows/ShadowEnvironment.java @@ -0,0 +1,50 @@ +/* + * Copyright (C) 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.server.testing.shadows; + +import android.annotation.Nullable; +import android.os.Environment; + +import org.robolectric.RuntimeEnvironment; +import org.robolectric.annotation.Implementation; +import org.robolectric.annotation.Implements; +import org.robolectric.annotation.Resetter; + +import java.io.File; +import java.nio.file.Path; + +/** Implementation mimics {@link org.robolectric.shadows.ShadowEnvironment}. */ +@Implements(Environment.class) +public class ShadowEnvironment extends org.robolectric.shadows.ShadowEnvironment { + @Nullable private static Path sDataDirectory; + + /** @see Environment#getDataDirectory() */ + @Implementation + public static File getDataDirectory() { + if (sDataDirectory == null) { + sDataDirectory = RuntimeEnvironment.getTempDirectory().create("data"); + } + return sDataDirectory.toFile(); + } + + /** Resets static state. */ + @Resetter + public static void reset() { + org.robolectric.shadows.ShadowEnvironment.reset(); + sDataDirectory = null; + } +} diff --git a/services/robotests/src/com/android/server/testing/shadows/ShadowUserManager.java b/services/robotests/src/com/android/server/testing/shadows/ShadowUserManager.java new file mode 100644 index 000000000000..c6ae1a1b6863 --- /dev/null +++ b/services/robotests/src/com/android/server/testing/shadows/ShadowUserManager.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 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.server.testing.shadows; + +import android.annotation.UserIdInt; +import android.os.UserManager; + +import org.robolectric.annotation.Implementation; +import org.robolectric.annotation.Implements; + +/** Shadow for {@link UserManager}. */ +@Implements(UserManager.class) +public class ShadowUserManager extends org.robolectric.shadows.ShadowUserManager { + /** @see UserManager#isUserUnlocked() */ + @Implementation + public boolean isUserUnlocked(@UserIdInt int userId) { + return false; + } +} |