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

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

Issue 686333002: Hotword Private API: Adds speech training functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 1 month 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/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 EXPECT_TRUE(listener.WaitUntilSatisfied()); 237 EXPECT_TRUE(listener.WaitUntilSatisfied());
238 238
239 ExtensionTestMessageListener listenerNotification("notification", false); 239 ExtensionTestMessageListener listenerNotification("notification", false);
240 profile()->GetPrefs()->SetBoolean(prefs::kHotwordSearchEnabled, true); 240 profile()->GetPrefs()->SetBoolean(prefs::kHotwordSearchEnabled, true);
241 EXPECT_TRUE(listenerNotification.WaitUntilSatisfied()); 241 EXPECT_TRUE(listenerNotification.WaitUntilSatisfied());
242 242
243 listenerNotification.Reset(); 243 listenerNotification.Reset();
244 profile()->GetPrefs()->SetBoolean(prefs::kHotwordAlwaysOnSearchEnabled, 244 profile()->GetPrefs()->SetBoolean(prefs::kHotwordAlwaysOnSearchEnabled,
245 true); 245 true);
246 EXPECT_TRUE(listenerNotification.WaitUntilSatisfied()); 246 EXPECT_TRUE(listenerNotification.WaitUntilSatisfied());
247
248 listenerNotification.Reset();
249 service()->StartTraining();
250 EXPECT_TRUE(listenerNotification.WaitUntilSatisfied());
247 } 251 }
248 252
249 IN_PROC_BROWSER_TEST_F(HotwordPrivateApiTest, HotwordSession) { 253 IN_PROC_BROWSER_TEST_F(HotwordPrivateApiTest, HotwordSession) {
250 extensions::HotwordPrivateEventService::GetFactoryInstance(); 254 extensions::HotwordPrivateEventService::GetFactoryInstance();
251 ExtensionTestMessageListener listener("ready", false); 255 ExtensionTestMessageListener listener("ready", false);
252 LoadExtensionAsComponent( 256 LoadExtensionAsComponent(
253 test_data_dir_.AppendASCII("hotwordSession")); 257 test_data_dir_.AppendASCII("hotwordSession"));
254 EXPECT_TRUE(listener.WaitUntilSatisfied()); 258 EXPECT_TRUE(listener.WaitUntilSatisfied());
255 259
256 ExtensionTestMessageListener listenerStopReady("stopReady", false); 260 ExtensionTestMessageListener listenerStopReady("stopReady", false);
257 ExtensionTestMessageListener listenerStopped("stopped", false); 261 ExtensionTestMessageListener listenerStopped("stopped", false);
258 MockHotwordClient client; 262 MockHotwordClient client;
259 service()->RequestHotwordSession(&client); 263 service()->RequestHotwordSession(&client);
260 EXPECT_TRUE(listenerStopReady.WaitUntilSatisfied()); 264 EXPECT_TRUE(listenerStopReady.WaitUntilSatisfied());
261 service()->StopHotwordSession(&client); 265 service()->StopHotwordSession(&client);
262 EXPECT_TRUE(listenerStopped.WaitUntilSatisfied()); 266 EXPECT_TRUE(listenerStopped.WaitUntilSatisfied());
263 267
264 EXPECT_TRUE(client.last_enabled()); 268 EXPECT_TRUE(client.last_enabled());
265 EXPECT_EQ(1, client.state_changed_count()); 269 EXPECT_EQ(1, client.state_changed_count());
266 EXPECT_EQ(1, client.recognized_count()); 270 EXPECT_EQ(1, client.recognized_count());
267 } 271 }
268 272
269 IN_PROC_BROWSER_TEST_F(HotwordPrivateApiTest, GetLaunchStateHotwordOnly) { 273 IN_PROC_BROWSER_TEST_F(HotwordPrivateApiTest, GetLaunchStateHotwordOnly) {
270 service()->SetHotwordAudioVerificationLaunchMode( 274 service()->SetHotwordAudioVerificationLaunchMode(
271 HotwordService::HOTWORD_ONLY); 275 HotwordService::HOTWORD_ONLY);
272 ExtensionTestMessageListener listener("launchMode: 1", false); 276 ExtensionTestMessageListener listener("launchMode: 0", false);
273 ASSERT_TRUE(RunComponentExtensionTest("getLaunchState")) << message_; 277 ASSERT_TRUE(RunComponentExtensionTest("getLaunchState")) << message_;
274 EXPECT_TRUE(listener.WaitUntilSatisfied()); 278 EXPECT_TRUE(listener.WaitUntilSatisfied());
275 } 279 }
276 280
277 IN_PROC_BROWSER_TEST_F(HotwordPrivateApiTest, 281 IN_PROC_BROWSER_TEST_F(HotwordPrivateApiTest,
278 GetLaunchStateHotwordAudioHistory) { 282 GetLaunchStateHotwordAudioHistory) {
279 service()->SetHotwordAudioVerificationLaunchMode( 283 service()->SetHotwordAudioVerificationLaunchMode(
280 HotwordService::HOTWORD_AND_AUDIO_HISTORY); 284 HotwordService::HOTWORD_AND_AUDIO_HISTORY);
281 ExtensionTestMessageListener listener("launchMode: 2", false); 285 ExtensionTestMessageListener listener("launchMode: 1", false);
282 ASSERT_TRUE(RunComponentExtensionTest("getLaunchState")) << message_; 286 ASSERT_TRUE(RunComponentExtensionTest("getLaunchState")) << message_;
283 EXPECT_TRUE(listener.WaitUntilSatisfied()); 287 EXPECT_TRUE(listener.WaitUntilSatisfied());
284 } 288 }
289
290 IN_PROC_BROWSER_TEST_F(HotwordPrivateApiTest, OnFinalizeSpeakerModel) {
291 // Trigger the pref registrar.
292 extensions::HotwordPrivateEventService::GetFactoryInstance();
293 ExtensionTestMessageListener listener("ready", false);
294 ASSERT_TRUE(
295 LoadExtensionAsComponent(test_data_dir_.AppendASCII(
296 "onFinalizeSpeakerModel")));
297 EXPECT_TRUE(listener.WaitUntilSatisfied());
298
299 ExtensionTestMessageListener listenerNotification("notification", false);
300 service()->FinalizeSpeakerModel();
301 EXPECT_TRUE(listenerNotification.WaitUntilSatisfied());
302 }
303
304 IN_PROC_BROWSER_TEST_F(HotwordPrivateApiTest, OnHotwordTriggered) {
305 // Trigger the pref registrar.
306 extensions::HotwordPrivateEventService::GetFactoryInstance();
307 ExtensionTestMessageListener listener("ready", false);
308 ASSERT_TRUE(
309 LoadExtensionAsComponent(test_data_dir_.AppendASCII(
310 "onHotwordTriggered")));
311 EXPECT_TRUE(listener.WaitUntilSatisfied());
312
313 ExtensionTestMessageListener listenerNotification("notification", false);
314 service()->NotifyHotwordTriggered();
315 EXPECT_TRUE(listenerNotification.WaitUntilSatisfied());
316 }
317
318 IN_PROC_BROWSER_TEST_F(HotwordPrivateApiTest, Training) {
319 EXPECT_FALSE(service()->IsTraining());
320
321 ExtensionTestMessageListener listenerTrue("start training", false);
322 ASSERT_TRUE(RunComponentExtensionTest("startTraining")) << message_;
323 EXPECT_TRUE(listenerTrue.WaitUntilSatisfied());
324 EXPECT_TRUE(service()->IsTraining());
325
326 ExtensionTestMessageListener listenerFalse("stop training", false);
327 ASSERT_TRUE(RunComponentExtensionTest("stopTraining")) << message_;
328 EXPECT_TRUE(listenerFalse.WaitUntilSatisfied());
329 EXPECT_FALSE(service()->IsTraining());
330 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/hotword_private/hotword_private_api.cc ('k') | chrome/browser/search/hotword_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698