Commit 2877dea5 authored by Vasilii Sukhanov's avatar Vasilii Sukhanov Committed by Commit Bot

Fix flakiness in PasswordBubbleBrowserTest tests.

The tests were creating PasswordStoreX early before it was overridden by
the testing factory. Now the tests will create TestPasswordStore from
the beginning.

Fixed: 1146503
Change-Id: I2701d9d44064536acf2d52a0721def71f9e69473
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2527382
Commit-Queue: Vasilii Sukhanov <vasilii@chromium.org>
Reviewed-by: default avatarJan Wilken Dörrie <jdoerrie@chromium.org>
Cr-Commit-Position: refs/heads/master@{#825737}
parent a5deaa4e
......@@ -81,14 +81,25 @@ ManagePasswordsTest::ManagePasswordsTest() {
ManagePasswordsTest::~ManagePasswordsTest() = default;
void ManagePasswordsTest::SetUpOnMainThread() {
PasswordStoreFactory::GetInstance()->SetTestingFactory(
browser()->profile(),
base::BindRepeating(
&password_manager::BuildPasswordStore<
content::BrowserContext, password_manager::TestPasswordStore>));
AddTabAtIndex(0, GURL(kTestOrigin), ui::PAGE_TRANSITION_TYPED);
}
void ManagePasswordsTest::SetUpInProcessBrowserTestFixture() {
InProcessBrowserTest::SetUpInProcessBrowserTestFixture();
create_services_subscription_ =
BrowserContextDependencyManager::GetInstance()
->RegisterCreateServicesCallbackForTesting(
base::BindRepeating([](content::BrowserContext* context) {
// Overwrite the password store early before it's accessed by
// safe browsing.
PasswordStoreFactory::GetInstance()->SetTestingFactory(
context,
base::BindRepeating(&password_manager::BuildPasswordStore<
content::BrowserContext,
password_manager::TestPasswordStore>));
}));
}
void ManagePasswordsTest::ExecuteManagePasswordsCommand() {
// Show the window to ensure that it's active.
browser()->window()->Show();
......
......@@ -13,6 +13,7 @@
#include "base/test/metrics/histogram_tester.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "components/autofill/core/common/form_data.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "components/password_manager/core/browser/fake_form_fetcher.h"
#include "components/password_manager/core/browser/password_form.h"
#include "components/password_manager/core/browser/stub_password_manager_client.h"
......@@ -31,6 +32,7 @@ class ManagePasswordsTest : public InProcessBrowserTest {
// InProcessBrowserTest:
void SetUpOnMainThread() override;
void SetUpInProcessBrowserTestFixture() override;
// Execute the browser command to open the manage passwords bubble.
void ExecuteManagePasswordsCommand();
......@@ -85,6 +87,10 @@ class ManagePasswordsTest : public InProcessBrowserTest {
password_manager::StubPasswordManagerDriver driver_;
password_manager::FakeFormFetcher fetcher_;
std::unique_ptr<
BrowserContextDependencyManager::CreateServicesCallbackList::Subscription>
create_services_subscription_;
DISALLOW_COPY_AND_ASSIGN(ManagePasswordsTest);
};
......
......@@ -77,7 +77,6 @@ class PasswordBubbleBrowserTest
private:
base::test::ScopedFeatureList scoped_feature_list_;
DISALLOW_COPY_AND_ASSIGN(PasswordBubbleBrowserTest);
};
INSTANTIATE_TEST_SUITE_P(All, PasswordBubbleBrowserTest, ::testing::Bool());
......@@ -101,34 +100,15 @@ IN_PROC_BROWSER_TEST_P(PasswordBubbleBrowserTest, InvokeUi_AutoSignin) {
ShowAndVerifyUi();
}
// TODO(crbug.com/1146503): Flaky on Linux
#if defined(OS_LINUX)
#define MAYBE_InvokeUi_SafeState DISABLED_InvokeUi_SafeState
#else
#define MAYBE_InvokeUi_SafeState InvokeUi_SafeState
#endif
IN_PROC_BROWSER_TEST_P(PasswordBubbleBrowserTest, MAYBE_InvokeUi_SafeState) {
IN_PROC_BROWSER_TEST_P(PasswordBubbleBrowserTest, InvokeUi_SafeState) {
ShowAndVerifyUi();
}
// TODO(crbug.com/1146503): Flaky on Linux
#if defined(OS_LINUX)
#define MAYBE_InvokeUi_MoreToFixState DISABLED_InvokeUi_MoreToFixState
#else
#define MAYBE_InvokeUi_MoreToFixState InvokeUi_MoreToFixState
#endif
IN_PROC_BROWSER_TEST_P(
PasswordBubbleBrowserTest, MAYBE_InvokeUi_MoreToFixState) {
IN_PROC_BROWSER_TEST_P(PasswordBubbleBrowserTest, InvokeUi_MoreToFixState) {
ShowAndVerifyUi();
}
// TODO(crbug.com/1146503): Flaky on Linux
#if defined(OS_LINUX)
#define MAYBE_InvokeUi_UnsafeState DISABLED_InvokeUi_UnsafeState
#else
#define MAYBE_InvokeUi_UnsafeState InvokeUi_UnsafeState
#endif
IN_PROC_BROWSER_TEST_P(PasswordBubbleBrowserTest, MAYBE_InvokeUi_UnsafeState) {
IN_PROC_BROWSER_TEST_P(PasswordBubbleBrowserTest, InvokeUi_UnsafeState) {
ShowAndVerifyUi();
}
......
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