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

Side by Side Diff: chrome/browser/chromeos/login/login_manager_test.cc

Issue 1079083002: [cros New-GAIA] Webview login and new GAIA endpoint enabled by default (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix saml test Created 5 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/login/login_manager_test.h" 5 #include "chrome/browser/chromeos/login/login_manager_test.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/json/json_file_value_serializer.h"
9 #include "base/path_service.h"
8 #include "base/prefs/scoped_user_pref_update.h" 10 #include "base/prefs/scoped_user_pref_update.h"
9 #include "chrome/browser/browser_process.h" 11 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/chrome_notification_types.h" 12 #include "chrome/browser/chrome_notification_types.h"
11 #include "chrome/browser/chromeos/login/existing_user_controller.h" 13 #include "chrome/browser/chromeos/login/existing_user_controller.h"
12 #include "chrome/browser/chromeos/login/session/user_session_manager.h" 14 #include "chrome/browser/chromeos/login/session/user_session_manager.h"
13 #include "chrome/browser/chromeos/login/session/user_session_manager_test_api.h" 15 #include "chrome/browser/chromeos/login/session/user_session_manager_test_api.h"
16 #include "chrome/browser/chromeos/login/startup_utils.h"
14 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" 17 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h"
15 #include "chrome/browser/chromeos/login/ui/webui_login_view.h" 18 #include "chrome/browser/chromeos/login/ui/webui_login_view.h"
19 #include "chrome/common/chrome_constants.h"
20 #include "chrome/common/chrome_paths.h"
21 #include "chrome/common/pref_names.h"
16 #include "chromeos/chromeos_switches.h" 22 #include "chromeos/chromeos_switches.h"
17 #include "chromeos/login/auth/key.h" 23 #include "chromeos/login/auth/key.h"
18 #include "chromeos/login/auth/user_context.h" 24 #include "chromeos/login/auth/user_context.h"
19 #include "components/user_manager/user.h" 25 #include "components/user_manager/user.h"
20 #include "components/user_manager/user_manager.h" 26 #include "components/user_manager/user_manager.h"
21 #include "content/public/browser/notification_service.h" 27 #include "content/public/browser/notification_service.h"
22 #include "content/public/browser/web_contents.h" 28 #include "content/public/browser/web_contents.h"
23 #include "content/public/test/browser_test_utils.h" 29 #include "content/public/test/browser_test_utils.h"
24 #include "content/public/test/test_utils.h" 30 #include "content/public/test/test_utils.h"
25 #include "testing/gtest/include/gtest/gtest.h" 31 #include "testing/gtest/include/gtest/gtest.h"
26 32
27 namespace chromeos { 33 namespace chromeos {
28 34
29 LoginManagerTest::LoginManagerTest(bool should_launch_browser) 35 LoginManagerTest::LoginManagerTest(bool should_launch_browser)
30 : should_launch_browser_(should_launch_browser), 36 : use_webview_(false),
37 should_launch_browser_(should_launch_browser),
31 web_contents_(NULL) { 38 web_contents_(NULL) {
32 set_exit_when_last_browser_closes(false); 39 set_exit_when_last_browser_closes(false);
33 } 40 }
34 41
35 void LoginManagerTest::TearDownOnMainThread() { 42 void LoginManagerTest::TearDownOnMainThread() {
36 MixinBasedBrowserTest::TearDownOnMainThread(); 43 MixinBasedBrowserTest::TearDownOnMainThread();
37 if (LoginDisplayHostImpl::default_host()) 44 if (LoginDisplayHostImpl::default_host())
38 LoginDisplayHostImpl::default_host()->Finalize(); 45 LoginDisplayHostImpl::default_host()->Finalize();
39 base::MessageLoop::current()->RunUntilIdle(); 46 base::MessageLoop::current()->RunUntilIdle();
40 } 47 }
(...skipping 13 matching lines...) Expand all
54 content::WindowedNotificationObserver( 61 content::WindowedNotificationObserver(
55 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, 62 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE,
56 content::NotificationService::AllSources()).Wait(); 63 content::NotificationService::AllSources()).Wait();
57 InitializeWebContents(); 64 InitializeWebContents();
58 test::UserSessionManagerTestApi session_manager_test_api( 65 test::UserSessionManagerTestApi session_manager_test_api(
59 UserSessionManager::GetInstance()); 66 UserSessionManager::GetInstance());
60 session_manager_test_api.SetShouldLaunchBrowserInTests( 67 session_manager_test_api.SetShouldLaunchBrowserInTests(
61 should_launch_browser_); 68 should_launch_browser_);
62 } 69 }
63 70
71 bool LoginManagerTest::SetUpUserDataDirectory() {
72 base::FilePath user_data_dir;
73 CHECK(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir));
74 base::FilePath local_state_path =
75 user_data_dir.Append(chrome::kLocalStateFilename);
76
77 if (!use_webview()) {
78 // Set webview disabled flag only when local state file does not exist.
79 // Otherwise, we break PRE tests that leave state in it.
80 if (!base::PathExists(local_state_path)) {
81 base::DictionaryValue local_state_dict;
82
83 // TODO(nkostylev): Fix tests that fail with webview signin.
84 local_state_dict.SetBoolean(prefs::kWebviewSigninDisabled, true);
85
86 CHECK(JSONFileValueSerializer(local_state_path)
87 .Serialize(local_state_dict));
88 }
89 }
90
91 return MixinBasedBrowserTest::SetUpUserDataDirectory();
92 }
93
64 void LoginManagerTest::RegisterUser(const std::string& user_id) { 94 void LoginManagerTest::RegisterUser(const std::string& user_id) {
65 ListPrefUpdate users_pref(g_browser_process->local_state(), "LoggedInUsers"); 95 ListPrefUpdate users_pref(g_browser_process->local_state(), "LoggedInUsers");
66 users_pref->AppendIfNotPresent(new base::StringValue(user_id)); 96 users_pref->AppendIfNotPresent(new base::StringValue(user_id));
67 } 97 }
68 98
69 void LoginManagerTest::SetExpectedCredentials(const UserContext& user_context) { 99 void LoginManagerTest::SetExpectedCredentials(const UserContext& user_context) {
70 test::UserSessionManagerTestApi session_manager_test_api( 100 test::UserSessionManagerTestApi session_manager_test_api(
71 UserSessionManager::GetInstance()); 101 UserSessionManager::GetInstance());
72 session_manager_test_api.InjectStubUserContext(user_context); 102 session_manager_test_api.InjectStubUserContext(user_context);
73 } 103 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 EXPECT_TRUE(host != NULL); 157 EXPECT_TRUE(host != NULL);
128 158
129 content::WebContents* web_contents = 159 content::WebContents* web_contents =
130 host->GetWebUILoginView()->GetWebContents(); 160 host->GetWebUILoginView()->GetWebContents();
131 EXPECT_TRUE(web_contents != NULL); 161 EXPECT_TRUE(web_contents != NULL);
132 set_web_contents(web_contents); 162 set_web_contents(web_contents);
133 js_checker_.set_web_contents(web_contents); 163 js_checker_.set_web_contents(web_contents);
134 } 164 }
135 165
136 } // namespace chromeos 166 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/login_manager_test.h ('k') | chrome/browser/chromeos/login/oobe_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698