Commit 8c4407db authored by Roman Sorokin's avatar Roman Sorokin Committed by Commit Bot

OOBE: Add focus checks for the EndToEnd tests

Also removed GOOGLE_CHROME_BRANDIND guards for the tests to align more
to the real cases.

Bug: 1108996, 1032194
Change-Id: I726c7b826c222b879df1da167ba82b8e5245d684
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2409910
Commit-Queue: Roman Sorokin [CET] <rsorokin@chromium.org>
Reviewed-by: default avatarDenis Kuznetsov [CET] <antrim@chromium.org>
Cr-Commit-Position: refs/heads/master@{#808826}
parent c02f927d
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "chrome/browser/chromeos/login/test/device_state_mixin.h" #include "chrome/browser/chromeos/login/test/device_state_mixin.h"
#include "chrome/browser/chromeos/login/test/embedded_test_server_mixin.h" #include "chrome/browser/chromeos/login/test/embedded_test_server_mixin.h"
#include "chrome/browser/chromeos/login/test/enrollment_ui_mixin.h" #include "chrome/browser/chromeos/login/test/enrollment_ui_mixin.h"
#include "chrome/browser/chromeos/login/test/fake_eula_mixin.h"
#include "chrome/browser/chromeos/login/test/fake_gaia_mixin.h" #include "chrome/browser/chromeos/login/test/fake_gaia_mixin.h"
#include "chrome/browser/chromeos/login/test/js_checker.h" #include "chrome/browser/chromeos/login/test/js_checker.h"
#include "chrome/browser/chromeos/login/test/local_policy_test_server_mixin.h" #include "chrome/browser/chromeos/login/test/local_policy_test_server_mixin.h"
...@@ -103,6 +104,9 @@ void RunWelcomeScreenChecks() { ...@@ -103,6 +104,9 @@ void RunWelcomeScreenChecks() {
test::OobeJS().ExpectHiddenPath({"connect", "languageScreen"}); test::OobeJS().ExpectHiddenPath({"connect", "languageScreen"});
test::OobeJS().ExpectHiddenPath({"connect", "timezoneScreen"}); test::OobeJS().ExpectHiddenPath({"connect", "timezoneScreen"});
test::OobeJS().ExpectFocused(
{"connect", "welcomeScreen", "welcomeNextButton"});
test::OobeJS().ExpectEQ( test::OobeJS().ExpectEQ(
"(() => {let cnt = 0; for (let v of " "(() => {let cnt = 0; for (let v of "
"$('connect').$.welcomeScreen.root.querySelectorAll('video')) " "$('connect').$.welcomeScreen.root.querySelectorAll('video')) "
...@@ -120,21 +124,22 @@ void RunNetworkSelectionScreenChecks() { ...@@ -120,21 +124,22 @@ void RunNetworkSelectionScreenChecks() {
EXPECT_TRUE(ash::LoginScreenTestApi::IsShutdownButtonShown()); EXPECT_TRUE(ash::LoginScreenTestApi::IsShutdownButtonShown());
EXPECT_FALSE(ash::LoginScreenTestApi::IsGuestButtonShown()); EXPECT_FALSE(ash::LoginScreenTestApi::IsGuestButtonShown());
EXPECT_FALSE(ash::LoginScreenTestApi::IsAddUserButtonShown()); EXPECT_FALSE(ash::LoginScreenTestApi::IsAddUserButtonShown());
test::OobeJS().CreateFocusWaiter({"network-selection", "nextButton"})->Wait();
} }
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
void RunEulaScreenChecks() { void RunEulaScreenChecks() {
// Wait for actual EULA to appear. // Wait for actual EULA to appear.
test::OobeJS() test::OobeJS()
.CreateVisibilityWaiter(true, {"oobe-eula-md", "eulaDialog"}) .CreateVisibilityWaiter(true, {"oobe-eula-md", "eulaDialog"})
->Wait(); ->Wait();
test::OobeJS().ExpectEnabledPath({"oobe-eula-md", "acceptButton"}); test::OobeJS().ExpectEnabledPath({"oobe-eula-md", "acceptButton"});
test::OobeJS().CreateFocusWaiter({"oobe-eula-md", "crosEulaFrame"})->Wait();
EXPECT_TRUE(ash::LoginScreenTestApi::IsShutdownButtonShown); EXPECT_TRUE(ash::LoginScreenTestApi::IsShutdownButtonShown);
EXPECT_FALSE(ash::LoginScreenTestApi::IsGuestButtonShown()); EXPECT_FALSE(ash::LoginScreenTestApi::IsGuestButtonShown());
EXPECT_FALSE(ash::LoginScreenTestApi::IsAddUserButtonShown()); EXPECT_FALSE(ash::LoginScreenTestApi::IsAddUserButtonShown());
} }
#endif
void WaitForGaiaSignInScreen(bool arc_available) { void WaitForGaiaSignInScreen(bool arc_available) {
OobeScreenWaiter(GaiaView::kScreenId).Wait(); OobeScreenWaiter(GaiaView::kScreenId).Wait();
...@@ -165,9 +170,31 @@ void LogInAsRegularUser() { ...@@ -165,9 +170,31 @@ void LogInAsRegularUser() {
LOG(INFO) << "OobeInteractiveUITest: Logged in."; LOG(INFO) << "OobeInteractiveUITest: Logged in.";
} }
void RunSyncConsentScreenChecks() {
SyncConsentScreen* screen = static_cast<SyncConsentScreen*>(
WizardController::default_controller()->GetScreen(
SyncConsentScreenView::kScreenId));
screen->SetProfileSyncEngineInitializedForTesting(true);
screen->OnStateChanged(nullptr);
const std::string button_name =
chromeos::features::IsSplitSettingsSyncEnabled()
? "acceptButton"
: "settingsSaveAndContinueButton";
test::OobeJS().ExpectEnabledPath({"sync-consent", button_name});
test::OobeJS().CreateFocusWaiter({"sync-consent", button_name})->Wait();
EXPECT_FALSE(ash::LoginScreenTestApi::IsShutdownButtonShown());
EXPECT_FALSE(ash::LoginScreenTestApi::IsGuestButtonShown());
EXPECT_FALSE(ash::LoginScreenTestApi::IsAddUserButtonShown());
}
void RunFingerprintScreenChecks() { void RunFingerprintScreenChecks() {
test::OobeJS().ExpectVisible("fingerprint-setup"); test::OobeJS().ExpectVisible("fingerprint-setup");
test::OobeJS().ExpectVisiblePath({"fingerprint-setup", "setupFingerprint"}); test::OobeJS().ExpectVisiblePath({"fingerprint-setup", "setupFingerprint"});
test::OobeJS().CreateFocusWaiter({"fingerprint-setup", "next"})->Wait();
test::OobeJS().TapOnPath({"fingerprint-setup", "next"}); test::OobeJS().TapOnPath({"fingerprint-setup", "next"});
test::OobeJS().ExpectHiddenPath({"fingerprint-setup", "setupFingerprint"}); test::OobeJS().ExpectHiddenPath({"fingerprint-setup", "setupFingerprint"});
LOG(INFO) << "OobeInteractiveUITest: Waiting for fingerprint setup " LOG(INFO) << "OobeInteractiveUITest: Waiting for fingerprint setup "
...@@ -187,6 +214,9 @@ void RunDiscoverScreenChecks() { ...@@ -187,6 +214,9 @@ void RunDiscoverScreenChecks() {
test::OobeJS().ExpectVisiblePath({"discover-impl", "pin-setup-impl"}); test::OobeJS().ExpectVisiblePath({"discover-impl", "pin-setup-impl"});
test::OobeJS().ExpectVisiblePath( test::OobeJS().ExpectVisiblePath(
{"discover-impl", "pin-setup-impl", "setup"}); {"discover-impl", "pin-setup-impl", "setup"});
test::OobeJS()
.CreateFocusWaiter({"discover-impl", "pin-setup-impl", "pinKeyboard"})
->Wait();
EXPECT_FALSE(ash::LoginScreenTestApi::IsShutdownButtonShown()); EXPECT_FALSE(ash::LoginScreenTestApi::IsShutdownButtonShown());
EXPECT_FALSE(ash::LoginScreenTestApi::IsGuestButtonShown()); EXPECT_FALSE(ash::LoginScreenTestApi::IsGuestButtonShown());
...@@ -375,6 +405,9 @@ void HandleMarketingOptInScreen() { ...@@ -375,6 +405,9 @@ void HandleMarketingOptInScreen() {
.CreateVisibilityWaiter( .CreateVisibilityWaiter(
true, {"marketing-opt-in", "marketing-opt-in-next-button"}) true, {"marketing-opt-in", "marketing-opt-in-next-button"})
->Wait(); ->Wait();
test::OobeJS()
.CreateFocusWaiter({"marketing-opt-in", "marketing-opt-in-next-button"})
->Wait();
test::OobeJS().TapOnPath( test::OobeJS().TapOnPath(
{"marketing-opt-in", "marketing-opt-in-next-button"}); {"marketing-opt-in", "marketing-opt-in-next-button"});
...@@ -632,10 +665,15 @@ class OobeInteractiveUITest : public OobeBaseTest, ...@@ -632,10 +665,15 @@ class OobeInteractiveUITest : public OobeBaseTest,
public ::testing::WithParamInterface< public ::testing::WithParamInterface<
std::tuple<bool, bool, bool, ArcState>> { std::tuple<bool, bool, bool, ArcState>> {
public: public:
OobeInteractiveUITest() = default; OobeInteractiveUITest() {
// TODO(https://crbug.com/1130502): Merge these functions into one.
branded_build_override_ = WizardController::ForceBrandedBuildForTesting();
sync_branded_build_override_ =
SyncConsentScreen::ForceBrandedBuildForTesting(true);
}
~OobeInteractiveUITest() override = default; ~OobeInteractiveUITest() override = default;
// OobeInteractiveUITest: // OobeBaseTest:
void TearDownOnMainThread() override { void TearDownOnMainThread() override {
// If the login display is still showing, exit gracefully. // If the login display is still showing, exit gracefully.
if (LoginDisplayHost::default_host()) { if (LoginDisplayHost::default_host()) {
...@@ -668,7 +706,10 @@ class OobeInteractiveUITest : public OobeBaseTest, ...@@ -668,7 +706,10 @@ class OobeInteractiveUITest : public OobeBaseTest,
const OobeEndToEndTestSetupMixin* test_setup() const { return &setup_; } const OobeEndToEndTestSetupMixin* test_setup() const { return &setup_; }
private: private:
std::unique_ptr<base::AutoReset<bool>> branded_build_override_;
std::unique_ptr<base::AutoReset<bool>> sync_branded_build_override_;
FakeGaiaMixin fake_gaia_{&mixin_host_, embedded_test_server()}; FakeGaiaMixin fake_gaia_{&mixin_host_, embedded_test_server()};
FakeEulaMixin fake_eula_{&mixin_host_, embedded_test_server()};
net::EmbeddedTestServer arc_tos_server_{net::EmbeddedTestServer::TYPE_HTTPS}; net::EmbeddedTestServer arc_tos_server_{net::EmbeddedTestServer::TYPE_HTTPS};
EmbeddedTestServerSetupMixin arc_tos_server_setup_{&mixin_host_, EmbeddedTestServerSetupMixin arc_tos_server_setup_{&mixin_host_,
...@@ -686,11 +727,9 @@ void OobeInteractiveUITest::PerformStepsBeforeEnrollmentCheck() { ...@@ -686,11 +727,9 @@ void OobeInteractiveUITest::PerformStepsBeforeEnrollmentCheck() {
RunNetworkSelectionScreenChecks(); RunNetworkSelectionScreenChecks();
test::TapNetworkSelectionNext(); test::TapNetworkSelectionNext();
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
test::WaitForEulaScreen(); test::WaitForEulaScreen();
RunEulaScreenChecks(); RunEulaScreenChecks();
test::TapEulaAccept(); test::TapEulaAccept();
#endif
test::WaitForUpdateScreen(); test::WaitForUpdateScreen();
test::ExitUpdateScreenNoUpdate(); test::ExitUpdateScreenNoUpdate();
...@@ -706,10 +745,9 @@ void OobeInteractiveUITest::PerformSessionSignInSteps( ...@@ -706,10 +745,9 @@ void OobeInteractiveUITest::PerformSessionSignInSteps(
WaitForGaiaSignInScreen(test_setup()->arc_state() != ArcState::kNotAvailable); WaitForGaiaSignInScreen(test_setup()->arc_state() != ArcState::kNotAvailable);
LogInAsRegularUser(); LogInAsRegularUser();
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
test::WaitForSyncConsentScreen(); test::WaitForSyncConsentScreen();
RunSyncConsentScreenChecks();
test::ExitScreenSyncConsent(); test::ExitScreenSyncConsent();
#endif
if (test_setup()->is_quick_unlock_enabled()) { if (test_setup()->is_quick_unlock_enabled()) {
test::WaitForFingerprintScreen(); test::WaitForFingerprintScreen();
...@@ -1044,10 +1082,9 @@ IN_PROC_BROWSER_TEST_P(EphemeralUserOobeTest, DISABLED_RegularEphemeralUser) { ...@@ -1044,10 +1082,9 @@ IN_PROC_BROWSER_TEST_P(EphemeralUserOobeTest, DISABLED_RegularEphemeralUser) {
WaitForGaiaSignInScreen(test_setup()->arc_state() != ArcState::kNotAvailable); WaitForGaiaSignInScreen(test_setup()->arc_state() != ArcState::kNotAvailable);
LogInAsRegularUser(); LogInAsRegularUser();
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
test::WaitForSyncConsentScreen(); test::WaitForSyncConsentScreen();
RunSyncConsentScreenChecks();
test::ExitScreenSyncConsent(); test::ExitScreenSyncConsent();
#endif
if (test_setup()->is_quick_unlock_enabled()) { if (test_setup()->is_quick_unlock_enabled()) {
test::WaitForFingerprintScreen(); test::WaitForFingerprintScreen();
......
...@@ -278,6 +278,11 @@ SyncConsentScreen::ForceBrandedBuildForTesting(bool value) { ...@@ -278,6 +278,11 @@ SyncConsentScreen::ForceBrandedBuildForTesting(bool value) {
return std::make_unique<base::AutoReset<bool>>(&g_is_branded_build, value); return std::make_unique<base::AutoReset<bool>>(&g_is_branded_build, value);
} }
// static
bool SyncConsentScreen::IsBrandedBuildForTesting() {
return g_is_branded_build;
}
void SyncConsentScreen::SetDelegateForTesting( void SyncConsentScreen::SetDelegateForTesting(
SyncConsentScreen::SyncConsentScreenTestDelegate* delegate) { SyncConsentScreen::SyncConsentScreenTestDelegate* delegate) {
test_delegate_ = delegate; test_delegate_ = delegate;
......
...@@ -107,6 +107,8 @@ class SyncConsentScreen : public BaseScreen, ...@@ -107,6 +107,8 @@ class SyncConsentScreen : public BaseScreen,
static std::unique_ptr<base::AutoReset<bool>> ForceBrandedBuildForTesting( static std::unique_ptr<base::AutoReset<bool>> ForceBrandedBuildForTesting(
bool value); bool value);
static bool IsBrandedBuildForTesting();
// Sets internal condition "Sync disabled by policy" for tests. // Sets internal condition "Sync disabled by policy" for tests.
void SetProfileSyncDisabledByPolicyForTesting(bool value); void SetProfileSyncDisabledByPolicyForTesting(bool value);
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
#include "chrome/browser/chromeos/login/test/oobe_screens_utils.h" #include "chrome/browser/chromeos/login/test/oobe_screens_utils.h"
#include "build/branding_buildflags.h"
#include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/chromeos/login/oobe_screen.h" #include "chrome/browser/chromeos/login/oobe_screen.h"
#include "chrome/browser/chromeos/login/screens/sync_consent_screen.h" #include "chrome/browser/chromeos/login/screens/sync_consent_screen.h"
...@@ -151,25 +150,26 @@ void WaitForLastScreenAndTapGetStarted() { ...@@ -151,25 +150,26 @@ void WaitForLastScreenAndTapGetStarted() {
} }
void WaitForEulaScreen() { void WaitForEulaScreen() {
#if BUILDFLAG(GOOGLE_CHROME_BRANDING) if (!WizardController::IsBrandedBuildForTesting())
return;
WaitFor(EulaView::kScreenId); WaitFor(EulaView::kScreenId);
#endif
} }
void TapEulaAccept() { void TapEulaAccept() {
#if BUILDFLAG(GOOGLE_CHROME_BRANDING) if (!WizardController::IsBrandedBuildForTesting())
return;
test::OobeJS().TapOnPath({"oobe-eula-md", "acceptButton"}); test::OobeJS().TapOnPath({"oobe-eula-md", "acceptButton"});
#endif
} }
void WaitForSyncConsentScreen() { void WaitForSyncConsentScreen() {
#if BUILDFLAG(GOOGLE_CHROME_BRANDING) if (!SyncConsentScreen::IsBrandedBuildForTesting())
return;
WaitFor(SyncConsentScreenView::kScreenId); WaitFor(SyncConsentScreenView::kScreenId);
#endif
} }
void ExitScreenSyncConsent() { void ExitScreenSyncConsent() {
#if BUILDFLAG(GOOGLE_CHROME_BRANDING) if (!SyncConsentScreen::IsBrandedBuildForTesting())
return;
SyncConsentScreen* screen = static_cast<SyncConsentScreen*>( SyncConsentScreen* screen = static_cast<SyncConsentScreen*>(
WizardController::default_controller()->GetScreen( WizardController::default_controller()->GetScreen(
SyncConsentScreenView::kScreenId)); SyncConsentScreenView::kScreenId));
...@@ -177,7 +177,6 @@ void ExitScreenSyncConsent() { ...@@ -177,7 +177,6 @@ void ExitScreenSyncConsent() {
screen->SetProfileSyncDisabledByPolicyForTesting(true); screen->SetProfileSyncDisabledByPolicyForTesting(true);
screen->OnStateChanged(nullptr); screen->OnStateChanged(nullptr);
WaitForExit(SyncConsentScreenView::kScreenId); WaitForExit(SyncConsentScreenView::kScreenId);
#endif
} }
LanguageReloadObserver::LanguageReloadObserver(WelcomeScreen* welcome_screen) LanguageReloadObserver::LanguageReloadObserver(WelcomeScreen* welcome_screen)
......
...@@ -104,6 +104,8 @@ class WizardController { ...@@ -104,6 +104,8 @@ class WizardController {
// Zero-Touch Hands-Off Enrollment Flow. // Zero-Touch Hands-Off Enrollment Flow.
static bool UsingHandsOffEnrollment(); static bool UsingHandsOffEnrollment();
static bool IsBrandedBuildForTesting() { return is_branded_build_; }
bool is_initialized() { return is_initialized_; } bool is_initialized() { return is_initialized_; }
// Shows the first screen defined by |first_screen| or by default if the // Shows the first screen defined by |first_screen| or by default if the
......
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