Commit 896c7258 authored by Roman Sorokin's avatar Roman Sorokin Committed by Commit Bot

cros: Removing kShowWebUiLogin switch from tests

Migrated to Views where needed

PreferencesTest.MultiProfiles
ForceMaximizeOnFirstRun
RestoreOnStartupTestChromeOS
DeviceID*
ActiveDirectoryLogin
OAuth2Tests

Bug: 987587
Change-Id: I48d32c20a078e21c6ce9d24d8081037178f1beab
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2124383Reviewed-by: default avatarDenis Kuznetsov [CET] <antrim@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Roman Sorokin [CET] <rsorokin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#754539}
parent 8b5b381c
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
#include <string> #include <string>
#include "ash/public/cpp/ash_switches.h"
#include "base/base_paths.h" #include "base/base_paths.h"
#include "base/environment.h" #include "base/environment.h"
#include "base/path_service.h" #include "base/path_service.h"
...@@ -232,23 +231,8 @@ IN_PROC_BROWSER_TEST_F(ActiveDirectoryLoginTest, PasswordChange_UIErrors) { ...@@ -232,23 +231,8 @@ IN_PROC_BROWSER_TEST_F(ActiveDirectoryLoginTest, PasswordChange_UIErrors) {
ad_login_.TestPasswordChangeOldPasswordError(); ad_login_.TestPasswordChangeOldPasswordError();
} }
class ActiveDirectoryWebUILoginTest : public ActiveDirectoryLoginTest {
public:
ActiveDirectoryWebUILoginTest() = default;
~ActiveDirectoryWebUILoginTest() override = default;
// chromeos::ActiveDirectoryLoginTest:
void SetUpCommandLine(base::CommandLine* command_line) override {
command_line->AppendSwitch(ash::switches::kShowWebUiLogin);
chromeos::ActiveDirectoryLoginTest::SetUpCommandLine(command_line);
}
private:
DISALLOW_COPY_AND_ASSIGN(ActiveDirectoryWebUILoginTest);
};
// Test reopening Active Directory password change screen clears errors. // Test reopening Active Directory password change screen clears errors.
IN_PROC_BROWSER_TEST_F(ActiveDirectoryWebUILoginTest, IN_PROC_BROWSER_TEST_F(ActiveDirectoryLoginTest,
PasswordChange_ReopenClearErrors) { PasswordChange_ReopenClearErrors) {
OobeBaseTest::WaitForSigninScreen(); OobeBaseTest::WaitForSigninScreen();
ASSERT_TRUE(InstallAttributes::Get()->IsActiveDirectoryManaged()); ASSERT_TRUE(InstallAttributes::Get()->IsActiveDirectoryManaged());
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "ash/public/cpp/ash_switches.h" #include "ash/public/cpp/login_screen_test_api.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/json/json_reader.h" #include "base/json/json_reader.h"
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
#include "components/signin/public/base/signin_pref_names.h" #include "components/signin/public/base/signin_pref_names.h"
#include "components/user_manager/known_user.h" #include "components/user_manager/known_user.h"
#include "components/user_manager/remove_user_delegate.h"
#include "components/user_manager/user_manager.h" #include "components/user_manager/user_manager.h"
namespace { namespace {
...@@ -45,21 +44,22 @@ char kSecondUserRefreshToken2[] = "refresh_token_second_user_2"; ...@@ -45,21 +44,22 @@ char kSecondUserRefreshToken2[] = "refresh_token_second_user_2";
namespace chromeos { namespace chromeos {
class DeviceIDTest : public OobeBaseTest, class DeviceIDTest : public OobeBaseTest,
public user_manager::RemoveUserDelegate { public user_manager::UserManager::Observer {
public: public:
void SetUpCommandLine(base::CommandLine* command_line) override { void SetUpCommandLine(base::CommandLine* command_line) override {
OobeBaseTest::SetUpCommandLine(command_line); OobeBaseTest::SetUpCommandLine(command_line);
command_line->AppendSwitch(switches::kOobeSkipPostLogin); command_line->AppendSwitch(switches::kOobeSkipPostLogin);
command_line->AppendSwitch(ash::switches::kShowWebUiLogin);
} }
void SetUpOnMainThread() override { void SetUpOnMainThread() override {
user_removal_loop_.reset(new base::RunLoop); user_removal_loop_.reset(new base::RunLoop);
OobeBaseTest::SetUpOnMainThread(); OobeBaseTest::SetUpOnMainThread();
LoadRefreshTokenToDeviceIdMap(); LoadRefreshTokenToDeviceIdMap();
user_manager::UserManager::Get()->AddObserver(this);
} }
void TearDownOnMainThread() override { void TearDownOnMainThread() override {
user_manager::UserManager::Get()->RemoveObserver(this);
SaveRefreshTokenToDeviceIdMap(); SaveRefreshTokenToDeviceIdMap();
OobeBaseTest::TearDownOnMainThread(); OobeBaseTest::TearDownOnMainThread();
} }
...@@ -117,24 +117,19 @@ class DeviceIDTest : public OobeBaseTest, ...@@ -117,24 +117,19 @@ class DeviceIDTest : public OobeBaseTest,
} }
void SignInOffline(const std::string& user_id, const std::string& password) { void SignInOffline(const std::string& user_id, const std::string& password) {
WaitForSigninScreen(); ash::LoginScreenTestApi::SubmitPassword(AccountId::FromUserEmail(user_id),
FakeGaiaMixin::kFakeUserPassword,
test::OobeJS().ExecuteAsync(base::StringPrintf( false /* check_if_submittable */);
"chrome.send('authenticateUser', ['%s', '%s', false])", user_id.c_str(),
password.c_str()));
test::WaitForPrimaryUserSessionStart(); test::WaitForPrimaryUserSessionStart();
} }
void RemoveUser(const AccountId& account_id) { void RemoveUser(const AccountId& account_id) {
user_manager::UserManager::Get()->RemoveUser(account_id, this); ASSERT_TRUE(ash::LoginScreenTestApi::RemoveUser(account_id));
user_removal_loop_->Run(); user_removal_loop_->Run();
} }
private: private:
// user_manager::RemoveUserDelegate: void LocalStateChanged(user_manager::UserManager* manager) override {
void OnBeforeUserRemoved(const AccountId& account_id) override {}
void OnUserRemoved(const AccountId& account_id) override {
user_removal_loop_->Quit(); user_removal_loop_->Quit();
} }
...@@ -195,6 +190,7 @@ IN_PROC_BROWSER_TEST_F(DeviceIDTest, PRE_PRE_PRE_PRE_NewUsers) { ...@@ -195,6 +190,7 @@ IN_PROC_BROWSER_TEST_F(DeviceIDTest, PRE_PRE_PRE_PRE_NewUsers) {
EXPECT_FALSE(device_id.empty()); EXPECT_FALSE(device_id.empty());
EXPECT_EQ(device_id, GetDeviceIdFromGAIA(kRefreshToken1)); EXPECT_EQ(device_id, GetDeviceIdFromGAIA(kRefreshToken1));
ASSERT_TRUE(ash::LoginScreenTestApi::ClickAddUserButton());
SignInOnline(FakeGaiaMixin::kFakeUserEmail, FakeGaiaMixin::kFakeUserPassword, SignInOnline(FakeGaiaMixin::kFakeUserEmail, FakeGaiaMixin::kFakeUserPassword,
kRefreshToken2, FakeGaiaMixin::kFakeUserGaiaId); kRefreshToken2, FakeGaiaMixin::kFakeUserGaiaId);
CheckDeviceIDIsConsistent( CheckDeviceIDIsConsistent(
...@@ -225,8 +221,7 @@ IN_PROC_BROWSER_TEST_F(DeviceIDTest, PRE_PRE_PRE_NewUsers) { ...@@ -225,8 +221,7 @@ IN_PROC_BROWSER_TEST_F(DeviceIDTest, PRE_PRE_PRE_NewUsers) {
// Add the second user. // Add the second user.
IN_PROC_BROWSER_TEST_F(DeviceIDTest, PRE_PRE_NewUsers) { IN_PROC_BROWSER_TEST_F(DeviceIDTest, PRE_PRE_NewUsers) {
WaitForSigninScreen(); ASSERT_TRUE(ash::LoginScreenTestApi::ClickAddUserButton());
test::OobeJS().ExecuteAsync("chrome.send('showAddUser')");
SignInOnline(kSecondUserEmail, kSecondUserPassword, kSecondUserRefreshToken1, SignInOnline(kSecondUserEmail, kSecondUserPassword, kSecondUserRefreshToken1,
kSecondUserGaiaId); kSecondUserGaiaId);
CheckDeviceIDIsConsistent(AccountId::FromUserEmail(kSecondUserEmail), CheckDeviceIDIsConsistent(AccountId::FromUserEmail(kSecondUserEmail),
...@@ -235,13 +230,13 @@ IN_PROC_BROWSER_TEST_F(DeviceIDTest, PRE_PRE_NewUsers) { ...@@ -235,13 +230,13 @@ IN_PROC_BROWSER_TEST_F(DeviceIDTest, PRE_PRE_NewUsers) {
// Remove the second user. // Remove the second user.
IN_PROC_BROWSER_TEST_F(DeviceIDTest, PRE_NewUsers) { IN_PROC_BROWSER_TEST_F(DeviceIDTest, PRE_NewUsers) {
WaitForSigninScreen();
RemoveUser(AccountId::FromUserEmail(kSecondUserEmail)); RemoveUser(AccountId::FromUserEmail(kSecondUserEmail));
} }
// Add the second user back. Verify that device ID has been changed. // Add the second user back. Verify that device ID has been changed.
IN_PROC_BROWSER_TEST_F(DeviceIDTest, NewUsers) { IN_PROC_BROWSER_TEST_F(DeviceIDTest, NewUsers) {
EXPECT_TRUE(GetDeviceId(AccountId::FromUserEmail(kSecondUserEmail)).empty()); EXPECT_TRUE(GetDeviceId(AccountId::FromUserEmail(kSecondUserEmail)).empty());
ASSERT_TRUE(ash::LoginScreenTestApi::ClickAddUserButton());
SignInOnline(kSecondUserEmail, kSecondUserPassword, kSecondUserRefreshToken2, SignInOnline(kSecondUserEmail, kSecondUserPassword, kSecondUserRefreshToken2,
kSecondUserGaiaId); kSecondUserGaiaId);
CheckDeviceIDIsConsistent(AccountId::FromUserEmail(kSecondUserEmail), CheckDeviceIDIsConsistent(AccountId::FromUserEmail(kSecondUserEmail),
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#include <string> #include <string>
#include <utility> #include <utility>
#include "ash/public/cpp/ash_switches.h" #include "ash/public/cpp/login_screen_test_api.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
...@@ -244,7 +244,6 @@ class OAuth2Test : public OobeBaseTest { ...@@ -244,7 +244,6 @@ class OAuth2Test : public OobeBaseTest {
// OobeBaseTest overrides. // OobeBaseTest overrides.
void SetUpCommandLine(base::CommandLine* command_line) override { void SetUpCommandLine(base::CommandLine* command_line) override {
OobeBaseTest::SetUpCommandLine(command_line); OobeBaseTest::SetUpCommandLine(command_line);
command_line->AppendSwitch(ash::switches::kShowWebUiLogin);
base::PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir_); base::PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir_);
...@@ -304,9 +303,6 @@ class OAuth2Test : public OobeBaseTest { ...@@ -304,9 +303,6 @@ class OAuth2Test : public OobeBaseTest {
} }
void LoginAsExistingUser() { void LoginAsExistingUser() {
test::OobeJS().ExpectTrue("!!document.querySelector('#account-picker')");
test::OobeJS().ExpectTrue("!!document.querySelector('#pod-row')");
// PickAccountId does not work at this point as the primary user profile has // PickAccountId does not work at this point as the primary user profile has
// not yet been created. // not yet been created.
const std::string email = kTestEmail; const std::string email = kTestEmail;
...@@ -314,9 +310,10 @@ class OAuth2Test : public OobeBaseTest { ...@@ -314,9 +310,10 @@ class OAuth2Test : public OobeBaseTest {
user_manager::User::OAUTH2_TOKEN_STATUS_VALID); user_manager::User::OAUTH2_TOKEN_STATUS_VALID);
// Try login. Primary profile has changed. // Try login. Primary profile has changed.
EXPECT_TRUE( ash::LoginScreenTestApi::SubmitPassword(
TryToLogin(AccountId::FromUserEmailGaiaId(kTestEmail, kTestGaiaId), AccountId::FromUserEmailGaiaId(kTestEmail, kTestGaiaId),
kTestAccountPassword)); kTestAccountPassword, true /*check_if_submittable */);
test::WaitForPrimaryUserSessionStart();
Profile* profile = ProfileManager::GetPrimaryUserProfile(); Profile* profile = ProfileManager::GetPrimaryUserProfile();
CoreAccountId account_id = PickAccountId(profile, kTestGaiaId, kTestEmail); CoreAccountId account_id = PickAccountId(profile, kTestGaiaId, kTestEmail);
ASSERT_EQ(email, account_id.ToString()); ASSERT_EQ(email, account_id.ToString());
...@@ -568,8 +565,7 @@ IN_PROC_BROWSER_TEST_F(OAuth2Test, PRE_MergeSession) { ...@@ -568,8 +565,7 @@ IN_PROC_BROWSER_TEST_F(OAuth2Test, PRE_MergeSession) {
IN_PROC_BROWSER_TEST_F(OAuth2Test, MergeSession) { IN_PROC_BROWSER_TEST_F(OAuth2Test, MergeSession) {
SimulateNetworkOnline(); SimulateNetworkOnline();
test::OobeJS().ExpectTrue("!!document.querySelector('#account-picker')"); EXPECT_EQ(1, ash::LoginScreenTestApi::GetUsersCount());
test::OobeJS().ExpectTrue("!!document.querySelector('#pod-row')");
// PickAccountId does not work at this point as the primary user profile has // PickAccountId does not work at this point as the primary user profile has
// not yet been created. // not yet been created.
......
...@@ -4,12 +4,13 @@ ...@@ -4,12 +4,13 @@
#include <string> #include <string>
#include "ash/public/cpp/ash_switches.h" #include "ash/public/cpp/login_screen_test_api.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/values.h" #include "base/values.h"
#include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/chromeos/login/test/session_manager_state_waiter.h"
#include "chrome/browser/chromeos/policy/login_policy_test_base.h" #include "chrome/browser/chromeos/policy/login_policy_test_base.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h" #include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
...@@ -50,11 +51,6 @@ class ForceMaximizeOnFirstRunTest : public LoginPolicyTestBase { ...@@ -50,11 +51,6 @@ class ForceMaximizeOnFirstRunTest : public LoginPolicyTestBase {
return CreateBrowser(profile); return CreateBrowser(profile);
} }
void SetUpCommandLine(base::CommandLine* command_line) override {
LoginPolicyTestBase::SetUpCommandLine(command_line);
command_line->AppendSwitch(ash::switches::kShowWebUiLogin);
}
private: private:
DISALLOW_COPY_AND_ASSIGN(ForceMaximizeOnFirstRunTest); DISALLOW_COPY_AND_ASSIGN(ForceMaximizeOnFirstRunTest);
}; };
...@@ -84,7 +80,10 @@ IN_PROC_BROWSER_TEST_F(ForceMaximizeOnFirstRunTest, PRE_TwoRuns) { ...@@ -84,7 +80,10 @@ IN_PROC_BROWSER_TEST_F(ForceMaximizeOnFirstRunTest, PRE_TwoRuns) {
IN_PROC_BROWSER_TEST_F(ForceMaximizeOnFirstRunTest, TwoRuns) { IN_PROC_BROWSER_TEST_F(ForceMaximizeOnFirstRunTest, TwoRuns) {
SetUpResolution(); SetUpResolution();
LogIn(kAccountId, kAccountPassword, kEmptyServices); ash::LoginScreenTestApi::SubmitPassword(AccountId::FromUserEmail(kAccountId),
kAccountPassword,
true /* check_if_submittable */);
chromeos::test::WaitForPrimaryUserSessionStart();
const Browser* const browser = OpenNewBrowserWindow(); const Browser* const browser = OpenNewBrowserWindow();
ASSERT_TRUE(browser); ASSERT_TRUE(browser);
......
...@@ -5,10 +5,11 @@ ...@@ -5,10 +5,11 @@
#include <memory> #include <memory>
#include <utility> #include <utility>
#include "ash/public/cpp/ash_switches.h" #include "ash/public/cpp/login_screen_test_api.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/values.h" #include "base/values.h"
#include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/chromeos/login/test/session_manager_state_waiter.h"
#include "chrome/browser/chromeos/policy/login_policy_test_base.h" #include "chrome/browser/chromeos/policy/login_policy_test_base.h"
#include "chrome/browser/prefs/session_startup_pref.h" #include "chrome/browser/prefs/session_startup_pref.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
...@@ -36,9 +37,8 @@ class RestoreOnStartupTestChromeOS : public LoginPolicyTestBase { ...@@ -36,9 +37,8 @@ class RestoreOnStartupTestChromeOS : public LoginPolicyTestBase {
// LoginPolicyTestBase: // LoginPolicyTestBase:
void GetMandatoryPoliciesValue(base::DictionaryValue* policy) const override; void GetMandatoryPoliciesValue(base::DictionaryValue* policy) const override;
void SetUpCommandLine(base::CommandLine* command_line) override;
void LogInAndVerifyStartUpURLs(); void VerifyStartUpURLs();
private: private:
DISALLOW_COPY_AND_ASSIGN(RestoreOnStartupTestChromeOS); DISALLOW_COPY_AND_ASSIGN(RestoreOnStartupTestChromeOS);
...@@ -57,15 +57,7 @@ void RestoreOnStartupTestChromeOS::GetMandatoryPoliciesValue( ...@@ -57,15 +57,7 @@ void RestoreOnStartupTestChromeOS::GetMandatoryPoliciesValue(
policy->Set(key::kRestoreOnStartupURLs, std::move(urls)); policy->Set(key::kRestoreOnStartupURLs, std::move(urls));
} }
void RestoreOnStartupTestChromeOS::SetUpCommandLine( void RestoreOnStartupTestChromeOS::VerifyStartUpURLs() {
base::CommandLine* command_line) {
LoginPolicyTestBase::SetUpCommandLine(command_line);
command_line->AppendSwitch(ash::switches::kShowWebUiLogin);
}
void RestoreOnStartupTestChromeOS::LogInAndVerifyStartUpURLs() {
LogIn(kAccountId, kAccountPassword, kEmptyServices);
const BrowserList* const browser_list = BrowserList::GetInstance(); const BrowserList* const browser_list = BrowserList::GetInstance();
ASSERT_EQ(1U, browser_list->size()); ASSERT_EQ(1U, browser_list->size());
const Browser* const browser = browser_list->get(0); const Browser* const browser = browser_list->get(0);
...@@ -80,12 +72,17 @@ void RestoreOnStartupTestChromeOS::LogInAndVerifyStartUpURLs() { ...@@ -80,12 +72,17 @@ void RestoreOnStartupTestChromeOS::LogInAndVerifyStartUpURLs() {
// Verify that the policies are honored on a new user's login. // Verify that the policies are honored on a new user's login.
IN_PROC_BROWSER_TEST_F(RestoreOnStartupTestChromeOS, PRE_LogInAndVerify) { IN_PROC_BROWSER_TEST_F(RestoreOnStartupTestChromeOS, PRE_LogInAndVerify) {
SkipToLoginScreen(); SkipToLoginScreen();
LogInAndVerifyStartUpURLs(); LogIn(kAccountId, kAccountPassword, kEmptyServices);
VerifyStartUpURLs();
} }
// Verify that the policies are honored on an existing user's login. // Verify that the policies are honored on an existing user's login.
IN_PROC_BROWSER_TEST_F(RestoreOnStartupTestChromeOS, LogInAndVerify) { IN_PROC_BROWSER_TEST_F(RestoreOnStartupTestChromeOS, LogInAndVerify) {
LogInAndVerifyStartUpURLs(); ash::LoginScreenTestApi::SubmitPassword(AccountId::FromUserEmail(kAccountId),
kAccountPassword,
true /* check_if_submittable */);
chromeos::test::WaitForPrimaryUserSessionStart();
VerifyStartUpURLs();
} }
} // namespace policy } // namespace policy
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#include <sys/types.h> #include <sys/types.h>
#include "ash/public/cpp/ash_pref_names.h" #include "ash/public/cpp/ash_pref_names.h"
#include "ash/public/cpp/ash_switches.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/stl_util.h" #include "base/stl_util.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
...@@ -147,28 +146,13 @@ class PreferencesTest : public LoginManagerTest { ...@@ -147,28 +146,13 @@ class PreferencesTest : public LoginManagerTest {
DISALLOW_COPY_AND_ASSIGN(PreferencesTest); DISALLOW_COPY_AND_ASSIGN(PreferencesTest);
}; };
class PreferencesTestForceWebUiLogin : public PreferencesTest { IN_PROC_BROWSER_TEST_F(PreferencesTest, PRE_MultiProfiles) {
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]);
StartupUtils::MarkOobeCompleted(); StartupUtils::MarkOobeCompleted();
} }
IN_PROC_BROWSER_TEST_F(PreferencesTestForceWebUiLogin, MultiProfiles) { IN_PROC_BROWSER_TEST_F(PreferencesTest, 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