Commit c06cc9fa authored by Dominic Battre's avatar Dominic Battre Committed by Commit Bot

Fix racy access to ScopedFeatureList

We must not initialize a ScopedFeatureList in multithreaded
tests unless we do it in the constructor of a fixture. See the linked
bug for details.

Bug: 1125487
Change-Id: I1b96dc73dcfbce37d9c6b68d11e031894ea51984
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2395657
Commit-Queue: Dominic Battré <battre@chromium.org>
Reviewed-by: default avatarDominic Battré <battre@chromium.org>
Reviewed-by: default avatarVictor Costan <pwnall@chromium.org>
Reviewed-by: default avatarVasilii Sukhanov <vasilii@chromium.org>
Auto-Submit: Dominic Battré <battre@chromium.org>
Cr-Commit-Position: refs/heads/master@{#804750}
parent 104e5da2
......@@ -281,15 +281,25 @@ TEST_F(LocalCardMigrationBubbleControllerImplTest,
Bucket(AutofillMetrics::LOCAL_CARD_MIGRATION_BUBBLE_SHOWN, 1)));
}
class LocalCardMigrationBubbleControllerImplTestWithStickyPaymentsBubble
: public LocalCardMigrationBubbleControllerImplTest {
public:
LocalCardMigrationBubbleControllerImplTestWithStickyPaymentsBubble() {
scoped_feature_list_.InitAndEnableFeature(
features::kAutofillEnableStickyPaymentsBubble);
}
~LocalCardMigrationBubbleControllerImplTestWithStickyPaymentsBubble()
override = default;
private:
base::test::ScopedFeatureList scoped_feature_list_;
};
// Ensures the bubble should still stick around even if the time since bubble
// showing is longer than kCardBubbleSurviveNavigationTime (5 seconds) when the
// feature is enabled.
TEST_F(LocalCardMigrationBubbleControllerImplTest,
TEST_F(LocalCardMigrationBubbleControllerImplTestWithStickyPaymentsBubble,
StickyBubble_ShouldNotDismissUponNavigation) {
base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitAndEnableFeature(
features::kAutofillEnableStickyPaymentsBubble);
ShowBubble();
base::HistogramTester histogram_tester;
controller()->set_elapsed(base::TimeDelta::FromSeconds(10));
......@@ -307,19 +317,11 @@ class LocalCardMigrationBubbleLoggingTest
: public LocalCardMigrationBubbleControllerImplTest,
public ::testing::WithParamInterface<bool> {
public:
LocalCardMigrationBubbleLoggingTest() = default;
~LocalCardMigrationBubbleLoggingTest() override = default;
void SetUp() override {
LocalCardMigrationBubbleControllerImplTest::SetUp();
if (GetParam()) {
scoped_feature_list_.InitAndEnableFeature(
features::kAutofillEnableFixedPaymentsBubbleLogging);
} else {
scoped_feature_list_.InitAndDisableFeature(
features::kAutofillEnableFixedPaymentsBubbleLogging);
}
LocalCardMigrationBubbleLoggingTest() {
scoped_feature_list_.InitWithFeatureState(
features::kAutofillEnableFixedPaymentsBubbleLogging, GetParam());
}
~LocalCardMigrationBubbleLoggingTest() override = default;
private:
base::test::ScopedFeatureList scoped_feature_list_;
......
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