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

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

Issue 340413003: Revert 277718 "[Hotword] Remove non-English languages due to fea..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: 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 | « trunk/src/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()));
106 SetApplicationLocale(static_cast<Profile*>(profile.get()), "de_DE"); 104 SetApplicationLocale(static_cast<Profile*>(profile.get()), "de_DE");
107 EXPECT_FALSE(HotwordServiceFactory::IsHotwordAllowed(profile.get())); 105 EXPECT_TRUE(HotwordServiceFactory::IsHotwordAllowed(profile.get()));
108 SetApplicationLocale(static_cast<Profile*>(profile.get()), "fr_fr"); 106 SetApplicationLocale(static_cast<Profile*>(profile.get()), "fr_fr");
109 EXPECT_FALSE(HotwordServiceFactory::IsHotwordAllowed(profile.get())); 107 EXPECT_TRUE(HotwordServiceFactory::IsHotwordAllowed(profile.get()));
110 108
111 // Test that incognito even with a valid locale and valid field trial 109 // Test that incognito even with a valid locale and valid field trial
112 // still returns false. 110 // still returns false.
113 SetApplicationLocale(static_cast<Profile*>(otr_profile.get()), "en"); 111 SetApplicationLocale(static_cast<Profile*>(otr_profile.get()), "en");
114 EXPECT_FALSE(HotwordServiceFactory::IsHotwordAllowed(otr_profile.get())); 112 EXPECT_FALSE(HotwordServiceFactory::IsHotwordAllowed(otr_profile.get()));
115 } 113 }
116 114
117 TEST_F(HotwordServiceTest, AudioLoggingPrefSetCorrectly) { 115 TEST_F(HotwordServiceTest, AudioLoggingPrefSetCorrectly) {
118 TestingProfile::Builder profile_builder; 116 TestingProfile::Builder profile_builder;
119 scoped_ptr<TestingProfile> profile = profile_builder.Build(); 117 scoped_ptr<TestingProfile> profile = profile_builder.Build();
120 118
121 HotwordServiceFactory* hotword_service_factory = 119 HotwordServiceFactory* hotword_service_factory =
122 HotwordServiceFactory::GetInstance(); 120 HotwordServiceFactory::GetInstance();
123 HotwordService* hotword_service = 121 HotwordService* hotword_service =
124 hotword_service_factory->GetForProfile(profile.get()); 122 hotword_service_factory->GetForProfile(profile.get());
125 EXPECT_TRUE(hotword_service != NULL); 123 EXPECT_TRUE(hotword_service != NULL);
126 124
127 // If it's a fresh profile, although the default value is true, 125 // If it's a fresh profile, although the default value is true,
128 // it should return false if the preference has never been set. 126 // it should return false if the preference has never been set.
129 EXPECT_FALSE(hotword_service->IsOptedIntoAudioLogging()); 127 EXPECT_FALSE(hotword_service->IsOptedIntoAudioLogging());
130 } 128 }
OLDNEW
« no previous file with comments | « trunk/src/chrome/browser/search/hotword_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698