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