Commit f4fb9c04 authored by Thomas Tangl's avatar Thomas Tangl Committed by Commit Bot

[profile-menu] Add macro PROFILE_MENU_CLICK_TEST

Bug: 995720
Change-Id: Ie4dd2cfe80494c54281f9174a797efdf39dcd136
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1857119Reviewed-by: default avatarDavid Roger <droger@chromium.org>
Commit-Queue: Thomas Tangl <tangltom@chromium.org>
Cr-Commit-Position: refs/heads/master@{#705490}
parent 241a7d7b
...@@ -737,11 +737,28 @@ class ProfileMenuClickTest : public SyncTest, ...@@ -737,11 +737,28 @@ class ProfileMenuClickTest : public SyncTest,
DISALLOW_COPY_AND_ASSIGN(ProfileMenuClickTest); DISALLOW_COPY_AND_ASSIGN(ProfileMenuClickTest);
}; };
class ProfileMenuClickTest_MultipleProfiles : public ProfileMenuClickTest { #define PROFILE_MENU_CLICK_TEST(actionable_item_list, test_case_name) \
public: class test_case_name : public ProfileMenuClickTest { \
// List of actionable items in the correct order as they appear in the menu. public: \
// If a new button is added to the menu, it should also be added to this list. test_case_name() = default; \
static constexpr ProfileMenuView::ActionableItem kOrderedActionableItems[10] = \
ProfileMenuView::ActionableItem GetExpectedActionableItemAtIndex( \
size_t index) override { \
return actionable_item_list[index]; \
} \
\
DISALLOW_COPY_AND_ASSIGN(test_case_name); \
}; \
\
INSTANTIATE_TEST_SUITE_P( \
, test_case_name, \
::testing::Range(size_t(0), base::size(actionable_item_list))); \
\
IN_PROC_BROWSER_TEST_P(test_case_name, test_case_name)
// List of actionable items in the correct order as they appear in the menu.
// If a new button is added to the menu, it should also be added to this list.
constexpr ProfileMenuView::ActionableItem kActionableItems_MultipleProfiles[] =
{ProfileMenuView::ActionableItem::kPasswordsButton, {ProfileMenuView::ActionableItem::kPasswordsButton,
ProfileMenuView::ActionableItem::kCreditCardsButton, ProfileMenuView::ActionableItem::kCreditCardsButton,
ProfileMenuView::ActionableItem::kAddressesButton, ProfileMenuView::ActionableItem::kAddressesButton,
...@@ -755,41 +772,18 @@ class ProfileMenuClickTest_MultipleProfiles : public ProfileMenuClickTest { ...@@ -755,41 +772,18 @@ class ProfileMenuClickTest_MultipleProfiles : public ProfileMenuClickTest {
// there are no other buttons at the end. // there are no other buttons at the end.
ProfileMenuView::ActionableItem::kPasswordsButton}; ProfileMenuView::ActionableItem::kPasswordsButton};
ProfileMenuClickTest_MultipleProfiles() = default; PROFILE_MENU_CLICK_TEST(kActionableItems_MultipleProfiles,
ProfileMenuClickTest_MultipleProfiles) {
ProfileMenuView::ActionableItem GetExpectedActionableItemAtIndex(
size_t index) override {
return kOrderedActionableItems[index];
}
DISALLOW_COPY_AND_ASSIGN(ProfileMenuClickTest_MultipleProfiles);
};
// static
constexpr ProfileMenuView::ActionableItem
ProfileMenuClickTest_MultipleProfiles::kOrderedActionableItems[];
IN_PROC_BROWSER_TEST_P(ProfileMenuClickTest_MultipleProfiles, SetupAndRunTest) {
ProfileManager* profile_manager = g_browser_process->profile_manager(); ProfileManager* profile_manager = g_browser_process->profile_manager();
CreateTestingProfile(profile_manager->GenerateNextProfileDirectoryPath()); CreateTestingProfile(profile_manager->GenerateNextProfileDirectoryPath());
CreateTestingProfile(profile_manager->GenerateNextProfileDirectoryPath()); CreateTestingProfile(profile_manager->GenerateNextProfileDirectoryPath());
RunTest(); RunTest();
} }
INSTANTIATE_TEST_SUITE_P( // List of actionable items in the correct order as they appear in the menu.
, // If a new button is added to the menu, it should also be added to this list.
ProfileMenuClickTest_MultipleProfiles, constexpr ProfileMenuView::ActionableItem kActionableItems_SyncEnabled[] = {
::testing::Range( ProfileMenuView::ActionableItem::kPasswordsButton,
size_t(0),
base::size(
ProfileMenuClickTest_MultipleProfiles::kOrderedActionableItems)));
class ProfileMenuClickTest_SyncEnabled : public ProfileMenuClickTest {
public:
// List of actionable items in the correct order as they appear in the menu.
// If a new button is added to the menu, it should also be added to this list.
static constexpr ProfileMenuView::ActionableItem kOrderedActionableItems[9] =
{ProfileMenuView::ActionableItem::kPasswordsButton,
ProfileMenuView::ActionableItem::kCreditCardsButton, ProfileMenuView::ActionableItem::kCreditCardsButton,
ProfileMenuView::ActionableItem::kAddressesButton, ProfileMenuView::ActionableItem::kAddressesButton,
ProfileMenuView::ActionableItem::kSyncSettingsButton, ProfileMenuView::ActionableItem::kSyncSettingsButton,
...@@ -801,21 +795,8 @@ class ProfileMenuClickTest_SyncEnabled : public ProfileMenuClickTest { ...@@ -801,21 +795,8 @@ class ProfileMenuClickTest_SyncEnabled : public ProfileMenuClickTest {
// there are no other buttons at the end. // there are no other buttons at the end.
ProfileMenuView::ActionableItem::kPasswordsButton}; ProfileMenuView::ActionableItem::kPasswordsButton};
ProfileMenuClickTest_SyncEnabled() = default; PROFILE_MENU_CLICK_TEST(kActionableItems_SyncEnabled,
ProfileMenuClickTest_SyncEnabled) {
ProfileMenuView::ActionableItem GetExpectedActionableItemAtIndex(
size_t index) override {
return kOrderedActionableItems[index];
}
DISALLOW_COPY_AND_ASSIGN(ProfileMenuClickTest_SyncEnabled);
};
// static
constexpr ProfileMenuView::ActionableItem
ProfileMenuClickTest_SyncEnabled::kOrderedActionableItems[];
IN_PROC_BROWSER_TEST_P(ProfileMenuClickTest_SyncEnabled, SetupAndRunTest) {
ASSERT_TRUE(sync_harness()->SetupSync()); ASSERT_TRUE(sync_harness()->SetupSync());
// Check that the sync setup was successful. // Check that the sync setup was successful.
ASSERT_TRUE(identity_manager()->HasPrimaryAccount()); ASSERT_TRUE(identity_manager()->HasPrimaryAccount());
...@@ -824,19 +805,10 @@ IN_PROC_BROWSER_TEST_P(ProfileMenuClickTest_SyncEnabled, SetupAndRunTest) { ...@@ -824,19 +805,10 @@ IN_PROC_BROWSER_TEST_P(ProfileMenuClickTest_SyncEnabled, SetupAndRunTest) {
RunTest(); RunTest();
} }
INSTANTIATE_TEST_SUITE_P( // List of actionable items in the correct order as they appear in the menu.
, // If a new button is added to the menu, it should also be added to this list.
ProfileMenuClickTest_SyncEnabled, constexpr ProfileMenuView::ActionableItem kActionableItems_SyncError[] = {
::testing::Range( ProfileMenuView::ActionableItem::kPasswordsButton,
size_t(0),
base::size(ProfileMenuClickTest_SyncEnabled::kOrderedActionableItems)));
class ProfileMenuClickTest_SyncError : public ProfileMenuClickTest {
public:
// List of actionable items in the correct order as they appear in the menu.
// If a new button is added to the menu, it should also be added to this list.
static constexpr ProfileMenuView::ActionableItem kOrderedActionableItems[9] =
{ProfileMenuView::ActionableItem::kPasswordsButton,
ProfileMenuView::ActionableItem::kCreditCardsButton, ProfileMenuView::ActionableItem::kCreditCardsButton,
ProfileMenuView::ActionableItem::kAddressesButton, ProfileMenuView::ActionableItem::kAddressesButton,
ProfileMenuView::ActionableItem::kSyncErrorButton, ProfileMenuView::ActionableItem::kSyncErrorButton,
...@@ -848,21 +820,8 @@ class ProfileMenuClickTest_SyncError : public ProfileMenuClickTest { ...@@ -848,21 +820,8 @@ class ProfileMenuClickTest_SyncError : public ProfileMenuClickTest {
// there are no other buttons at the end. // there are no other buttons at the end.
ProfileMenuView::ActionableItem::kPasswordsButton}; ProfileMenuView::ActionableItem::kPasswordsButton};
ProfileMenuClickTest_SyncError() = default; PROFILE_MENU_CLICK_TEST(kActionableItems_SyncError,
ProfileMenuClickTest_SyncError) {
ProfileMenuView::ActionableItem GetExpectedActionableItemAtIndex(
size_t index) override {
return kOrderedActionableItems[index];
}
DISALLOW_COPY_AND_ASSIGN(ProfileMenuClickTest_SyncError);
};
// static
constexpr ProfileMenuView::ActionableItem
ProfileMenuClickTest_SyncError::kOrderedActionableItems[];
IN_PROC_BROWSER_TEST_P(ProfileMenuClickTest_SyncError, SetupAndRunTest) {
ASSERT_TRUE(sync_harness()->SignInPrimaryAccount()); ASSERT_TRUE(sync_harness()->SignInPrimaryAccount());
// Check that the setup was successful. // Check that the setup was successful.
ASSERT_TRUE(identity_manager()->HasPrimaryAccount()); ASSERT_TRUE(identity_manager()->HasPrimaryAccount());
...@@ -871,20 +830,11 @@ IN_PROC_BROWSER_TEST_P(ProfileMenuClickTest_SyncError, SetupAndRunTest) { ...@@ -871,20 +830,11 @@ IN_PROC_BROWSER_TEST_P(ProfileMenuClickTest_SyncError, SetupAndRunTest) {
RunTest(); RunTest();
} }
INSTANTIATE_TEST_SUITE_P( // List of actionable items in the correct order as they appear in the menu.
, // If a new button is added to the menu, it should also be added to this list.
ProfileMenuClickTest_SyncError, constexpr ProfileMenuView::ActionableItem
::testing::Range( kActionableItems_WithUnconsentedPrimaryAccount[] = {
size_t(0), ProfileMenuView::ActionableItem::kPasswordsButton,
base::size(ProfileMenuClickTest_SyncError::kOrderedActionableItems)));
class ProfileMenuClickTest_WithUnconsentedPrimaryAccount
: public ProfileMenuClickTest {
public:
// List of actionable items in the correct order as they appear in the menu.
// If a new button is added to the menu, it should also be added to this list.
static constexpr ProfileMenuView::ActionableItem kOrderedActionableItems[10] =
{ProfileMenuView::ActionableItem::kPasswordsButton,
ProfileMenuView::ActionableItem::kCreditCardsButton, ProfileMenuView::ActionableItem::kCreditCardsButton,
ProfileMenuView::ActionableItem::kAddressesButton, ProfileMenuView::ActionableItem::kAddressesButton,
ProfileMenuView::ActionableItem::kSigninAccountButton, ProfileMenuView::ActionableItem::kSigninAccountButton,
...@@ -897,24 +847,10 @@ class ProfileMenuClickTest_WithUnconsentedPrimaryAccount ...@@ -897,24 +847,10 @@ class ProfileMenuClickTest_WithUnconsentedPrimaryAccount
// there are no other buttons at the end. // there are no other buttons at the end.
ProfileMenuView::ActionableItem::kPasswordsButton}; ProfileMenuView::ActionableItem::kPasswordsButton};
ProfileMenuClickTest_WithUnconsentedPrimaryAccount() = default;
ProfileMenuView::ActionableItem GetExpectedActionableItemAtIndex(
size_t index) override {
return kOrderedActionableItems[index];
}
DISALLOW_COPY_AND_ASSIGN(ProfileMenuClickTest_WithUnconsentedPrimaryAccount);
};
// static
constexpr ProfileMenuView::ActionableItem
ProfileMenuClickTest_WithUnconsentedPrimaryAccount::kOrderedActionableItems
[];
// TODO(crbug.com/1012167): Flaky. // TODO(crbug.com/1012167): Flaky.
IN_PROC_BROWSER_TEST_P(ProfileMenuClickTest_WithUnconsentedPrimaryAccount, PROFILE_MENU_CLICK_TEST(
DISABLED_SetupAndRunTest) { kActionableItems_WithUnconsentedPrimaryAccount,
DISABLED_ProfileMenuClickTest_WithUnconsentedPrimaryAccount) {
signin::MakeAccountAvailableWithCookies(identity_manager(), signin::MakeAccountAvailableWithCookies(identity_manager(),
&test_url_loader_factory_, &test_url_loader_factory_,
"user@example.com", "gaia_id"); "user@example.com", "gaia_id");
...@@ -934,41 +870,18 @@ IN_PROC_BROWSER_TEST_P(ProfileMenuClickTest_WithUnconsentedPrimaryAccount, ...@@ -934,41 +870,18 @@ IN_PROC_BROWSER_TEST_P(ProfileMenuClickTest_WithUnconsentedPrimaryAccount,
} }
} }
INSTANTIATE_TEST_SUITE_P( // List of actionable items in the correct order as they appear in the menu.
, // If a new button is added to the menu, it should also be added to this list.
ProfileMenuClickTest_WithUnconsentedPrimaryAccount, constexpr ProfileMenuView::ActionableItem kActionableItems_GuestProfile[] = {
::testing::Range( ProfileMenuView::ActionableItem::kManageProfilesButton,
size_t(0),
base::size(ProfileMenuClickTest_WithUnconsentedPrimaryAccount::
kOrderedActionableItems)));
class ProfileMenuClickTest_GuestProfile : public ProfileMenuClickTest {
public:
// List of actionable items in the correct order as they appear in the menu.
// If a new button is added to the menu, it should also be added to this list.
static constexpr ProfileMenuView::ActionableItem kOrderedActionableItems[4] =
{ProfileMenuView::ActionableItem::kManageProfilesButton,
ProfileMenuView::ActionableItem::kOtherProfileButton, ProfileMenuView::ActionableItem::kOtherProfileButton,
ProfileMenuView::ActionableItem::kAddNewProfileButton, ProfileMenuView::ActionableItem::kAddNewProfileButton,
// The first button is added again to finish the cycle and test that // The first button is added again to finish the cycle and test that
// there are no other buttons at the end. // there are no other buttons at the end.
ProfileMenuView::ActionableItem::kManageProfilesButton}; ProfileMenuView::ActionableItem::kManageProfilesButton};
ProfileMenuClickTest_GuestProfile() = default; PROFILE_MENU_CLICK_TEST(kActionableItems_GuestProfile,
ProfileMenuClickTest_GuestProfile) {
ProfileMenuView::ActionableItem GetExpectedActionableItemAtIndex(
size_t index) override {
return kOrderedActionableItems[index];
}
DISALLOW_COPY_AND_ASSIGN(ProfileMenuClickTest_GuestProfile);
};
// static
constexpr ProfileMenuView::ActionableItem
ProfileMenuClickTest_GuestProfile::kOrderedActionableItems[];
IN_PROC_BROWSER_TEST_P(ProfileMenuClickTest_GuestProfile, SetupAndRunTest) {
profiles::SwitchToGuestProfile(ProfileManager::CreateCallback()); profiles::SwitchToGuestProfile(ProfileManager::CreateCallback());
ui_test_utils::WaitForBrowserToOpen(); ui_test_utils::WaitForBrowserToOpen();
Profile* guest = g_browser_process->profile_manager()->GetProfileByPath( Profile* guest = g_browser_process->profile_manager()->GetProfileByPath(
...@@ -979,19 +892,9 @@ IN_PROC_BROWSER_TEST_P(ProfileMenuClickTest_GuestProfile, SetupAndRunTest) { ...@@ -979,19 +892,9 @@ IN_PROC_BROWSER_TEST_P(ProfileMenuClickTest_GuestProfile, SetupAndRunTest) {
RunTest(); RunTest();
} }
INSTANTIATE_TEST_SUITE_P( // List of actionable items in the correct order as they appear in the menu.
, // If a new button is added to the menu, it should also be added to this list.
ProfileMenuClickTest_GuestProfile, constexpr ProfileMenuView::ActionableItem kActionableItems_IncognitoProfile[] =
::testing::Range(
size_t(0),
base::size(
ProfileMenuClickTest_GuestProfile::kOrderedActionableItems)));
class ProfileMenuClickTest_IncognitoProfile : public ProfileMenuClickTest {
public:
// List of actionable items in the correct order as they appear in the menu.
// If a new button is added to the menu, it should also be added to this list.
static constexpr ProfileMenuView::ActionableItem kOrderedActionableItems[4] =
{ProfileMenuView::ActionableItem::kPasswordsButton, {ProfileMenuView::ActionableItem::kPasswordsButton,
ProfileMenuView::ActionableItem::kCreditCardsButton, ProfileMenuView::ActionableItem::kCreditCardsButton,
ProfileMenuView::ActionableItem::kAddressesButton, ProfileMenuView::ActionableItem::kAddressesButton,
...@@ -999,32 +902,10 @@ class ProfileMenuClickTest_IncognitoProfile : public ProfileMenuClickTest { ...@@ -999,32 +902,10 @@ class ProfileMenuClickTest_IncognitoProfile : public ProfileMenuClickTest {
// there are no other buttons at the end. // there are no other buttons at the end.
ProfileMenuView::ActionableItem::kPasswordsButton}; ProfileMenuView::ActionableItem::kPasswordsButton};
ProfileMenuClickTest_IncognitoProfile() = default;
ProfileMenuView::ActionableItem GetExpectedActionableItemAtIndex(
size_t index) override {
return kOrderedActionableItems[index];
}
DISALLOW_COPY_AND_ASSIGN(ProfileMenuClickTest_IncognitoProfile);
};
// static
constexpr ProfileMenuView::ActionableItem
ProfileMenuClickTest_IncognitoProfile::kOrderedActionableItems[];
// TODO(crbug.com/1012167): Flaky. // TODO(crbug.com/1012167): Flaky.
IN_PROC_BROWSER_TEST_P(ProfileMenuClickTest_IncognitoProfile, PROFILE_MENU_CLICK_TEST(kActionableItems_IncognitoProfile,
DISABLED_SetupAndRunTest) { DISABLED_ProfileMenuClickTest_IncognitoProfile) {
SetTargetBrowser(CreateIncognitoBrowser(browser()->profile())); SetTargetBrowser(CreateIncognitoBrowser(browser()->profile()));
RunTest(); RunTest();
} }
INSTANTIATE_TEST_SUITE_P(
,
ProfileMenuClickTest_IncognitoProfile,
::testing::Range(
size_t(0),
base::size(
ProfileMenuClickTest_IncognitoProfile::kOrderedActionableItems)));
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