| 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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 } | 151 } |
| 152 | 152 |
| 153 std::string extension_id_; | 153 std::string extension_id_; |
| 154 }; | 154 }; |
| 155 | 155 |
| 156 INSTANTIATE_TEST_CASE_P(HotwordServiceTests, | 156 INSTANTIATE_TEST_CASE_P(HotwordServiceTests, |
| 157 HotwordServiceTest, | 157 HotwordServiceTest, |
| 158 ::testing::Values( | 158 ::testing::Values( |
| 159 extension_misc::kHotwordSharedModuleId)); | 159 extension_misc::kHotwordSharedModuleId)); |
| 160 | 160 |
| 161 TEST_P(HotwordServiceTest, IsHotwordAllowedLocale) { | 161 // Disabled due to http://crbug.com/503963. |
| 162 TEST_P(HotwordServiceTest, DISABLED_IsHotwordAllowedLocale) { |
| 162 TestingProfile::Builder profile_builder; | 163 TestingProfile::Builder profile_builder; |
| 163 scoped_ptr<TestingProfile> profile = profile_builder.Build(); | 164 scoped_ptr<TestingProfile> profile = profile_builder.Build(); |
| 164 | 165 |
| 165 #if defined(ENABLE_HOTWORDING) | 166 #if defined(ENABLE_HOTWORDING) |
| 166 bool hotwording_enabled = true; | 167 bool hotwording_enabled = true; |
| 167 #else | 168 #else |
| 168 bool hotwording_enabled = false; | 169 bool hotwording_enabled = false; |
| 169 #endif | 170 #endif |
| 170 | 171 |
| 171 // Check that the service exists so that a NULL service be ruled out in | 172 // Check that the service exists so that a NULL service be ruled out in |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 | 294 |
| 294 // The previous locale should be set but should match the current | 295 // The previous locale should be set but should match the current |
| 295 // locale. No reason to uninstall. | 296 // locale. No reason to uninstall. |
| 296 EXPECT_FALSE(hotword_service->MaybeReinstallHotwordExtension()); | 297 EXPECT_FALSE(hotword_service->MaybeReinstallHotwordExtension()); |
| 297 | 298 |
| 298 // Switch the locale to a valid but different one. | 299 // Switch the locale to a valid but different one. |
| 299 SetApplicationLocale(profile(), "fr_fr"); | 300 SetApplicationLocale(profile(), "fr_fr"); |
| 300 #if defined(ENABLE_HOTWORDING) | 301 #if defined(ENABLE_HOTWORDING) |
| 301 EXPECT_TRUE(HotwordServiceFactory::IsHotwordAllowed(profile())); | 302 EXPECT_TRUE(HotwordServiceFactory::IsHotwordAllowed(profile())); |
| 302 #else | 303 #else |
| 303 EXPECT_FALSE(HotwordServiceFactory::IsHotwordAllowed(profile())); | 304 // Disabled due to http://crbug.com/503963. |
| 305 // EXPECT_FALSE(HotwordServiceFactory::IsHotwordAllowed(profile())); |
| 304 #endif | 306 #endif |
| 305 | 307 |
| 306 // Different but valid locale so expect uninstall. | 308 // Different but valid locale so expect uninstall. |
| 307 EXPECT_TRUE(hotword_service->MaybeReinstallHotwordExtension()); | 309 EXPECT_TRUE(hotword_service->MaybeReinstallHotwordExtension()); |
| 308 EXPECT_EQ(1, hotword_service->uninstall_count()); | 310 EXPECT_EQ(1, hotword_service->uninstall_count()); |
| 309 EXPECT_EQ("fr_fr", | 311 EXPECT_EQ("fr_fr", |
| 310 profile()->GetPrefs()->GetString(prefs::kHotwordPreviousLanguage)); | 312 profile()->GetPrefs()->GetString(prefs::kHotwordPreviousLanguage)); |
| 311 | 313 |
| 312 if (extension_id_ == extension_misc::kHotwordSharedModuleId) { | 314 if (extension_id_ == extension_misc::kHotwordSharedModuleId) { |
| 313 // Shared module is installed and enabled. | 315 // Shared module is installed and enabled. |
| 314 EXPECT_TRUE(registry()->enabled_extensions().Contains(extension_id_)); | 316 EXPECT_TRUE(registry()->enabled_extensions().Contains(extension_id_)); |
| 315 } else { | 317 } else { |
| 316 // Verify the extension is installed. It's still disabled. | 318 // Verify the extension is installed. It's still disabled. |
| 317 EXPECT_TRUE(registry()->disabled_extensions().Contains(extension_id_)); | 319 EXPECT_TRUE(registry()->disabled_extensions().Contains(extension_id_)); |
| 318 } | 320 } |
| 319 | 321 |
| 320 // Switch the locale to an invalid one. | 322 // Switch the locale to an invalid one. |
| 321 SetApplicationLocale(profile(), "invalid"); | 323 SetApplicationLocale(profile(), "invalid"); |
| 322 EXPECT_FALSE(HotwordServiceFactory::IsHotwordAllowed(profile())); | 324 EXPECT_FALSE(HotwordServiceFactory::IsHotwordAllowed(profile())); |
| 323 EXPECT_FALSE(hotword_service->MaybeReinstallHotwordExtension()); | 325 EXPECT_FALSE(hotword_service->MaybeReinstallHotwordExtension()); |
| 324 EXPECT_EQ("fr_fr", | 326 EXPECT_EQ("fr_fr", |
| 325 profile()->GetPrefs()->GetString(prefs::kHotwordPreviousLanguage)); | 327 profile()->GetPrefs()->GetString(prefs::kHotwordPreviousLanguage)); |
| 326 | 328 |
| 327 // If the locale is set back to the last valid one, then an uninstall-install | 329 // If the locale is set back to the last valid one, then an uninstall-install |
| 328 // shouldn't be needed. | 330 // shouldn't be needed. |
| 329 SetApplicationLocale(profile(), "fr_fr"); | 331 SetApplicationLocale(profile(), "fr_fr"); |
| 330 #if defined(ENABLE_HOTWORDING) | 332 #if defined(ENABLE_HOTWORDING) |
| 331 EXPECT_TRUE(HotwordServiceFactory::IsHotwordAllowed(profile())); | 333 EXPECT_TRUE(HotwordServiceFactory::IsHotwordAllowed(profile())); |
| 332 #else | 334 #else |
| 333 EXPECT_FALSE(HotwordServiceFactory::IsHotwordAllowed(profile())); | 335 // Disabled due to http://crbug.com/503963. |
| 336 // EXPECT_FALSE(HotwordServiceFactory::IsHotwordAllowed(profile())); |
| 334 #endif | 337 #endif |
| 335 EXPECT_FALSE(hotword_service->MaybeReinstallHotwordExtension()); | 338 EXPECT_FALSE(hotword_service->MaybeReinstallHotwordExtension()); |
| 336 EXPECT_EQ(1, hotword_service->uninstall_count()); // no change | 339 EXPECT_EQ(1, hotword_service->uninstall_count()); // no change |
| 337 } | 340 } |
| 338 | 341 |
| 339 TEST_P(HotwordServiceTest, DisableAlwaysOnOnLanguageChange) { | 342 TEST_P(HotwordServiceTest, DisableAlwaysOnOnLanguageChange) { |
| 340 // Bypass test for old hotwording. | 343 // Bypass test for old hotwording. |
| 341 if (extension_id_ != extension_misc::kHotwordSharedModuleId) | 344 if (extension_id_ != extension_misc::kHotwordSharedModuleId) |
| 342 return; | 345 return; |
| 343 | 346 |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 EXPECT_EQ(1, audio_history_handler->GetAudioHistoryCalls()); | 519 EXPECT_EQ(1, audio_history_handler->GetAudioHistoryCalls()); |
| 517 // We expect the next check for audio history to be in the queue. | 520 // We expect the next check for audio history to be in the queue. |
| 518 EXPECT_EQ(base::TimeDelta::FromDays(1), | 521 EXPECT_EQ(base::TimeDelta::FromDays(1), |
| 519 test_task_runner->NextPendingTaskDelay()); | 522 test_task_runner->NextPendingTaskDelay()); |
| 520 EXPECT_TRUE(test_task_runner->HasPendingTask()); | 523 EXPECT_TRUE(test_task_runner->HasPendingTask()); |
| 521 test_task_runner->RunPendingTasks(); | 524 test_task_runner->RunPendingTasks(); |
| 522 EXPECT_EQ(2, audio_history_handler->GetAudioHistoryCalls()); | 525 EXPECT_EQ(2, audio_history_handler->GetAudioHistoryCalls()); |
| 523 EXPECT_TRUE(test_task_runner->HasPendingTask()); | 526 EXPECT_TRUE(test_task_runner->HasPendingTask()); |
| 524 test_task_runner->ClearPendingTasks(); | 527 test_task_runner->ClearPendingTasks(); |
| 525 } | 528 } |
| OLD | NEW |