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

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

Issue 10832035: Switch from SignedSettings to DeviceSettingsService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More test fixing... Created 8 years, 4 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 | Annotate | Revision Log
OLDNEW
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/parallel_authenticator.h" 5 #include "chrome/browser/chromeos/login/parallel_authenticator.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/message_loop.h" 12 #include "base/message_loop.h"
13 #include "base/string_util.h" 13 #include "base/string_util.h"
14 #include "base/stringprintf.h" 14 #include "base/stringprintf.h"
15 #include "chrome/browser/chromeos/cros/cros_library.h" 15 #include "chrome/browser/chromeos/cros/cros_library.h"
16 #include "chrome/browser/chromeos/cros/mock_cert_library.h" 16 #include "chrome/browser/chromeos/cros/mock_cert_library.h"
17 #include "chrome/browser/chromeos/cros/mock_cryptohome_library.h" 17 #include "chrome/browser/chromeos/cros/mock_cryptohome_library.h"
18 #include "chrome/browser/chromeos/cros_settings.h" 18 #include "chrome/browser/chromeos/cros_settings.h"
19 #include "chrome/browser/chromeos/cryptohome/mock_async_method_caller.h" 19 #include "chrome/browser/chromeos/cryptohome/mock_async_method_caller.h"
20 #include "chrome/browser/chromeos/login/device_settings_test_helper.h"
20 #include "chrome/browser/chromeos/login/mock_login_status_consumer.h" 21 #include "chrome/browser/chromeos/login/mock_login_status_consumer.h"
21 #include "chrome/browser/chromeos/login/mock_url_fetchers.h" 22 #include "chrome/browser/chromeos/login/mock_url_fetchers.h"
22 #include "chrome/browser/chromeos/login/mock_user_manager.h" 23 #include "chrome/browser/chromeos/login/mock_user_manager.h"
23 #include "chrome/browser/chromeos/login/test_attempt_state.h" 24 #include "chrome/browser/chromeos/login/test_attempt_state.h"
24 #include "chrome/browser/chromeos/stub_cros_settings_provider.h" 25 #include "chrome/browser/chromeos/stub_cros_settings_provider.h"
25 #include "chrome/common/net/gaia/mock_url_fetcher_factory.h" 26 #include "chrome/common/net/gaia/mock_url_fetcher_factory.h"
26 #include "chrome/test/base/testing_profile.h" 27 #include "chrome/test/base/testing_profile.h"
27 #include "chromeos/dbus/mock_cryptohome_client.h" 28 #include "chromeos/dbus/mock_cryptohome_client.h"
28 #include "chromeos/dbus/mock_dbus_thread_manager.h" 29 #include "chromeos/dbus/mock_dbus_thread_manager.h"
29 #include "content/public/test/test_browser_thread.h" 30 #include "content/public/test/test_browser_thread.h"
30 #include "googleurl/src/gurl.h" 31 #include "googleurl/src/gurl.h"
31 #include "net/base/net_errors.h" 32 #include "net/base/net_errors.h"
32 #include "net/url_request/url_request_status.h" 33 #include "net/url_request/url_request_status.h"
33 #include "testing/gmock/include/gmock/gmock.h" 34 #include "testing/gmock/include/gmock/gmock.h"
34 #include "testing/gtest/include/gtest/gtest.h" 35 #include "testing/gtest/include/gtest/gtest.h"
35 #include "third_party/cros_system_api/dbus/service_constants.h" 36 #include "third_party/cros_system_api/dbus/service_constants.h"
36 37
37 using content::BrowserThread;
38 using ::testing::AnyNumber; 38 using ::testing::AnyNumber;
39 using ::testing::DoAll; 39 using ::testing::DoAll;
40 using ::testing::Invoke; 40 using ::testing::Invoke;
41 using ::testing::Return; 41 using ::testing::Return;
42 using ::testing::SetArgPointee; 42 using ::testing::SetArgPointee;
43 using ::testing::_; 43 using ::testing::_;
44 using content::BrowserThread;
44 45
45 namespace chromeos { 46 namespace chromeos {
46 47
47 class TestOnlineAttempt : public OnlineAttempt { 48 class TestOnlineAttempt : public OnlineAttempt {
48 public: 49 public:
49 TestOnlineAttempt(AuthAttemptState* state, 50 TestOnlineAttempt(AuthAttemptState* state,
50 AuthAttemptStateResolver* resolver) 51 AuthAttemptStateResolver* resolver)
51 : OnlineAttempt(false, state, resolver) { 52 : OnlineAttempt(false, state, resolver) {
52 } 53 }
53 }; 54 };
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 202
202 MessageLoop message_loop_; 203 MessageLoop message_loop_;
203 content::TestBrowserThread ui_thread_; 204 content::TestBrowserThread ui_thread_;
204 content::TestBrowserThread file_thread_; 205 content::TestBrowserThread file_thread_;
205 content::TestBrowserThread io_thread_; 206 content::TestBrowserThread io_thread_;
206 207
207 std::string username_; 208 std::string username_;
208 std::string password_; 209 std::string password_;
209 std::string hash_ascii_; 210 std::string hash_ascii_;
210 211
212 ScopedDeviceSettingsTestHelper device_settings_test_helper_;
213
211 // Initializes / shuts down a stub CrosLibrary. 214 // Initializes / shuts down a stub CrosLibrary.
212 chromeos::ScopedStubCrosEnabler stub_cros_enabler_; 215 ScopedStubCrosEnabler stub_cros_enabler_;
213 216
214 // Mocks, destroyed by CrosLibrary class. 217 // Mocks, destroyed by CrosLibrary class.
215 MockCertLibrary* mock_cert_library_; 218 MockCertLibrary* mock_cert_library_;
216 MockCryptohomeLibrary* mock_cryptohome_library_; 219 MockCryptohomeLibrary* mock_cryptohome_library_;
217 ScopedMockUserManagerEnabler mock_user_manager_; 220 ScopedMockUserManagerEnabler mock_user_manager_;
218 221
219 cryptohome::MockAsyncMethodCaller* mock_caller_; 222 cryptohome::MockAsyncMethodCaller* mock_caller_;
220 223
221 MockConsumer consumer_; 224 MockConsumer consumer_;
222 scoped_refptr<ParallelAuthenticator> auth_; 225 scoped_refptr<ParallelAuthenticator> auth_;
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 device_settings_provider = 334 device_settings_provider =
332 CrosSettings::Get()->GetProvider(chromeos::kReportDeviceVersionInfo); 335 CrosSettings::Get()->GetProvider(chromeos::kReportDeviceVersionInfo);
333 EXPECT_TRUE(device_settings_provider != NULL); 336 EXPECT_TRUE(device_settings_provider != NULL);
334 EXPECT_TRUE( 337 EXPECT_TRUE(
335 CrosSettings::Get()->RemoveSettingsProvider(device_settings_provider)); 338 CrosSettings::Get()->RemoveSettingsProvider(device_settings_provider));
336 CrosSettings::Get()->AddSettingsProvider(&stub_settings_provider); 339 CrosSettings::Get()->AddSettingsProvider(&stub_settings_provider);
337 CrosSettings::Get()->SetBoolean(kPolicyMissingMitigationMode, true); 340 CrosSettings::Get()->SetBoolean(kPolicyMissingMitigationMode, true);
338 341
339 EXPECT_EQ(ParallelAuthenticator::CONTINUE, 342 EXPECT_EQ(ParallelAuthenticator::CONTINUE,
340 SetAndResolveState(auth_, state_.release())); 343 SetAndResolveState(auth_, state_.release()));
341 // Let the owner verification run on the FILE thread... 344 // Let the owner verification run.
342 message_loop_.RunAllPending(); 345 device_settings_test_helper_.Flush();
343 // and test that the mount has succeeded. 346 // and test that the mount has succeeded.
344 state_.reset(new TestAttemptState(username_, 347 state_.reset(new TestAttemptState(username_,
345 password_, 348 password_,
346 hash_ascii_, 349 hash_ascii_,
347 "", 350 "",
348 "", 351 "",
349 false)); 352 false));
350 state_->PresetCryptohomeStatus(true, cryptohome::MOUNT_ERROR_NONE); 353 state_->PresetCryptohomeStatus(true, cryptohome::MOUNT_ERROR_NONE);
351 EXPECT_EQ(ParallelAuthenticator::OWNER_REQUIRED, 354 EXPECT_EQ(ParallelAuthenticator::OWNER_REQUIRED,
352 SetAndResolveState(auth_, state_.release())); 355 SetAndResolveState(auth_, state_.release()));
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 .RetiresOnSaturation(); 753 .RetiresOnSaturation();
751 EXPECT_CALL(*mock_cryptohome_library_, GetSystemSalt()) 754 EXPECT_CALL(*mock_cryptohome_library_, GetSystemSalt())
752 .WillOnce(Return(std::string())) 755 .WillOnce(Return(std::string()))
753 .RetiresOnSaturation(); 756 .RetiresOnSaturation();
754 757
755 auth_->AuthenticateToUnlock(username_, ""); 758 auth_->AuthenticateToUnlock(username_, "");
756 message_loop_.Run(); 759 message_loop_.Run();
757 } 760 }
758 761
759 } // namespace chromeos 762 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698