| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/macros.h" | 6 #include "base/macros.h" |
| 7 #include "base/memory/ref_counted.h" |
| 7 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 9 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| 10 #include "chrome/browser/content_settings/cookie_settings_factory.h" | 11 #include "chrome/browser/content_settings/cookie_settings_factory.h" |
| 11 #include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" | 12 #include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" |
| 12 #include "chrome/browser/signin/fake_signin_manager_builder.h" | 13 #include "chrome/browser/signin/fake_signin_manager_builder.h" |
| 13 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 14 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 14 #include "chrome/browser/signin/signin_manager_factory.h" | 15 #include "chrome/browser/signin/signin_manager_factory.h" |
| 15 #include "chrome/browser/signin/signin_promo.h" | 16 #include "chrome/browser/signin/signin_promo.h" |
| 16 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 44 #include "content/public/browser/storage_partition.h" | 45 #include "content/public/browser/storage_partition.h" |
| 45 #include "content/public/browser/web_contents.h" | 46 #include "content/public/browser/web_contents.h" |
| 46 #include "content/public/browser/web_ui_controller.h" | 47 #include "content/public/browser/web_ui_controller.h" |
| 47 #include "content/public/common/url_constants.h" | 48 #include "content/public/common/url_constants.h" |
| 48 #include "content/public/test/browser_test_utils.h" | 49 #include "content/public/test/browser_test_utils.h" |
| 49 #include "content/public/test/test_navigation_observer.h" | 50 #include "content/public/test/test_navigation_observer.h" |
| 50 #include "google_apis/gaia/fake_gaia.h" | 51 #include "google_apis/gaia/fake_gaia.h" |
| 51 #include "google_apis/gaia/gaia_switches.h" | 52 #include "google_apis/gaia/gaia_switches.h" |
| 52 #include "google_apis/gaia/gaia_urls.h" | 53 #include "google_apis/gaia/gaia_urls.h" |
| 53 #include "net/base/url_util.h" | 54 #include "net/base/url_util.h" |
| 55 #include "net/http/http_response_headers.h" |
| 54 #include "net/test/embedded_test_server/embedded_test_server.h" | 56 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 55 #include "net/test/embedded_test_server/http_request.h" | 57 #include "net/test/embedded_test_server/http_request.h" |
| 56 #include "net/test/embedded_test_server/http_response.h" | 58 #include "net/test/embedded_test_server/http_response.h" |
| 57 #include "net/url_request/test_url_fetcher_factory.h" | 59 #include "net/url_request/test_url_fetcher_factory.h" |
| 58 #include "net/url_request/url_request_status.h" | 60 #include "net/url_request/url_request_status.h" |
| 59 #include "testing/gmock/include/gmock/gmock.h" | 61 #include "testing/gmock/include/gmock/gmock.h" |
| 60 #include "testing/gtest/include/gtest/gtest.h" | 62 #include "testing/gtest/include/gtest/gtest.h" |
| 61 #include "ui/base/l10n/l10n_util.h" | 63 #include "ui/base/l10n/l10n_util.h" |
| 62 | 64 |
| 63 using ::testing::_; | 65 using ::testing::_; |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 token_service_ = static_cast<FakeProfileOAuth2TokenService*>( | 472 token_service_ = static_cast<FakeProfileOAuth2TokenService*>( |
| 471 ProfileOAuth2TokenServiceFactory::GetInstance()->GetForProfile( | 473 ProfileOAuth2TokenServiceFactory::GetInstance()->GetForProfile( |
| 472 profile)); | 474 profile)); |
| 473 ASSERT_TRUE(token_service_); | 475 ASSERT_TRUE(token_service_); |
| 474 } | 476 } |
| 475 | 477 |
| 476 void SimulateStartCookieForOAuthLoginTokenExchangeSuccess( | 478 void SimulateStartCookieForOAuthLoginTokenExchangeSuccess( |
| 477 const std::string& cookie_string) { | 479 const std::string& cookie_string) { |
| 478 net::TestURLFetcher* fetcher = url_fetcher_factory_.GetFetcherByID(0); | 480 net::TestURLFetcher* fetcher = url_fetcher_factory_.GetFetcherByID(0); |
| 479 ASSERT_TRUE(fetcher); | 481 ASSERT_TRUE(fetcher); |
| 480 net::ResponseCookies cookies; | 482 scoped_refptr<net::HttpResponseHeaders> reponse_headers = |
| 481 cookies.push_back(cookie_string); | 483 new net::HttpResponseHeaders(""); |
| 484 reponse_headers->AddCookie(cookie_string); |
| 482 fetcher->set_status(net::URLRequestStatus()); | 485 fetcher->set_status(net::URLRequestStatus()); |
| 483 fetcher->set_response_code(net::HTTP_OK); | 486 fetcher->set_response_code(net::HTTP_OK); |
| 484 fetcher->set_cookies(cookies); | 487 fetcher->set_response_headers(reponse_headers); |
| 485 fetcher->delegate()->OnURLFetchComplete(fetcher); | 488 fetcher->delegate()->OnURLFetchComplete(fetcher); |
| 486 } | 489 } |
| 487 | 490 |
| 488 void SimulateStartAuthCodeForOAuth2TokenExchangeSuccess( | 491 void SimulateStartAuthCodeForOAuth2TokenExchangeSuccess( |
| 489 const std::string& json_response) { | 492 const std::string& json_response) { |
| 490 net::TestURLFetcher* fetcher = url_fetcher_factory_.GetFetcherByID(0); | 493 net::TestURLFetcher* fetcher = url_fetcher_factory_.GetFetcherByID(0); |
| 491 ASSERT_TRUE(fetcher); | 494 ASSERT_TRUE(fetcher); |
| 492 fetcher->set_status(net::URLRequestStatus()); | 495 fetcher->set_status(net::URLRequestStatus()); |
| 493 fetcher->set_response_code(net::HTTP_OK); | 496 fetcher->set_response_code(net::HTTP_OK); |
| 494 fetcher->SetResponseString(json_response); | 497 fetcher->SetResponseString(json_response); |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 882 ->AddObserver(&observer); | 885 ->AddObserver(&observer); |
| 883 base::RunLoop run_loop; | 886 base::RunLoop run_loop; |
| 884 EXPECT_CALL(observer, OnUntrustedLoginUIShown()) | 887 EXPECT_CALL(observer, OnUntrustedLoginUIShown()) |
| 885 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); | 888 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); |
| 886 | 889 |
| 887 ExecuteJsToSigninInSigninFrame(browser(), "email@gmail.com", "password"); | 890 ExecuteJsToSigninInSigninFrame(browser(), "email@gmail.com", "password"); |
| 888 run_loop.Run(); | 891 run_loop.Run(); |
| 889 base::RunLoop().RunUntilIdle(); | 892 base::RunLoop().RunUntilIdle(); |
| 890 } | 893 } |
| 891 #endif // OS_WIN | 894 #endif // OS_WIN |
| OLD | NEW |