Merge "Cleanup activity and task creation in unit tests."
This commit is contained in:
@@ -51,11 +51,6 @@ import org.junit.Test;
|
||||
@Presubmit
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ActivityRecordTests extends ActivityTestsBase {
|
||||
private final ComponentName testActivityComponent =
|
||||
ComponentName.unflattenFromString("com.foo/.BarActivity");
|
||||
private final ComponentName secondaryActivityComponent =
|
||||
ComponentName.unflattenFromString("com.foo/.BarActivity2");
|
||||
|
||||
private ActivityManagerService mService;
|
||||
private TestActivityStack mStack;
|
||||
private TaskRecord mTask;
|
||||
@@ -69,8 +64,8 @@ public class ActivityRecordTests extends ActivityTestsBase {
|
||||
mService = createActivityManagerService();
|
||||
mStack = mService.mStackSupervisor.getDefaultDisplay().createStack(
|
||||
WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, true /* onTop */);
|
||||
mTask = createTask(mService.mStackSupervisor, testActivityComponent, mStack);
|
||||
mActivity = createActivity(mService, testActivityComponent, mTask);
|
||||
mTask = new TaskBuilder(mService.mStackSupervisor).setStack(mStack).build();
|
||||
mActivity = new ActivityBuilder(mService).setTask(mTask).build();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -94,8 +89,8 @@ public class ActivityRecordTests extends ActivityTestsBase {
|
||||
|
||||
@Test
|
||||
public void testNoCleanupMovingActivityInSameStack() throws Exception {
|
||||
final TaskRecord newTask =
|
||||
createTask(mService.mStackSupervisor, testActivityComponent, mStack);
|
||||
final TaskRecord newTask = new TaskBuilder(mService.mStackSupervisor).setStack(mStack)
|
||||
.build();
|
||||
mActivity.reparent(newTask, 0, null /*reason*/);
|
||||
assertEquals(mStack.onActivityRemovedFromStackInvocationCount(), 0);
|
||||
}
|
||||
@@ -149,13 +144,13 @@ public class ActivityRecordTests extends ActivityTestsBase {
|
||||
mService.mSupportsMultiWindow = true;
|
||||
|
||||
final TaskRecord task = taskPresent
|
||||
? createTask(mService.mStackSupervisor, testActivityComponent, mStack) : null;
|
||||
? new TaskBuilder(mService.mStackSupervisor).setStack(mStack).build() : null;
|
||||
|
||||
if (task != null) {
|
||||
task.setResizeMode(taskResizeable ? RESIZE_MODE_RESIZEABLE : RESIZE_MODE_UNRESIZEABLE);
|
||||
}
|
||||
|
||||
final ActivityRecord record = createActivity(mService, secondaryActivityComponent, task);
|
||||
final ActivityRecord record = new ActivityBuilder(mService).setTask(task).build();
|
||||
record.info.resizeMode = activityResizeable
|
||||
? RESIZE_MODE_RESIZEABLE : RESIZE_MODE_UNRESIZEABLE;
|
||||
|
||||
|
||||
@@ -51,9 +51,6 @@ import static com.android.server.am.ActivityStackSupervisor.MATCH_TASK_IN_STACKS
|
||||
@Presubmit
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ActivityStackSupervisorTests extends ActivityTestsBase {
|
||||
private final ComponentName testActivityComponent =
|
||||
ComponentName.unflattenFromString("com.foo/.BarActivity");
|
||||
|
||||
private ActivityManagerService mService;
|
||||
private ActivityStackSupervisor mSupervisor;
|
||||
private ActivityStack mFullscreenStack;
|
||||
@@ -87,15 +84,14 @@ public class ActivityStackSupervisorTests extends ActivityTestsBase {
|
||||
*/
|
||||
@Test
|
||||
public void testReplacingTaskInPinnedStack() throws Exception {
|
||||
final TaskRecord firstTask = createTask(
|
||||
mSupervisor, testActivityComponent, mFullscreenStack);
|
||||
final ActivityRecord firstActivity = createActivity(mService, testActivityComponent,
|
||||
firstTask);
|
||||
// Create a new task on the full screen stack
|
||||
final TaskRecord secondTask = createTask(
|
||||
mSupervisor, testActivityComponent, mFullscreenStack);
|
||||
final ActivityRecord secondActivity = createActivity(mService, testActivityComponent,
|
||||
secondTask);
|
||||
final ActivityRecord firstActivity = new ActivityBuilder(mService).setCreateTask(true)
|
||||
.setStack(mFullscreenStack).build();
|
||||
final TaskRecord firstTask = firstActivity.getTask();
|
||||
|
||||
final ActivityRecord secondActivity = new ActivityBuilder(mService).setCreateTask(true)
|
||||
.setStack(mFullscreenStack).build();
|
||||
final TaskRecord secondTask = secondActivity.getTask();
|
||||
|
||||
mSupervisor.setFocusStackUnchecked("testReplacingTaskInPinnedStack", mFullscreenStack);
|
||||
|
||||
// Ensure full screen stack has both tasks.
|
||||
@@ -142,10 +138,8 @@ public class ActivityStackSupervisorTests extends ActivityTestsBase {
|
||||
*/
|
||||
@Test
|
||||
public void testStoppingActivityRemovedWhenResumed() throws Exception {
|
||||
final TaskRecord firstTask = createTask(
|
||||
mSupervisor, testActivityComponent, mFullscreenStack);
|
||||
final ActivityRecord firstActivity = createActivity(mService, testActivityComponent,
|
||||
firstTask);
|
||||
final ActivityRecord firstActivity = new ActivityBuilder(mService).setCreateTask(true)
|
||||
.setStack(mFullscreenStack).build();
|
||||
mSupervisor.mStoppingActivities.add(firstActivity);
|
||||
|
||||
firstActivity.completeResumeLocked();
|
||||
|
||||
@@ -23,7 +23,9 @@ import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
|
||||
import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
|
||||
import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY;
|
||||
import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_SECONDARY;
|
||||
|
||||
import static com.android.server.am.ActivityStack.REMOVE_TASK_MODE_DESTROYING;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
@@ -51,11 +53,6 @@ import org.junit.Test;
|
||||
@Presubmit
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ActivityStackTests extends ActivityTestsBase {
|
||||
private static final ComponentName testActivityComponent =
|
||||
ComponentName.unflattenFromString("com.foo/.BarActivity");
|
||||
private static final ComponentName testOverlayComponent =
|
||||
ComponentName.unflattenFromString("com.foo/.OverlayActivity");
|
||||
|
||||
private ActivityManagerService mService;
|
||||
private ActivityStackSupervisor mSupervisor;
|
||||
private ActivityStack mStack;
|
||||
@@ -70,7 +67,7 @@ public class ActivityStackTests extends ActivityTestsBase {
|
||||
mSupervisor = mService.mStackSupervisor;
|
||||
mStack = mService.mStackSupervisor.getDefaultDisplay().createStack(
|
||||
WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, true /* onTop */);
|
||||
mTask = createTask(mSupervisor, testActivityComponent, mStack);
|
||||
mTask = new TaskBuilder(mSupervisor).setStack(mStack).build();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -82,7 +79,7 @@ public class ActivityStackTests extends ActivityTestsBase {
|
||||
|
||||
@Test
|
||||
public void testOccupiedTaskCleanupOnRemove() throws Exception {
|
||||
final ActivityRecord r = createActivity(mService, testActivityComponent, mTask);
|
||||
final ActivityRecord r = new ActivityBuilder(mService).setTask(mTask).build();
|
||||
assertNotNull(mTask.getWindowContainerController());
|
||||
mStack.removeTask(mTask, "testOccupiedTaskCleanupOnRemove", REMOVE_TASK_MODE_DESTROYING);
|
||||
assertNotNull(mTask.getWindowContainerController());
|
||||
@@ -90,7 +87,7 @@ public class ActivityStackTests extends ActivityTestsBase {
|
||||
|
||||
@Test
|
||||
public void testNoPauseDuringResumeTopActivity() throws Exception {
|
||||
final ActivityRecord r = createActivity(mService, testActivityComponent, mTask);
|
||||
final ActivityRecord r = new ActivityBuilder(mService).setTask(mTask).build();
|
||||
|
||||
// Simulate the a resumed activity set during
|
||||
// {@link ActivityStack#resumeTopActivityUncheckedLocked}.
|
||||
@@ -108,7 +105,7 @@ public class ActivityStackTests extends ActivityTestsBase {
|
||||
|
||||
@Test
|
||||
public void testStopActivityWhenActivityDestroyed() throws Exception {
|
||||
final ActivityRecord r = createActivity(mService, testActivityComponent, mTask);
|
||||
final ActivityRecord r = new ActivityBuilder(mService).setTask(mTask).build();
|
||||
r.info.flags |= ActivityInfo.FLAG_NO_HISTORY;
|
||||
mSupervisor.setFocusStackUnchecked("testStopActivityWithDestroy", mStack);
|
||||
mStack.stopActivityLocked(r);
|
||||
@@ -118,18 +115,23 @@ public class ActivityStackTests extends ActivityTestsBase {
|
||||
|
||||
@Test
|
||||
public void testFindTaskWithOverlay() throws Exception {
|
||||
final ActivityRecord r = createActivity(mService, testActivityComponent, mTask, 0);
|
||||
final ActivityRecord r = new ActivityBuilder(mService)
|
||||
.setCreateTask(true)
|
||||
.setStack(mStack)
|
||||
.setUid(0)
|
||||
.build();
|
||||
final TaskRecord task = r.getTask();
|
||||
// Overlay must be for a different user to prevent recognizing a matching top activity
|
||||
final ActivityRecord taskOverlay = createActivity(mService, testOverlayComponent, mTask,
|
||||
UserHandle.PER_USER_RANGE * 2);
|
||||
final ActivityRecord taskOverlay = new ActivityBuilder(mService).setTask(task)
|
||||
.setUid(UserHandle.PER_USER_RANGE * 2).build();
|
||||
taskOverlay.mTaskOverlay = true;
|
||||
|
||||
final ActivityStackSupervisor.FindTaskResult result =
|
||||
new ActivityStackSupervisor.FindTaskResult();
|
||||
mStack.findTaskLocked(r, result);
|
||||
|
||||
assertEquals(mTask.getTopActivity(false /* includeOverlays */), r);
|
||||
assertEquals(mTask.getTopActivity(true /* includeOverlays */), taskOverlay);
|
||||
assertEquals(task.getTopActivity(false /* includeOverlays */), r);
|
||||
assertEquals(task.getTopActivity(true /* includeOverlays */), taskOverlay);
|
||||
assertNotNull(result.r);
|
||||
}
|
||||
|
||||
@@ -245,9 +247,8 @@ public class ActivityStackTests extends ActivityTestsBase {
|
||||
private <T extends ActivityStack> T createStackForShouldBeVisibleTest(
|
||||
ActivityDisplay display, int windowingMode, int activityType, boolean onTop) {
|
||||
final T stack = display.createStack(windowingMode, activityType, onTop);
|
||||
// Create a task and activity in the stack so that it has a top running activity.
|
||||
final TaskRecord task = createTask(mSupervisor, testActivityComponent, stack);
|
||||
final ActivityRecord r = createActivity(mService, testActivityComponent, task, 0);
|
||||
final ActivityRecord r = new ActivityBuilder(mService).setUid(0).setStack(stack)
|
||||
.setCreateTask(true).build();
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,9 +50,6 @@ import static org.mockito.Mockito.times;
|
||||
@Presubmit
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ActivityStarterTests extends ActivityTestsBase {
|
||||
private static final ComponentName testActivityComponent =
|
||||
ComponentName.unflattenFromString("com.foo/.BarActivity");
|
||||
|
||||
private ActivityManagerService mService;
|
||||
private ActivityStarter mStarter;
|
||||
|
||||
@@ -66,9 +63,10 @@ public class ActivityStarterTests extends ActivityTestsBase {
|
||||
@Test
|
||||
public void testUpdateLaunchBounds() throws Exception {
|
||||
// When in a non-resizeable stack, the task bounds should be updated.
|
||||
final TaskRecord task = createTask(mService.mStackSupervisor, testActivityComponent,
|
||||
mService.mStackSupervisor.getDefaultDisplay().createStack(
|
||||
WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, true /* onTop */));
|
||||
final TaskRecord task = new TaskBuilder(mService.mStackSupervisor)
|
||||
.setStack(mService.mStackSupervisor.getDefaultDisplay().createStack(
|
||||
WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, true /* onTop */))
|
||||
.build();
|
||||
final Rect bounds = new Rect(10, 10, 100, 100);
|
||||
|
||||
mStarter.updateBounds(task, bounds);
|
||||
@@ -76,9 +74,10 @@ public class ActivityStarterTests extends ActivityTestsBase {
|
||||
assertEquals(task.getStack().mBounds, null);
|
||||
|
||||
// When in a resizeable stack, the stack bounds should be updated as well.
|
||||
final TaskRecord task2 = createTask(mService.mStackSupervisor, testActivityComponent,
|
||||
mService.mStackSupervisor.getDefaultDisplay().createStack(
|
||||
WINDOWING_MODE_PINNED, ACTIVITY_TYPE_STANDARD, true /* onTop */));
|
||||
final TaskRecord task2 = new TaskBuilder(mService.mStackSupervisor)
|
||||
.setStack(mService.mStackSupervisor.getDefaultDisplay().createStack(
|
||||
WINDOWING_MODE_PINNED, ACTIVITY_TYPE_STANDARD, true /* onTop */))
|
||||
.build();
|
||||
assertTrue(task2.getStack() instanceof PinnedActivityStack);
|
||||
mStarter.updateBounds(task2, bounds);
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.android.server.am;
|
||||
|
||||
import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
|
||||
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
|
||||
import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
|
||||
import static android.view.Display.DEFAULT_DISPLAY;
|
||||
import static org.mockito.Mockito.mock;
|
||||
@@ -81,57 +83,156 @@ public class ActivityTestsBase {
|
||||
return service;
|
||||
}
|
||||
|
||||
protected static ActivityRecord createActivity(ActivityManagerService service,
|
||||
ComponentName component, TaskRecord task) {
|
||||
return createActivity(service, component, task, 0 /* userId */);
|
||||
}
|
||||
/**
|
||||
* Builder for creating new activities.
|
||||
*/
|
||||
protected static class ActivityBuilder {
|
||||
// An id appended to the end of the component name to make it unique
|
||||
private static int sCurrentActivityId = 0;
|
||||
|
||||
protected static ActivityRecord createActivity(ActivityManagerService service,
|
||||
ComponentName component, TaskRecord task, int uid) {
|
||||
Intent intent = new Intent();
|
||||
intent.setComponent(component);
|
||||
final ActivityInfo aInfo = new ActivityInfo();
|
||||
aInfo.applicationInfo = new ApplicationInfo();
|
||||
aInfo.applicationInfo.packageName = component.getPackageName();
|
||||
aInfo.applicationInfo.uid = uid;
|
||||
AttributeCache.init(service.mContext);
|
||||
final ActivityRecord activity = new ActivityRecord(service, null /* caller */,
|
||||
0 /* launchedFromPid */, 0, null, intent, null,
|
||||
aInfo /*aInfo*/, new Configuration(), null /* resultTo */, null /* resultWho */,
|
||||
0 /* reqCode */, false /*componentSpecified*/, false /* rootVoiceInteraction */,
|
||||
service.mStackSupervisor, null /* options */, null /* sourceRecord */);
|
||||
activity.mWindowContainerController = mock(AppWindowContainerController.class);
|
||||
// Default package name
|
||||
private static final String DEFAULT_PACKAGE = "com.foo";
|
||||
|
||||
if (task != null) {
|
||||
task.addActivityToTop(activity);
|
||||
// Default base activity name
|
||||
private static final String DEFAULT_BASE_ACTIVITY_NAME = ".BarActivity";
|
||||
|
||||
private final ActivityManagerService mService;
|
||||
|
||||
private ComponentName mComponent;
|
||||
private TaskRecord mTaskRecord;
|
||||
private int mUid;
|
||||
private boolean mCreateTask;
|
||||
private ActivityStack mStack;
|
||||
|
||||
ActivityBuilder(ActivityManagerService service) {
|
||||
mService = service;
|
||||
}
|
||||
|
||||
return activity;
|
||||
ActivityBuilder setComponent(ComponentName component) {
|
||||
mComponent = component;
|
||||
return this;
|
||||
}
|
||||
|
||||
ActivityBuilder setTask(TaskRecord task) {
|
||||
mTaskRecord = task;
|
||||
return this;
|
||||
}
|
||||
|
||||
ActivityBuilder setStack(ActivityStack stack) {
|
||||
mStack = stack;
|
||||
return this;
|
||||
}
|
||||
|
||||
ActivityBuilder setCreateTask(boolean createTask) {
|
||||
mCreateTask = createTask;
|
||||
return this;
|
||||
}
|
||||
|
||||
ActivityBuilder setUid(int uid) {
|
||||
mUid = uid;
|
||||
return this;
|
||||
}
|
||||
|
||||
ActivityRecord build() {
|
||||
if (mComponent == null) {
|
||||
final int id = sCurrentActivityId++;
|
||||
mComponent = ComponentName.createRelative(DEFAULT_PACKAGE,
|
||||
DEFAULT_BASE_ACTIVITY_NAME + id);
|
||||
}
|
||||
|
||||
if (mCreateTask) {
|
||||
mTaskRecord = new TaskBuilder(mService.mStackSupervisor)
|
||||
.setComponent(mComponent)
|
||||
.setStack(mStack).build();
|
||||
}
|
||||
|
||||
Intent intent = new Intent();
|
||||
intent.setComponent(mComponent);
|
||||
final ActivityInfo aInfo = new ActivityInfo();
|
||||
aInfo.applicationInfo = new ApplicationInfo();
|
||||
aInfo.applicationInfo.packageName = mComponent.getPackageName();
|
||||
aInfo.applicationInfo.uid = mUid;
|
||||
AttributeCache.init(mService.mContext);
|
||||
final ActivityRecord activity = new ActivityRecord(mService, null /* caller */,
|
||||
0 /* launchedFromPid */, 0, null, intent, null,
|
||||
aInfo /*aInfo*/, new Configuration(), null /* resultTo */, null /* resultWho */,
|
||||
0 /* reqCode */, false /*componentSpecified*/, false /* rootVoiceInteraction */,
|
||||
mService.mStackSupervisor, null /* options */, null /* sourceRecord */);
|
||||
activity.mWindowContainerController = mock(AppWindowContainerController.class);
|
||||
|
||||
if (mTaskRecord != null) {
|
||||
mTaskRecord.addActivityToTop(activity);
|
||||
}
|
||||
|
||||
return activity;
|
||||
}
|
||||
}
|
||||
|
||||
protected static TaskRecord createTask(ActivityStackSupervisor supervisor,
|
||||
ComponentName component, ActivityStack stack) {
|
||||
return createTask(supervisor, component, 0 /* flags */, 0 /* taskId */, stack);
|
||||
}
|
||||
/**
|
||||
* Builder for creating new tasks.
|
||||
*/
|
||||
protected static class TaskBuilder {
|
||||
private final ActivityStackSupervisor mSupervisor;
|
||||
|
||||
protected static TaskRecord createTask(ActivityStackSupervisor supervisor,
|
||||
ComponentName component, int flags, int taskId, ActivityStack stack) {
|
||||
final ActivityInfo aInfo = new ActivityInfo();
|
||||
aInfo.applicationInfo = new ApplicationInfo();
|
||||
aInfo.applicationInfo.packageName = component.getPackageName();
|
||||
private ComponentName mComponent;
|
||||
private String mPackage;
|
||||
private int mFlags = 0;
|
||||
private int mTaskId = 0;
|
||||
|
||||
Intent intent = new Intent();
|
||||
intent.setComponent(component);
|
||||
intent.setFlags(flags);
|
||||
private ActivityStack mStack;
|
||||
|
||||
final TaskRecord task = new TaskRecord(supervisor.mService, taskId, aInfo,
|
||||
intent /*intent*/, null /*_taskDescription*/);
|
||||
supervisor.setFocusStackUnchecked("test", stack);
|
||||
stack.addTask(task, true, "creating test task");
|
||||
task.setStack(stack);
|
||||
task.setWindowContainerController(mock(TaskWindowContainerController.class));
|
||||
TaskBuilder(ActivityStackSupervisor supervisor) {
|
||||
mSupervisor = supervisor;
|
||||
}
|
||||
|
||||
return task;
|
||||
TaskBuilder setComponent(ComponentName component) {
|
||||
mComponent = component;
|
||||
return this;
|
||||
}
|
||||
|
||||
TaskBuilder setPackage(String packageName) {
|
||||
mPackage = packageName;
|
||||
return this;
|
||||
}
|
||||
|
||||
TaskBuilder setFlags(int flags) {
|
||||
mFlags = flags;
|
||||
return this;
|
||||
}
|
||||
|
||||
TaskBuilder setTaskId(int taskId) {
|
||||
mTaskId = taskId;
|
||||
return this;
|
||||
}
|
||||
|
||||
TaskBuilder setStack(ActivityStack stack) {
|
||||
mStack = stack;
|
||||
return this;
|
||||
}
|
||||
|
||||
TaskRecord build() {
|
||||
if (mStack == null) {
|
||||
mStack = mSupervisor.getDefaultDisplay().createStack(
|
||||
WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, true /* onTop */);
|
||||
}
|
||||
|
||||
final ActivityInfo aInfo = new ActivityInfo();
|
||||
aInfo.applicationInfo = new ApplicationInfo();
|
||||
aInfo.applicationInfo.packageName = mPackage;
|
||||
|
||||
Intent intent = new Intent();
|
||||
intent.setComponent(mComponent);
|
||||
intent.setFlags(mFlags);
|
||||
|
||||
final TaskRecord task = new TaskRecord(mSupervisor.mService, mTaskId, aInfo,
|
||||
intent /*intent*/, null /*_taskDescription*/);
|
||||
mSupervisor.setFocusStackUnchecked("test", mStack);
|
||||
mStack.addTask(task, true, "creating test task");
|
||||
task.setStack(mStack);
|
||||
task.setWindowContainerController(mock(TaskWindowContainerController.class));
|
||||
|
||||
return task;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -49,9 +49,6 @@ import static com.android.server.am.LaunchingBoundsController.LaunchingBoundsPos
|
||||
@Presubmit
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class LaunchingActivityPositionerTests extends ActivityTestsBase {
|
||||
private final ComponentName testActivityComponent =
|
||||
ComponentName.unflattenFromString("com.foo/.BarActivity");
|
||||
|
||||
private LaunchingActivityPositioner mPositioner;
|
||||
private ActivityManagerService mService;
|
||||
private ActivityStack mStack;
|
||||
@@ -73,8 +70,8 @@ public class LaunchingActivityPositionerTests extends ActivityTestsBase {
|
||||
|
||||
mStack = mService.mStackSupervisor.getDefaultDisplay().createStack(
|
||||
WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, true /* onTop */);
|
||||
mTask = createTask(mService.mStackSupervisor, testActivityComponent, mStack);
|
||||
mActivity = createActivity(mService, testActivityComponent, mTask);
|
||||
mTask = new TaskBuilder(mService.mStackSupervisor).setStack(mStack).build();
|
||||
mActivity = new ActivityBuilder(mService).setTask(mTask).build();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -52,9 +52,6 @@ import static org.junit.Assert.assertEquals;
|
||||
@Presubmit
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class LaunchingTaskPositionerTests extends ActivityTestsBase {
|
||||
private final ComponentName testActivityComponent =
|
||||
ComponentName.unflattenFromString("com.foo/.BarActivity");
|
||||
|
||||
private final static int STACK_WIDTH = 100;
|
||||
private final static int STACK_HEIGHT = 200;
|
||||
|
||||
@@ -81,7 +78,7 @@ public class LaunchingTaskPositionerTests extends ActivityTestsBase {
|
||||
|
||||
// We must create the task after resizing to make sure it does not inherit the stack
|
||||
// dimensions on resize.
|
||||
mTask = createTask(mService.mStackSupervisor, testActivityComponent, mStack);
|
||||
mTask = new TaskBuilder(mService.mStackSupervisor).setStack(mStack).build();
|
||||
|
||||
mPositioner = new LaunchingTaskPositioner();
|
||||
|
||||
@@ -193,11 +190,10 @@ public class LaunchingTaskPositionerTests extends ActivityTestsBase {
|
||||
// wrap with try/finally to ensure cleanup of activity/stack.
|
||||
try {
|
||||
// empty tasks are ignored in conflicts
|
||||
activity = createActivity(mService, testActivityComponent, mTask);
|
||||
activity = new ActivityBuilder(mService).setTask(mTask).build();
|
||||
|
||||
// Create secondary task
|
||||
secondTask = createTask(mService.mStackSupervisor, testActivityComponent,
|
||||
mStack);
|
||||
secondTask = new TaskBuilder(mService.mStackSupervisor).setStack(mStack).build();
|
||||
|
||||
// layout second task
|
||||
assertEquals(RESULT_CONTINUE,
|
||||
|
||||
@@ -335,8 +335,9 @@ public class RecentTasksTest extends ActivityTestsBase {
|
||||
}
|
||||
|
||||
private TaskRecord createTask(String className, int flags, int userId) {
|
||||
TaskRecord task = createTask(mService.mStackSupervisor, createComponent(className), flags,
|
||||
LAST_TASK_ID++, mStack);
|
||||
TaskRecord task = new TaskBuilder(mService.mStackSupervisor)
|
||||
.setComponent(createComponent(className))
|
||||
.setStack(mStack).setFlags(flags).setTaskId(LAST_TASK_ID++).build();
|
||||
task.userId = userId;
|
||||
task.touchActiveTime();
|
||||
return task;
|
||||
|
||||
Reference in New Issue
Block a user