mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-27 23:36:47 +00:00
Merge "Removing LauncherActivityRule as it can be flaky based on when the rule was initialized" into udc-qpr-dev
This commit is contained in:
@@ -424,7 +424,6 @@ public class Launcher extends StatefulActivity<LauncherState>
|
||||
@Override
|
||||
@TargetApi(Build.VERSION_CODES.S)
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
TestProtocol.testLogD(TestProtocol.ACTIVITY_LIFECYCLE_RULE, "Launcher.onCreate 1");
|
||||
mStartupLatencyLogger = createStartupLatencyLogger(
|
||||
sIsNewProcess
|
||||
? LockedUserState.get(this).isUserUnlockedAtLauncherStartup()
|
||||
@@ -583,7 +582,6 @@ public class Launcher extends StatefulActivity<LauncherState>
|
||||
}
|
||||
setTitle(R.string.home_screen);
|
||||
mStartupLatencyLogger.logEnd(LAUNCHER_LATENCY_STARTUP_ACTIVITY_ON_CREATE);
|
||||
TestProtocol.testLogD(TestProtocol.ACTIVITY_LIFECYCLE_RULE, "Launcher.onCreate 2");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1058,7 +1056,6 @@ public class Launcher extends StatefulActivity<LauncherState>
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
TestProtocol.testLogD(TestProtocol.ACTIVITY_LIFECYCLE_RULE, "Launcher.onStop 1");
|
||||
super.onStop();
|
||||
if (mDeferOverlayCallbacks) {
|
||||
checkIfOverlayStillDeferred();
|
||||
@@ -1070,12 +1067,10 @@ public class Launcher extends StatefulActivity<LauncherState>
|
||||
mAppWidgetHolder.setActivityStarted(false);
|
||||
NotificationListener.removeNotificationsChangedListener(getPopupDataProvider());
|
||||
FloatingIconView.resetIconLoadResult();
|
||||
TestProtocol.testLogD(TestProtocol.ACTIVITY_LIFECYCLE_RULE, "Launcher.onStop 2");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
TestProtocol.testLogD(TestProtocol.ACTIVITY_LIFECYCLE_RULE, "Launcher.onStart 1");
|
||||
TraceHelper.INSTANCE.beginSection(ON_START_EVT);
|
||||
super.onStart();
|
||||
if (!mDeferOverlayCallbacks) {
|
||||
@@ -1084,7 +1079,6 @@ public class Launcher extends StatefulActivity<LauncherState>
|
||||
|
||||
mAppWidgetHolder.setActivityStarted(true);
|
||||
TraceHelper.INSTANCE.endSection();
|
||||
TestProtocol.testLogD(TestProtocol.ACTIVITY_LIFECYCLE_RULE, "Launcher.onStart 2");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1255,7 +1249,6 @@ public class Launcher extends StatefulActivity<LauncherState>
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
TestProtocol.testLogD(TestProtocol.ACTIVITY_LIFECYCLE_RULE, "Launcher.onResume 1");
|
||||
TraceHelper.INSTANCE.beginSection(ON_RESUME_EVT);
|
||||
super.onResume();
|
||||
|
||||
@@ -1267,12 +1260,10 @@ public class Launcher extends StatefulActivity<LauncherState>
|
||||
|
||||
DragView.removeAllViews(this);
|
||||
TraceHelper.INSTANCE.endSection();
|
||||
TestProtocol.testLogD(TestProtocol.ACTIVITY_LIFECYCLE_RULE, "Launcher.onResume 2");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
TestProtocol.testLogD(TestProtocol.ACTIVITY_LIFECYCLE_RULE, "Launcher.onPause 1");
|
||||
// Ensure that items added to Launcher are queued until Launcher returns
|
||||
ItemInstallQueue.INSTANCE.get(this).pauseModelPush(FLAG_ACTIVITY_PAUSED);
|
||||
|
||||
@@ -1285,7 +1276,6 @@ public class Launcher extends StatefulActivity<LauncherState>
|
||||
mOverlayManager.onActivityPaused(this);
|
||||
}
|
||||
mAppWidgetHolder.setActivityResumed(false);
|
||||
TestProtocol.testLogD(TestProtocol.ACTIVITY_LIFECYCLE_RULE, "Launcher.onPause 2");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1759,8 +1749,6 @@ public class Launcher extends StatefulActivity<LauncherState>
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
TestProtocol.testLogD(
|
||||
TestProtocol.ACTIVITY_LIFECYCLE_RULE, "Launcher.onSaveInstanceState 1");
|
||||
outState.putIntArray(RUNTIME_STATE_CURRENT_SCREEN_IDS,
|
||||
mWorkspace.getCurrentPageScreenIds().getArray().toArray());
|
||||
outState.putInt(RUNTIME_STATE, mStateManager.getState().ordinal);
|
||||
@@ -1792,13 +1780,10 @@ public class Launcher extends StatefulActivity<LauncherState>
|
||||
|
||||
super.onSaveInstanceState(outState);
|
||||
mOverlayManager.onActivitySaveInstanceState(this, outState);
|
||||
TestProtocol.testLogD(
|
||||
TestProtocol.ACTIVITY_LIFECYCLE_RULE, "Launcher.onSaveInstanceState 2");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
TestProtocol.testLogD(TestProtocol.ACTIVITY_LIFECYCLE_RULE, "Launcher.onDestroy 1");
|
||||
super.onDestroy();
|
||||
ACTIVITY_TRACKER.onActivityDestroyed(this);
|
||||
|
||||
@@ -1821,7 +1806,6 @@ public class Launcher extends StatefulActivity<LauncherState>
|
||||
LauncherAppState.getIDP(this).removeOnChangeListener(this);
|
||||
|
||||
mOverlayManager.onActivityDestroyed(this);
|
||||
TestProtocol.testLogD(TestProtocol.ACTIVITY_LIFECYCLE_RULE, "Launcher.onDestroy 2");
|
||||
}
|
||||
|
||||
public LauncherAccessibilityDelegate getAccessibilityDelegate() {
|
||||
|
||||
@@ -50,12 +50,10 @@ filegroup {
|
||||
"src/com/android/launcher3/util/Wait.java",
|
||||
"src/com/android/launcher3/util/WidgetUtils.java",
|
||||
"src/com/android/launcher3/util/rule/FailureWatcher.java",
|
||||
"src/com/android/launcher3/util/rule/LauncherActivityRule.java",
|
||||
"src/com/android/launcher3/util/rule/ViewCaptureRule.kt",
|
||||
"src/com/android/launcher3/util/rule/SamplerRule.java",
|
||||
"src/com/android/launcher3/util/rule/ScreenRecordRule.java",
|
||||
"src/com/android/launcher3/util/rule/ShellCommandRule.java",
|
||||
"src/com/android/launcher3/util/rule/SimpleActivityRule.java",
|
||||
"src/com/android/launcher3/util/rule/TestStabilityRule.java",
|
||||
"src/com/android/launcher3/util/rule/TISBindRule.java",
|
||||
"src/com/android/launcher3/util/viewcapture_analysis/*.java",
|
||||
|
||||
@@ -157,7 +157,6 @@ public final class TestProtocol {
|
||||
public static final String TWO_TASKBAR_LONG_CLICKS = "b/262282528";
|
||||
public static final String FLAKY_ACTIVITY_COUNT = "b/260260325";
|
||||
public static final String ICON_MISSING = "b/282963545";
|
||||
public static final String ACTIVITY_LIFECYCLE_RULE = "b/289161193";
|
||||
|
||||
public static final String REQUEST_EMULATE_DISPLAY = "emulate-display";
|
||||
public static final String REQUEST_STOP_EMULATE_DISPLAY = "stop-emulate-display";
|
||||
|
||||
@@ -65,7 +65,6 @@ import com.android.launcher3.util.SimpleBroadcastReceiver;
|
||||
import com.android.launcher3.util.TestUtil;
|
||||
import com.android.launcher3.util.Wait;
|
||||
import com.android.launcher3.util.rule.FailureWatcher;
|
||||
import com.android.launcher3.util.rule.LauncherActivityRule;
|
||||
import com.android.launcher3.util.rule.SamplerRule;
|
||||
import com.android.launcher3.util.rule.ScreenRecordRule;
|
||||
import com.android.launcher3.util.rule.ShellCommandRule;
|
||||
@@ -182,8 +181,6 @@ public abstract class AbstractLauncherUiTest {
|
||||
mLauncher.setOnLauncherCrashed(() -> mLauncherPid = 0);
|
||||
}
|
||||
|
||||
protected final LauncherActivityRule mActivityMonitor = new LauncherActivityRule();
|
||||
|
||||
@Rule
|
||||
public ShellCommandRule mDisableHeadsUpNotification =
|
||||
ShellCommandRule.disableHeadsUpNotification();
|
||||
@@ -204,7 +201,8 @@ public abstract class AbstractLauncherUiTest {
|
||||
}
|
||||
|
||||
protected TestRule getRulesInsideActivityMonitor() {
|
||||
final ViewCaptureRule viewCaptureRule = new ViewCaptureRule(mActivityMonitor::getActivity);
|
||||
final ViewCaptureRule viewCaptureRule = new ViewCaptureRule(
|
||||
Launcher.ACTIVITY_TRACKER::getCreatedActivity);
|
||||
final RuleChain inner = RuleChain
|
||||
.outerRule(new PortraitLandscapeRunner(this))
|
||||
.around(new FailureWatcher(mLauncher, viewCaptureRule::getViewCaptureData))
|
||||
@@ -219,7 +217,6 @@ public abstract class AbstractLauncherUiTest {
|
||||
public TestRule mOrderSensitiveRules = RuleChain
|
||||
.outerRule(new SamplerRule())
|
||||
.around(new TestStabilityRule())
|
||||
.around(mActivityMonitor)
|
||||
.around(getRulesInsideActivityMonitor());
|
||||
|
||||
public UiDevice getDevice() {
|
||||
@@ -322,7 +319,7 @@ public abstract class AbstractLauncherUiTest {
|
||||
|
||||
protected <T> T getFromLauncher(Function<Launcher, T> f) {
|
||||
if (!TestHelpers.isInLauncherProcess()) return null;
|
||||
return getOnUiThread(() -> f.apply(mActivityMonitor.getActivity()));
|
||||
return getOnUiThread(() -> f.apply(Launcher.ACTIVITY_TRACKER.getCreatedActivity()));
|
||||
}
|
||||
|
||||
protected void executeOnLauncher(Consumer<Launcher> f) {
|
||||
|
||||
@@ -30,6 +30,7 @@ import android.view.View;
|
||||
import androidx.test.filters.LargeTest;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.celllayout.FavoriteItemsTransaction;
|
||||
import com.android.launcher3.model.data.ItemInfo;
|
||||
import com.android.launcher3.model.data.LauncherAppWidgetInfo;
|
||||
@@ -124,7 +125,10 @@ public class AddConfigWidgetTest extends AbstractLauncherUiTest {
|
||||
|
||||
@Override
|
||||
public boolean isTrue() throws Throwable {
|
||||
return mMainThreadExecutor.submit(mActivityMonitor.itemExists(this)).get();
|
||||
return mMainThreadExecutor.submit(() -> {
|
||||
Launcher l = Launcher.ACTIVITY_TRACKER.getCreatedActivity();
|
||||
return l != null && l.getWorkspace().getFirstMatch(this) != null;
|
||||
}).get();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,7 +18,6 @@ package com.android.launcher3.ui.widget;
|
||||
import static com.android.launcher3.ui.TaplTestsLauncher3.getAppPackageName;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import android.platform.test.annotations.PlatinumTest;
|
||||
import android.platform.test.rule.ScreenRecordRule;
|
||||
@@ -27,7 +26,6 @@ import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import androidx.test.filters.LargeTest;
|
||||
|
||||
import com.android.launcher3.celllayout.FavoriteItemsTransaction;
|
||||
import com.android.launcher3.model.data.LauncherAppWidgetInfo;
|
||||
import com.android.launcher3.tapl.Widget;
|
||||
import com.android.launcher3.tapl.WidgetResizeFrame;
|
||||
import com.android.launcher3.ui.AbstractLauncherUiTest;
|
||||
@@ -70,11 +68,6 @@ public class AddWidgetTest extends AbstractLauncherUiTest {
|
||||
.getWidget(widgetInfo.getLabel(mTargetContext.getPackageManager()))
|
||||
.dragWidgetToWorkspace();
|
||||
|
||||
assertTrue(mActivityMonitor.itemExists(
|
||||
(info, view) -> info instanceof LauncherAppWidgetInfo &&
|
||||
((LauncherAppWidgetInfo) info).providerName.getClassName().equals(
|
||||
widgetInfo.provider.getClassName())).call());
|
||||
|
||||
assertNotNull("Widget resize frame not shown after widget add", resizeFrame);
|
||||
resizeFrame.dismiss();
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ import android.view.View;
|
||||
import androidx.test.filters.LargeTest;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.LauncherSettings.Favorites;
|
||||
import com.android.launcher3.celllayout.FavoriteItemsTransaction;
|
||||
import com.android.launcher3.model.data.ItemInfo;
|
||||
@@ -193,7 +194,10 @@ public class RequestPinItemTest extends AbstractLauncherUiTest {
|
||||
|
||||
@Override
|
||||
public boolean isTrue() throws Throwable {
|
||||
return mMainThreadExecutor.submit(mActivityMonitor.itemExists(mOp)).get();
|
||||
return mMainThreadExecutor.submit(() -> {
|
||||
Launcher l = Launcher.ACTIVITY_TRACKER.getCreatedActivity();
|
||||
return l != null && l.getWorkspace().getFirstMatch(mOp) != null;
|
||||
}).get();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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.util.rule;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.util.LauncherBindableItemsContainer.ItemOperator;
|
||||
|
||||
import org.junit.runner.Description;
|
||||
import org.junit.runners.model.Statement;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
/**
|
||||
* Test rule to get the current Launcher activity.
|
||||
*/
|
||||
public class LauncherActivityRule extends SimpleActivityRule<Launcher> {
|
||||
|
||||
public LauncherActivityRule() {
|
||||
super(Launcher.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Statement apply(Statement base, Description description) {
|
||||
|
||||
return new MyStatement(base) {
|
||||
@Override
|
||||
public void onActivityStarted(Activity activity) {
|
||||
if (activity instanceof Launcher) {
|
||||
((Launcher) activity).getRotationHelper().forceAllowRotationForTesting(true);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public Callable<Boolean> itemExists(final ItemOperator op) {
|
||||
return () -> {
|
||||
Launcher launcher = getActivity();
|
||||
if (launcher == null) {
|
||||
return false;
|
||||
}
|
||||
return launcher.getWorkspace().getFirstMatch(op) != null;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,131 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2019 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.util.rule;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Application;
|
||||
import android.app.Application.ActivityLifecycleCallbacks;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.test.InstrumentationRegistry;
|
||||
|
||||
import com.android.launcher3.testing.shared.TestProtocol;
|
||||
|
||||
import org.junit.rules.TestRule;
|
||||
import org.junit.runner.Description;
|
||||
import org.junit.runners.model.Statement;
|
||||
|
||||
/**
|
||||
* Test rule to get the current activity.
|
||||
*/
|
||||
public class SimpleActivityRule<T extends Activity> implements TestRule {
|
||||
|
||||
private final Class<T> mClass;
|
||||
private T mActivity;
|
||||
|
||||
public SimpleActivityRule(Class<T> clazz) {
|
||||
mClass = clazz;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Statement apply(Statement base, Description description) {
|
||||
return new MyStatement(base);
|
||||
}
|
||||
|
||||
public T getActivity() {
|
||||
return mActivity;
|
||||
}
|
||||
|
||||
protected class MyStatement extends Statement implements ActivityLifecycleCallbacks {
|
||||
|
||||
private final Statement mBase;
|
||||
|
||||
public MyStatement(Statement base) {
|
||||
mBase = base;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void evaluate() throws Throwable {
|
||||
Application app = (Application)
|
||||
InstrumentationRegistry.getTargetContext().getApplicationContext();
|
||||
app.registerActivityLifecycleCallbacks(this);
|
||||
try {
|
||||
mBase.evaluate();
|
||||
} finally {
|
||||
app.unregisterActivityLifecycleCallbacks(this);
|
||||
mActivity = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(Activity activity, Bundle bundle) {
|
||||
if (activity != null && mClass.isInstance(activity)) {
|
||||
TestProtocol.testLogD(
|
||||
TestProtocol.ACTIVITY_LIFECYCLE_RULE, "MyStatement.onActivityCreated");
|
||||
mActivity = (T) activity;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityStarted(Activity activity) {
|
||||
if (activity == mActivity) {
|
||||
TestProtocol.testLogD(
|
||||
TestProtocol.ACTIVITY_LIFECYCLE_RULE, "MyStatement.onActivityStarted");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResumed(Activity activity) {
|
||||
if (activity == mActivity) {
|
||||
TestProtocol.testLogD(
|
||||
TestProtocol.ACTIVITY_LIFECYCLE_RULE, "MyStatement.onActivityResumed");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityPaused(Activity activity) {
|
||||
if (activity == mActivity) {
|
||||
TestProtocol.testLogD(
|
||||
TestProtocol.ACTIVITY_LIFECYCLE_RULE, "MyStatement.onActivityPaused");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityStopped(Activity activity) {
|
||||
if (activity == mActivity) {
|
||||
TestProtocol.testLogD(
|
||||
TestProtocol.ACTIVITY_LIFECYCLE_RULE, "MyStatement.onAcgtivityStopped");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivitySaveInstanceState(Activity activity, Bundle bundle) {
|
||||
if (activity == mActivity) {
|
||||
TestProtocol.testLogD(TestProtocol.ACTIVITY_LIFECYCLE_RULE,
|
||||
"MyStatement.onActivitySaveInstanceState");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityDestroyed(Activity activity) {
|
||||
if (activity == mActivity) {
|
||||
TestProtocol.testLogD(
|
||||
TestProtocol.ACTIVITY_LIFECYCLE_RULE, "MyStatement.onActivityDestroyed");
|
||||
mActivity = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user