Commit 57dc2621 authored by Ted Choc's avatar Ted Choc Committed by Chromium LUCI CQ

Convert ConditionalTabStripTest to batched.

Makes BlankCTATabInitialStateRule more robust:
  * Handles the activity being restarted as part of the test.
  * Handles the case where all tabs are closed.

Performance metrics: 117777 -> 77156

BUG=989569

Change-Id: Ib1281d1160a76595c6ef5ead3cde2a7fcd370293
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2596034
Commit-Queue: Ted Choc <tedchoc@chromium.org>
Reviewed-by: default avatarYue Zhang <yuezhanggg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#838233}
parent cef23ac3
...@@ -11,6 +11,7 @@ import androidx.annotation.VisibleForTesting; ...@@ -11,6 +11,7 @@ import androidx.annotation.VisibleForTesting;
import org.chromium.base.ApiCompatibilityUtils; import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.Callback; import org.chromium.base.Callback;
import org.chromium.base.CommandLine;
import org.chromium.base.TraceEvent; import org.chromium.base.TraceEvent;
import org.chromium.base.supplier.ObservableSupplier; import org.chromium.base.supplier.ObservableSupplier;
import org.chromium.base.supplier.ObservableSupplierImpl; import org.chromium.base.supplier.ObservableSupplierImpl;
...@@ -33,6 +34,7 @@ import org.chromium.chrome.browser.datareduction.DataReductionPromoScreen; ...@@ -33,6 +34,7 @@ import org.chromium.chrome.browser.datareduction.DataReductionPromoScreen;
import org.chromium.chrome.browser.feature_engagement.TrackerFactory; import org.chromium.chrome.browser.feature_engagement.TrackerFactory;
import org.chromium.chrome.browser.firstrun.FirstRunStatus; import org.chromium.chrome.browser.firstrun.FirstRunStatus;
import org.chromium.chrome.browser.flags.ChromeFeatureList; import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.chrome.browser.flags.ChromeSwitches;
import org.chromium.chrome.browser.fullscreen.BrowserControlsManager; import org.chromium.chrome.browser.fullscreen.BrowserControlsManager;
import org.chromium.chrome.browser.gesturenav.HistoryNavigationCoordinator; import org.chromium.chrome.browser.gesturenav.HistoryNavigationCoordinator;
import org.chromium.chrome.browser.gesturenav.NavigationSheet; import org.chromium.chrome.browser.gesturenav.NavigationSheet;
...@@ -490,6 +492,10 @@ public class TabbedRootUiCoordinator extends RootUiCoordinator { ...@@ -490,6 +492,10 @@ public class TabbedRootUiCoordinator extends RootUiCoordinator {
*/ */
private boolean triggerPromo(boolean intentWithEffect) { private boolean triggerPromo(boolean intentWithEffect) {
try (TraceEvent e = TraceEvent.scoped("TabbedRootUiCoordinator.triggerPromo")) { try (TraceEvent e = TraceEvent.scoped("TabbedRootUiCoordinator.triggerPromo")) {
if (CommandLine.getInstance().hasSwitch(ChromeSwitches.DISABLE_STARTUP_PROMOS)) {
return false;
}
SharedPreferencesManager preferenceManager = SharedPreferencesManager.getInstance(); SharedPreferencesManager preferenceManager = SharedPreferencesManager.getInstance();
// Promos can only be shown when we start with ACTION_MAIN intent and // Promos can only be shown when we start with ACTION_MAIN intent and
// after FRE is complete. Native initialization can finish before the FRE flow is // after FRE is complete. Native initialization can finish before the FRE flow is
......
...@@ -218,6 +218,10 @@ public class CachedFeatureFlags { ...@@ -218,6 +218,10 @@ public class CachedFeatureFlags {
@VisibleForTesting @VisibleForTesting
public static void setOverrideTestValue(String preferenceKey, String overrideValue) { public static void setOverrideTestValue(String preferenceKey, String overrideValue) {
if (sOverridesTestFeatures == null) {
sOverridesTestFeatures = new HashMap<>();
}
sOverridesTestFeatures.put(preferenceKey, overrideValue); sOverridesTestFeatures.put(preferenceKey, overrideValue);
} }
......
...@@ -33,6 +33,9 @@ public abstract class ChromeSwitches {{ ...@@ -33,6 +33,9 @@ public abstract class ChromeSwitches {{
/** Disable the First Run Experience. */ /** Disable the First Run Experience. */
public static final String DISABLE_FIRST_RUN_EXPERIENCE = "disable-fre"; public static final String DISABLE_FIRST_RUN_EXPERIENCE = "disable-fre";
/** Disable promos shown on startup. */
public static final String DISABLE_STARTUP_PROMOS = "disable-startup-promos-for-testing";
/** /**
* Forces the First Run Experience (FRE) flow complete check to always return true. * Forces the First Run Experience (FRE) flow complete check to always return true.
*/ */
......
...@@ -54,17 +54,29 @@ public class BlankCTATabInitialStateRule implements TestRule { ...@@ -54,17 +54,29 @@ public class BlankCTATabInitialStateRule implements TestRule {
sActivity = mActivityTestRule.getActivity(); sActivity = mActivityTestRule.getActivity();
} else { } else {
mActivityTestRule.setActivity(sActivity); mActivityTestRule.setActivity(sActivity);
if (mClearAllTabState) { if (shouldPerformFastReset()) {
resetTabStateThorough();
} else {
resetTabStateFast(); resetTabStateFast();
} else {
resetTabStateThorough();
} }
} }
base.evaluate(); try {
base.evaluate();
} finally {
// If the activity was relaunched during the test, update the reference to use
// the most up to date Activity.
sActivity = mActivityTestRule.getActivity();
}
} }
}; };
} }
private boolean shouldPerformFastReset() {
if (mClearAllTabState) return false;
return TestThreadUtils.runOnUiThreadBlockingNoException(
() -> { return sActivity.getTabModelSelector().getModel(false).getCount() > 0; });
}
// Avoids closing the primary tab (and killing the renderer) in order to reset tab state // Avoids closing the primary tab (and killing the renderer) in order to reset tab state
// quickly, at the cost of thoroughness. This should be adequate for most tests. // quickly, at the cost of thoroughness. This should be adequate for most tests.
private void resetTabStateFast() { private void resetTabStateFast() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment