OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
15 #include "base/string_util.h" | 15 #include "base/string_util.h" |
16 #include "base/stringprintf.h" | 16 #include "base/stringprintf.h" |
| 17 #include "base/test/thread_test_helper.h" |
17 #include "chrome/browser/chromeos/cros/mock_cryptohome_library.h" | 18 #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/mock_library_loader.h" |
19 #include "chrome/browser/chromeos/login/mock_auth_response_handler.h" | 20 #include "chrome/browser/chromeos/login/mock_auth_response_handler.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/test_attempt_state.h" | 23 #include "chrome/browser/chromeos/login/test_attempt_state.h" |
23 #include "chrome/common/chrome_paths.h" | 24 #include "chrome/common/chrome_paths.h" |
24 #include "chrome/common/net/gaia/gaia_auth_fetcher_unittest.h" | 25 #include "chrome/common/net/gaia/gaia_auth_fetcher_unittest.h" |
25 #include "chrome/test/testing_profile.h" | 26 #include "chrome/test/testing_profile.h" |
26 #include "chrome/test/thread_test_helper.h" | |
27 #include "content/browser/browser_thread.h" | 27 #include "content/browser/browser_thread.h" |
28 #include "content/common/url_fetcher.h" | 28 #include "content/common/url_fetcher.h" |
29 #include "googleurl/src/gurl.h" | 29 #include "googleurl/src/gurl.h" |
30 #include "net/base/net_errors.h" | 30 #include "net/base/net_errors.h" |
31 #include "net/url_request/url_request_status.h" | 31 #include "net/url_request/url_request_status.h" |
32 #include "testing/gmock/include/gmock/gmock.h" | 32 #include "testing/gmock/include/gmock/gmock.h" |
33 #include "testing/gtest/include/gtest/gtest.h" | 33 #include "testing/gtest/include/gtest/gtest.h" |
34 | 34 |
35 using file_util::CloseFile; | 35 using file_util::CloseFile; |
36 using file_util::CreateAndOpenTemporaryFile; | 36 using file_util::CreateAndOpenTemporaryFile; |
37 using file_util::CreateAndOpenTemporaryFileInDir; | 37 using file_util::CreateAndOpenTemporaryFileInDir; |
38 using file_util::Delete; | 38 using file_util::Delete; |
39 using file_util::WriteFile; | 39 using file_util::WriteFile; |
40 using ::testing::AnyNumber; | 40 using ::testing::AnyNumber; |
41 using ::testing::DoAll; | 41 using ::testing::DoAll; |
42 using ::testing::Invoke; | 42 using ::testing::Invoke; |
43 using ::testing::Return; | 43 using ::testing::Return; |
44 using ::testing::SetArgumentPointee; | 44 using ::testing::SetArgumentPointee; |
45 using ::testing::_; | 45 using ::testing::_; |
46 | 46 |
47 namespace chromeos { | 47 namespace chromeos { |
48 class ResolveChecker : public ThreadTestHelper { | 48 class ResolveChecker : public base::ThreadTestHelper { |
49 public: | 49 public: |
50 ResolveChecker(TestAttemptState* state, | 50 ResolveChecker(TestAttemptState* state, |
51 ParallelAuthenticator* auth, | 51 ParallelAuthenticator* auth, |
52 ParallelAuthenticator::AuthState expected) | 52 ParallelAuthenticator::AuthState expected) |
53 : ThreadTestHelper(BrowserThread::IO), | 53 : base::ThreadTestHelper( |
| 54 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)), |
54 state_(state), | 55 state_(state), |
55 auth_(auth), | 56 auth_(auth), |
56 expected_(expected) { | 57 expected_(expected) { |
57 } | 58 } |
58 ~ResolveChecker() {} | 59 ~ResolveChecker() {} |
59 | 60 |
60 virtual void RunTest() { | 61 virtual void RunTest() { |
61 auth_->set_attempt_state(state_); | 62 auth_->set_attempt_state(state_); |
62 set_test_result(expected_ == auth_->ResolveState()); | 63 set_test_result(expected_ == auth_->ResolveState()); |
63 } | 64 } |
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
723 FilePath tmp_file_path = FakeLocalaccountFile(username_); | 724 FilePath tmp_file_path = FakeLocalaccountFile(username_); |
724 ReadLocalaccountFile(auth_.get(), tmp_file_path.BaseName().value()); | 725 ReadLocalaccountFile(auth_.get(), tmp_file_path.BaseName().value()); |
725 | 726 |
726 auth_->AuthenticateToUnlock(username_, ""); | 727 auth_->AuthenticateToUnlock(username_, ""); |
727 message_loop_.Run(); | 728 message_loop_.Run(); |
728 | 729 |
729 Delete(tmp_file_path, false); | 730 Delete(tmp_file_path, false); |
730 } | 731 } |
731 | 732 |
732 } // namespace chromeos | 733 } // namespace chromeos |
OLD | NEW |