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,85 +737,66 @@ class ProfileMenuClickTest : public SyncTest, ...@@ -737,85 +737,66 @@ 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::kPasswordsButton, ProfileMenuView::ActionableItem GetExpectedActionableItemAtIndex( \
ProfileMenuView::ActionableItem::kCreditCardsButton, size_t index) override { \
ProfileMenuView::ActionableItem::kAddressesButton, return actionable_item_list[index]; \
ProfileMenuView::ActionableItem::kSigninButton, } \
ProfileMenuView::ActionableItem::kManageProfilesButton, \
ProfileMenuView::ActionableItem::kOtherProfileButton, DISALLOW_COPY_AND_ASSIGN(test_case_name); \
ProfileMenuView::ActionableItem::kOtherProfileButton, }; \
ProfileMenuView::ActionableItem::kGuestProfileButton, \
ProfileMenuView::ActionableItem::kAddNewProfileButton, INSTANTIATE_TEST_SUITE_P( \
// The first button is added again to finish the cycle and test that , test_case_name, \
// there are no other buttons at the end. ::testing::Range(size_t(0), base::size(actionable_item_list))); \
ProfileMenuView::ActionableItem::kPasswordsButton}; \
IN_PROC_BROWSER_TEST_P(test_case_name, test_case_name)
ProfileMenuClickTest_MultipleProfiles() = default;
// List of actionable items in the correct order as they appear in the menu.
ProfileMenuView::ActionableItem GetExpectedActionableItemAtIndex( // If a new button is added to the menu, it should also be added to this list.
size_t index) override { constexpr ProfileMenuView::ActionableItem kActionableItems_MultipleProfiles[] =
return kOrderedActionableItems[index]; {ProfileMenuView::ActionableItem::kPasswordsButton,
} ProfileMenuView::ActionableItem::kCreditCardsButton,
ProfileMenuView::ActionableItem::kAddressesButton,
DISALLOW_COPY_AND_ASSIGN(ProfileMenuClickTest_MultipleProfiles); ProfileMenuView::ActionableItem::kSigninButton,
}; ProfileMenuView::ActionableItem::kManageProfilesButton,
ProfileMenuView::ActionableItem::kOtherProfileButton,
// static ProfileMenuView::ActionableItem::kOtherProfileButton,
constexpr ProfileMenuView::ActionableItem ProfileMenuView::ActionableItem::kGuestProfileButton,
ProfileMenuClickTest_MultipleProfiles::kOrderedActionableItems[]; ProfileMenuView::ActionableItem::kAddNewProfileButton,
// The first button is added again to finish the cycle and test that
IN_PROC_BROWSER_TEST_P(ProfileMenuClickTest_MultipleProfiles, SetupAndRunTest) { // there are no other buttons at the end.
ProfileMenuView::ActionableItem::kPasswordsButton};
PROFILE_MENU_CLICK_TEST(kActionableItems_MultipleProfiles,
ProfileMenuClickTest_MultipleProfiles) {
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), ProfileMenuView::ActionableItem::kCreditCardsButton,
base::size( ProfileMenuView::ActionableItem::kAddressesButton,
ProfileMenuClickTest_MultipleProfiles::kOrderedActionableItems))); ProfileMenuView::ActionableItem::kSyncSettingsButton,
ProfileMenuView::ActionableItem::kManageGoogleAccountButton,
class ProfileMenuClickTest_SyncEnabled : public ProfileMenuClickTest { ProfileMenuView::ActionableItem::kManageProfilesButton,
public: ProfileMenuView::ActionableItem::kGuestProfileButton,
// List of actionable items in the correct order as they appear in the menu. ProfileMenuView::ActionableItem::kAddNewProfileButton,
// If a new button is added to the menu, it should also be added to this list. // The first button is added again to finish the cycle and test that
static constexpr ProfileMenuView::ActionableItem kOrderedActionableItems[9] = // there are no other buttons at the end.
{ProfileMenuView::ActionableItem::kPasswordsButton, ProfileMenuView::ActionableItem::kPasswordsButton};
ProfileMenuView::ActionableItem::kCreditCardsButton,
ProfileMenuView::ActionableItem::kAddressesButton, PROFILE_MENU_CLICK_TEST(kActionableItems_SyncEnabled,
ProfileMenuView::ActionableItem::kSyncSettingsButton, ProfileMenuClickTest_SyncEnabled) {
ProfileMenuView::ActionableItem::kManageGoogleAccountButton,
ProfileMenuView::ActionableItem::kManageProfilesButton,
ProfileMenuView::ActionableItem::kGuestProfileButton,
ProfileMenuView::ActionableItem::kAddNewProfileButton,
// The first button is added again to finish the cycle and test that
// there are no other buttons at the end.
ProfileMenuView::ActionableItem::kPasswordsButton};
ProfileMenuClickTest_SyncEnabled() = default;
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,45 +805,23 @@ IN_PROC_BROWSER_TEST_P(ProfileMenuClickTest_SyncEnabled, SetupAndRunTest) { ...@@ -824,45 +805,23 @@ 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), ProfileMenuView::ActionableItem::kCreditCardsButton,
base::size(ProfileMenuClickTest_SyncEnabled::kOrderedActionableItems))); ProfileMenuView::ActionableItem::kAddressesButton,
ProfileMenuView::ActionableItem::kSyncErrorButton,
class ProfileMenuClickTest_SyncError : public ProfileMenuClickTest { ProfileMenuView::ActionableItem::kManageGoogleAccountButton,
public: ProfileMenuView::ActionableItem::kManageProfilesButton,
// List of actionable items in the correct order as they appear in the menu. ProfileMenuView::ActionableItem::kGuestProfileButton,
// If a new button is added to the menu, it should also be added to this list. ProfileMenuView::ActionableItem::kAddNewProfileButton,
static constexpr ProfileMenuView::ActionableItem kOrderedActionableItems[9] = // The first button is added again to finish the cycle and test that
{ProfileMenuView::ActionableItem::kPasswordsButton, // there are no other buttons at the end.
ProfileMenuView::ActionableItem::kCreditCardsButton, ProfileMenuView::ActionableItem::kPasswordsButton};
ProfileMenuView::ActionableItem::kAddressesButton,
ProfileMenuView::ActionableItem::kSyncErrorButton, PROFILE_MENU_CLICK_TEST(kActionableItems_SyncError,
ProfileMenuView::ActionableItem::kManageGoogleAccountButton, ProfileMenuClickTest_SyncError) {
ProfileMenuView::ActionableItem::kManageProfilesButton,
ProfileMenuView::ActionableItem::kGuestProfileButton,
ProfileMenuView::ActionableItem::kAddNewProfileButton,
// The first button is added again to finish the cycle and test that
// there are no other buttons at the end.
ProfileMenuView::ActionableItem::kPasswordsButton};
ProfileMenuClickTest_SyncError() = default;
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,50 +830,27 @@ IN_PROC_BROWSER_TEST_P(ProfileMenuClickTest_SyncError, SetupAndRunTest) { ...@@ -871,50 +830,27 @@ 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,
::testing::Range(
size_t(0),
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::kAddressesButton,
ProfileMenuView::ActionableItem::kSigninAccountButton,
ProfileMenuView::ActionableItem::kManageGoogleAccountButton,
ProfileMenuView::ActionableItem::kSignoutButton,
ProfileMenuView::ActionableItem::kManageProfilesButton,
ProfileMenuView::ActionableItem::kGuestProfileButton,
ProfileMenuView::ActionableItem::kAddNewProfileButton,
// The first button is added again to finish the cycle and test that
// there are no other buttons at the end.
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 constexpr ProfileMenuView::ActionableItem
ProfileMenuClickTest_WithUnconsentedPrimaryAccount::kOrderedActionableItems kActionableItems_WithUnconsentedPrimaryAccount[] = {
[]; ProfileMenuView::ActionableItem::kPasswordsButton,
ProfileMenuView::ActionableItem::kCreditCardsButton,
ProfileMenuView::ActionableItem::kAddressesButton,
ProfileMenuView::ActionableItem::kSigninAccountButton,
ProfileMenuView::ActionableItem::kManageGoogleAccountButton,
ProfileMenuView::ActionableItem::kSignoutButton,
ProfileMenuView::ActionableItem::kManageProfilesButton,
ProfileMenuView::ActionableItem::kGuestProfileButton,
ProfileMenuView::ActionableItem::kAddNewProfileButton,
// The first button is added again to finish the cycle and test that
// there are no other buttons at the end.
ProfileMenuView::ActionableItem::kPasswordsButton};
// 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), ProfileMenuView::ActionableItem::kOtherProfileButton,
base::size(ProfileMenuClickTest_WithUnconsentedPrimaryAccount:: ProfileMenuView::ActionableItem::kAddNewProfileButton,
kOrderedActionableItems))); // The first button is added again to finish the cycle and test that
// there are no other buttons at the end.
class ProfileMenuClickTest_GuestProfile : public ProfileMenuClickTest { ProfileMenuView::ActionableItem::kManageProfilesButton};
public:
// List of actionable items in the correct order as they appear in the menu. PROFILE_MENU_CLICK_TEST(kActionableItems_GuestProfile,
// If a new button is added to the menu, it should also be added to this list. ProfileMenuClickTest_GuestProfile) {
static constexpr ProfileMenuView::ActionableItem kOrderedActionableItems[4] =
{ProfileMenuView::ActionableItem::kManageProfilesButton,
ProfileMenuView::ActionableItem::kOtherProfileButton,
ProfileMenuView::ActionableItem::kAddNewProfileButton,
// The first button is added again to finish the cycle and test that
// there are no other buttons at the end.
ProfileMenuView::ActionableItem::kManageProfilesButton};
ProfileMenuClickTest_GuestProfile() = default;
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,52 +892,20 @@ IN_PROC_BROWSER_TEST_P(ProfileMenuClickTest_GuestProfile, SetupAndRunTest) { ...@@ -979,52 +892,20 @@ 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( {ProfileMenuView::ActionableItem::kPasswordsButton,
size_t(0), ProfileMenuView::ActionableItem::kCreditCardsButton,
base::size( ProfileMenuView::ActionableItem::kAddressesButton,
ProfileMenuClickTest_GuestProfile::kOrderedActionableItems))); // The first button is added again to finish the cycle and test that
// there are no other buttons at the end.
class ProfileMenuClickTest_IncognitoProfile : public ProfileMenuClickTest { ProfileMenuView::ActionableItem::kPasswordsButton};
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::kCreditCardsButton,
ProfileMenuView::ActionableItem::kAddressesButton,
// The first button is added again to finish the cycle and test that
// there are no other buttons at the end.
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