| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_utils.h" | 5 #include "chrome/browser/chromeos/login/login_utils.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 // Map BrowserThread::IO to this loop. This allows posting to IO but nothing | 175 // Map BrowserThread::IO to this loop. This allows posting to IO but nothing |
| 176 // will be executed. | 176 // will be executed. |
| 177 io_thread_.reset( | 177 io_thread_.reset( |
| 178 new content::TestBrowserThread(BrowserThread::IO, fake_io_loop)); | 178 new content::TestBrowserThread(BrowserThread::IO, fake_io_loop)); |
| 179 | 179 |
| 180 ASSERT_TRUE(scoped_temp_dir_.CreateUniqueTempDir()); | 180 ASSERT_TRUE(scoped_temp_dir_.CreateUniqueTempDir()); |
| 181 | 181 |
| 182 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 182 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 183 command_line->AppendSwitchASCII(switches::kDeviceManagementUrl, kDMServer); | 183 command_line->AppendSwitchASCII(switches::kDeviceManagementUrl, kDMServer); |
| 184 command_line->AppendSwitchASCII(switches::kLoginProfile, "user"); | 184 command_line->AppendSwitchASCII(switches::kLoginProfile, "user"); |
| 185 // TODO(mnissler): Figure out how to beat this test into submission on |
| 186 // OAuth2 path. |
| 187 command_line->AppendSwitch(switches::kForceOAuth1); |
| 185 | 188 |
| 186 local_state_.Get()->RegisterStringPref(prefs::kApplicationLocale, ""); | 189 local_state_.Get()->RegisterStringPref(prefs::kApplicationLocale, ""); |
| 187 | 190 |
| 188 // DBusThreadManager should be initialized before io_thread_state_, as | 191 // DBusThreadManager should be initialized before io_thread_state_, as |
| 189 // DBusThreadManager is used from chromeos::ProxyConfigServiceImpl, | 192 // DBusThreadManager is used from chromeos::ProxyConfigServiceImpl, |
| 190 // which is part of io_thread_state_. | 193 // which is part of io_thread_state_. |
| 191 DBusThreadManager::InitializeForTesting(&mock_dbus_thread_manager_); | 194 DBusThreadManager::InitializeForTesting(&mock_dbus_thread_manager_); |
| 192 | 195 |
| 193 input_method::InitializeForTesting(&mock_input_method_manager_); | 196 input_method::InitializeForTesting(&mock_input_method_manager_); |
| 194 disks::DiskMountManager::InitializeForTesting(&mock_disk_mount_manager_); | 197 disks::DiskMountManager::InitializeForTesting(&mock_disk_mount_manager_); |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 .WillRepeatedly(Return(std::string("stub_system_salt"))); | 396 .WillRepeatedly(Return(std::string("stub_system_salt"))); |
| 394 EXPECT_CALL(*mock_async_method_caller_, AsyncMount(_, _, _, _)) | 397 EXPECT_CALL(*mock_async_method_caller_, AsyncMount(_, _, _, _)) |
| 395 .WillRepeatedly(Return()); | 398 .WillRepeatedly(Return()); |
| 396 | 399 |
| 397 scoped_refptr<Authenticator> authenticator = | 400 scoped_refptr<Authenticator> authenticator = |
| 398 LoginUtils::Get()->CreateAuthenticator(this); | 401 LoginUtils::Get()->CreateAuthenticator(this); |
| 399 authenticator->CompleteLogin(ProfileManager::GetDefaultProfile(), | 402 authenticator->CompleteLogin(ProfileManager::GetDefaultProfile(), |
| 400 username, | 403 username, |
| 401 "password"); | 404 "password"); |
| 402 | 405 |
| 403 const bool kPendingRequests = false; | |
| 404 const bool kUsingOAuth = true; | 406 const bool kUsingOAuth = true; |
| 405 // Setting |kHasCookies| to false prevents ProfileAuthData::Transfer from | 407 // Setting |kHasCookies| to false prevents ProfileAuthData::Transfer from |
| 406 // waiting for an IO task before proceeding. | 408 // waiting for an IO task before proceeding. |
| 407 const bool kHasCookies = false; | 409 const bool kHasCookies = false; |
| 408 LoginUtils::Get()->PrepareProfile(username, std::string(), "password", | 410 LoginUtils::Get()->PrepareProfile(username, std::string(), "password", |
| 409 kPendingRequests, kUsingOAuth, | 411 kUsingOAuth, kHasCookies, this); |
| 410 kHasCookies, this); | |
| 411 device_settings_test_helper.Flush(); | 412 device_settings_test_helper.Flush(); |
| 412 RunUntilIdle(); | 413 RunUntilIdle(); |
| 413 } | 414 } |
| 414 | 415 |
| 415 net::TestURLFetcher* PrepareOAuthFetcher(const std::string& expected_url) { | 416 net::TestURLFetcher* PrepareOAuthFetcher(const std::string& expected_url) { |
| 416 net::TestURLFetcher* fetcher = test_url_fetcher_factory_.GetFetcherByID(0); | 417 net::TestURLFetcher* fetcher = test_url_fetcher_factory_.GetFetcherByID(0); |
| 417 EXPECT_TRUE(fetcher); | 418 EXPECT_TRUE(fetcher); |
| 418 EXPECT_TRUE(fetcher->delegate()); | 419 EXPECT_TRUE(fetcher->delegate()); |
| 419 EXPECT_TRUE(StartsWithASCII(fetcher->GetOriginalURL().spec(), | 420 EXPECT_TRUE(StartsWithASCII(fetcher->GetOriginalURL().spec(), |
| 420 expected_url, | 421 expected_url, |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 665 } | 666 } |
| 666 | 667 |
| 667 INSTANTIATE_TEST_CASE_P( | 668 INSTANTIATE_TEST_CASE_P( |
| 668 LoginUtilsBlockingLoginTestInstance, | 669 LoginUtilsBlockingLoginTestInstance, |
| 669 LoginUtilsBlockingLoginTest, | 670 LoginUtilsBlockingLoginTest, |
| 670 testing::Values(0, 1, 2, 3, 4, 5)); | 671 testing::Values(0, 1, 2, 3, 4, 5)); |
| 671 | 672 |
| 672 } // namespace | 673 } // namespace |
| 673 | 674 |
| 674 } | 675 } |
| OLD | NEW |