Merge "Added test coverage to Context.startActivityAsUser" into qt-dev
am: 471a664375
Change-Id: Ifbed2659b088b72bba4d9d80d87f0d4762d4bba8
This commit is contained in:
@@ -19,6 +19,7 @@ package android.content;
|
|||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
import android.app.ActivityThread;
|
import android.app.ActivityThread;
|
||||||
|
import android.os.UserHandle;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
|
||||||
import androidx.test.InstrumentationRegistry;
|
import androidx.test.InstrumentationRegistry;
|
||||||
@@ -58,4 +59,32 @@ public class ContextTest {
|
|||||||
assertEquals(defaultDisplayContext.getDisplay().getDisplayId(),
|
assertEquals(defaultDisplayContext.getDisplay().getDisplayId(),
|
||||||
defaultDisplayContext.getDisplayId());
|
defaultDisplayContext.getDisplayId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(expected = NullPointerException.class)
|
||||||
|
public void testStartActivityAsUserNullIntentNullUser() {
|
||||||
|
final Context testContext =
|
||||||
|
InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||||
|
testContext.startActivityAsUser(null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expected = NullPointerException.class)
|
||||||
|
public void testStartActivityAsUserNullIntentNonNullUser() {
|
||||||
|
final Context testContext =
|
||||||
|
InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||||
|
testContext.startActivityAsUser(null, new UserHandle(UserHandle.USER_ALL));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expected = NullPointerException.class)
|
||||||
|
public void testStartActivityAsUserNonNullIntentNullUser() {
|
||||||
|
final Context testContext =
|
||||||
|
InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||||
|
testContext.startActivityAsUser(new Intent(), null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expected = RuntimeException.class)
|
||||||
|
public void testStartActivityAsUserNonNullIntentNonNullUser() {
|
||||||
|
final Context testContext =
|
||||||
|
InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||||
|
testContext.startActivityAsUser(new Intent(), new UserHandle(UserHandle.USER_ALL));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user