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

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

Issue 1201163002: Remove hotword installation code at compile time if hotwording disabled. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 11 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/external_component_loader.cc ('k') | chrome/chrome_browser.gypi » ('j') | 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 <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 } 156 }
157 157
158 std::string extension_id_; 158 std::string extension_id_;
159 }; 159 };
160 160
161 INSTANTIATE_TEST_CASE_P(HotwordServiceTests, 161 INSTANTIATE_TEST_CASE_P(HotwordServiceTests,
162 HotwordServiceTest, 162 HotwordServiceTest,
163 ::testing::Values( 163 ::testing::Values(
164 extension_misc::kHotwordSharedModuleId)); 164 extension_misc::kHotwordSharedModuleId));
165 165
166 // Disabled due to http://crbug.com/503963. 166 TEST_P(HotwordServiceTest, IsHotwordAllowedLocale) {
167 TEST_P(HotwordServiceTest, DISABLED_IsHotwordAllowedLocale) {
168 TestingProfile::Builder profile_builder; 167 TestingProfile::Builder profile_builder;
169 scoped_ptr<TestingProfile> profile = profile_builder.Build(); 168 scoped_ptr<TestingProfile> profile = profile_builder.Build();
170 169
171 #if defined(ENABLE_HOTWORDING) 170 #if defined(ENABLE_HOTWORDING)
172 bool hotwording_enabled = true; 171 bool hotwording_enabled = true;
173 #else 172 #else
174 bool hotwording_enabled = false; 173 bool hotwording_enabled = false;
175 #endif 174 #endif
176 175
177 // Check that the service exists so that a NULL service be ruled out in 176 // 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
299 298
300 // The previous locale should be set but should match the current 299 // The previous locale should be set but should match the current
301 // locale. No reason to uninstall. 300 // locale. No reason to uninstall.
302 EXPECT_FALSE(hotword_service->MaybeReinstallHotwordExtension()); 301 EXPECT_FALSE(hotword_service->MaybeReinstallHotwordExtension());
303 302
304 // Switch the locale to a valid but different one. 303 // Switch the locale to a valid but different one.
305 SetApplicationLocale(profile(), "fr_fr"); 304 SetApplicationLocale(profile(), "fr_fr");
306 #if defined(ENABLE_HOTWORDING) 305 #if defined(ENABLE_HOTWORDING)
307 EXPECT_TRUE(HotwordServiceFactory::IsHotwordAllowed(profile())); 306 EXPECT_TRUE(HotwordServiceFactory::IsHotwordAllowed(profile()));
308 #else 307 #else
309 // Disabled due to http://crbug.com/503963. 308 EXPECT_FALSE(HotwordServiceFactory::IsHotwordAllowed(profile()));
310 // EXPECT_FALSE(HotwordServiceFactory::IsHotwordAllowed(profile()));
311 #endif 309 #endif
312 310
313 // Different but valid locale so expect uninstall. 311 // Different but valid locale so expect uninstall.
314 EXPECT_TRUE(hotword_service->MaybeReinstallHotwordExtension()); 312 EXPECT_TRUE(hotword_service->MaybeReinstallHotwordExtension());
315 EXPECT_EQ(1, hotword_service->uninstall_count()); 313 EXPECT_EQ(1, hotword_service->uninstall_count());
316 EXPECT_EQ("fr_fr", 314 EXPECT_EQ("fr_fr",
317 profile()->GetPrefs()->GetString(prefs::kHotwordPreviousLanguage)); 315 profile()->GetPrefs()->GetString(prefs::kHotwordPreviousLanguage));
318 316
319 if (extension_id_ == extension_misc::kHotwordSharedModuleId) { 317 if (extension_id_ == extension_misc::kHotwordSharedModuleId) {
320 // Shared module is installed and enabled. 318 // Shared module is installed and enabled.
321 EXPECT_TRUE(registry()->enabled_extensions().Contains(extension_id_)); 319 EXPECT_TRUE(registry()->enabled_extensions().Contains(extension_id_));
322 } else { 320 } else {
323 // Verify the extension is installed. It's still disabled. 321 // Verify the extension is installed. It's still disabled.
324 EXPECT_TRUE(registry()->disabled_extensions().Contains(extension_id_)); 322 EXPECT_TRUE(registry()->disabled_extensions().Contains(extension_id_));
325 } 323 }
326 324
327 // Switch the locale to an invalid one. 325 // Switch the locale to an invalid one.
328 SetApplicationLocale(profile(), "invalid"); 326 SetApplicationLocale(profile(), "invalid");
329 EXPECT_FALSE(HotwordServiceFactory::IsHotwordAllowed(profile())); 327 EXPECT_FALSE(HotwordServiceFactory::IsHotwordAllowed(profile()));
330 EXPECT_FALSE(hotword_service->MaybeReinstallHotwordExtension()); 328 EXPECT_FALSE(hotword_service->MaybeReinstallHotwordExtension());
331 EXPECT_EQ("fr_fr", 329 EXPECT_EQ("fr_fr",
332 profile()->GetPrefs()->GetString(prefs::kHotwordPreviousLanguage)); 330 profile()->GetPrefs()->GetString(prefs::kHotwordPreviousLanguage));
333 331
334 // If the locale is set back to the last valid one, then an uninstall-install 332 // If the locale is set back to the last valid one, then an uninstall-install
335 // shouldn't be needed. 333 // shouldn't be needed.
336 SetApplicationLocale(profile(), "fr_fr"); 334 SetApplicationLocale(profile(), "fr_fr");
337 #if defined(ENABLE_HOTWORDING) 335 #if defined(ENABLE_HOTWORDING)
338 EXPECT_TRUE(HotwordServiceFactory::IsHotwordAllowed(profile())); 336 EXPECT_TRUE(HotwordServiceFactory::IsHotwordAllowed(profile()));
339 #else 337 #else
340 // Disabled due to http://crbug.com/503963. 338 EXPECT_FALSE(HotwordServiceFactory::IsHotwordAllowed(profile()));
341 // EXPECT_FALSE(HotwordServiceFactory::IsHotwordAllowed(profile()));
342 #endif 339 #endif
343 EXPECT_FALSE(hotword_service->MaybeReinstallHotwordExtension()); 340 EXPECT_FALSE(hotword_service->MaybeReinstallHotwordExtension());
344 EXPECT_EQ(1, hotword_service->uninstall_count()); // no change 341 EXPECT_EQ(1, hotword_service->uninstall_count()); // no change
345 } 342 }
346 343
347 TEST_P(HotwordServiceTest, DisableAlwaysOnOnLanguageChange) { 344 TEST_P(HotwordServiceTest, DisableAlwaysOnOnLanguageChange) {
348 // Bypass test for old hotwording. 345 // Bypass test for old hotwording.
349 if (extension_id_ != extension_misc::kHotwordSharedModuleId) 346 if (extension_id_ != extension_misc::kHotwordSharedModuleId)
350 return; 347 return;
351 348
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 EXPECT_EQ(1, audio_history_handler->GetAudioHistoryCalls()); 521 EXPECT_EQ(1, audio_history_handler->GetAudioHistoryCalls());
525 // We expect the next check for audio history to be in the queue. 522 // We expect the next check for audio history to be in the queue.
526 EXPECT_EQ(base::TimeDelta::FromDays(1), 523 EXPECT_EQ(base::TimeDelta::FromDays(1),
527 test_task_runner->NextPendingTaskDelay()); 524 test_task_runner->NextPendingTaskDelay());
528 EXPECT_TRUE(test_task_runner->HasPendingTask()); 525 EXPECT_TRUE(test_task_runner->HasPendingTask());
529 test_task_runner->RunPendingTasks(); 526 test_task_runner->RunPendingTasks();
530 EXPECT_EQ(2, audio_history_handler->GetAudioHistoryCalls()); 527 EXPECT_EQ(2, audio_history_handler->GetAudioHistoryCalls());
531 EXPECT_TRUE(test_task_runner->HasPendingTask()); 528 EXPECT_TRUE(test_task_runner->HasPendingTask());
532 test_task_runner->ClearPendingTasks(); 529 test_task_runner->ClearPendingTasks();
533 } 530 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/external_component_loader.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698