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

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

Issue 337243003: [Hotword] Remove non-English languages due to feature getting bumped to next milestone. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove debugging Created 6 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/search/hotword_service.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 "base/metrics/field_trial.h" 5 #include "base/metrics/field_trial.h"
6 #include "base/prefs/pref_service.h" 6 #include "base/prefs/pref_service.h"
7 #include "chrome/browser/browser_process.h" 7 #include "chrome/browser/browser_process.h"
8 #include "chrome/browser/search/hotword_service.h" 8 #include "chrome/browser/search/hotword_service.h"
9 #include "chrome/browser/search/hotword_service_factory.h" 9 #include "chrome/browser/search/hotword_service_factory.h"
10 #include "chrome/common/pref_names.h" 10 #include "chrome/common/pref_names.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 SetApplicationLocale(static_cast<Profile*>(profile.get()), "non-valid"); 94 SetApplicationLocale(static_cast<Profile*>(profile.get()), "non-valid");
95 EXPECT_FALSE(HotwordServiceFactory::IsHotwordAllowed(profile.get())); 95 EXPECT_FALSE(HotwordServiceFactory::IsHotwordAllowed(profile.get()));
96 96
97 // Now with valid locales it should be fine. 97 // Now with valid locales it should be fine.
98 SetApplicationLocale(static_cast<Profile*>(profile.get()), "en"); 98 SetApplicationLocale(static_cast<Profile*>(profile.get()), "en");
99 EXPECT_TRUE(HotwordServiceFactory::IsHotwordAllowed(profile.get())); 99 EXPECT_TRUE(HotwordServiceFactory::IsHotwordAllowed(profile.get()));
100 SetApplicationLocale(static_cast<Profile*>(profile.get()), "en-US"); 100 SetApplicationLocale(static_cast<Profile*>(profile.get()), "en-US");
101 EXPECT_TRUE(HotwordServiceFactory::IsHotwordAllowed(profile.get())); 101 EXPECT_TRUE(HotwordServiceFactory::IsHotwordAllowed(profile.get()));
102 SetApplicationLocale(static_cast<Profile*>(profile.get()), "en_us"); 102 SetApplicationLocale(static_cast<Profile*>(profile.get()), "en_us");
103 EXPECT_TRUE(HotwordServiceFactory::IsHotwordAllowed(profile.get())); 103 EXPECT_TRUE(HotwordServiceFactory::IsHotwordAllowed(profile.get()));
104 SetApplicationLocale(static_cast<Profile*>(profile.get()), "en_gb");
105 EXPECT_FALSE(HotwordServiceFactory::IsHotwordAllowed(profile.get()));
104 SetApplicationLocale(static_cast<Profile*>(profile.get()), "de_DE"); 106 SetApplicationLocale(static_cast<Profile*>(profile.get()), "de_DE");
105 EXPECT_TRUE(HotwordServiceFactory::IsHotwordAllowed(profile.get())); 107 EXPECT_FALSE(HotwordServiceFactory::IsHotwordAllowed(profile.get()));
106 SetApplicationLocale(static_cast<Profile*>(profile.get()), "fr_fr"); 108 SetApplicationLocale(static_cast<Profile*>(profile.get()), "fr_fr");
107 EXPECT_TRUE(HotwordServiceFactory::IsHotwordAllowed(profile.get())); 109 EXPECT_FALSE(HotwordServiceFactory::IsHotwordAllowed(profile.get()));
108 110
109 // Test that incognito even with a valid locale and valid field trial 111 // Test that incognito even with a valid locale and valid field trial
110 // still returns false. 112 // still returns false.
111 SetApplicationLocale(static_cast<Profile*>(otr_profile.get()), "en"); 113 SetApplicationLocale(static_cast<Profile*>(otr_profile.get()), "en");
112 EXPECT_FALSE(HotwordServiceFactory::IsHotwordAllowed(otr_profile.get())); 114 EXPECT_FALSE(HotwordServiceFactory::IsHotwordAllowed(otr_profile.get()));
113 } 115 }
114 116
115 TEST_F(HotwordServiceTest, AudioLoggingPrefSetCorrectly) { 117 TEST_F(HotwordServiceTest, AudioLoggingPrefSetCorrectly) {
116 TestingProfile::Builder profile_builder; 118 TestingProfile::Builder profile_builder;
117 scoped_ptr<TestingProfile> profile = profile_builder.Build(); 119 scoped_ptr<TestingProfile> profile = profile_builder.Build();
118 120
119 HotwordServiceFactory* hotword_service_factory = 121 HotwordServiceFactory* hotword_service_factory =
120 HotwordServiceFactory::GetInstance(); 122 HotwordServiceFactory::GetInstance();
121 HotwordService* hotword_service = 123 HotwordService* hotword_service =
122 hotword_service_factory->GetForProfile(profile.get()); 124 hotword_service_factory->GetForProfile(profile.get());
123 EXPECT_TRUE(hotword_service != NULL); 125 EXPECT_TRUE(hotword_service != NULL);
124 126
125 // If it's a fresh profile, although the default value is true, 127 // If it's a fresh profile, although the default value is true,
126 // it should return false if the preference has never been set. 128 // it should return false if the preference has never been set.
127 EXPECT_FALSE(hotword_service->IsOptedIntoAudioLogging()); 129 EXPECT_FALSE(hotword_service->IsOptedIntoAudioLogging());
128 } 130 }
OLDNEW
« no previous file with comments | « chrome/browser/search/hotword_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698