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

Side by Side Diff: chrome/browser/search/hotword_service_unittest.cc

Issue 2045833003: Fix HotwordServiceTest under ubsan: no more vcalls on garbage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix two more test cases Created 4 years, 6 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
« no previous file with comments | « chrome/browser/extensions/component_loader_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/browser/search/hotword_service.h" 5 #include "chrome/browser/search/hotword_service.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 SetApplicationLocale(profile(), "en"); 227 SetApplicationLocale(profile(), "en");
228 hotword_service->SetPreviousLanguagePref(); 228 hotword_service->SetPreviousLanguagePref();
229 229
230 // Now a locale is set, but it hasn't changed. 230 // Now a locale is set, but it hasn't changed.
231 EXPECT_FALSE(hotword_service->ShouldReinstallHotwordExtension()); 231 EXPECT_FALSE(hotword_service->ShouldReinstallHotwordExtension());
232 232
233 SetApplicationLocale(profile(), "fr_fr"); 233 SetApplicationLocale(profile(), "fr_fr");
234 234
235 // Now it's a different locale so it should uninstall. 235 // Now it's a different locale so it should uninstall.
236 EXPECT_TRUE(hotword_service->ShouldReinstallHotwordExtension()); 236 EXPECT_TRUE(hotword_service->ShouldReinstallHotwordExtension());
237
238 base::MessageLoop::current()->RunUntilIdle();
237 } 239 }
238 240
239 TEST_P(HotwordServiceTest, PreviousLanguageSetOnInstall) { 241 TEST_P(HotwordServiceTest, PreviousLanguageSetOnInstall) {
240 InitializeEmptyExtensionService(); 242 InitializeEmptyExtensionService();
241 service_->Init(); 243 service_->Init();
242 244
243 HotwordServiceFactory* hotword_service_factory = 245 HotwordServiceFactory* hotword_service_factory =
244 HotwordServiceFactory::GetInstance(); 246 HotwordServiceFactory::GetInstance();
245 247
246 MockHotwordService* hotword_service = static_cast<MockHotwordService*>( 248 MockHotwordService* hotword_service = static_cast<MockHotwordService*>(
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 447
446 // Bypass hardware check. 448 // Bypass hardware check.
447 base::CommandLine::ForCurrentProcess()->AppendSwitch( 449 base::CommandLine::ForCurrentProcess()->AppendSwitch(
448 switches::kEnableExperimentalHotwordHardware); 450 switches::kEnableExperimentalHotwordHardware);
449 EXPECT_TRUE(hotword_service->IsAlwaysOnEnabled()); 451 EXPECT_TRUE(hotword_service->IsAlwaysOnEnabled());
450 452
451 // Disable. 453 // Disable.
452 profile()->GetPrefs()->SetBoolean(prefs::kHotwordAlwaysOnSearchEnabled, 454 profile()->GetPrefs()->SetBoolean(prefs::kHotwordAlwaysOnSearchEnabled,
453 false); 455 false);
454 EXPECT_FALSE(hotword_service->IsAlwaysOnEnabled()); 456 EXPECT_FALSE(hotword_service->IsAlwaysOnEnabled());
457 base::MessageLoop::current()->RunUntilIdle();
455 } 458 }
456 459
457 TEST_P(HotwordServiceTest, IsSometimesOnEnabled) { 460 TEST_P(HotwordServiceTest, IsSometimesOnEnabled) {
458 InitializeEmptyExtensionService(); 461 InitializeEmptyExtensionService();
459 service_->Init(); 462 service_->Init();
460 HotwordServiceFactory* hotword_service_factory = 463 HotwordServiceFactory* hotword_service_factory =
461 HotwordServiceFactory::GetInstance(); 464 HotwordServiceFactory::GetInstance();
462 465
463 MockHotwordService* hotword_service = static_cast<MockHotwordService*>( 466 MockHotwordService* hotword_service = static_cast<MockHotwordService*>(
464 hotword_service_factory->SetTestingFactoryAndUse( 467 hotword_service_factory->SetTestingFactoryAndUse(
(...skipping 29 matching lines...) Expand all
494 EXPECT_FALSE(hotword_service->IsSometimesOnEnabled()); 497 EXPECT_FALSE(hotword_service->IsSometimesOnEnabled());
495 498
496 // Set pref. 499 // Set pref.
497 profile()->GetPrefs()->SetBoolean(prefs::kHotwordSearchEnabled, true); 500 profile()->GetPrefs()->SetBoolean(prefs::kHotwordSearchEnabled, true);
498 EXPECT_FALSE(hotword_service->IsSometimesOnEnabled()); 501 EXPECT_FALSE(hotword_service->IsSometimesOnEnabled());
499 502
500 // Disable always-on. 503 // Disable always-on.
501 profile()->GetPrefs()->SetBoolean(prefs::kHotwordAlwaysOnSearchEnabled, 504 profile()->GetPrefs()->SetBoolean(prefs::kHotwordAlwaysOnSearchEnabled,
502 false); 505 false);
503 EXPECT_FALSE(hotword_service->IsSometimesOnEnabled()); 506 EXPECT_FALSE(hotword_service->IsSometimesOnEnabled());
507 base::MessageLoop::current()->RunUntilIdle();
504 } 508 }
505 509
506 TEST_P(HotwordServiceTest, AudioHistorySyncOccurs) { 510 TEST_P(HotwordServiceTest, AudioHistorySyncOccurs) {
507 InitializeEmptyExtensionService(); 511 InitializeEmptyExtensionService();
508 service_->Init(); 512 service_->Init();
509 513
510 HotwordServiceFactory* hotword_service_factory = 514 HotwordServiceFactory* hotword_service_factory =
511 HotwordServiceFactory::GetInstance(); 515 HotwordServiceFactory::GetInstance();
512 516
513 MockHotwordService* hotword_service = static_cast<MockHotwordService*>( 517 MockHotwordService* hotword_service = static_cast<MockHotwordService*>(
(...skipping 10 matching lines...) Expand all
524 hotword_service->SetAudioHistoryHandler(audio_history_handler); 528 hotword_service->SetAudioHistoryHandler(audio_history_handler);
525 EXPECT_EQ(1, audio_history_handler->GetAudioHistoryCalls()); 529 EXPECT_EQ(1, audio_history_handler->GetAudioHistoryCalls());
526 // We expect the next check for audio history to be in the queue. 530 // We expect the next check for audio history to be in the queue.
527 EXPECT_EQ(base::TimeDelta::FromDays(1), 531 EXPECT_EQ(base::TimeDelta::FromDays(1),
528 test_task_runner->NextPendingTaskDelay()); 532 test_task_runner->NextPendingTaskDelay());
529 EXPECT_TRUE(test_task_runner->HasPendingTask()); 533 EXPECT_TRUE(test_task_runner->HasPendingTask());
530 test_task_runner->RunPendingTasks(); 534 test_task_runner->RunPendingTasks();
531 EXPECT_EQ(2, audio_history_handler->GetAudioHistoryCalls()); 535 EXPECT_EQ(2, audio_history_handler->GetAudioHistoryCalls());
532 EXPECT_TRUE(test_task_runner->HasPendingTask()); 536 EXPECT_TRUE(test_task_runner->HasPendingTask());
533 test_task_runner->ClearPendingTasks(); 537 test_task_runner->ClearPendingTasks();
538 base::MessageLoop::current()->RunUntilIdle();
534 } 539 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/component_loader_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698