Commit 5d8a985d authored by Ramin Halavati's avatar Ramin Halavati Committed by Commit Bot

Update Profile menu click test to cover Ephemeral Guest profiles.

Profile menu click tests are updated to cover ephemeral Guest profiles.

Please see go/ephemeral-guest-profiles for more context.

Bug: 1125474
Change-Id: I777f465213b21ebc9187e6ed308d4198bc5d4fe7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2485053
Commit-Queue: Ramin Halavati <rhalavati@chromium.org>
Reviewed-by: default avatarPeter Boström <pbos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#819309}
parent af2d77b5
......@@ -45,6 +45,7 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/test/base/testing_profile.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/autofill/core/common/autofill_payments_features.h"
#include "components/prefs/pref_service.h"
......@@ -794,6 +795,22 @@ PROFILE_MENU_CLICK_TEST(
RunTest();
}
// 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 ProfileMenuViewBase::ActionableItem
kActionableItems_IncognitoProfile[] = {
ProfileMenuViewBase::ActionableItem::kExitProfileButton,
// The first button is added again to finish the cycle and test that
// there are no other buttons at the end.
ProfileMenuViewBase::ActionableItem::kExitProfileButton};
PROFILE_MENU_CLICK_TEST(kActionableItems_IncognitoProfile,
ProfileMenuClickTest_IncognitoProfile) {
SetTargetBrowser(CreateIncognitoBrowser(browser()->profile()));
RunTest();
}
// 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 ProfileMenuViewBase::ActionableItem kActionableItems_GuestProfile[] =
......@@ -803,37 +820,96 @@ constexpr ProfileMenuViewBase::ActionableItem kActionableItems_GuestProfile[] =
ProfileMenuViewBase::ActionableItem::kAddNewProfileButton,
// The first button is added again to finish the cycle and test that
// there are no other buttons at the end.
// Note that the test does not rely on the specific order of running test
// instances, but considers the relative order of the actionable items in
// this array. So for the last item, it does N+1 steps through the menu (N
// being the number of items in the menu) and checks if the last item in
// this array triggers the same action as the first one.
ProfileMenuViewBase::ActionableItem::kExitProfileButton};
PROFILE_MENU_CLICK_TEST(kActionableItems_GuestProfile,
ProfileMenuClickTest_GuestProfile) {
profiles::SwitchToGuestProfile(ProfileManager::CreateCallback());
ui_test_utils::WaitForBrowserToOpen();
Profile* guest = g_browser_process->profile_manager()->GetProfileByPath(
ProfileManager::GetGuestProfilePath());
ASSERT_TRUE(guest);
// TODO(https://crbug.com/1125474): Revert to using PROFILE_MENU_CLICK_TEST when
// non-ephemeral Guest profiles are removed.
class GuestProfileMenuClickTest : public ProfileMenuClickTest {
public:
GuestProfileMenuClickTest() {
TestingProfile::SetScopedFeatureListForEphemeralGuestProfiles(
scoped_feature_list_, false);
}
ProfileMenuViewBase::ActionableItem GetExpectedActionableItemAtIndex(
size_t index) override {
return kActionableItems_GuestProfile[index];
}
private:
base::test::ScopedFeatureList scoped_feature_list_;
DISALLOW_COPY_AND_ASSIGN(GuestProfileMenuClickTest);
};
IN_PROC_BROWSER_TEST_P(GuestProfileMenuClickTest,
ProfileMenuClickTest_GuestProfile) {
Browser* browser = CreateGuestBrowser();
ASSERT_TRUE(browser);
// Open a second guest browser window, so the ExitProfileButton is shown.
SetTargetBrowser(CreateIncognitoBrowser(guest));
SetTargetBrowser(CreateGuestBrowser());
RunTest();
}
INSTANTIATE_TEST_SUITE_P(
All,
GuestProfileMenuClickTest,
::testing::Range(size_t(0), base::size(kActionableItems_GuestProfile)));
// TODO(https://crbug.com/1125474): Remove OS_CHROMEOS and enable for Lacros
// when supported.
#if defined(OS_WIN) || defined(OS_MAC) || \
(defined(OS_LINUX) && !defined(OS_CHROMEOS))
// 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 ProfileMenuViewBase::ActionableItem
kActionableItems_IncognitoProfile[] = {
ProfileMenuViewBase::ActionableItem::kExitProfileButton,
// The first button is added again to finish the cycle and test that
// there are no other buttons at the end.
kActionableItems_EphemeralGuestProfile[] = {
ProfileMenuViewBase::ActionableItem::kExitProfileButton};
PROFILE_MENU_CLICK_TEST(kActionableItems_IncognitoProfile,
ProfileMenuClickTest_IncognitoProfile) {
SetTargetBrowser(CreateIncognitoBrowser(browser()->profile()));
class EphemeralGuestProfileMenuClickTest : public ProfileMenuClickTest {
public:
EphemeralGuestProfileMenuClickTest() {
EXPECT_TRUE(TestingProfile::SetScopedFeatureListForEphemeralGuestProfiles(
scoped_feature_list_, true));
}
ProfileMenuViewBase::ActionableItem GetExpectedActionableItemAtIndex(
size_t index) override {
return kActionableItems_EphemeralGuestProfile[index];
}
private:
base::test::ScopedFeatureList scoped_feature_list_;
DISALLOW_COPY_AND_ASSIGN(EphemeralGuestProfileMenuClickTest);
};
IN_PROC_BROWSER_TEST_P(EphemeralGuestProfileMenuClickTest,
ProfileMenuClickTest_GuestProfile) {
Browser* browser = CreateGuestBrowser();
ASSERT_TRUE(browser);
// Open a second guest browser window, so the ExitProfileButton is shown.
SetTargetBrowser(CreateGuestBrowser());
RunTest();
}
INSTANTIATE_TEST_SUITE_P(
All,
EphemeralGuestProfileMenuClickTest,
::testing::Range(size_t(0),
base::size(kActionableItems_EphemeralGuestProfile)));
#endif // defined(OS_WIN) || defined(OS_MAC) || (defined(OS_LINUX) &&
// !defined(OS_CHROMEOS))
class ProfileMenuClickKeyAcceleratorTest : public ProfileMenuClickTestBase {
public:
ProfileMenuClickKeyAcceleratorTest() = default;
......
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