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

Unified Diff: chrome/browser/extensions/api/hotword_private/hotword_private_apitest.cc

Issue 1027683002: Hotword Private API: Add function and event to query the existence of a speaker model (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/hotword_private/hotword_private_apitest.cc
diff --git a/chrome/browser/extensions/api/hotword_private/hotword_private_apitest.cc b/chrome/browser/extensions/api/hotword_private/hotword_private_apitest.cc
index 68a8966f879486d1815650306993dae263eb89d5..2cdf288993070617f1512803fac6a5cefc315c42 100644
--- a/chrome/browser/extensions/api/hotword_private/hotword_private_apitest.cc
+++ b/chrome/browser/extensions/api/hotword_private/hotword_private_apitest.cc
@@ -89,7 +89,7 @@ class MockAudioHistoryHandler : public HotwordAudioHistoryHandler {
class MockHotwordService : public HotwordService {
public:
explicit MockHotwordService(Profile* profile)
- : HotwordService(profile), service_available_(true) {};
+ : HotwordService(profile), service_available_(true) {}
~MockHotwordService() override {}
bool IsServiceAvailable() override { return service_available_; }
@@ -405,6 +405,41 @@ IN_PROC_BROWSER_TEST_F(HotwordPrivateApiTest, OnDeleteSpeakerModel) {
EXPECT_TRUE(listenerNotification.WaitUntilSatisfied());
}
+IN_PROC_BROWSER_TEST_F(HotwordPrivateApiTest, OnSpeakerModelExists) {
+ extensions::HotwordPrivateEventService::GetFactoryInstance();
+ ExtensionTestMessageListener listener("ready", false);
+ ASSERT_TRUE(
+ LoadExtensionAsComponent(test_data_dir_.AppendASCII(
+ "onSpeakerModelExists")));
+ EXPECT_TRUE(listener.WaitUntilSatisfied());
+
+ service()->OptIntoHotwording(HotwordService::HOTWORD_ONLY);
+
+ ExtensionTestMessageListener listenerNotification("notification", false);
+ EXPECT_TRUE(listenerNotification.WaitUntilSatisfied());
+}
+
+IN_PROC_BROWSER_TEST_F(HotwordPrivateApiTest, SpeakerModelExistsResult) {
+ EXPECT_FALSE(profile()->GetPrefs()->GetBoolean(
+ prefs::kHotwordAlwaysOnSearchEnabled));
+
+ ExtensionTestMessageListener listenerTrue("ready", false);
+ ASSERT_TRUE(RunComponentExtensionTest(
+ "speakerModelExistsResultTrue")) << message_;
+ EXPECT_TRUE(listenerTrue.WaitUntilSatisfied());
+ EXPECT_TRUE(profile()->GetPrefs()->GetBoolean(
+ prefs::kHotwordAlwaysOnSearchEnabled));
+
+ PrefService* prefs = profile()->GetPrefs();
+ prefs->SetBoolean(prefs::kHotwordAlwaysOnSearchEnabled, false);
+ ExtensionTestMessageListener listenerFalse("ready", false);
+ ASSERT_TRUE(RunComponentExtensionTest(
+ "speakerModelExistsResultFalse")) << message_;
+ EXPECT_TRUE(listenerFalse.WaitUntilSatisfied());
+ EXPECT_FALSE(profile()->GetPrefs()->GetBoolean(
+ prefs::kHotwordAlwaysOnSearchEnabled));
+}
+
IN_PROC_BROWSER_TEST_F(HotwordPrivateApiTest, Training) {
EXPECT_FALSE(service()->IsTraining());

Powered by Google App Engine
This is Rietveld 408576698