Commit 76d2b41e authored by Jacob Dufault's avatar Jacob Dufault Committed by Commit Bot

cros: Force tests to use webui login.

These tests fail in views-based login since OobeBaseTest has some hard
dependencies on webui login. Refactoring OobeBaseTest will likely take
some time.

Change-Id: Ic7cac68c1e9e0d6630deacfbfdad36a3651f5e6b
BUG: 784495
Reviewed-on: https://chromium-review.googlesource.com/957967Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarAchuith Bhandarkar <achuith@chromium.org>
Commit-Queue: Jacob Dufault <jdufault@chromium.org>
Cr-Commit-Position: refs/heads/master@{#544829}
parent 4320c836
...@@ -183,6 +183,9 @@ This file contains the strings for ash. ...@@ -183,6 +183,9 @@ This file contains the strings for ash.
<message name="IDS_ASH_ADD_USER_BUTTON" desc="Text shown on an add user button on login/locker screen"> <message name="IDS_ASH_ADD_USER_BUTTON" desc="Text shown on an add user button on login/locker screen">
Add Person Add Person
</message> </message>
<message name="IDS_ASH_SHOW_WEBUI_LOGIN_BUTTON" desc="Button on login/lock screen which reverts to the previous implementation.">
(TEMP) Show webui login; if used file bug (crbug.com) or feedback (alt+shift+i)
</message>
<message name="IDS_ASH_KEYBOARD_OVERLAY_TITLE" desc="The title of the keyboard overlay."> <message name="IDS_ASH_KEYBOARD_OVERLAY_TITLE" desc="The title of the keyboard overlay.">
Keyboard overlay Keyboard overlay
......
...@@ -96,6 +96,9 @@ void LoginScreenController::ShowLoginScreen(ShowLoginScreenCallback on_shown) { ...@@ -96,6 +96,9 @@ void LoginScreenController::ShowLoginScreen(ShowLoginScreenCallback on_shown) {
// Login screen can only be used during login. // Login screen can only be used during login.
if (Shell::Get()->session_controller()->GetSessionState() != if (Shell::Get()->session_controller()->GetSessionState() !=
session_manager::SessionState::LOGIN_PRIMARY) { session_manager::SessionState::LOGIN_PRIMARY) {
LOG(ERROR) << "Not showing login screen since session state is "
<< static_cast<int>(
Shell::Get()->session_controller()->GetSessionState());
std::move(on_shown).Run(false); std::move(on_shown).Run(false);
return; return;
} }
......
...@@ -122,14 +122,16 @@ const char kHasInternalStylus[] = "has-internal-stylus"; ...@@ -122,14 +122,16 @@ const char kHasInternalStylus[] = "has-internal-stylus";
// option "Show taps". // option "Show taps".
const char kShowTaps[] = "show-taps"; const char kShowTaps[] = "show-taps";
// If true, the views login screen will be shown. This will become the default // Forces the views login implementation.
// in the future.
const char kShowViewsLogin[] = "show-views-login"; const char kShowViewsLogin[] = "show-views-login";
// If true, the webui lock screen wil be shown. This is deprecated and will be // If true, the webui lock screen wil be shown. This is deprecated and will be
// removed in the future. // removed in the future.
const char kShowWebUiLock[] = "show-webui-lock"; const char kShowWebUiLock[] = "show-webui-lock";
// Forces the webui login implementation.
const char kShowWebUiLogin[] = "show-webui-login";
// Chromebases' touchscreens can be used to wake from suspend, unlike the // Chromebases' touchscreens can be used to wake from suspend, unlike the
// touchscreens on other Chrome OS devices. If set, the touchscreen is kept // touchscreens on other Chrome OS devices. If set, the touchscreen is kept
// enabled while the screen is off so that it can be used to turn the screen // enabled while the screen is off so that it can be used to turn the screen
...@@ -156,7 +158,10 @@ bool IsSidebarEnabled() { ...@@ -156,7 +158,10 @@ bool IsSidebarEnabled() {
} }
bool IsUsingViewsLogin() { bool IsUsingViewsLogin() {
return base::CommandLine::ForCurrentProcess()->HasSwitch(kShowViewsLogin); // Only show views login if it is forced. If both switches are present use
// webui.
base::CommandLine* cl = base::CommandLine::ForCurrentProcess();
return !cl->HasSwitch(kShowWebUiLogin) && cl->HasSwitch(kShowViewsLogin);
} }
bool IsUsingViewsLock() { bool IsUsingViewsLock() {
......
...@@ -57,6 +57,7 @@ ASH_PUBLIC_EXPORT extern const char kHasInternalStylus[]; ...@@ -57,6 +57,7 @@ ASH_PUBLIC_EXPORT extern const char kHasInternalStylus[];
ASH_PUBLIC_EXPORT extern const char kShowTaps[]; ASH_PUBLIC_EXPORT extern const char kShowTaps[];
ASH_PUBLIC_EXPORT extern const char kShowViewsLogin[]; ASH_PUBLIC_EXPORT extern const char kShowViewsLogin[];
ASH_PUBLIC_EXPORT extern const char kShowWebUiLock[]; ASH_PUBLIC_EXPORT extern const char kShowWebUiLock[];
ASH_PUBLIC_EXPORT extern const char kShowWebUiLogin[];
ASH_PUBLIC_EXPORT extern const char kSuppressMessageCenterPopups[]; ASH_PUBLIC_EXPORT extern const char kSuppressMessageCenterPopups[];
ASH_PUBLIC_EXPORT extern const char kTouchscreenUsableWhileScreenOff[]; ASH_PUBLIC_EXPORT extern const char kTouchscreenUsableWhileScreenOff[];
ASH_PUBLIC_EXPORT extern const char kUseIMEService[]; ASH_PUBLIC_EXPORT extern const char kUseIMEService[];
......
...@@ -156,6 +156,8 @@ LoginShelfView::LoginShelfView( ...@@ -156,6 +156,8 @@ LoginShelfView::LoginShelfView(
add_button(kBrowseAsGuest, IDS_ASH_BROWSE_AS_GUEST_BUTTON, add_button(kBrowseAsGuest, IDS_ASH_BROWSE_AS_GUEST_BUTTON,
kShelfBrowseAsGuestButtonIcon); kShelfBrowseAsGuestButtonIcon);
add_button(kAddUser, IDS_ASH_ADD_USER_BUTTON, kShelfAddPersonButtonIcon); add_button(kAddUser, IDS_ASH_ADD_USER_BUTTON, kShelfAddPersonButtonIcon);
add_button(kShowWebUiLogin, IDS_ASH_SHOW_WEBUI_LOGIN_BUTTON,
kShelfSignOutButtonIcon);
// Adds observers for states that affect the visiblity of different buttons. // Adds observers for states that affect the visiblity of different buttons.
tray_action_observer_.Add(Shell::Get()->tray_action()); tray_action_observer_.Add(Shell::Get()->tray_action());
...@@ -215,6 +217,9 @@ void LoginShelfView::GetAccessibleNodeData(ui::AXNodeData* node_data) { ...@@ -215,6 +217,9 @@ void LoginShelfView::GetAccessibleNodeData(ui::AXNodeData* node_data) {
void LoginShelfView::ButtonPressed(views::Button* sender, void LoginShelfView::ButtonPressed(views::Button* sender,
const ui::Event& event) { const ui::Event& event) {
// Intentional crash. session_manager will add --show-webui-login.
CHECK(sender->id() != kShowWebUiLogin);
UserMetricsRecorder::RecordUserClickOnShelfButton( UserMetricsRecorder::RecordUserClickOnShelfButton(
GetUserClickTarget(sender->id())); GetUserClickTarget(sender->id()));
switch (sender->id()) { switch (sender->id()) {
......
...@@ -43,6 +43,7 @@ class ASH_EXPORT LoginShelfView : public views::View, ...@@ -43,6 +43,7 @@ class ASH_EXPORT LoginShelfView : public views::View,
kCancel, // Cancel multiple user sign-in. kCancel, // Cancel multiple user sign-in.
kBrowseAsGuest, // Use in guest mode. kBrowseAsGuest, // Use in guest mode.
kAddUser, // Add a new user. kAddUser, // Add a new user.
kShowWebUiLogin // Show webui login.
}; };
explicit LoginShelfView( explicit LoginShelfView(
......
...@@ -459,7 +459,9 @@ class ShelfWidgetViewsVisibilityTest : public AshTestBase { ...@@ -459,7 +459,9 @@ class ShelfWidgetViewsVisibilityTest : public AshTestBase {
}; };
TEST_F(ShelfWidgetViewsVisibilityTest, LoginWebUiLockViews) { TEST_F(ShelfWidgetViewsVisibilityTest, LoginWebUiLockViews) {
// Web UI login enabled by default. Views lock enabled by default. // Enable web UI login.
base::CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kShowWebUiLogin);
ASSERT_NO_FATAL_FAILURE(InitShelfVariables()); ASSERT_NO_FATAL_FAILURE(InitShelfVariables());
// Both shelf views are hidden when session state hasn't been initialized. // Both shelf views are hidden when session state hasn't been initialized.
...@@ -499,9 +501,10 @@ TEST_F(ShelfWidgetViewsVisibilityTest, LoginViewsLockViews) { ...@@ -499,9 +501,10 @@ TEST_F(ShelfWidgetViewsVisibilityTest, LoginViewsLockViews) {
} }
TEST_F(ShelfWidgetViewsVisibilityTest, LoginWebUiLockWebUi) { TEST_F(ShelfWidgetViewsVisibilityTest, LoginWebUiLockWebUi) {
// Enable web UI lock. Web UI login enabled by default. // Enable web UI lock and login.
base::CommandLine::ForCurrentProcess()->AppendSwitch( base::CommandLine* cl = base::CommandLine::ForCurrentProcess();
switches::kShowWebUiLock); cl->AppendSwitch(switches::kShowWebUiLogin);
cl->AppendSwitch(switches::kShowWebUiLock);
ASSERT_NO_FATAL_FAILURE(InitShelfVariables()); ASSERT_NO_FATAL_FAILURE(InitShelfVariables());
// Views based shelf is never visible. // Views based shelf is never visible.
......
...@@ -178,6 +178,7 @@ void DeriveCommandLine(const GURL& start_url, ...@@ -178,6 +178,7 @@ void DeriveCommandLine(const GURL& start_url,
ash::switches::kShowTaps, ash::switches::kShowTaps,
ash::switches::kShowViewsLogin, ash::switches::kShowViewsLogin,
ash::switches::kShowWebUiLock, ash::switches::kShowWebUiLock,
ash::switches::kShowWebUiLogin,
chromeos::switches::kDefaultWallpaperLarge, chromeos::switches::kDefaultWallpaperLarge,
chromeos::switches::kDefaultWallpaperSmall, chromeos::switches::kDefaultWallpaperSmall,
chromeos::switches::kGuestWallpaperLarge, chromeos::switches::kGuestWallpaperLarge,
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <string> #include <string>
#include "ash/public/cpp/ash_switches.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/bind_helpers.h" #include "base/bind_helpers.h"
#include "base/command_line.h" #include "base/command_line.h"
...@@ -103,6 +104,7 @@ void LoginManagerTest::TearDownOnMainThread() { ...@@ -103,6 +104,7 @@ void LoginManagerTest::TearDownOnMainThread() {
} }
void LoginManagerTest::SetUpCommandLine(base::CommandLine* command_line) { void LoginManagerTest::SetUpCommandLine(base::CommandLine* command_line) {
command_line->AppendSwitch(ash::switches::kShowWebUiLogin);
command_line->AppendSwitch(chromeos::switches::kLoginManager); command_line->AppendSwitch(chromeos::switches::kLoginManager);
command_line->AppendSwitch(chromeos::switches::kForceLoginManagerInTests); command_line->AppendSwitch(chromeos::switches::kForceLoginManagerInTests);
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "chrome/browser/chromeos/login/test/oobe_base_test.h" #include "chrome/browser/chromeos/login/test/oobe_base_test.h"
#include "ash/public/cpp/ash_switches.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/location.h" #include "base/location.h"
#include "base/path_service.h" #include "base/path_service.h"
...@@ -138,6 +139,7 @@ void OobeBaseTest::TearDownOnMainThread() { ...@@ -138,6 +139,7 @@ void OobeBaseTest::TearDownOnMainThread() {
void OobeBaseTest::SetUpCommandLine(base::CommandLine* command_line) { void OobeBaseTest::SetUpCommandLine(base::CommandLine* command_line) {
ExtensionApiTest::SetUpCommandLine(command_line); ExtensionApiTest::SetUpCommandLine(command_line);
command_line->AppendSwitch(ash::switches::kShowWebUiLogin);
command_line->AppendSwitch(chromeos::switches::kLoginManager); command_line->AppendSwitch(chromeos::switches::kLoginManager);
command_line->AppendSwitch(chromeos::switches::kForceLoginManagerInTests); command_line->AppendSwitch(chromeos::switches::kForceLoginManagerInTests);
if (!needs_background_networking_) if (!needs_background_networking_)
......
...@@ -177,6 +177,7 @@ bool IsOobeComplete() { ...@@ -177,6 +177,7 @@ bool IsOobeComplete() {
connector->IsEnterpriseManaged()); connector->IsEnterpriseManaged());
} }
// Returns true if signin (not oobe) should be displayed.
bool ShouldShowSigninScreen(chromeos::OobeScreen first_screen) { bool ShouldShowSigninScreen(chromeos::OobeScreen first_screen) {
return (first_screen == chromeos::OobeScreen::SCREEN_UNKNOWN && return (first_screen == chromeos::OobeScreen::SCREEN_UNKNOWN &&
IsOobeComplete()) || IsOobeComplete()) ||
...@@ -1186,9 +1187,10 @@ void ShowLoginWizard(OobeScreen first_screen) { ...@@ -1186,9 +1187,10 @@ void ShowLoginWizard(OobeScreen first_screen) {
base::CommandLine::ForCurrentProcess()->HasSwitch( base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kNaturalScrollDefault)); switches::kNaturalScrollDefault));
session_manager::SessionManager::Get()->SetSessionState( auto session_state = session_manager::SessionState::OOBE;
IsOobeComplete() ? session_manager::SessionState::LOGIN_PRIMARY if (IsOobeComplete() || first_screen == OobeScreen::SCREEN_SPECIAL_LOGIN)
: session_manager::SessionState::OOBE); session_state = session_manager::SessionState::LOGIN_PRIMARY;
session_manager::SessionManager::Get()->SetSessionState(session_state);
bool show_app_launch_splash_screen = bool show_app_launch_splash_screen =
(first_screen == OobeScreen::SCREEN_APP_LAUNCH_SPLASH); (first_screen == OobeScreen::SCREEN_APP_LAUNCH_SPLASH);
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include <stddef.h> #include <stddef.h>
#include <sys/types.h> #include <sys/types.h>
#include "ash/public/cpp/ash_switches.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/macros.h" #include "base/macros.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
...@@ -124,13 +125,28 @@ class PreferencesTest : public LoginManagerTest { ...@@ -124,13 +125,28 @@ class PreferencesTest : public LoginManagerTest {
DISALLOW_COPY_AND_ASSIGN(PreferencesTest); DISALLOW_COPY_AND_ASSIGN(PreferencesTest);
}; };
IN_PROC_BROWSER_TEST_F(PreferencesTest, PRE_MultiProfiles) { class PreferencesTestForceWebUiLogin : public PreferencesTest {
public:
PreferencesTestForceWebUiLogin() = default;
~PreferencesTestForceWebUiLogin() override = default;
// PreferencesTest:
void SetUpCommandLine(base::CommandLine* command_line) override {
PreferencesTest::SetUpCommandLine(command_line);
command_line->AppendSwitch(ash::switches::kShowWebUiLogin);
}
private:
DISALLOW_COPY_AND_ASSIGN(PreferencesTestForceWebUiLogin);
};
IN_PROC_BROWSER_TEST_F(PreferencesTestForceWebUiLogin, PRE_MultiProfiles) {
RegisterUser(test_users_[0]); RegisterUser(test_users_[0]);
RegisterUser(test_users_[1]); RegisterUser(test_users_[1]);
chromeos::StartupUtils::MarkOobeCompleted(); chromeos::StartupUtils::MarkOobeCompleted();
} }
IN_PROC_BROWSER_TEST_F(PreferencesTest, MultiProfiles) { IN_PROC_BROWSER_TEST_F(PreferencesTestForceWebUiLogin, MultiProfiles) {
user_manager::UserManager* user_manager = user_manager::UserManager::Get(); user_manager::UserManager* user_manager = user_manager::UserManager::Get();
// Add first user and init its preferences. Check that corresponding // Add first user and init its preferences. Check that corresponding
......
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