ozone: evdev: Sync caps lock LED state to evdev
[chromium-blink-merge.git] / chrome / browser / search / hotword_service_unittest.cc
blobee68d692030749f7eb3695ad5696a3666808d4e5
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
3 // found in the LICENSE file.
5 #include "base/command_line.h"
6 #include "base/memory/scoped_ptr.h"
7 #include "base/metrics/field_trial.h"
8 #include "base/prefs/pref_service.h"
9 #include "base/test/test_simple_task_runner.h"
10 #include "chrome/browser/browser_process.h"
11 #include "chrome/browser/extensions/extension_service_test_base.h"
12 #include "chrome/browser/extensions/test_extension_service.h"
13 #include "chrome/browser/search/hotword_audio_history_handler.h"
14 #include "chrome/browser/search/hotword_service.h"
15 #include "chrome/browser/search/hotword_service_factory.h"
16 #include "chrome/common/chrome_switches.h"
17 #include "chrome/common/extensions/extension_constants.h"
18 #include "chrome/common/pref_names.h"
19 #include "chrome/test/base/testing_profile.h"
20 #include "components/history/core/browser/web_history_service.h"
21 #include "content/public/test/test_browser_thread_bundle.h"
22 #include "extensions/browser/extension_system.h"
23 #include "extensions/common/extension.h"
24 #include "extensions/common/extension_builder.h"
25 #include "extensions/common/manifest.h"
26 #include "extensions/common/one_shot_event.h"
27 #include "testing/gtest/include/gtest/gtest.h"
29 #if defined(OS_CHROMEOS)
30 #include "chromeos/audio/cras_audio_handler.h"
31 #endif
33 namespace {
35 class MockAudioHistoryHandler : public HotwordAudioHistoryHandler {
36 public:
37 MockAudioHistoryHandler(
38 content::BrowserContext* context,
39 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
40 history::WebHistoryService* web_history)
41 : HotwordAudioHistoryHandler(context, task_runner),
42 get_audio_history_calls_(0),
43 web_history_(web_history) {
45 ~MockAudioHistoryHandler() override {}
47 void GetAudioHistoryEnabled(
48 const HotwordAudioHistoryCallback& callback) override {
49 get_audio_history_calls_++;
50 callback.Run(true, true);
53 history::WebHistoryService* GetWebHistory() override {
54 return web_history_.get();
57 int GetAudioHistoryCalls() {
58 return get_audio_history_calls_;
61 private:
62 int get_audio_history_calls_;
63 scoped_ptr<history::WebHistoryService> web_history_;
66 class MockHotwordService : public HotwordService {
67 public:
68 explicit MockHotwordService(Profile* profile)
69 : HotwordService(profile),
70 uninstall_count_(0) {
73 bool UninstallHotwordExtension(ExtensionService* extension_service) override {
74 uninstall_count_++;
75 return HotwordService::UninstallHotwordExtension(extension_service);
78 void InstallHotwordExtensionFromWebstore(int num_tries) override {
79 scoped_ptr<base::DictionaryValue> manifest =
80 extensions::DictionaryBuilder()
81 .Set("name", "Hotword Test Extension")
82 .Set("version", "1.0")
83 .Set("manifest_version", 2)
84 .Build();
85 scoped_refptr<extensions::Extension> extension =
86 extensions::ExtensionBuilder().SetManifest(manifest.Pass())
87 .AddFlags(extensions::Extension::FROM_WEBSTORE
88 | extensions::Extension::WAS_INSTALLED_BY_DEFAULT)
89 .SetID(extension_id_)
90 .SetLocation(extensions::Manifest::EXTERNAL_COMPONENT)
91 .Build();
92 ASSERT_TRUE(extension.get());
93 service_->OnExtensionInstalled(extension.get(), syncer::StringOrdinal());
97 int uninstall_count() { return uninstall_count_; }
99 void SetExtensionService(ExtensionService* service) { service_ = service; }
100 void SetExtensionId(const std::string& extension_id) {
101 extension_id_ = extension_id;
104 ExtensionService* extension_service() { return service_; }
106 private:
107 ExtensionService* service_;
108 int uninstall_count_;
109 std::string extension_id_;
112 KeyedService* BuildMockHotwordService(content::BrowserContext* context) {
113 return new MockHotwordService(static_cast<Profile*>(context));
116 } // namespace
118 class HotwordServiceTest :
119 public extensions::ExtensionServiceTestBase,
120 public ::testing::WithParamInterface<const char*> {
121 protected:
122 HotwordServiceTest() : field_trial_list_(NULL) {}
123 virtual ~HotwordServiceTest() {}
125 void SetApplicationLocale(Profile* profile, const std::string& new_locale) {
126 #if defined(OS_CHROMEOS)
127 // On ChromeOS locale is per-profile.
128 profile->GetPrefs()->SetString(prefs::kApplicationLocale, new_locale);
129 #else
130 g_browser_process->SetApplicationLocale(new_locale);
131 #endif
134 void SetUp() override {
135 extension_id_ = GetParam();
136 if (extension_id_ == extension_misc::kHotwordExtensionId) {
137 base::CommandLine::ForCurrentProcess()->AppendSwitch(
138 switches::kDisableExperimentalHotwording);
140 #if defined(OS_CHROMEOS)
141 // Tests on chromeos need to have the handler initialized.
142 chromeos::CrasAudioHandler::InitializeForTesting();
143 #endif
145 extensions::ExtensionServiceTestBase::SetUp();
148 void TearDown() override {
149 #if defined(OS_CHROMEOS)
150 DCHECK(chromeos::CrasAudioHandler::IsInitialized());
151 chromeos::CrasAudioHandler::Shutdown();
152 #endif
155 base::FieldTrialList field_trial_list_;
156 std::string extension_id_;
159 INSTANTIATE_TEST_CASE_P(HotwordServiceTests,
160 HotwordServiceTest,
161 ::testing::Values(
162 extension_misc::kHotwordExtensionId,
163 extension_misc::kHotwordSharedModuleId));
165 TEST_P(HotwordServiceTest, IsHotwordAllowedBadFieldTrial) {
166 TestingProfile::Builder profile_builder;
167 scoped_ptr<TestingProfile> profile = profile_builder.Build();
169 // Check that the service exists so that a NULL service be ruled out in
170 // following tests.
171 HotwordService* hotword_service =
172 HotwordServiceFactory::GetForProfile(profile.get());
173 EXPECT_TRUE(hotword_service != NULL);
175 // When the field trial is empty or Disabled, it should not be allowed.
176 std::string group = base::FieldTrialList::FindFullName(
177 hotword_internal::kHotwordFieldTrialName);
178 EXPECT_TRUE(group.empty());
179 EXPECT_FALSE(HotwordServiceFactory::IsHotwordAllowed(profile.get()));
181 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
182 hotword_internal::kHotwordFieldTrialName,
183 hotword_internal::kHotwordFieldTrialDisabledGroupName));
184 group = base::FieldTrialList::FindFullName(
185 hotword_internal::kHotwordFieldTrialName);
186 EXPECT_TRUE(group == hotword_internal::kHotwordFieldTrialDisabledGroupName);
187 EXPECT_FALSE(HotwordServiceFactory::IsHotwordAllowed(profile.get()));
189 // Set a valid locale with invalid field trial to be sure it is
190 // still false.
191 SetApplicationLocale(static_cast<Profile*>(profile.get()), "en");
192 EXPECT_FALSE(HotwordServiceFactory::IsHotwordAllowed(profile.get()));
194 // Test that incognito returns false as well.
195 EXPECT_FALSE(HotwordServiceFactory::IsHotwordAllowed(
196 profile->GetOffTheRecordProfile()));
199 TEST_P(HotwordServiceTest, IsHotwordAllowedLocale) {
200 TestingProfile::Builder profile_builder;
201 scoped_ptr<TestingProfile> profile = profile_builder.Build();
203 // Check that the service exists so that a NULL service be ruled out in
204 // following tests.
205 HotwordService* hotword_service =
206 HotwordServiceFactory::GetForProfile(profile.get());
207 EXPECT_TRUE(hotword_service != NULL);
209 // Set the field trial to a valid one.
210 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
211 hotword_internal::kHotwordFieldTrialName, "Good"));
213 // Set the language to an invalid one.
214 SetApplicationLocale(static_cast<Profile*>(profile.get()), "non-valid");
215 EXPECT_FALSE(HotwordServiceFactory::IsHotwordAllowed(profile.get()));
217 // Now with valid locales it should be fine.
218 SetApplicationLocale(static_cast<Profile*>(profile.get()), "en");
219 EXPECT_TRUE(HotwordServiceFactory::IsHotwordAllowed(profile.get()));
220 SetApplicationLocale(static_cast<Profile*>(profile.get()), "en-US");
221 EXPECT_TRUE(HotwordServiceFactory::IsHotwordAllowed(profile.get()));
222 SetApplicationLocale(static_cast<Profile*>(profile.get()), "en_us");
223 EXPECT_TRUE(HotwordServiceFactory::IsHotwordAllowed(profile.get()));
224 SetApplicationLocale(static_cast<Profile*>(profile.get()), "de_DE");
225 EXPECT_TRUE(HotwordServiceFactory::IsHotwordAllowed(profile.get()));
226 SetApplicationLocale(static_cast<Profile*>(profile.get()), "fr_fr");
227 EXPECT_TRUE(HotwordServiceFactory::IsHotwordAllowed(profile.get()));
229 // Test that incognito even with a valid locale and valid field trial
230 // still returns false.
231 Profile* otr_profile = profile->GetOffTheRecordProfile();
232 SetApplicationLocale(otr_profile, "en");
233 EXPECT_FALSE(HotwordServiceFactory::IsHotwordAllowed(otr_profile));
236 TEST_P(HotwordServiceTest, ShouldReinstallExtension) {
237 // Set the field trial to a valid one.
238 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
239 hotword_internal::kHotwordFieldTrialName, "Install"));
241 InitializeEmptyExtensionService();
243 HotwordServiceFactory* hotword_service_factory =
244 HotwordServiceFactory::GetInstance();
246 MockHotwordService* hotword_service = static_cast<MockHotwordService*>(
247 hotword_service_factory->SetTestingFactoryAndUse(
248 profile(), BuildMockHotwordService));
249 EXPECT_TRUE(hotword_service != NULL);
250 hotword_service->SetExtensionId(extension_id_);
252 // If no locale has been set, no reason to uninstall.
253 EXPECT_FALSE(hotword_service->ShouldReinstallHotwordExtension());
255 SetApplicationLocale(profile(), "en");
256 hotword_service->SetPreviousLanguagePref();
258 // Now a locale is set, but it hasn't changed.
259 EXPECT_FALSE(hotword_service->ShouldReinstallHotwordExtension());
261 SetApplicationLocale(profile(), "fr_fr");
263 // Now it's a different locale so it should uninstall.
264 EXPECT_TRUE(hotword_service->ShouldReinstallHotwordExtension());
267 TEST_P(HotwordServiceTest, PreviousLanguageSetOnInstall) {
268 // Set the field trial to a valid one.
269 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
270 hotword_internal::kHotwordFieldTrialName, "Install"));
272 InitializeEmptyExtensionService();
273 service_->Init();
275 HotwordServiceFactory* hotword_service_factory =
276 HotwordServiceFactory::GetInstance();
278 MockHotwordService* hotword_service = static_cast<MockHotwordService*>(
279 hotword_service_factory->SetTestingFactoryAndUse(
280 profile(), BuildMockHotwordService));
281 EXPECT_TRUE(hotword_service != NULL);
282 hotword_service->SetExtensionService(service());
283 hotword_service->SetExtensionId(extension_id_);
285 // If no locale has been set, no reason to uninstall.
286 EXPECT_FALSE(hotword_service->ShouldReinstallHotwordExtension());
288 SetApplicationLocale(profile(), "test_locale");
290 hotword_service->InstallHotwordExtensionFromWebstore(1);
291 base::MessageLoop::current()->RunUntilIdle();
293 EXPECT_EQ("test_locale",
294 profile()->GetPrefs()->GetString(prefs::kHotwordPreviousLanguage));
297 TEST_P(HotwordServiceTest, UninstallReinstallTriggeredCorrectly) {
298 // Set the field trial to a valid one.
299 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
300 hotword_internal::kHotwordFieldTrialName, "Install"));
302 InitializeEmptyExtensionService();
303 service_->Init();
305 HotwordServiceFactory* hotword_service_factory =
306 HotwordServiceFactory::GetInstance();
308 MockHotwordService* hotword_service = static_cast<MockHotwordService*>(
309 hotword_service_factory->SetTestingFactoryAndUse(
310 profile(), BuildMockHotwordService));
311 EXPECT_TRUE(hotword_service != NULL);
312 hotword_service->SetExtensionService(service());
313 hotword_service->SetExtensionId(extension_id_);
315 // Initialize the locale to "en".
316 SetApplicationLocale(profile(), "en");
318 // The previous locale should not be set. No reason to uninstall.
319 EXPECT_FALSE(hotword_service->MaybeReinstallHotwordExtension());
321 // Do an initial installation.
322 hotword_service->InstallHotwordExtensionFromWebstore(1);
323 base::MessageLoop::current()->RunUntilIdle();
324 EXPECT_EQ("en",
325 profile()->GetPrefs()->GetString(prefs::kHotwordPreviousLanguage));
327 if (extension_id_ == extension_misc::kHotwordSharedModuleId) {
328 // Shared module is installed and enabled.
329 EXPECT_EQ(0U, registry()->disabled_extensions().size());
330 EXPECT_TRUE(registry()->enabled_extensions().Contains(extension_id_));
331 } else {
332 // Verify the extension is installed but disabled.
333 EXPECT_EQ(1U, registry()->disabled_extensions().size());
334 EXPECT_TRUE(registry()->disabled_extensions().Contains(extension_id_));
337 // The previous locale should be set but should match the current
338 // locale. No reason to uninstall.
339 EXPECT_FALSE(hotword_service->MaybeReinstallHotwordExtension());
341 // Switch the locale to a valid but different one.
342 SetApplicationLocale(profile(), "fr_fr");
343 EXPECT_TRUE(HotwordServiceFactory::IsHotwordAllowed(profile()));
345 // Different but valid locale so expect uninstall.
346 EXPECT_TRUE(hotword_service->MaybeReinstallHotwordExtension());
347 EXPECT_EQ(1, hotword_service->uninstall_count());
348 EXPECT_EQ("fr_fr",
349 profile()->GetPrefs()->GetString(prefs::kHotwordPreviousLanguage));
351 if (extension_id_ == extension_misc::kHotwordSharedModuleId) {
352 // Shared module is installed and enabled.
353 EXPECT_TRUE(registry()->enabled_extensions().Contains(extension_id_));
354 } else {
355 // Verify the extension is installed. It's still disabled.
356 EXPECT_TRUE(registry()->disabled_extensions().Contains(extension_id_));
359 // Switch the locale to an invalid one.
360 SetApplicationLocale(profile(), "invalid");
361 EXPECT_FALSE(HotwordServiceFactory::IsHotwordAllowed(profile()));
362 EXPECT_FALSE(hotword_service->MaybeReinstallHotwordExtension());
363 EXPECT_EQ("fr_fr",
364 profile()->GetPrefs()->GetString(prefs::kHotwordPreviousLanguage));
366 // If the locale is set back to the last valid one, then an uninstall-install
367 // shouldn't be needed.
368 SetApplicationLocale(profile(), "fr_fr");
369 EXPECT_TRUE(HotwordServiceFactory::IsHotwordAllowed(profile()));
370 EXPECT_FALSE(hotword_service->MaybeReinstallHotwordExtension());
371 EXPECT_EQ(1, hotword_service->uninstall_count()); // no change
374 TEST_P(HotwordServiceTest, DisableAlwaysOnOnLanguageChange) {
375 // Bypass test for old hotwording.
376 if (extension_id_ != extension_misc::kHotwordSharedModuleId)
377 return;
379 // Turn on Always On
380 base::CommandLine::ForCurrentProcess()->AppendSwitch(
381 switches::kEnableExperimentalHotwordHardware);
383 // Set the field trial to a valid one.
384 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
385 hotword_internal::kHotwordFieldTrialName, "Install"));
387 InitializeEmptyExtensionService();
388 service_->Init();
390 // Enable always-on.
391 profile()->GetPrefs()->SetBoolean(prefs::kHotwordAlwaysOnSearchEnabled, true);
393 HotwordServiceFactory* hotword_service_factory =
394 HotwordServiceFactory::GetInstance();
396 MockHotwordService* hotword_service = static_cast<MockHotwordService*>(
397 hotword_service_factory->SetTestingFactoryAndUse(
398 profile(), BuildMockHotwordService));
399 EXPECT_TRUE(hotword_service != NULL);
400 hotword_service->SetExtensionService(service());
401 hotword_service->SetExtensionId(extension_id_);
403 // Initialize the locale to "en".
404 SetApplicationLocale(profile(), "en");
406 // The previous locale should not be set. No reason to uninstall.
407 EXPECT_FALSE(hotword_service->MaybeReinstallHotwordExtension());
408 EXPECT_TRUE(hotword_service->IsAlwaysOnEnabled());
410 // Do an initial installation.
411 hotword_service->InstallHotwordExtensionFromWebstore(1);
412 base::MessageLoop::current()->RunUntilIdle();
414 // The previous locale should be set but should match the current
415 // locale. No reason to uninstall.
416 EXPECT_FALSE(hotword_service->MaybeReinstallHotwordExtension());
417 EXPECT_TRUE(hotword_service->IsAlwaysOnEnabled());
419 // Switch the locale to a valid but different one.
420 SetApplicationLocale(profile(), "fr_fr");
421 EXPECT_TRUE(HotwordServiceFactory::IsHotwordAllowed(profile()));
423 // Different but valid locale so expect uninstall.
424 EXPECT_TRUE(hotword_service->MaybeReinstallHotwordExtension());
425 EXPECT_FALSE(hotword_service->IsAlwaysOnEnabled());
427 // Re-enable always-on.
428 profile()->GetPrefs()->SetBoolean(prefs::kHotwordAlwaysOnSearchEnabled, true);
430 // Switch the locale to an invalid one.
431 SetApplicationLocale(profile(), "invalid");
432 EXPECT_FALSE(HotwordServiceFactory::IsHotwordAllowed(profile()));
433 EXPECT_FALSE(hotword_service->MaybeReinstallHotwordExtension());
434 EXPECT_TRUE(hotword_service->IsAlwaysOnEnabled());
436 // If the locale is set back to the last valid one, then an uninstall-install
437 // shouldn't be needed.
438 SetApplicationLocale(profile(), "fr_fr");
439 EXPECT_TRUE(HotwordServiceFactory::IsHotwordAllowed(profile()));
440 EXPECT_FALSE(hotword_service->MaybeReinstallHotwordExtension());
441 EXPECT_TRUE(hotword_service->IsAlwaysOnEnabled());
444 TEST_P(HotwordServiceTest, IsAlwaysOnEnabled) {
445 // Bypass test for old hotwording.
446 if (extension_id_ != extension_misc::kHotwordSharedModuleId)
447 return;
449 // Set the field trial to a valid one.
450 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
451 hotword_internal::kHotwordFieldTrialName, "Install"));
453 InitializeEmptyExtensionService();
454 service_->Init();
455 HotwordServiceFactory* hotword_service_factory =
456 HotwordServiceFactory::GetInstance();
458 MockHotwordService* hotword_service = static_cast<MockHotwordService*>(
459 hotword_service_factory->SetTestingFactoryAndUse(
460 profile(), BuildMockHotwordService));
461 EXPECT_TRUE(hotword_service != NULL);
462 hotword_service->SetExtensionService(service());
463 hotword_service->SetExtensionId(extension_id_);
465 // No hardware available. Should never be true.
466 EXPECT_FALSE(hotword_service->IsAlwaysOnEnabled());
468 // Enable always-on, still not available.
469 profile()->GetPrefs()->SetBoolean(prefs::kHotwordAlwaysOnSearchEnabled, true);
470 EXPECT_FALSE(hotword_service->IsAlwaysOnEnabled());
472 // Enable regular hotwording, still not available.
473 profile()->GetPrefs()->SetBoolean(prefs::kHotwordSearchEnabled, true);
474 EXPECT_FALSE(hotword_service->IsAlwaysOnEnabled());
476 // Bypass hardware check.
477 base::CommandLine::ForCurrentProcess()->AppendSwitch(
478 switches::kEnableExperimentalHotwordHardware);
479 EXPECT_TRUE(hotword_service->IsAlwaysOnEnabled());
481 // Disable.
482 profile()->GetPrefs()->SetBoolean(prefs::kHotwordAlwaysOnSearchEnabled,
483 false);
484 EXPECT_FALSE(hotword_service->IsAlwaysOnEnabled());
487 TEST_P(HotwordServiceTest, IsSometimesOnEnabled) {
488 // Set the field trial to a valid one.
489 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
490 hotword_internal::kHotwordFieldTrialName, "Install"));
492 InitializeEmptyExtensionService();
493 service_->Init();
494 HotwordServiceFactory* hotword_service_factory =
495 HotwordServiceFactory::GetInstance();
497 MockHotwordService* hotword_service = static_cast<MockHotwordService*>(
498 hotword_service_factory->SetTestingFactoryAndUse(
499 profile(), BuildMockHotwordService));
500 EXPECT_TRUE(hotword_service != NULL);
501 hotword_service->SetExtensionService(service());
502 hotword_service->SetExtensionId(extension_id_);
504 // No pref set.
505 EXPECT_FALSE(hotword_service->IsSometimesOnEnabled());
507 // Set pref.
508 profile()->GetPrefs()->SetBoolean(prefs::kHotwordSearchEnabled, true);
509 EXPECT_TRUE(hotword_service->IsSometimesOnEnabled());
511 // Turn on always-on pref. Should have no effect.
512 profile()->GetPrefs()->SetBoolean(prefs::kHotwordAlwaysOnSearchEnabled, true);
513 EXPECT_TRUE(hotword_service->IsSometimesOnEnabled());
515 // Disable.
516 profile()->GetPrefs()->SetBoolean(prefs::kHotwordSearchEnabled, false);
517 EXPECT_FALSE(hotword_service->IsSometimesOnEnabled());
519 // Bypass rest of test for old hotwording.
520 if (extension_id_ != extension_misc::kHotwordSharedModuleId)
521 return;
523 // Bypass hardware check.
524 base::CommandLine::ForCurrentProcess()->AppendSwitch(
525 switches::kEnableExperimentalHotwordHardware);
527 // With hardware, only always-on is allowed.
528 EXPECT_FALSE(hotword_service->IsSometimesOnEnabled());
530 // Set pref.
531 profile()->GetPrefs()->SetBoolean(prefs::kHotwordSearchEnabled, true);
532 EXPECT_FALSE(hotword_service->IsSometimesOnEnabled());
534 // Disable always-on.
535 profile()->GetPrefs()->SetBoolean(prefs::kHotwordAlwaysOnSearchEnabled,
536 false);
537 EXPECT_FALSE(hotword_service->IsSometimesOnEnabled());
540 TEST_P(HotwordServiceTest, AudioHistorySyncOccurs) {
541 // Set the field trial to a valid one.
542 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
543 hotword_internal::kHotwordFieldTrialName, "Install"));
545 InitializeEmptyExtensionService();
546 service_->Init();
548 HotwordServiceFactory* hotword_service_factory =
549 HotwordServiceFactory::GetInstance();
551 MockHotwordService* hotword_service = static_cast<MockHotwordService*>(
552 hotword_service_factory->SetTestingFactoryAndUse(
553 profile(), BuildMockHotwordService));
554 EXPECT_TRUE(hotword_service != NULL);
555 hotword_service->SetExtensionService(service());
556 hotword_service->SetExtensionId(extension_id_);
558 scoped_refptr<base::TestSimpleTaskRunner> test_task_runner(
559 new base::TestSimpleTaskRunner());
560 MockAudioHistoryHandler* audio_history_handler =
561 new MockAudioHistoryHandler(profile(), test_task_runner, nullptr);
562 hotword_service->SetAudioHistoryHandler(audio_history_handler);
563 EXPECT_EQ(1, audio_history_handler->GetAudioHistoryCalls());
564 // We expect the next check for audio history to be in the queue.
565 EXPECT_EQ(base::TimeDelta::FromDays(1),
566 test_task_runner->NextPendingTaskDelay());
567 EXPECT_TRUE(test_task_runner->HasPendingTask());
568 test_task_runner->RunPendingTasks();
569 EXPECT_EQ(2, audio_history_handler->GetAudioHistoryCalls());
570 EXPECT_TRUE(test_task_runner->HasPendingTask());
571 test_task_runner->ClearPendingTasks();