Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(178)

Side by Side Diff: chrome/browser/extensions/api/hotword_private/hotword_private_apitest.cc

Issue 528113003: Hotword Audio Verification App: Adds to hotwordPrivate API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@page-one
Patch Set: Rebase Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/extensions/extension_test_message_listener.h" 10 #include "chrome/browser/extensions/extension_test_message_listener.h"
(...skipping 20 matching lines...) Expand all
31 } 31 }
32 32
33 void setServiceAvailable(bool available) { 33 void setServiceAvailable(bool available) {
34 service_available_ = available; 34 service_available_ = available;
35 } 35 }
36 36
37 static KeyedService* Build(content::BrowserContext* profile) { 37 static KeyedService* Build(content::BrowserContext* profile) {
38 return new MockHotwordService(static_cast<Profile*>(profile)); 38 return new MockHotwordService(static_cast<Profile*>(profile));
39 } 39 }
40 40
41 virtual LaunchMode GetHotwordAudioVerificationLaunchMode() OVERRIDE {
42 return launch_mode_;
43 }
44
45 void SetHotwordAudioVerificationLaunchMode(const LaunchMode& launch_mode) {
46 launch_mode_ = launch_mode;
47 }
48
41 private: 49 private:
42 bool service_available_; 50 bool service_available_;
51 LaunchMode launch_mode_;
43 52
44 DISALLOW_COPY_AND_ASSIGN(MockHotwordService); 53 DISALLOW_COPY_AND_ASSIGN(MockHotwordService);
45 }; 54 };
46 55
47 class MockHotwordClient : public HotwordClient { 56 class MockHotwordClient : public HotwordClient {
48 public: 57 public:
49 MockHotwordClient() 58 MockHotwordClient()
50 : last_enabled_(false), 59 : last_enabled_(false),
51 state_changed_count_(0), 60 state_changed_count_(0),
52 recognized_count_(0) { 61 recognized_count_(0) {
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 MockHotwordClient client; 243 MockHotwordClient client;
235 service()->RequestHotwordSession(&client); 244 service()->RequestHotwordSession(&client);
236 EXPECT_TRUE(listenerStopReady.WaitUntilSatisfied()); 245 EXPECT_TRUE(listenerStopReady.WaitUntilSatisfied());
237 service()->StopHotwordSession(&client); 246 service()->StopHotwordSession(&client);
238 EXPECT_TRUE(listenerStopped.WaitUntilSatisfied()); 247 EXPECT_TRUE(listenerStopped.WaitUntilSatisfied());
239 248
240 EXPECT_TRUE(client.last_enabled()); 249 EXPECT_TRUE(client.last_enabled());
241 EXPECT_EQ(1, client.state_changed_count()); 250 EXPECT_EQ(1, client.state_changed_count());
242 EXPECT_EQ(1, client.recognized_count()); 251 EXPECT_EQ(1, client.recognized_count());
243 } 252 }
253
254 IN_PROC_BROWSER_TEST_F(HotwordPrivateApiTest, GetLaunchStateHotwordOnly) {
255 service()->SetHotwordAudioVerificationLaunchMode(
256 HotwordService::HOTWORD_ONLY);
257 ExtensionTestMessageListener listener("launchMode: 1", false);
258 ASSERT_TRUE(RunComponentExtensionTest("getLaunchState")) << message_;
259 EXPECT_TRUE(listener.WaitUntilSatisfied());
260 }
261
262 IN_PROC_BROWSER_TEST_F(HotwordPrivateApiTest,
263 GetLaunchStateHotwordAudioHistory) {
264 service()->SetHotwordAudioVerificationLaunchMode(
265 HotwordService::HOTWORD_AND_AUDIO_HISTORY);
266 ExtensionTestMessageListener listener("launchMode: 2", false);
267 ASSERT_TRUE(RunComponentExtensionTest("getLaunchState")) << message_;
268 EXPECT_TRUE(listener.WaitUntilSatisfied());
269 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698