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

Commit 348e518b authored by Sunny Goyal's avatar Sunny Goyal Committed by Android (Google) Code Review
Browse files

Merge "Using a runtime generated layout for tests instead of defining xml" into udc-dev

parents e67092ee ab2f8081
Loading
Loading
Loading
Loading
+0 −39
Original line number Diff line number Diff line
@@ -218,29 +218,6 @@ public class DebugTestInformationHandler extends TestInformationHandler {
                }
            }

            case TestProtocol.REQUEST_USE_TEST_WORKSPACE_LAYOUT: {
                useTestWorkspaceLayout(
                        LauncherSettings.Settings.ARG_DEFAULT_WORKSPACE_LAYOUT_TEST);
                return response;
            }

            case TestProtocol.REQUEST_USE_TEST2_WORKSPACE_LAYOUT: {
                useTestWorkspaceLayout(
                        LauncherSettings.Settings.ARG_DEFAULT_WORKSPACE_LAYOUT_TEST2);
                return response;
            }

            case TestProtocol.REQUEST_USE_TAPL_WORKSPACE_LAYOUT: {
                useTestWorkspaceLayout(
                        LauncherSettings.Settings.ARG_DEFAULT_WORKSPACE_LAYOUT_TAPL);
                return response;
            }

            case TestProtocol.REQUEST_USE_DEFAULT_WORKSPACE_LAYOUT: {
                useTestWorkspaceLayout(null);
                return response;
            }

            case TestProtocol.REQUEST_HOTSEAT_ICON_NAMES: {
                return getLauncherUIProperty(Bundle::putStringArrayList, l -> {
                    ShortcutAndWidgetContainer hotseatIconsContainer =
@@ -278,20 +255,4 @@ public class DebugTestInformationHandler extends TestInformationHandler {
                return super.call(method, arg, extras);
        }
    }

    private void useTestWorkspaceLayout(String layout) {
        final long identity = Binder.clearCallingIdentity();
        try {
            if (layout != null) {
                LauncherSettings.Settings.call(mContext.getContentResolver(),
                        LauncherSettings.Settings.METHOD_SET_USE_TEST_WORKSPACE_LAYOUT_FLAG,
                        layout);
            } else {
                LauncherSettings.Settings.call(mContext.getContentResolver(),
                        LauncherSettings.Settings.METHOD_CLEAR_USE_TEST_WORKSPACE_LAYOUT_FLAG);
            }
        } finally {
            Binder.restoreCallingIdentity(identity);
        }
    }
}
+13 −3
Original line number Diff line number Diff line
@@ -29,6 +29,8 @@ import androidx.test.runner.AndroidJUnit4;

import com.android.launcher3.tapl.Taskbar;
import com.android.launcher3.ui.TaplTestsLauncher3;
import com.android.launcher3.util.LauncherLayoutBuilder;
import com.android.launcher3.util.TestUtil;
import com.android.launcher3.util.rule.ScreenRecordRule.ScreenRecord;
import com.android.quickstep.TaskbarModeSwitchRule.TaskbarModeSwitch;

@@ -49,11 +51,17 @@ public class TaplTestsTaskbar extends AbstractQuickStepTest {
    private static final String CALCULATOR_APP_PACKAGE =
            resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR);

    private AutoCloseable mLauncherLayout;

    @Override
    public void setUp() throws Exception {
        Assume.assumeTrue(mLauncher.isTablet());
        super.setUp();
        mLauncher.useTestWorkspaceLayoutOnReload();

        LauncherLayoutBuilder layoutBuilder = new LauncherLayoutBuilder().atHotseat(0).putApp(
                "com.google.android.apps.nexuslauncher.tests",
                "com.android.launcher3.testcomponent.BaseTestingActivity");
        mLauncherLayout = TestUtil.setLauncherDefaultLayout(mTargetContext, layoutBuilder);
        TaplTestsLauncher3.initialize(this);

        startAppFast(CALCULATOR_APP_PACKAGE);
@@ -62,9 +70,11 @@ public class TaplTestsTaskbar extends AbstractQuickStepTest {
    }

    @After
    public void tearDown() {
        mLauncher.useDefaultWorkspaceLayoutOnReload();
    public void tearDown() throws Exception {
        mLauncher.enableBlockTimeout(false);
        if (mLauncherLayout != null) {
            mLauncherLayout.close();
        }
    }

    @Test
+0 −28
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2023 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<!-- Split display specific version of Launcher3/res/xml/default_workspace_4x4.xml -->
<favorites xmlns:launcher="http://schemas.android.com/apk/res-auto/com.android.launcher3" >

    <!-- Hotseat (We use the screen as the position of the item in the hotseat) -->
    <favorite
        launcher:container="-101"
        launcher:screen="0"
        launcher:x="0"
        launcher:y="0"
        launcher:className="com.google.android.apps.chrome.Main"
        launcher:packageName="com.android.chrome" />

</favorites>
+0 −57
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Split display specific version of Launcher3/res/xml/default_workspace_4x4.xml -->
<favorites xmlns:launcher="http://schemas.android.com/apk/res-auto/com.android.launcher3" >

    <!-- Hotseat (We use the screen as the position of the item in the hotseat) -->
    <!-- Dialer Messaging Chrome Camera -->
    <favorite
        launcher:container="-101"
        launcher:screen="0"
        launcher:x="0"
        launcher:y="0"
        launcher:className="com.google.android.dialer.extensions.GoogleDialtactsActivity"
        launcher:packageName="com.google.android.dialer" />

    <favorite
        launcher:container="-101"
        launcher:screen="1"
        launcher:x="1"
        launcher:y="0"
        launcher:className="com.google.android.apps.messaging.ui.ConversationListActivity"
        launcher:packageName="com.google.android.apps.messaging" />

    <favorite
        launcher:container="-101"
        launcher:screen="2"
        launcher:x="2"
        launcher:y="0"
        launcher:className="com.google.android.apps.chrome.Main"
        launcher:packageName="com.android.chrome" />

    <favorite
        launcher:container="-101"
        launcher:screen="3"
        launcher:x="3"
        launcher:y="0"
        launcher:className="com.android.camera.CameraLauncher"
        launcher:packageName="com.google.android.GoogleCamera" />

    <!-- Bottom row -->
    <!-- Maps [space] [space] Play -->
    <favorite
        launcher:className="com.google.android.maps.MapsActivity"
        launcher:packageName="com.google.android.apps.maps"
        launcher:screen="0"
        launcher:x="0"
        launcher:y="-1" />

    <favorite
        launcher:className="com.android.vending.AssetBrowserActivity"
        launcher:packageName="com.android.vending"
        launcher:screen="0"
        launcher:x="3"
        launcher:y="-1" />

    <!-- TODO: Place weather widget when it's available -->

</favorites>
+0 −29
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2022 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->

<!-- Split display specific version of Launcher3/res/xml/default_workspace_4x4.xml -->
<favorites xmlns:launcher="http://schemas.android.com/apk/res-auto/com.android.launcher3" >

    <!-- Launcher Test Activity -->
    <resolve
        launcher:container="-101"
        launcher:screen="0"
        launcher:x="0"
        launcher:y="0" >
        <favorite launcher:uri="#Intent;action=android.intent.action.MAIN;category=android.intent.category.CATEGORY_TEST;component=com.google.android.apps.nexuslauncher.tests/com.android.launcher3.testcomponent.BaseTestingActivity;end" />
    </resolve>

</favorites>
Loading