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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/prefs/pref_service.h" | 6 #include "base/prefs/pref_service.h" |
7 #include "chrome/browser/extensions/api/hotword_private/hotword_private_api.h" | 7 #include "chrome/browser/extensions/api/hotword_private/hotword_private_api.h" |
8 #include "chrome/browser/extensions/extension_apitest.h" | 8 #include "chrome/browser/extensions/extension_apitest.h" |
9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
10 #include "chrome/browser/history/web_history_service.h" | |
11 #include "chrome/browser/history/web_history_service_factory.h" | 10 #include "chrome/browser/history/web_history_service_factory.h" |
12 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/search/hotword_audio_history_handler.h" | 12 #include "chrome/browser/search/hotword_audio_history_handler.h" |
14 #include "chrome/browser/search/hotword_client.h" | 13 #include "chrome/browser/search/hotword_client.h" |
15 #include "chrome/browser/search/hotword_service.h" | 14 #include "chrome/browser/search/hotword_service.h" |
16 #include "chrome/browser/search/hotword_service_factory.h" | 15 #include "chrome/browser/search/hotword_service_factory.h" |
| 16 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 17 #include "chrome/browser/signin/signin_manager_factory.h" |
17 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
18 #include "chrome/common/pref_names.h" | 19 #include "chrome/common/pref_names.h" |
| 20 #include "components/history/core/browser/web_history_service.h" |
| 21 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
| 22 #include "components/signin/core/browser/signin_manager.h" |
19 #include "extensions/common/switches.h" | 23 #include "extensions/common/switches.h" |
20 #include "extensions/test/extension_test_message_listener.h" | 24 #include "extensions/test/extension_test_message_listener.h" |
| 25 #include "net/url_request/url_request_context_getter.h" |
21 | 26 |
22 namespace { | 27 namespace { |
23 | 28 |
24 const char kHotwordTestExtensionId[] = "cpfhkdbjfdgdebcjlifoldbijinjfifp"; | 29 const char kHotwordTestExtensionId[] = "cpfhkdbjfdgdebcjlifoldbijinjfifp"; |
25 | 30 |
26 // Mock the web history service so that we don't make actual requests over the | 31 // Mock the web history service so that we don't make actual requests over the |
27 // network. | 32 // network. |
28 class MockWebHistoryService : public history::WebHistoryService { | 33 class MockWebHistoryService : public history::WebHistoryService { |
29 public: | 34 public: |
30 explicit MockWebHistoryService(Profile* profile) | 35 explicit MockWebHistoryService(Profile* profile) |
31 : WebHistoryService(profile), | 36 : WebHistoryService( |
| 37 ProfileOAuth2TokenServiceFactory::GetForProfile(profile), |
| 38 SigninManagerFactory::GetForProfile(profile), |
| 39 profile->GetRequestContext()), |
32 expected_success_(true), | 40 expected_success_(true), |
33 expected_value_(false) {} | 41 expected_value_(false) {} |
34 ~MockWebHistoryService() override {} | 42 ~MockWebHistoryService() override {} |
35 | 43 |
36 // For both of the following functions, just call the callback to simulate | 44 // For both of the following functions, just call the callback to simulate |
37 // a successful return from the url fetch. | 45 // a successful return from the url fetch. |
38 void GetAudioHistoryEnabled( | 46 void GetAudioHistoryEnabled( |
39 const AudioWebHistoryCallback& callback) override { | 47 const AudioWebHistoryCallback& callback) override { |
40 callback.Run(expected_success_, expected_value_ && expected_success_); | 48 callback.Run(expected_success_, expected_value_ && expected_success_); |
41 } | 49 } |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 ExtensionTestMessageListener setListenerT("set AH: false failure", false); | 501 ExtensionTestMessageListener setListenerT("set AH: false failure", false); |
494 ExtensionTestMessageListener setListenerF("set AH: false failure", false); | 502 ExtensionTestMessageListener setListenerF("set AH: false failure", false); |
495 ExtensionTestMessageListener getListener("get AH: false failure", false); | 503 ExtensionTestMessageListener getListener("get AH: false failure", false); |
496 | 504 |
497 ASSERT_TRUE(RunComponentExtensionTest("audioHistory")) << message_; | 505 ASSERT_TRUE(RunComponentExtensionTest("audioHistory")) << message_; |
498 | 506 |
499 EXPECT_TRUE(setListenerT.WaitUntilSatisfied()); | 507 EXPECT_TRUE(setListenerT.WaitUntilSatisfied()); |
500 EXPECT_TRUE(setListenerF.WaitUntilSatisfied()); | 508 EXPECT_TRUE(setListenerF.WaitUntilSatisfied()); |
501 EXPECT_TRUE(getListener.WaitUntilSatisfied()); | 509 EXPECT_TRUE(getListener.WaitUntilSatisfied()); |
502 } | 510 } |
OLD | NEW |