Commit 1c81957e authored by Ted Choc's avatar Ted Choc Committed by Commit Bot

Attempt to deflake MainIntentBehaviorMetricsIntegrationTest

My hypothesis is the static last main intent value was leaking
across test runs.  A previous fix exposed the MainIntentMetrics
as a getter, which can remove the need for this to be a static.

BUG=784649

Change-Id: I79716cd7fa1402a3ed5da2a4f529dcd1fd5df43b
Reviewed-on: https://chromium-review.googlesource.com/767927Reviewed-by: 's avatarMaria Khomenko <mariakhomenko@chromium.org>
Commit-Queue: Ted Choc <tedchoc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#516140}
parent e23356c2
......@@ -51,8 +51,6 @@ public class MainIntentBehaviorMetrics implements ApplicationStatus.ActivityStat
private static final int DURATION_HISTOGRAM_MAX = 48 * 60;
private static final int DURATION_HISTOGRAM_BUCKET_COUNT = 50;
@MainIntentActionType
private static Integer sLastMainIntentBehavior;
private static long sTimeoutDurationMs = TIMEOUT_DURATION_MS;
private final ChromeActivity mActivity;
......@@ -64,6 +62,9 @@ public class MainIntentBehaviorMetrics implements ApplicationStatus.ActivityStat
private TabModelSelectorTabModelObserver mTabModelObserver;
private boolean mIgnoreEvents;
@MainIntentActionType
private Integer mLastMainIntentBehavior;
/**
* Constructs a metrics handler for ACTION_MAIN intents received for the specified activity.
*/
......@@ -85,7 +86,7 @@ public class MainIntentBehaviorMetrics implements ApplicationStatus.ActivityStat
*/
@SuppressFBWarnings("ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD")
public void onMainIntentWithNative(long backgroundDurationMs) {
sLastMainIntentBehavior = null;
mLastMainIntentBehavior = null;
RecordUserAction.record("MobileStartup.MainIntentReceived");
......@@ -150,8 +151,8 @@ public class MainIntentBehaviorMetrics implements ApplicationStatus.ActivityStat
* received or if the event has not yet occurred.
*/
@MainIntentActionType
public static Integer getLastMainIntentBehaviorForTesting() {
return sLastMainIntentBehavior;
public Integer getLastMainIntentBehaviorForTesting() {
return mLastMainIntentBehavior;
}
/**
......@@ -189,7 +190,7 @@ public class MainIntentBehaviorMetrics implements ApplicationStatus.ActivityStat
if (!mPendingActionRecordForMainIntent || mIgnoreEvents) return;
mPendingActionRecordForMainIntent = false;
sLastMainIntentBehavior = behavior;
mLastMainIntentBehavior = behavior;
String histogramName = getHistogramNameForBehavior(behavior);
if (histogramName != null) {
RecordHistogram.recordCustomCountHistogram(
......
......@@ -126,7 +126,7 @@ public class MainIntentBehaviorMetricsIntegrationTest {
@MediumTest
@Test
public void testMainIntentWithLauncherCategory() throws InterruptedException {
public void testMainIntentWithoutLauncherCategory() throws InterruptedException {
mActivityTestRule.startMainActivityFromIntent(new Intent(Intent.ACTION_MAIN), null);
assertMainIntentBehavior(null);
Assert.assertFalse(mActivityTestRule.getActivity().getMainIntentBehaviorMetricsForTesting()
......@@ -137,7 +137,9 @@ public class MainIntentBehaviorMetricsIntegrationTest {
CriteriaHelper.pollUiThread(Criteria.equals(expected, new Callable<Integer>() {
@Override
public Integer call() throws Exception {
return MainIntentBehaviorMetrics.getLastMainIntentBehaviorForTesting();
return mActivityTestRule.getActivity()
.getMainIntentBehaviorMetricsForTesting()
.getLastMainIntentBehaviorForTesting();
}
}));
}
......
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