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

Commit 6e43c6aa authored by Sebastián Franco's avatar Sebastián Franco Committed by Android (Google) Code Review
Browse files

Merge "Moving ReorderWidgetsTest to an integration test instead of E2E" into main

parents f30a5a3c 224f67a0
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -37,6 +37,8 @@ import com.android.launcher3.accessibility.DragViewStateAnnouncer;
import com.android.launcher3.celllayout.CellLayoutLayoutParams;
import com.android.launcher3.celllayout.CellPosMapper.CellPos;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.debug.TestEvent;
import com.android.launcher3.debug.TestEventEmitter;
import com.android.launcher3.dragndrop.DragLayer;
import com.android.launcher3.keyboard.ViewGroupFocusHelper;
import com.android.launcher3.logging.InstanceId;
@@ -221,6 +223,9 @@ public class AppWidgetResizeFrame extends AbstractFloatingView implements View.O
        dl.addView(frame);
        frame.mIsOpen = true;
        frame.post(() -> frame.snapToWidget(false));
        TestEventEmitter.INSTANCE.get(widget.getContext()).sendEvent(
                TestEvent.RESIZE_FRAME_SHOWING
        );
    }

    private void setCornerRadiusFromWidget() {
+3 −1
Original line number Diff line number Diff line
@@ -166,7 +166,6 @@ import androidx.annotation.VisibleForTesting;
import androidx.core.os.BuildCompat;
import androidx.window.embedding.RuleController;

import com.android.launcher3.DeviceProfile;
import com.android.launcher3.DropTarget.DragObject;
import com.android.launcher3.accessibility.LauncherAccessibilityDelegate;
import com.android.launcher3.allapps.ActivityAllAppsContainerView;
@@ -181,6 +180,8 @@ import com.android.launcher3.celllayout.CellPosMapper.CellPos;
import com.android.launcher3.celllayout.CellPosMapper.TwoPanelCellPosMapper;
import com.android.launcher3.compat.AccessibilityManagerCompat;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.debug.TestEvent;
import com.android.launcher3.debug.TestEventEmitter;
import com.android.launcher3.dot.DotInfo;
import com.android.launcher3.dragndrop.DragController;
import com.android.launcher3.dragndrop.DragLayer;
@@ -595,6 +596,7 @@ public class Launcher extends StatefulActivity<LauncherState>
            RuleController.getInstance(this).setRules(
                    RuleController.parseRules(this, R.xml.split_configuration));
        }
        TestEventEmitter.INSTANCE.get(this).sendEvent(TestEvent.LAUNCHER_ON_CREATE);
    }

    protected ModelCallbacks createModelCallbacks() {
+3 −0
Original line number Diff line number Diff line
@@ -11,6 +11,8 @@ import com.android.launcher3.Utilities.SHOULD_SHOW_FIRST_PAGE_WIDGET
import com.android.launcher3.WorkspaceLayoutManager.FIRST_SCREEN_ID
import com.android.launcher3.allapps.AllAppsStore
import com.android.launcher3.config.FeatureFlags
import com.android.launcher3.debug.TestEvent
import com.android.launcher3.debug.TestEventEmitter
import com.android.launcher3.model.BgDataModel
import com.android.launcher3.model.StringCache
import com.android.launcher3.model.data.AppInfo
@@ -156,6 +158,7 @@ class ModelCallbacks(private var launcher: Launcher) : BgDataModel.Callbacks {
            /*pause=*/ false,
            deviceProfile.isTwoPanels
        )
        TestEventEmitter.INSTANCE.get(launcher).sendEvent(TestEvent.WORKSPACE_FINISH_LOADING)
    }

    /**
+3 −1
Original line number Diff line number Diff line
@@ -80,6 +80,8 @@ import com.android.launcher3.celllayout.CellLayoutLayoutParams;
import com.android.launcher3.celllayout.CellPosMapper;
import com.android.launcher3.celllayout.CellPosMapper.CellPos;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.debug.TestEvent;
import com.android.launcher3.debug.TestEventEmitter;
import com.android.launcher3.dot.FolderDotInfo;
import com.android.launcher3.dragndrop.DragController;
import com.android.launcher3.dragndrop.DragLayer;
@@ -314,7 +316,6 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
     */
    public Workspace(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);

        mLauncher = Launcher.getLauncher(context);
        mStateTransitionAnimation = new WorkspaceStateTransitionAnimation(mLauncher, this);
        mWallpaperManager = WallpaperManager.getInstance(context);
@@ -2218,6 +2219,7 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
        if (d.stateAnnouncer != null && !droppedOnOriginalCell) {
            d.stateAnnouncer.completeAction(R.string.item_moved);
        }
        TestEventEmitter.INSTANCE.get(getContext()).sendEvent(TestEvent.WORKSPACE_ON_DROP);
    }

    @Nullable
+54 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 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.
 */

package com.android.launcher3.debug

import android.content.Context
import com.android.launcher3.util.MainThreadInitializedObject
import com.android.launcher3.util.SafeCloseable

/** Events fired by the launcher. */
enum class TestEvent(val event: String) {
    LAUNCHER_ON_CREATE("LAUNCHER_ON_CREATE"),
    WORKSPACE_ON_DROP("WORKSPACE_ON_DROP"),
    RESIZE_FRAME_SHOWING("RESIZE_FRAME_SHOWING"),
    WORKSPACE_FINISH_LOADING("WORKSPACE_FINISH_LOADING"),
}

/** Interface to create TestEventEmitters. */
interface TestEventEmitter : SafeCloseable {

    companion object {
        @JvmField
        val INSTANCE =
            MainThreadInitializedObject<TestEventEmitter> { _: Context? ->
                TestEventsEmitterProduction()
            }
    }

    fun sendEvent(event: TestEvent)
}

/**
 * TestEventsEmitterProduction shouldn't do anything since it runs on the launcher code and not on
 * tests. This is just a placeholder and test should override this class.
 */
class TestEventsEmitterProduction : TestEventEmitter {

    override fun close() {}

    override fun sendEvent(event: TestEvent) {}
}
Loading