| OLD | NEW |
| 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/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 7 #include "base/metrics/field_trial.h" | 7 #include "base/metrics/field_trial.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "base/test/test_simple_task_runner.h" | 9 #include "base/test/test_simple_task_runner.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 #if defined(OS_CHROMEOS) | 126 #if defined(OS_CHROMEOS) |
| 127 // On ChromeOS locale is per-profile. | 127 // On ChromeOS locale is per-profile. |
| 128 profile->GetPrefs()->SetString(prefs::kApplicationLocale, new_locale); | 128 profile->GetPrefs()->SetString(prefs::kApplicationLocale, new_locale); |
| 129 #else | 129 #else |
| 130 g_browser_process->SetApplicationLocale(new_locale); | 130 g_browser_process->SetApplicationLocale(new_locale); |
| 131 #endif | 131 #endif |
| 132 } | 132 } |
| 133 | 133 |
| 134 void SetUp() override { | 134 void SetUp() override { |
| 135 extension_id_ = GetParam(); | 135 extension_id_ = GetParam(); |
| 136 if (extension_id_ == extension_misc::kHotwordExtensionId) { | |
| 137 base::CommandLine::ForCurrentProcess()->AppendSwitch( | |
| 138 switches::kDisableExperimentalHotwording); | |
| 139 } | |
| 140 #if defined(OS_CHROMEOS) | 136 #if defined(OS_CHROMEOS) |
| 141 // Tests on chromeos need to have the handler initialized. | 137 // Tests on chromeos need to have the handler initialized. |
| 142 chromeos::CrasAudioHandler::InitializeForTesting(); | 138 chromeos::CrasAudioHandler::InitializeForTesting(); |
| 143 #endif | 139 #endif |
| 144 | 140 |
| 145 extensions::ExtensionServiceTestBase::SetUp(); | 141 extensions::ExtensionServiceTestBase::SetUp(); |
| 146 } | 142 } |
| 147 | 143 |
| 148 void TearDown() override { | 144 void TearDown() override { |
| 149 #if defined(OS_CHROMEOS) | 145 #if defined(OS_CHROMEOS) |
| 150 DCHECK(chromeos::CrasAudioHandler::IsInitialized()); | 146 DCHECK(chromeos::CrasAudioHandler::IsInitialized()); |
| 151 chromeos::CrasAudioHandler::Shutdown(); | 147 chromeos::CrasAudioHandler::Shutdown(); |
| 152 #endif | 148 #endif |
| 153 } | 149 } |
| 154 | 150 |
| 155 base::FieldTrialList field_trial_list_; | 151 base::FieldTrialList field_trial_list_; |
| 156 std::string extension_id_; | 152 std::string extension_id_; |
| 157 }; | 153 }; |
| 158 | 154 |
| 159 INSTANTIATE_TEST_CASE_P(HotwordServiceTests, | 155 INSTANTIATE_TEST_CASE_P(HotwordServiceTests, |
| 160 HotwordServiceTest, | 156 HotwordServiceTest, |
| 161 ::testing::Values( | 157 ::testing::Values( |
| 162 extension_misc::kHotwordExtensionId, | |
| 163 extension_misc::kHotwordSharedModuleId)); | 158 extension_misc::kHotwordSharedModuleId)); |
| 164 | 159 |
| 165 TEST_P(HotwordServiceTest, IsHotwordAllowedDisabledFieldTrial) { | 160 TEST_P(HotwordServiceTest, IsHotwordAllowedDisabledFieldTrial) { |
| 166 TestingProfile::Builder profile_builder; | 161 TestingProfile::Builder profile_builder; |
| 167 scoped_ptr<TestingProfile> profile = profile_builder.Build(); | 162 scoped_ptr<TestingProfile> profile = profile_builder.Build(); |
| 168 | 163 |
| 169 // Check that the service exists so that a NULL service be ruled out in | 164 // Check that the service exists so that a NULL service be ruled out in |
| 170 // following tests. | 165 // following tests. |
| 171 HotwordService* hotword_service = | 166 HotwordService* hotword_service = |
| 172 HotwordServiceFactory::GetForProfile(profile.get()); | 167 HotwordServiceFactory::GetForProfile(profile.get()); |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 EXPECT_EQ(1, audio_history_handler->GetAudioHistoryCalls()); | 550 EXPECT_EQ(1, audio_history_handler->GetAudioHistoryCalls()); |
| 556 // We expect the next check for audio history to be in the queue. | 551 // We expect the next check for audio history to be in the queue. |
| 557 EXPECT_EQ(base::TimeDelta::FromDays(1), | 552 EXPECT_EQ(base::TimeDelta::FromDays(1), |
| 558 test_task_runner->NextPendingTaskDelay()); | 553 test_task_runner->NextPendingTaskDelay()); |
| 559 EXPECT_TRUE(test_task_runner->HasPendingTask()); | 554 EXPECT_TRUE(test_task_runner->HasPendingTask()); |
| 560 test_task_runner->RunPendingTasks(); | 555 test_task_runner->RunPendingTasks(); |
| 561 EXPECT_EQ(2, audio_history_handler->GetAudioHistoryCalls()); | 556 EXPECT_EQ(2, audio_history_handler->GetAudioHistoryCalls()); |
| 562 EXPECT_TRUE(test_task_runner->HasPendingTask()); | 557 EXPECT_TRUE(test_task_runner->HasPendingTask()); |
| 563 test_task_runner->ClearPendingTasks(); | 558 test_task_runner->ClearPendingTasks(); |
| 564 } | 559 } |
| OLD | NEW |