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

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

Issue 555423002: Expose always-on hotword preference via hotwordPrivate API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 EXPECT_TRUE(listener.WaitUntilSatisfied()); 158 EXPECT_TRUE(listener.WaitUntilSatisfied());
159 } 159 }
160 160
161 IN_PROC_BROWSER_TEST_F(HotwordPrivateApiTest, IsAvailableFalse) { 161 IN_PROC_BROWSER_TEST_F(HotwordPrivateApiTest, IsAvailableFalse) {
162 service()->setServiceAvailable(false); 162 service()->setServiceAvailable(false);
163 ExtensionTestMessageListener listener("available: false", false); 163 ExtensionTestMessageListener listener("available: false", false);
164 ASSERT_TRUE(RunComponentExtensionTest("isAvailable")) << message_; 164 ASSERT_TRUE(RunComponentExtensionTest("isAvailable")) << message_;
165 EXPECT_TRUE(listener.WaitUntilSatisfied()); 165 EXPECT_TRUE(listener.WaitUntilSatisfied());
166 } 166 }
167 167
168 IN_PROC_BROWSER_TEST_F(HotwordPrivateApiTest, AlwaysOnEnabled) {
169 {
170 ExtensionTestMessageListener listener("alwaysOnEnabled: false",
171 false);
172 ASSERT_TRUE(RunComponentExtensionTest("alwaysOnEnabled"))
173 << message_;
174 EXPECT_TRUE(listener.WaitUntilSatisfied());
175 }
176
177 profile()->GetPrefs()->SetBoolean(prefs::kHotwordAlwaysOnSearchEnabled, true);
178 {
179 ExtensionTestMessageListener listener("alwaysOnEnabled: true",
180 false);
181 ASSERT_TRUE(RunComponentExtensionTest("alwaysOnEnabled"))
182 << message_;
183 EXPECT_TRUE(listener.WaitUntilSatisfied());
184 }
185 }
186
168 IN_PROC_BROWSER_TEST_F(HotwordPrivateApiTest, ExperimentalHotwordEnabled) { 187 IN_PROC_BROWSER_TEST_F(HotwordPrivateApiTest, ExperimentalHotwordEnabled) {
169 // Disabled by default. 188 // Disabled by default.
170 ExtensionTestMessageListener listener("experimentalHotwordEnabled: false", 189 ExtensionTestMessageListener listener("experimentalHotwordEnabled: false",
171 false); 190 false);
172 ASSERT_TRUE(RunComponentExtensionTest("experimentalHotwordEnabled")) 191 ASSERT_TRUE(RunComponentExtensionTest("experimentalHotwordEnabled"))
173 << message_; 192 << message_;
174 EXPECT_TRUE(listener.WaitUntilSatisfied()); 193 EXPECT_TRUE(listener.WaitUntilSatisfied());
175 } 194 }
176 195
177 IN_PROC_BROWSER_TEST_F(HotwordPrivateApiTest, 196 IN_PROC_BROWSER_TEST_F(HotwordPrivateApiTest,
(...skipping 11 matching lines...) Expand all
189 // Trigger the pref registrar. 208 // Trigger the pref registrar.
190 extensions::HotwordPrivateEventService::GetFactoryInstance(); 209 extensions::HotwordPrivateEventService::GetFactoryInstance();
191 ExtensionTestMessageListener listener("ready", false); 210 ExtensionTestMessageListener listener("ready", false);
192 ASSERT_TRUE( 211 ASSERT_TRUE(
193 LoadExtensionAsComponent(test_data_dir_.AppendASCII("onEnabledChanged"))); 212 LoadExtensionAsComponent(test_data_dir_.AppendASCII("onEnabledChanged")));
194 EXPECT_TRUE(listener.WaitUntilSatisfied()); 213 EXPECT_TRUE(listener.WaitUntilSatisfied());
195 214
196 ExtensionTestMessageListener listenerNotification("notification", false); 215 ExtensionTestMessageListener listenerNotification("notification", false);
197 profile()->GetPrefs()->SetBoolean(prefs::kHotwordSearchEnabled, true); 216 profile()->GetPrefs()->SetBoolean(prefs::kHotwordSearchEnabled, true);
198 EXPECT_TRUE(listenerNotification.WaitUntilSatisfied()); 217 EXPECT_TRUE(listenerNotification.WaitUntilSatisfied());
218
219 listenerNotification.Reset();
220 profile()->GetPrefs()->SetBoolean(prefs::kHotwordAlwaysOnSearchEnabled,
221 true);
222 EXPECT_TRUE(listenerNotification.WaitUntilSatisfied());
199 } 223 }
200 224
201 IN_PROC_BROWSER_TEST_F(HotwordPrivateApiTest, HotwordSession) { 225 IN_PROC_BROWSER_TEST_F(HotwordPrivateApiTest, HotwordSession) {
202 extensions::HotwordPrivateEventService::GetFactoryInstance(); 226 extensions::HotwordPrivateEventService::GetFactoryInstance();
203 ExtensionTestMessageListener listener("ready", false); 227 ExtensionTestMessageListener listener("ready", false);
204 LoadExtensionAsComponent( 228 LoadExtensionAsComponent(
205 test_data_dir_.AppendASCII("hotwordSession")); 229 test_data_dir_.AppendASCII("hotwordSession"));
206 EXPECT_TRUE(listener.WaitUntilSatisfied()); 230 EXPECT_TRUE(listener.WaitUntilSatisfied());
207 231
208 ExtensionTestMessageListener listenerStopReady("stopReady", false); 232 ExtensionTestMessageListener listenerStopReady("stopReady", false);
209 ExtensionTestMessageListener listenerStopped("stopped", false); 233 ExtensionTestMessageListener listenerStopped("stopped", false);
210 MockHotwordClient client; 234 MockHotwordClient client;
211 service()->RequestHotwordSession(&client); 235 service()->RequestHotwordSession(&client);
212 EXPECT_TRUE(listenerStopReady.WaitUntilSatisfied()); 236 EXPECT_TRUE(listenerStopReady.WaitUntilSatisfied());
213 service()->StopHotwordSession(&client); 237 service()->StopHotwordSession(&client);
214 EXPECT_TRUE(listenerStopped.WaitUntilSatisfied()); 238 EXPECT_TRUE(listenerStopped.WaitUntilSatisfied());
215 239
216 EXPECT_TRUE(client.last_enabled()); 240 EXPECT_TRUE(client.last_enabled());
217 EXPECT_EQ(1, client.state_changed_count()); 241 EXPECT_EQ(1, client.state_changed_count());
218 EXPECT_EQ(1, client.recognized_count()); 242 EXPECT_EQ(1, client.recognized_count());
219 } 243 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/hotword_private/hotword_private_api.cc ('k') | chrome/common/extensions/api/hotword_private.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698