Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1392)

Unified Diff: chrome/browser/chromeos/login/login_manager_test_helper.cc

Issue 270563002: Componentize LoginManagerTest. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/chromeos/login/login_manager_test_helper.h ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/login/login_manager_test_helper.cc
diff --git a/chrome/browser/chromeos/login/login_manager_test.cc b/chrome/browser/chromeos/login/login_manager_test_helper.cc
similarity index 62%
copy from chrome/browser/chromeos/login/login_manager_test.cc
copy to chrome/browser/chromeos/login/login_manager_test_helper.cc
index 3066bed910c41e125d64db05b798a80d65212304..dab273383db13205b5c0bab68b597aa0c8390a27 100644
--- a/chrome/browser/chromeos/login/login_manager_test.cc
+++ b/chrome/browser/chromeos/login/login_manager_test_helper.cc
@@ -1,8 +1,8 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/chromeos/login/login_manager_test.h"
+#include "chrome/browser/chromeos/login/login_manager_test_helper.h"
#include "base/prefs/scoped_user_pref_update.h"
#include "chrome/browser/browser_process.h"
@@ -10,64 +10,60 @@
#include "chrome/browser/chromeos/login/auth/user_context.h"
#include "chrome/browser/chromeos/login/existing_user_controller.h"
#include "chrome/browser/chromeos/login/ui/login_display_host_impl.h"
-#include "chrome/browser/chromeos/login/ui/webui_login_view.h"
#include "chrome/browser/chromeos/login/users/user.h"
#include "chrome/browser/chromeos/login/users/user_manager.h"
#include "chrome/common/chrome_switches.h"
#include "chromeos/chromeos_switches.h"
#include "content/public/browser/notification_service.h"
-#include "content/public/browser/web_contents.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace chromeos {
-LoginManagerTest::LoginManagerTest(bool should_launch_browser)
- : should_launch_browser_(should_launch_browser),
- web_contents_(NULL) {
- set_exit_when_last_browser_closes(false);
-}
+LoginManagerTestHelper::LoginManagerTestHelper() {}
-void LoginManagerTest::CleanUpOnMainThread() {
- if (LoginDisplayHostImpl::default_host())
- LoginDisplayHostImpl::default_host()->Finalize();
- base::MessageLoop::current()->RunUntilIdle();
-}
+LoginManagerTestHelper::~LoginManagerTestHelper() {}
-void LoginManagerTest::SetUpCommandLine(CommandLine* command_line) {
+void LoginManagerTestHelper::SetUpCommandLine(CommandLine* command_line) {
command_line->AppendSwitch(chromeos::switches::kLoginManager);
command_line->AppendSwitch(chromeos::switches::kForceLoginManagerInTests);
command_line->AppendSwitch(::switches::kMultiProfiles);
}
-void LoginManagerTest::SetUpInProcessBrowserTestFixture() {
+void LoginManagerTestHelper::SetUpLoginUtils(bool should_launch_browser) {
mock_login_utils_ = new testing::NiceMock<MockLoginUtils>();
mock_login_utils_->DelegateToFake();
mock_login_utils_->GetFakeLoginUtils()->set_should_launch_browser(
- should_launch_browser_);
+ should_launch_browser);
LoginUtils::Set(mock_login_utils_);
}
-void LoginManagerTest::SetUpOnMainThread() {
+void LoginManagerTestHelper::WaitForLoginWebUI() {
content::WindowedNotificationObserver(
chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE,
content::NotificationService::AllSources()).Wait();
- InitializeWebContents();
}
-void LoginManagerTest::RegisterUser(const std::string& username) {
+void LoginManagerTestHelper::CloseLoginWebUI() {
+ if (LoginDisplayHostImpl::default_host())
+ LoginDisplayHostImpl::default_host()->Finalize();
+ base::MessageLoop::current()->RunUntilIdle();
+}
+
+void LoginManagerTestHelper::RegisterUser(const std::string& username) {
ListPrefUpdate users_pref(g_browser_process->local_state(), "LoggedInUsers");
users_pref->AppendIfNotPresent(new base::StringValue(username));
}
-void LoginManagerTest::SetExpectedCredentials(const std::string& username,
- const std::string& password) {
- login_utils().GetFakeLoginUtils()->SetExpectedCredentials(username, password);
+void LoginManagerTestHelper::SetExpectedCredentials(
+ const std::string& username, const std::string& password) {
+ mock_login_utils_->GetFakeLoginUtils()->SetExpectedCredentials(username,
+ password);
}
-bool LoginManagerTest::TryToLogin(const std::string& username,
- const std::string& password) {
+bool LoginManagerTestHelper::TryToLogIn(const std::string& username,
+ const std::string& password) {
if (!AddUserToSession(username, password))
return false;
if (const User* active_user = UserManager::Get()->GetActiveUser())
@@ -75,8 +71,8 @@ bool LoginManagerTest::TryToLogin(const std::string& username,
return false;
}
-bool LoginManagerTest::AddUserToSession(const std::string& username,
- const std::string& password) {
+bool LoginManagerTestHelper::AddUserToSession(const std::string& username,
+ const std::string& password) {
ExistingUserController* controller =
ExistingUserController::current_controller();
if (!controller) {
@@ -98,29 +94,14 @@ bool LoginManagerTest::AddUserToSession(const std::string& username,
return false;
}
-void LoginManagerTest::LoginUser(const std::string& username) {
+void LoginManagerTestHelper::LogInUser(const std::string& username) {
SetExpectedCredentials(username, "password");
- EXPECT_TRUE(TryToLogin(username, "password"));
+ EXPECT_TRUE(TryToLogIn(username, "password"));
}
-void LoginManagerTest::AddUser(const std::string& username) {
+void LoginManagerTestHelper::AddUser(const std::string& username) {
SetExpectedCredentials(username, "password");
EXPECT_TRUE(AddUserToSession(username, "password"));
}
-void LoginManagerTest::JSExpect(const std::string& expression) {
- js_checker_.ExpectTrue(expression);
-}
-
-void LoginManagerTest::InitializeWebContents() {
- LoginDisplayHost* host = LoginDisplayHostImpl::default_host();
- EXPECT_TRUE(host != NULL);
-
- content::WebContents* web_contents =
- host->GetWebUILoginView()->GetWebContents();
- EXPECT_TRUE(web_contents != NULL);
- set_web_contents(web_contents);
- js_checker_.set_web_contents(web_contents);
- }
-
} // namespace chromeos
« no previous file with comments | « chrome/browser/chromeos/login/login_manager_test_helper.h ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698