Commit 5dca5ccd authored by David Maunder's avatar David Maunder Committed by Chromium LUCI CQ

Batch UndoTabModelTest

Speedup: 49246ms -> 10061ms (80% improvement)

Bug: 1164552
Change-Id: I85bf73b14b2def7b9c0d5d3d4a1f2505d037a2cc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2617051Reviewed-by: default avatarWei-Yin Chen (陳威尹) <wychen@chromium.org>
Reviewed-by: default avatarMichael Thiessen <mthiesse@chromium.org>
Commit-Queue: David Maunder <davidjm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#842834}
parent d2ae250b
...@@ -54,6 +54,9 @@ public class BlankCTATabInitialStateRule implements TestRule { ...@@ -54,6 +54,9 @@ public class BlankCTATabInitialStateRule implements TestRule {
() -> { FirstRunStatus.setFirstRunFlowComplete(true); }); () -> { FirstRunStatus.setFirstRunFlowComplete(true); });
mActivityTestRule.startMainActivityOnBlankPage(); mActivityTestRule.startMainActivityOnBlankPage();
sActivity = mActivityTestRule.getActivity(); sActivity = mActivityTestRule.getActivity();
// Previous tests may have left tabs open and finished the Activity.
if (regularTabCount() > 1) resetTabStateFast();
} else { } else {
mActivityTestRule.setActivity(sActivity); mActivityTestRule.setActivity(sActivity);
if (shouldPerformFastReset()) { if (shouldPerformFastReset()) {
...@@ -68,15 +71,22 @@ public class BlankCTATabInitialStateRule implements TestRule { ...@@ -68,15 +71,22 @@ public class BlankCTATabInitialStateRule implements TestRule {
// If the activity was relaunched during the test, update the reference to use // If the activity was relaunched during the test, update the reference to use
// the most up to date Activity. // the most up to date Activity.
sActivity = mActivityTestRule.getActivity(); sActivity = mActivityTestRule.getActivity();
if (sActivity.isActivityFinishingOrDestroyed()) {
sActivity = null;
}
} }
} }
}; };
} }
private int regularTabCount() {
return TestThreadUtils.runOnUiThreadBlockingNoException(
() -> { return sActivity.getTabModelSelector().getModel(false).getCount(); });
}
private boolean shouldPerformFastReset() { private boolean shouldPerformFastReset() {
if (mClearAllTabState) return false; if (mClearAllTabState) return false;
return TestThreadUtils.runOnUiThreadBlockingNoException( return regularTabCount() > 0;
() -> { 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
......
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