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

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

Issue 10626002: Reland "Remove chromeos::LibraryLoader" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix copyright Created 8 years, 6 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/mock_library_loader.h"
19 #include "chrome/browser/chromeos/cros_settings.h" 18 #include "chrome/browser/chromeos/cros_settings.h"
20 #include "chrome/browser/chromeos/cryptohome/mock_async_method_caller.h" 19 #include "chrome/browser/chromeos/cryptohome/mock_async_method_caller.h"
21 #include "chrome/browser/chromeos/login/mock_login_status_consumer.h" 20 #include "chrome/browser/chromeos/login/mock_login_status_consumer.h"
22 #include "chrome/browser/chromeos/login/mock_url_fetchers.h" 21 #include "chrome/browser/chromeos/login/mock_url_fetchers.h"
23 #include "chrome/browser/chromeos/login/mock_user_manager.h" 22 #include "chrome/browser/chromeos/login/mock_user_manager.h"
24 #include "chrome/browser/chromeos/login/test_attempt_state.h" 23 #include "chrome/browser/chromeos/login/test_attempt_state.h"
25 #include "chrome/browser/chromeos/stub_cros_settings_provider.h" 24 #include "chrome/browser/chromeos/stub_cros_settings_provider.h"
26 #include "chrome/common/net/gaia/mock_url_fetcher_factory.h" 25 #include "chrome/common/net/gaia/mock_url_fetcher_factory.h"
27 #include "chrome/test/base/testing_profile.h" 26 #include "chrome/test/base/testing_profile.h"
28 #include "chromeos/dbus/mock_cryptohome_client.h" 27 #include "chromeos/dbus/mock_cryptohome_client.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 DCHECK(!mock_caller_); 69 DCHECK(!mock_caller_);
71 } 70 }
72 71
73 virtual void SetUp() { 72 virtual void SetUp() {
74 mock_caller_ = new cryptohome::MockAsyncMethodCaller; 73 mock_caller_ = new cryptohome::MockAsyncMethodCaller;
75 cryptohome::AsyncMethodCaller::InitializeForTesting(mock_caller_); 74 cryptohome::AsyncMethodCaller::InitializeForTesting(mock_caller_);
76 75
77 chromeos::CrosLibrary::TestApi* test_api = 76 chromeos::CrosLibrary::TestApi* test_api =
78 chromeos::CrosLibrary::Get()->GetTestApi(); 77 chromeos::CrosLibrary::Get()->GetTestApi();
79 78
80 loader_ = new MockLibraryLoader();
81 ON_CALL(*loader_, Load(_))
82 .WillByDefault(Return(true));
83 EXPECT_CALL(*loader_, Load(_))
84 .Times(AnyNumber());
85
86 test_api->SetLibraryLoader(loader_, true);
87
88 mock_cryptohome_library_ = new MockCryptohomeLibrary(); 79 mock_cryptohome_library_ = new MockCryptohomeLibrary();
89 test_api->SetCryptohomeLibrary(mock_cryptohome_library_, true); 80 test_api->SetCryptohomeLibrary(mock_cryptohome_library_, true);
90 81
91 mock_cert_library_ = new MockCertLibrary(); 82 mock_cert_library_ = new MockCertLibrary();
92 EXPECT_CALL(*mock_cert_library_, LoadKeyStore()).Times(AnyNumber()); 83 EXPECT_CALL(*mock_cert_library_, LoadKeyStore()).Times(AnyNumber());
93 test_api->SetCertLibrary(mock_cert_library_, true); 84 test_api->SetCertLibrary(mock_cert_library_, true);
94 85
95 io_thread_.Start(); 86 io_thread_.Start();
96 87
97 auth_ = new ParallelAuthenticator(&consumer_); 88 auth_ = new ParallelAuthenticator(&consumer_);
98 auth_->set_using_oauth(false); 89 auth_->set_using_oauth(false);
99 state_.reset(new TestAttemptState(username_, 90 state_.reset(new TestAttemptState(username_,
100 password_, 91 password_,
101 hash_ascii_, 92 hash_ascii_,
102 "", 93 "",
103 "", 94 "",
104 false)); 95 false));
105 } 96 }
106 97
107 // Tears down the test fixture. 98 // Tears down the test fixture.
108 virtual void TearDown() { 99 virtual void TearDown() {
109 // Prevent bogus gMock leak check from firing. 100 // Prevent bogus gMock leak check from firing.
110 chromeos::CrosLibrary::TestApi* test_api = 101 chromeos::CrosLibrary::TestApi* test_api =
111 chromeos::CrosLibrary::Get()->GetTestApi(); 102 chromeos::CrosLibrary::Get()->GetTestApi();
112 test_api->SetLibraryLoader(NULL, false);
113 test_api->SetCryptohomeLibrary(NULL, false); 103 test_api->SetCryptohomeLibrary(NULL, false);
114 104
115 cryptohome::AsyncMethodCaller::Shutdown(); 105 cryptohome::AsyncMethodCaller::Shutdown();
116 mock_caller_ = NULL; 106 mock_caller_ = NULL;
117 } 107 }
118 108
119 FilePath PopulateTempFile(const char* data, int data_len) { 109 FilePath PopulateTempFile(const char* data, int data_len) {
120 FilePath out; 110 FilePath out;
121 FILE* tmp_file = file_util::CreateAndOpenTemporaryFile(&out); 111 FILE* tmp_file = file_util::CreateAndOpenTemporaryFile(&out);
122 EXPECT_NE(tmp_file, static_cast<FILE*>(NULL)); 112 EXPECT_NE(tmp_file, static_cast<FILE*>(NULL));
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 std::string username_; 207 std::string username_;
218 std::string password_; 208 std::string password_;
219 std::string hash_ascii_; 209 std::string hash_ascii_;
220 210
221 // Initializes / shuts down a stub CrosLibrary. 211 // Initializes / shuts down a stub CrosLibrary.
222 chromeos::ScopedStubCrosEnabler stub_cros_enabler_; 212 chromeos::ScopedStubCrosEnabler stub_cros_enabler_;
223 213
224 // Mocks, destroyed by CrosLibrary class. 214 // Mocks, destroyed by CrosLibrary class.
225 MockCertLibrary* mock_cert_library_; 215 MockCertLibrary* mock_cert_library_;
226 MockCryptohomeLibrary* mock_cryptohome_library_; 216 MockCryptohomeLibrary* mock_cryptohome_library_;
227 MockLibraryLoader* loader_;
228 ScopedMockUserManagerEnabler mock_user_manager_; 217 ScopedMockUserManagerEnabler mock_user_manager_;
229 218
230 cryptohome::MockAsyncMethodCaller* mock_caller_; 219 cryptohome::MockAsyncMethodCaller* mock_caller_;
231 220
232 MockConsumer consumer_; 221 MockConsumer consumer_;
233 scoped_refptr<ParallelAuthenticator> auth_; 222 scoped_refptr<ParallelAuthenticator> auth_;
234 scoped_ptr<TestAttemptState> state_; 223 scoped_ptr<TestAttemptState> state_;
235 }; 224 };
236 225
237 TEST_F(ParallelAuthenticatorTest, OnLoginSuccess) { 226 TEST_F(ParallelAuthenticatorTest, OnLoginSuccess) {
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
761 .RetiresOnSaturation(); 750 .RetiresOnSaturation();
762 EXPECT_CALL(*mock_cryptohome_library_, HashPassword(_)) 751 EXPECT_CALL(*mock_cryptohome_library_, HashPassword(_))
763 .WillOnce(Return(std::string())) 752 .WillOnce(Return(std::string()))
764 .RetiresOnSaturation(); 753 .RetiresOnSaturation();
765 754
766 auth_->AuthenticateToUnlock(username_, ""); 755 auth_->AuthenticateToUnlock(username_, "");
767 message_loop_.Run(); 756 message_loop_.Run();
768 } 757 }
769 758
770 } // namespace chromeos 759 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/online_attempt_unittest.cc ('k') | chrome/browser/chromeos/login/signed_settings_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698