| 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 <memory> |
| 6 |
| 5 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 6 #include "base/macros.h" | 8 #include "base/macros.h" |
| 7 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/ptr_util.h" |
| 8 #include "chrome/browser/extensions/api/hotword_private/hotword_private_api.h" | 10 #include "chrome/browser/extensions/api/hotword_private/hotword_private_api.h" |
| 9 #include "chrome/browser/extensions/extension_apitest.h" | 11 #include "chrome/browser/extensions/extension_apitest.h" |
| 10 #include "chrome/browser/extensions/extension_service.h" | 12 #include "chrome/browser/extensions/extension_service.h" |
| 11 #include "chrome/browser/history/web_history_service_factory.h" | 13 #include "chrome/browser/history/web_history_service_factory.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/search/hotword_audio_history_handler.h" | 15 #include "chrome/browser/search/hotword_audio_history_handler.h" |
| 14 #include "chrome/browser/search/hotword_client.h" | 16 #include "chrome/browser/search/hotword_client.h" |
| 15 #include "chrome/browser/search/hotword_service.h" | 17 #include "chrome/browser/search/hotword_service.h" |
| 16 #include "chrome/browser/search/hotword_service_factory.h" | 18 #include "chrome/browser/search/hotword_service_factory.h" |
| 17 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 19 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 : HotwordAudioHistoryHandler(context, | 80 : HotwordAudioHistoryHandler(context, |
| 79 base::MessageLoop::current()->task_runner()), | 81 base::MessageLoop::current()->task_runner()), |
| 80 web_history_(web_history) {} | 82 web_history_(web_history) {} |
| 81 ~MockAudioHistoryHandler() override {} | 83 ~MockAudioHistoryHandler() override {} |
| 82 | 84 |
| 83 history::WebHistoryService* GetWebHistory() override { | 85 history::WebHistoryService* GetWebHistory() override { |
| 84 return web_history_.get(); | 86 return web_history_.get(); |
| 85 } | 87 } |
| 86 | 88 |
| 87 private: | 89 private: |
| 88 scoped_ptr<history::WebHistoryService> web_history_; | 90 std::unique_ptr<history::WebHistoryService> web_history_; |
| 89 }; | 91 }; |
| 90 | 92 |
| 91 class MockHotwordService : public HotwordService { | 93 class MockHotwordService : public HotwordService { |
| 92 public: | 94 public: |
| 93 explicit MockHotwordService(Profile* profile) | 95 explicit MockHotwordService(Profile* profile) |
| 94 : HotwordService(profile), service_available_(true) {} | 96 : HotwordService(profile), service_available_(true) {} |
| 95 ~MockHotwordService() override {} | 97 ~MockHotwordService() override {} |
| 96 | 98 |
| 97 bool IsServiceAvailable() override { return service_available_; } | 99 bool IsServiceAvailable() override { return service_available_; } |
| 98 | 100 |
| 99 void setServiceAvailable(bool available) { | 101 void setServiceAvailable(bool available) { |
| 100 service_available_ = available; | 102 service_available_ = available; |
| 101 } | 103 } |
| 102 | 104 |
| 103 static scoped_ptr<KeyedService> Build(content::BrowserContext* profile) { | 105 static std::unique_ptr<KeyedService> Build(content::BrowserContext* profile) { |
| 104 return make_scoped_ptr( | 106 return base::WrapUnique( |
| 105 new MockHotwordService(static_cast<Profile*>(profile))); | 107 new MockHotwordService(static_cast<Profile*>(profile))); |
| 106 } | 108 } |
| 107 | 109 |
| 108 LaunchMode GetHotwordAudioVerificationLaunchMode() override { | 110 LaunchMode GetHotwordAudioVerificationLaunchMode() override { |
| 109 return launch_mode_; | 111 return launch_mode_; |
| 110 } | 112 } |
| 111 | 113 |
| 112 void SetHotwordAudioVerificationLaunchMode(const LaunchMode& launch_mode) { | 114 void SetHotwordAudioVerificationLaunchMode(const LaunchMode& launch_mode) { |
| 113 launch_mode_ = launch_mode; | 115 launch_mode_ = launch_mode; |
| 114 } | 116 } |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 ExtensionTestMessageListener setListenerT("set AH: false failure", false); | 530 ExtensionTestMessageListener setListenerT("set AH: false failure", false); |
| 529 ExtensionTestMessageListener setListenerF("set AH: false failure", false); | 531 ExtensionTestMessageListener setListenerF("set AH: false failure", false); |
| 530 ExtensionTestMessageListener getListener("get AH: false failure", false); | 532 ExtensionTestMessageListener getListener("get AH: false failure", false); |
| 531 | 533 |
| 532 ASSERT_TRUE(RunComponentExtensionTest("audioHistory")) << message_; | 534 ASSERT_TRUE(RunComponentExtensionTest("audioHistory")) << message_; |
| 533 | 535 |
| 534 EXPECT_TRUE(setListenerT.WaitUntilSatisfied()); | 536 EXPECT_TRUE(setListenerT.WaitUntilSatisfied()); |
| 535 EXPECT_TRUE(setListenerF.WaitUntilSatisfied()); | 537 EXPECT_TRUE(setListenerF.WaitUntilSatisfied()); |
| 536 EXPECT_TRUE(getListener.WaitUntilSatisfied()); | 538 EXPECT_TRUE(getListener.WaitUntilSatisfied()); |
| 537 } | 539 } |
| OLD | NEW |