• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package com.android.tests.packagemanager.multiuser.host;
2 
3 import static com.google.common.truth.Truth.assertThat;
4 
5 import android.platform.test.annotations.AppModeFull;
6 
7 import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
8 
9 import org.junit.After;
10 import org.junit.Before;
11 import org.junit.Test;
12 import org.junit.runner.RunWith;
13 
14 import java.util.Map;
15 
16 @RunWith(DeviceJUnit4ClassRunner.class)
17 public class PackageManagerMultiUserTest extends PackageManagerMultiUserTestBase {
18 
19     @Before
20     @Override
setUp()21     public void setUp() throws Exception {
22         super.setUp();
23     }
24 
25     @After
26     @Override
tearDown()27     public void tearDown() throws Exception {
28         super.tearDown();
29     }
30 
getInstalledModules(int userId)31     private String getInstalledModules(int userId) throws Exception {
32         runDeviceTestAsUser("testGetInstalledModules", userId, null);
33         Map<String, String> results = getLastDeviceRunResults().getRunMetrics();
34         return results.get("installedModules");
35     }
36 
37     /**
38      * Tests that all users see the same set of installed modules.
39      */
40     @Test
41     @AppModeFull
testGetInstalledModules()42     public void testGetInstalledModules() throws Exception {
43         int newUserId = createUser();
44         getDevice().startUser(newUserId);
45         String list2 = getInstalledModules(newUserId);
46         String list1 = getInstalledModules(mUserId);
47         assertThat(list2).isEqualTo(list1);
48     }
49 }
50