Commit e6f17955 authored by David Roger's avatar David Roger Committed by Commit Bot

[signin] De-flake DiceSigninUiUtilTest

The cause of the flake is not known but it may be the combination of
BrowserWithTestWindowTest and MOCK_TIME.
Some tests in that suite need BrowserWithTestWindowTest, and one test
needs MOCK_TIME. There is no test that needs both.

This CL splits the tests in two groups:
- tests that need BrowserWithTestWindowTest. They are now no longer using
  MOCK_TIME
- test that needs MOCK_TIME, now no longer using BrowserWithTestWindowTest.

Fixed: 1014790
Change-Id: I2ee2cce2b38f21c00de3d841913c7307b17b2a78
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2151590Reviewed-by: default avatarMonica Basta <msalama@chromium.org>
Commit-Queue: David Roger <droger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#760015}
parent 315797d8
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "chrome/browser/signin/signin_promo.h" #include "chrome/browser/signin/signin_promo.h"
#include "chrome/browser/ui/ui_features.h" #include "chrome/browser/ui/ui_features.h"
#include "chrome/test/base/browser_with_test_window_test.h" #include "chrome/test/base/browser_with_test_window_test.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile_manager.h" #include "chrome/test/base/testing_profile_manager.h"
#include "components/account_id/account_id.h" #include "components/account_id/account_id.h"
#include "components/google/core/common/google_util.h" #include "components/google/core/common/google_util.h"
...@@ -89,9 +90,7 @@ class SigninUiUtilTestBrowserWindow : public TestBrowserWindow { ...@@ -89,9 +90,7 @@ class SigninUiUtilTestBrowserWindow : public TestBrowserWindow {
class DiceSigninUiUtilTest : public BrowserWithTestWindowTest { class DiceSigninUiUtilTest : public BrowserWithTestWindowTest {
public: public:
DiceSigninUiUtilTest() DiceSigninUiUtilTest() : BrowserWithTestWindowTest() {}
: BrowserWithTestWindowTest(
base::test::TaskEnvironment::TimeSource::MOCK_TIME) {}
~DiceSigninUiUtilTest() override = default; ~DiceSigninUiUtilTest() override = default;
struct CreateDiceTurnSyncOnHelperParams { struct CreateDiceTurnSyncOnHelperParams {
...@@ -244,14 +243,7 @@ class DiceSigninUiUtilTest : public BrowserWithTestWindowTest { ...@@ -244,14 +243,7 @@ class DiceSigninUiUtilTest : public BrowserWithTestWindowTest {
CreateDiceTurnSyncOnHelperParams create_dice_turn_sync_on_helper_params_; CreateDiceTurnSyncOnHelperParams create_dice_turn_sync_on_helper_params_;
}; };
// TODO(https://crbug.com/1014790): Timeout on Mac10.12 and Win10. TEST_F(DiceSigninUiUtilTest, EnableSyncWithExistingAccount) {
#if defined(OS_MACOSX) || defined(OS_WIN)
#define MAYBE_EnableSyncWithExistingAccount \
DISABLED_EnableSyncWithExistingAccount
#else
#define MAYBE_EnableSyncWithExistingAccount EnableSyncWithExistingAccount
#endif
TEST_F(DiceSigninUiUtilTest, MAYBE_EnableSyncWithExistingAccount) {
CoreAccountId account_id = CoreAccountId account_id =
GetIdentityManager()->GetAccountsMutator()->AddOrUpdateAccount( GetIdentityManager()->GetAccountsMutator()->AddOrUpdateAccount(
kMainGaiaID, kMainEmail, "refresh_token", false, kMainGaiaID, kMainEmail, "refresh_token", false,
...@@ -362,14 +354,7 @@ TEST_F(DiceSigninUiUtilTest, EnableSyncWithAccountThatNeedsReauth) { ...@@ -362,14 +354,7 @@ TEST_F(DiceSigninUiUtilTest, EnableSyncWithAccountThatNeedsReauth) {
} }
} }
// TODO(https://crbug.com/1014790): Timeout on Mac10.12, Win7 and Win10. TEST_F(DiceSigninUiUtilTest, EnableSyncForNewAccountWithNoTab) {
#if defined(OS_MACOSX) || defined(OS_WIN)
#define MAYBE_EnableSyncForNewAccountWithNoTab \
DISABLED_EnableSyncForNewAccountWithNoTab
#else
#define MAYBE_EnableSyncForNewAccountWithNoTab EnableSyncForNewAccountWithNoTab
#endif
TEST_F(DiceSigninUiUtilTest, MAYBE_EnableSyncForNewAccountWithNoTab) {
base::HistogramTester histogram_tester; base::HistogramTester histogram_tester;
base::UserActionTester user_action_tester; base::UserActionTester user_action_tester;
...@@ -398,16 +383,7 @@ TEST_F(DiceSigninUiUtilTest, MAYBE_EnableSyncForNewAccountWithNoTab) { ...@@ -398,16 +383,7 @@ TEST_F(DiceSigninUiUtilTest, MAYBE_EnableSyncForNewAccountWithNoTab) {
active_contents->GetVisibleURL()); active_contents->GetVisibleURL());
} }
// TODO(https://crbug.com/1014790): Timeout on Mac10.12. TEST_F(DiceSigninUiUtilTest, EnableSyncForNewAccountWithNoTabWithExisting) {
#if defined(OS_MACOSX)
#define MAYBE_EnableSyncForNewAccountWithNoTabWithExisting \
DISABLED_EnableSyncForNewAccountWithNoTabWithExisting
#else
#define MAYBE_EnableSyncForNewAccountWithNoTabWithExisting \
EnableSyncForNewAccountWithNoTabWithExisting
#endif
TEST_F(DiceSigninUiUtilTest,
MAYBE_EnableSyncForNewAccountWithNoTabWithExisting) {
base::HistogramTester histogram_tester; base::HistogramTester histogram_tester;
base::UserActionTester user_action_tester; base::UserActionTester user_action_tester;
...@@ -432,15 +408,7 @@ TEST_F(DiceSigninUiUtilTest, ...@@ -432,15 +408,7 @@ TEST_F(DiceSigninUiUtilTest,
"Signin_SigninNewAccountExistingAccount_FromBookmarkBubble")); "Signin_SigninNewAccountExistingAccount_FromBookmarkBubble"));
} }
// TODO(https://crbug.com/1014790): Timeout on Mac10.12 and Win7. TEST_F(DiceSigninUiUtilTest, EnableSyncForNewAccountWithOneTab) {
#if defined(OS_MACOSX) || defined(OS_WIN)
#define MAYBE_EnableSyncForNewAccountWithOneTab \
DISABLED_EnableSyncForNewAccountWithOneTab
#else
#define MAYBE_EnableSyncForNewAccountWithOneTab \
EnableSyncForNewAccountWithOneTab
#endif
TEST_F(DiceSigninUiUtilTest, MAYBE_EnableSyncForNewAccountWithOneTab) {
base::HistogramTester histogram_tester; base::HistogramTester histogram_tester;
base::UserActionTester user_action_tester; base::UserActionTester user_action_tester;
AddTab(browser(), GURL("http://foo/1")); AddTab(browser(), GURL("http://foo/1"));
...@@ -470,13 +438,7 @@ TEST_F(DiceSigninUiUtilTest, MAYBE_EnableSyncForNewAccountWithOneTab) { ...@@ -470,13 +438,7 @@ TEST_F(DiceSigninUiUtilTest, MAYBE_EnableSyncForNewAccountWithOneTab) {
active_contents->GetVisibleURL()); active_contents->GetVisibleURL());
} }
// TODO(https://crbug.com/1014790): Timeout on Mac10.12 and Win7 x64. TEST_F(DiceSigninUiUtilTest, GetAccountsForDicePromos) {
#if defined(OS_MACOSX) || defined(OS_WIN)
#define MAYBE_GetAccountsForDicePromos DISABLED_GetAccountsForDicePromos
#else
#define MAYBE_GetAccountsForDicePromos GetAccountsForDicePromos
#endif
TEST_F(DiceSigninUiUtilTest, MAYBE_GetAccountsForDicePromos) {
// Should start off with no accounts. // Should start off with no accounts.
std::vector<AccountInfo> accounts = GetAccountsForDicePromos(profile()); std::vector<AccountInfo> accounts = GetAccountsForDicePromos(profile());
EXPECT_TRUE(accounts.empty()); EXPECT_TRUE(accounts.empty());
...@@ -484,13 +446,7 @@ TEST_F(DiceSigninUiUtilTest, MAYBE_GetAccountsForDicePromos) { ...@@ -484,13 +446,7 @@ TEST_F(DiceSigninUiUtilTest, MAYBE_GetAccountsForDicePromos) {
// TODO(tangltom): Flesh out this test. // TODO(tangltom): Flesh out this test.
} }
// TODO(https://crbug.com/1014790): Timeout on Mac10.12 and Win7. TEST_F(DiceSigninUiUtilTest, MergeDiceSigninTab) {
#if defined(OS_MACOSX) || defined(OS_WIN)
#define MAYBE_MergeDiceSigninTab DISABLED_MergeDiceSigninTab
#else
#define MAYBE_MergeDiceSigninTab MergeDiceSigninTab
#endif
TEST_F(DiceSigninUiUtilTest, MAYBE_MergeDiceSigninTab) {
base::UserActionTester user_action_tester; base::UserActionTester user_action_tester;
EnableSync(AccountInfo(), false); EnableSync(AccountInfo(), false);
EXPECT_EQ( EXPECT_EQ(
...@@ -539,17 +495,8 @@ TEST_F(DiceSigninUiUtilTest, ...@@ -539,17 +495,8 @@ TEST_F(DiceSigninUiUtilTest,
*profile_manager()->profile_attributes_storage(), profile())); *profile_manager()->profile_attributes_storage(), profile()));
} }
// TODO(https://crbug.com/1014790): Timeout on Mac10.12 and Win7. TEST_F(DiceSigninUiUtilTest,
#if defined(OS_MACOSX) || defined(OS_WIN) ShouldShowAnimatedIdentityOnOpeningWindow_ReturnsTrueForMultiSignin) {
#define MAYBE_ShouldShowAnimatedIdentityOnOpeningWindow_ReturnsTrueForMultiSignin \
DISABLED_ShouldShowAnimatedIdentityOnOpeningWindow_ReturnsTrueForMultiSignin
#else
#define MAYBE_ShouldShowAnimatedIdentityOnOpeningWindow_ReturnsTrueForMultiSignin \
ShouldShowAnimatedIdentityOnOpeningWindow_ReturnsTrueForMultiSignin
#endif
TEST_F(
DiceSigninUiUtilTest,
MAYBE_ShouldShowAnimatedIdentityOnOpeningWindow_ReturnsTrueForMultiSignin) {
GetIdentityManager()->GetAccountsMutator()->AddOrUpdateAccount( GetIdentityManager()->GetAccountsMutator()->AddOrUpdateAccount(
kMainGaiaID, kMainEmail, "refresh_token", false, kMainGaiaID, kMainEmail, "refresh_token", false,
signin_metrics::SourceForRefreshTokenOperation::kUnknown); signin_metrics::SourceForRefreshTokenOperation::kUnknown);
...@@ -567,17 +514,9 @@ TEST_F( ...@@ -567,17 +514,9 @@ TEST_F(
*profile_manager()->profile_attributes_storage(), profile())); *profile_manager()->profile_attributes_storage(), profile()));
} }
// TODO(https://crbug.com/1014790): Timeout on Mac10.12 and Win7 x64.
#if defined(OS_MACOSX) || defined(OS_WIN)
#define MAYBE_ShouldShowAnimatedIdentityOnOpeningWindow_ReturnsFalseForSingleProfileSingleSignin \
DISABLED_ShouldShowAnimatedIdentityOnOpeningWindow_ReturnsFalseForSingleProfileSingleSignin
#else
#define MAYBE_ShouldShowAnimatedIdentityOnOpeningWindow_ReturnsFalseForSingleProfileSingleSignin \
ShouldShowAnimatedIdentityOnOpeningWindow_ReturnsFalseForSingleProfileSingleSignin
#endif
TEST_F( TEST_F(
DiceSigninUiUtilTest, DiceSigninUiUtilTest,
MAYBE_ShouldShowAnimatedIdentityOnOpeningWindow_ReturnsFalseForSingleProfileSingleSignin) { ShouldShowAnimatedIdentityOnOpeningWindow_ReturnsFalseForSingleProfileSingleSignin) {
GetIdentityManager()->GetAccountsMutator()->AddOrUpdateAccount( GetIdentityManager()->GetAccountsMutator()->AddOrUpdateAccount(
kMainGaiaID, kMainEmail, "refresh_token", false, kMainGaiaID, kMainEmail, "refresh_token", false,
signin_metrics::SourceForRefreshTokenOperation::kUnknown); signin_metrics::SourceForRefreshTokenOperation::kUnknown);
...@@ -586,26 +525,45 @@ TEST_F( ...@@ -586,26 +525,45 @@ TEST_F(
*profile_manager()->profile_attributes_storage(), profile())); *profile_manager()->profile_attributes_storage(), profile()));
} }
TEST_F(DiceSigninUiUtilTest, // This test does not use the DiceSigninUiUtilTest test fixture, because it
ShouldShowAnimatedIdentityOnOpeningWindow_ReturnsFalseForNewWindow) { // needs a mock time environment, and BrowserWithTestWindowTest may be flaky
GetIdentityManager()->GetAccountsMutator()->AddOrUpdateAccount( // when used with mock time (see https://crbug.com/1014790).
TEST(ShouldShowAnimatedIdentityOnOpeningWindow, ReturnsFalseForNewWindow) {
// Setup a testing profile manager with mock time.
content::BrowserTaskEnvironment task_environment(
base::test::TaskEnvironment::TimeSource::MOCK_TIME);
ScopedTestingLocalState local_state(TestingBrowserProcess::GetGlobal());
TestingProfileManager profile_manager(TestingBrowserProcess::GetGlobal(),
&local_state);
ASSERT_TRUE(profile_manager.SetUp());
std::string name("testing_profile");
TestingProfile* profile = profile_manager.CreateTestingProfile(
name, std::unique_ptr<sync_preferences::PrefServiceSyncable>(),
base::UTF8ToUTF16(name), 0, std::string(),
IdentityTestEnvironmentProfileAdaptor::
GetIdentityTestEnvironmentFactories());
// Setup accounts.
signin::IdentityManager* identity_manager =
IdentityManagerFactory::GetForProfile(profile);
identity_manager->GetAccountsMutator()->AddOrUpdateAccount(
kMainGaiaID, kMainEmail, "refresh_token", false, kMainGaiaID, kMainEmail, "refresh_token", false,
signin_metrics::SourceForRefreshTokenOperation::kUnknown); signin_metrics::SourceForRefreshTokenOperation::kUnknown);
GetIdentityManager()->GetAccountsMutator()->AddOrUpdateAccount( identity_manager->GetAccountsMutator()->AddOrUpdateAccount(
kSecondaryGaiaID, kSecondaryEmail, "refresh_token", false, kSecondaryGaiaID, kSecondaryEmail, "refresh_token", false,
signin_metrics::SourceForRefreshTokenOperation::kUnknown); signin_metrics::SourceForRefreshTokenOperation::kUnknown);
EXPECT_TRUE(ShouldShowAnimatedIdentityOnOpeningWindow( EXPECT_TRUE(ShouldShowAnimatedIdentityOnOpeningWindow(
*profile_manager()->profile_attributes_storage(), profile())); *profile_manager.profile_attributes_storage(), profile));
// Animation is shown once. // Animation is shown once.
RecordAnimatedIdentityTriggered(profile()); RecordAnimatedIdentityTriggered(profile);
// Wait a few seconds. // Wait a few seconds.
task_environment()->FastForwardBy(base::TimeDelta::FromSeconds(6)); task_environment.FastForwardBy(base::TimeDelta::FromSeconds(6));
// Animation is not shown again in a new window. // Animation is not shown again in a new window.
EXPECT_FALSE(ShouldShowAnimatedIdentityOnOpeningWindow( EXPECT_FALSE(ShouldShowAnimatedIdentityOnOpeningWindow(
*profile_manager()->profile_attributes_storage(), profile())); *profile_manager.profile_attributes_storage(), profile));
} }
} // namespace signin_ui_util } // namespace signin_ui_util
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