| 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/google_authenticator.h" | 5 #include "chrome/browser/chromeos/login/google_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 "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" | 18 #include "chrome/browser/chromeos/cros/mock_library_loader.h" |
| 19 #include "chrome/browser/chromeos/login/client_login_response_handler.h" | 19 #include "chrome/browser/chromeos/login/client_login_response_handler.h" |
| 20 #include "chrome/browser/chromeos/login/issue_response_handler.h" | 20 #include "chrome/browser/chromeos/login/issue_response_handler.h" |
| 21 #include "chrome/browser/chromeos/login/mock_auth_response_handler.h" | 21 #include "chrome/browser/chromeos/login/mock_auth_response_handler.h" |
| 22 #include "chrome/browser/chromeos/login/mock_login_status_consumer.h" | 22 #include "chrome/browser/chromeos/login/mock_login_status_consumer.h" |
| 23 #include "chrome/browser/chromeos/login/mock_url_fetchers.h" | 23 #include "chrome/browser/chromeos/login/mock_url_fetchers.h" |
| 24 #include "chrome/browser/chromeos/login/mock_user_manager.h" | 24 #include "chrome/browser/chromeos/login/mock_user_manager.h" |
| 25 #include "chrome/browser/chromeos/login/user_manager.h" | 25 #include "chrome/browser/chromeos/login/user_manager.h" |
| 26 #include "chrome/common/chrome_paths.h" | 26 #include "chrome/common/chrome_paths.h" |
| 27 #include "chrome/common/net/gaia/gaia_auth_fetcher_unittest.h" | 27 #include "chrome/common/net/gaia/gaia_auth_fetcher_unittest.h" |
| 28 #include "chrome/common/net/gaia/gaia_urls.h" | 28 #include "chrome/common/net/gaia/gaia_urls.h" |
| 29 #include "chrome/test/base/testing_browser_process_test.h" |
| 29 #include "chrome/test/base/testing_profile.h" | 30 #include "chrome/test/base/testing_profile.h" |
| 30 #include "content/browser/browser_thread.h" | 31 #include "content/browser/browser_thread.h" |
| 31 #include "content/common/url_fetcher.h" | 32 #include "content/common/url_fetcher.h" |
| 32 #include "googleurl/src/gurl.h" | 33 #include "googleurl/src/gurl.h" |
| 33 #include "net/base/net_errors.h" | 34 #include "net/base/net_errors.h" |
| 34 #include "net/url_request/url_request_status.h" | 35 #include "net/url_request/url_request_status.h" |
| 35 #include "testing/gmock/include/gmock/gmock.h" | 36 #include "testing/gmock/include/gmock/gmock.h" |
| 36 #include "testing/gtest/include/gtest/gtest.h" | 37 #include "testing/gtest/include/gtest/gtest.h" |
| 37 | 38 |
| 38 using file_util::CloseFile; | 39 using file_util::CloseFile; |
| 39 using file_util::CreateAndOpenTemporaryFile; | 40 using file_util::CreateAndOpenTemporaryFile; |
| 40 using file_util::CreateAndOpenTemporaryFileInDir; | 41 using file_util::CreateAndOpenTemporaryFileInDir; |
| 41 using file_util::Delete; | 42 using file_util::Delete; |
| 42 using file_util::WriteFile; | 43 using file_util::WriteFile; |
| 43 using ::testing::AnyNumber; | 44 using ::testing::AnyNumber; |
| 44 using ::testing::DoAll; | 45 using ::testing::DoAll; |
| 45 using ::testing::Eq; | 46 using ::testing::Eq; |
| 46 using ::testing::Invoke; | 47 using ::testing::Invoke; |
| 47 using ::testing::Return; | 48 using ::testing::Return; |
| 48 using ::testing::SetArgumentPointee; | 49 using ::testing::SetArgumentPointee; |
| 49 using ::testing::_; | 50 using ::testing::_; |
| 50 | 51 |
| 51 namespace chromeos { | 52 namespace chromeos { |
| 52 | 53 |
| 53 class GoogleAuthenticatorTest : public ::testing::Test { | 54 class GoogleAuthenticatorTest : public TestingBrowserProcessTest { |
| 54 public: | 55 public: |
| 55 GoogleAuthenticatorTest() | 56 GoogleAuthenticatorTest() |
| 56 : message_loop_ui_(MessageLoop::TYPE_UI), | 57 : message_loop_ui_(MessageLoop::TYPE_UI), |
| 57 ui_thread_(BrowserThread::UI, &message_loop_ui_), | 58 ui_thread_(BrowserThread::UI, &message_loop_ui_), |
| 58 username_("me@nowhere.org"), | 59 username_("me@nowhere.org"), |
| 59 password_("fakepass"), | 60 password_("fakepass"), |
| 60 result_("", "", "", ""), | 61 result_("", "", "", ""), |
| 61 bytes_as_ascii_("ffff"), | 62 bytes_as_ascii_("ffff"), |
| 62 user_manager_(new MockUserManager) { | 63 user_manager_(new MockUserManager) { |
| 63 memset(fake_hash_, 0, sizeof(fake_hash_)); | 64 memset(fake_hash_, 0, sizeof(fake_hash_)); |
| (...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 705 &profile, username_, hash_ascii_, std::string(), std::string()); | 706 &profile, username_, hash_ascii_, std::string(), std::string()); |
| 706 | 707 |
| 707 // Post a task to cancel the login attempt. | 708 // Post a task to cancel the login attempt. |
| 708 CancelLogin(auth.get()); | 709 CancelLogin(auth.get()); |
| 709 | 710 |
| 710 // Run the UI thread until we exit it gracefully. | 711 // Run the UI thread until we exit it gracefully. |
| 711 message_loop_ui_.Run(); | 712 message_loop_ui_.Run(); |
| 712 } | 713 } |
| 713 | 714 |
| 714 } // namespace chromeos | 715 } // namespace chromeos |
| OLD | NEW |