| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/history/core/browser/web_history_service.h" | 5 #include "components/history/core/browser/web_history_service.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "chrome/browser/history/web_history_service_factory.h" | 9 #include "chrome/browser/history/web_history_service_factory.h" |
| 10 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 10 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 Request* request) { | 188 Request* request) { |
| 189 return expected_post_data_[request]; | 189 return expected_post_data_[request]; |
| 190 } | 190 } |
| 191 | 191 |
| 192 std::string TestingWebHistoryService::GetExpectedAudioHistoryValue() { | 192 std::string TestingWebHistoryService::GetExpectedAudioHistoryValue() { |
| 193 if (expected_audio_history_value_) | 193 if (expected_audio_history_value_) |
| 194 return "true"; | 194 return "true"; |
| 195 return "false"; | 195 return "false"; |
| 196 } | 196 } |
| 197 | 197 |
| 198 static KeyedService* BuildWebHistoryService(content::BrowserContext* context) { | 198 static scoped_ptr<KeyedService> BuildWebHistoryService( |
| 199 content::BrowserContext* context) { |
| 199 Profile* profile = static_cast<Profile*>(context); | 200 Profile* profile = static_cast<Profile*>(context); |
| 200 return new TestingWebHistoryService( | 201 return make_scoped_ptr(new TestingWebHistoryService( |
| 201 ProfileOAuth2TokenServiceFactory::GetForProfile(profile), | 202 ProfileOAuth2TokenServiceFactory::GetForProfile(profile), |
| 202 SigninManagerFactory::GetForProfile(profile), | 203 SigninManagerFactory::GetForProfile(profile), |
| 203 profile->GetRequestContext()); | 204 profile->GetRequestContext())); |
| 204 } | 205 } |
| 205 | 206 |
| 206 } // namespace | 207 } // namespace |
| 207 | 208 |
| 208 // A test class used for testing the WebHistoryService class. | 209 // A test class used for testing the WebHistoryService class. |
| 209 // In order for WebHistoryService to be valid, we must have a valid | 210 // In order for WebHistoryService to be valid, we must have a valid |
| 210 // ProfileSyncService. Using the ProfileSyncServiceMock class allows to | 211 // ProfileSyncService. Using the ProfileSyncServiceMock class allows to |
| 211 // assign specific return values as needed to make sure the web history | 212 // assign specific return values as needed to make sure the web history |
| 212 // service is available. | 213 // service is available. |
| 213 class WebHistoryServiceTest : public testing::Test { | 214 class WebHistoryServiceTest : public testing::Test { |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 " \"history_recording\": true\n" | 420 " \"history_recording\": true\n" |
| 420 "}")); | 421 "}")); |
| 421 scoped_ptr<base::DictionaryValue> response_value5; | 422 scoped_ptr<base::DictionaryValue> response_value5; |
| 422 // ReadResponse deletes the request | 423 // ReadResponse deletes the request |
| 423 response_value5 = TestingWebHistoryService::ReadResponse(request5.get()); | 424 response_value5 = TestingWebHistoryService::ReadResponse(request5.get()); |
| 424 enabled_value = true; | 425 enabled_value = true; |
| 425 EXPECT_FALSE(response_value5->GetBoolean("history_recording_enabled", | 426 EXPECT_FALSE(response_value5->GetBoolean("history_recording_enabled", |
| 426 &enabled_value)); | 427 &enabled_value)); |
| 427 EXPECT_TRUE(enabled_value); | 428 EXPECT_TRUE(enabled_value); |
| 428 } | 429 } |
| OLD | NEW |