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