Chromium Code Reviews| Index: chrome/browser/history/web_history_service_unittest.cc |
| diff --git a/chrome/browser/history/web_history_service_unittest.cc b/chrome/browser/history/web_history_service_unittest.cc |
| index abd6259d3ca0c74794ef4ff6936231e6b7b9912a..5700f9b67558ecfa43da59b431ae66261220770d 100644 |
| --- a/chrome/browser/history/web_history_service_unittest.cc |
| +++ b/chrome/browser/history/web_history_service_unittest.cc |
| @@ -2,17 +2,22 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#include "chrome/browser/history/web_history_service.h" |
| +#include "components/history/core/browser/web_history_service.h" |
| #include "base/memory/scoped_ptr.h" |
| #include "base/run_loop.h" |
| #include "chrome/browser/history/web_history_service_factory.h" |
| +#include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| +#include "chrome/browser/signin/signin_manager_factory.h" |
| #include "chrome/browser/sync/profile_sync_service.h" |
| #include "chrome/browser/sync/profile_sync_service_factory.h" |
| #include "chrome/browser/sync/profile_sync_service_mock.h" |
| #include "chrome/test/base/testing_profile.h" |
| +#include "components/signin/core/browser/profile_oauth2_token_service.h" |
| +#include "components/signin/core/browser/signin_manager.h" |
| #include "content/public/test/test_browser_thread_bundle.h" |
| #include "net/http/http_status_code.h" |
| +#include "net/url_request/url_request_context_getter.h" |
| #include "testing/gmock/include/gmock/gmock.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| @@ -25,13 +30,14 @@ namespace { |
| // TestRequest instead of a normal request. |
| class TestingWebHistoryService : public WebHistoryService { |
| public: |
| - explicit TestingWebHistoryService(Profile* profile) |
| - : WebHistoryService(profile), |
| - profile_(profile), |
| - expected_url_(GURL()), |
| - expected_audio_history_value_(false), |
| - current_expected_post_data_("") { |
| - } |
| + explicit TestingWebHistoryService( |
| + ProfileOAuth2TokenService* token_service, |
| + SigninManagerBase* signin_manager, |
| + const scoped_refptr<net::URLRequestContextGetter>& request_context) |
| + : WebHistoryService(token_service, signin_manager, request_context), |
| + expected_url_(GURL()), |
| + expected_audio_history_value_(false), |
| + current_expected_post_data_("") {} |
| ~TestingWebHistoryService() override {} |
| WebHistoryService::Request* CreateRequest( |
| @@ -69,7 +75,6 @@ class TestingWebHistoryService : public WebHistoryService { |
| } |
| private: |
| - Profile* profile_; |
| GURL expected_url_; |
| bool expected_audio_history_value_; |
| std::string current_expected_post_data_; |
| @@ -81,13 +86,11 @@ class TestingWebHistoryService : public WebHistoryService { |
| // A testing request class that allows expected values to be filled in. |
| class TestRequest : public WebHistoryService::Request { |
| public: |
| - TestRequest(Profile* profile, |
| - const GURL& url, |
| + TestRequest(const GURL& url, |
| const WebHistoryService::CompletionCallback& callback, |
| int response_code, |
| const std::string& response_body) |
| - : profile_(profile), |
| - web_history_service_(nullptr), |
| + : web_history_service_(nullptr), |
| url_(url), |
| callback_(callback), |
| response_code_(response_code), |
| @@ -96,12 +99,10 @@ class TestRequest : public WebHistoryService::Request { |
| is_pending_(false) { |
| } |
| - TestRequest(Profile* profile, |
| - const GURL& url, |
| + TestRequest(const GURL& url, |
| const WebHistoryService::CompletionCallback& callback, |
| TestingWebHistoryService* web_history_service) |
| - : profile_(profile), |
| - web_history_service_(web_history_service), |
| + : web_history_service_(web_history_service), |
| url_(url), |
| callback_(callback), |
| response_code_(net::HTTP_OK), |
| @@ -138,7 +139,6 @@ class TestRequest : public WebHistoryService::Request { |
| } |
| private: |
| - Profile* profile_; |
| TestingWebHistoryService* web_history_service_; |
| GURL url_; |
| WebHistoryService::CompletionCallback callback_; |
| @@ -154,7 +154,7 @@ WebHistoryService::Request* TestingWebHistoryService::CreateRequest( |
| const GURL& url, const CompletionCallback& callback) { |
| EXPECT_EQ(expected_url_, url); |
| WebHistoryService::Request* request = |
| - new TestRequest(profile_, url, callback, this); |
| + new TestRequest(url, callback, this); |
| expected_post_data_[request] = current_expected_post_data_; |
| return request; |
| } |
| @@ -195,8 +195,12 @@ std::string TestingWebHistoryService::GetExpectedAudioHistoryValue() { |
| return "false"; |
| } |
| -static KeyedService* BuildWebHistoryService(content::BrowserContext* profile) { |
| - return new TestingWebHistoryService(static_cast<Profile*>(profile)); |
| +static KeyedService* BuildWebHistoryService(content::BrowserContext* context) { |
| + Profile* profile = static_cast<Profile*>(context); |
|
droger
2015/01/28 11:03:15
You can use Profile::FromBrowserContext() here ins
|
| + return new TestingWebHistoryService( |
| + ProfileOAuth2TokenServiceFactory::GetForProfile(profile), |
| + SigninManagerFactory::GetForProfile(profile), |
| + profile->GetRequestContext()); |
| } |
| } // namespace |
| @@ -344,7 +348,6 @@ TEST_F(WebHistoryServiceTest, VerifyReadResponse) { |
| WebHistoryService::CompletionCallback completion_callback; |
| scoped_ptr<WebHistoryService::Request> request( |
| new TestRequest( |
| - profile(), |
| GURL("http://history.google.com/"), |
| completion_callback, |
| net::HTTP_OK, /* response code */ |
| @@ -362,7 +365,6 @@ TEST_F(WebHistoryServiceTest, VerifyReadResponse) { |
| // as expected. |
| scoped_ptr<WebHistoryService::Request> request2( |
| new TestRequest( |
| - profile(), |
| GURL("http://history.google.com/"), |
| completion_callback, |
| net::HTTP_OK, |
| @@ -379,7 +381,6 @@ TEST_F(WebHistoryServiceTest, VerifyReadResponse) { |
| // Test that a bad response code returns false. |
| scoped_ptr<WebHistoryService::Request> request3( |
| new TestRequest( |
| - profile(), |
| GURL("http://history.google.com/"), |
| completion_callback, |
| net::HTTP_UNAUTHORIZED, |
| @@ -397,7 +398,6 @@ TEST_F(WebHistoryServiceTest, VerifyReadResponse) { |
| // This test tests how that situation is handled. |
| scoped_ptr<WebHistoryService::Request> request4( |
| new TestRequest( |
| - profile(), |
| GURL("http://history.google.com/"), |
| completion_callback, |
| net::HTTP_OK, |
| @@ -412,7 +412,6 @@ TEST_F(WebHistoryServiceTest, VerifyReadResponse) { |
| // Test that improperly formatted response returns false. |
| scoped_ptr<WebHistoryService::Request> request5( |
| new TestRequest( |
| - profile(), |
| GURL("http://history.google.com/"), |
| completion_callback, |
| net::HTTP_OK, |