Fix OwnersTest when run with -e package

It was because UserManager.get() returns a static cached instance but
we should always be using the mock instance that's created for each test.

Bug 24378326

Change-Id: Id4663e7676d2d0130622055a97fbde0884714349
This commit is contained in:
Makoto Onuki
2015-09-25 16:01:43 -07:00
parent cf2bb175bb
commit 72a3a0c7d2
2 changed files with 6 additions and 1 deletions

View File

@@ -101,7 +101,7 @@ class Owners {
public Owners(Context context) {
mContext = context;
mUserManager = UserManager.get(mContext);
mUserManager = context.getSystemService(UserManager.class);
}
/**

View File

@@ -218,6 +218,11 @@ public class DpmMockContext extends MockContext {
throw new UnsupportedOperationException();
}
@Override
public String getSystemServiceName(Class<?> serviceClass) {
return realTestContext.getSystemServiceName(serviceClass);
}
@Override
public PackageManager getPackageManager() {
return packageManager;