Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c2e17bf7 authored by Kazuki Takise's avatar Kazuki Takise
Browse files

Change some initializations in am tests for ARC

This CL upstreams the following changes in ARC. These
changes do not affect the behavior on phones, but should be
upstreamed to avoid future merge conflicts.

Changes to be upstreamed:
- Fix com.android.server.am.TaskRecordTests(ag/4488735)
This Cl initializes task.realActivity, which is used in
ActivityManagerInjectorArc#onTaskCreated().

- Create user as guest in TaskPersisterTest(ag/4477502)
In ARC, the maximum number of supported users is one, which is
different from the ones of most phones (more than 4). This prevents
TaskPersisterTest from creating another user for test. However,
since guest users can be added as much as possible, we create guest
user in the test.

- Change taskId in ActivityTestBase from 0 to 1(ag/4474682)
In ActivityTestBase, taskId is set as 0 by default. However, since
0 is reserved in ARC, currently assertion failure occurs in
wayland_service.cpp. This CL shifts the id to 1 and makes all the
tests in ActivityStackTests pass.

Bug: 72843139
Test: atest TaskPersisterTest
Test: atest TaskRecordTests
Test: atest ActivityStackTests
Change-Id: I6ba49547ae3b34a752e401150caeb1d786f199cf
parent a800f9ab
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -248,7 +248,8 @@ public class ActivityTestsBase {
        private ComponentName mComponent;
        private String mPackage;
        private int mFlags = 0;
        private int mTaskId = 0;
        // Task id 0 is reserved in ARC for the home app.
        private int mTaskId = 1;
        private int mUserId = 0;
        private IVoiceInteractionSession mVoiceSession;
        private boolean mCreateStack = true;
+5 −1
Original line number Diff line number Diff line
@@ -44,7 +44,11 @@ public class TaskPersisterTest extends AndroidTestCase {
        super.setUp();
        mUserManager = UserManager.get(getContext());
        mTaskPersister = new TaskPersister(getContext().getFilesDir());
        testUserId = createUser(TEST_USER_NAME, 0);
        // In ARC, the maximum number of supported users is one, which is different from the ones of
        // most phones (more than 4). This prevents TaskPersisterTest from creating another user for
        // test. However, since guest users can be added as much as possible, we create guest user
        // in the test.
        testUserId = createUser(TEST_USER_NAME, UserInfo.FLAG_GUEST);
    }

    @Override
+3 −3
Original line number Diff line number Diff line
@@ -156,9 +156,9 @@ public class TaskRecordTests extends ActivityTestsBase {

    private TaskRecord createTaskRecord(int taskId) {
        return new TaskRecord(mService.mActivityTaskManager, taskId, new Intent(), null, null, null,
                null, null, false,
                false, false, 0, 10050, null, new ArrayList<>(), 0, false, null, 0, 0, 0, 0, 0,
                null, 0, false, false, false, 0, 0);
                ActivityBuilder.getDefaultComponent(), null, false, false, false, 0, 10050, null,
                new ArrayList<>(), 0, false, null, 0, 0, 0, 0, 0, null, 0, false, false, false, 0, 0
        );
    }

    private static class TestTaskRecordFactory extends TaskRecordFactory {