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

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

Issue 731373002: Enable MSVC warning for unused locals. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Another Windows fix Created 6 years, 1 month 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
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/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 "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/extensions/extension_service_test_base.h" 10 #include "chrome/browser/extensions/extension_service_test_base.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 INSTANTIATE_TEST_CASE_P(HotwordServiceTests, 110 INSTANTIATE_TEST_CASE_P(HotwordServiceTests,
111 HotwordServiceTest, 111 HotwordServiceTest,
112 ::testing::Values( 112 ::testing::Values(
113 extension_misc::kHotwordExtensionId, 113 extension_misc::kHotwordExtensionId,
114 extension_misc::kHotwordSharedModuleId)); 114 extension_misc::kHotwordSharedModuleId));
115 115
116 TEST_P(HotwordServiceTest, IsHotwordAllowedBadFieldTrial) { 116 TEST_P(HotwordServiceTest, IsHotwordAllowedBadFieldTrial) {
117 TestingProfile::Builder profile_builder; 117 TestingProfile::Builder profile_builder;
118 scoped_ptr<TestingProfile> profile = profile_builder.Build(); 118 scoped_ptr<TestingProfile> profile = profile_builder.Build();
119 119
120 HotwordServiceFactory* hotword_service_factory =
121 HotwordServiceFactory::GetInstance();
122
123 // Check that the service exists so that a NULL service be ruled out in 120 // Check that the service exists so that a NULL service be ruled out in
124 // following tests. 121 // following tests.
125 HotwordService* hotword_service = 122 HotwordService* hotword_service =
126 hotword_service_factory->GetForProfile(profile.get()); 123 HotwordServiceFactory::GetForProfile(profile.get());
127 EXPECT_TRUE(hotword_service != NULL); 124 EXPECT_TRUE(hotword_service != NULL);
128 125
129 // When the field trial is empty or Disabled, it should not be allowed. 126 // When the field trial is empty or Disabled, it should not be allowed.
130 std::string group = base::FieldTrialList::FindFullName( 127 std::string group = base::FieldTrialList::FindFullName(
131 hotword_internal::kHotwordFieldTrialName); 128 hotword_internal::kHotwordFieldTrialName);
132 EXPECT_TRUE(group.empty()); 129 EXPECT_TRUE(group.empty());
133 EXPECT_FALSE(HotwordServiceFactory::IsHotwordAllowed(profile.get())); 130 EXPECT_FALSE(HotwordServiceFactory::IsHotwordAllowed(profile.get()));
134 131
135 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( 132 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
136 hotword_internal::kHotwordFieldTrialName, 133 hotword_internal::kHotwordFieldTrialName,
137 hotword_internal::kHotwordFieldTrialDisabledGroupName)); 134 hotword_internal::kHotwordFieldTrialDisabledGroupName));
138 group = base::FieldTrialList::FindFullName( 135 group = base::FieldTrialList::FindFullName(
139 hotword_internal::kHotwordFieldTrialName); 136 hotword_internal::kHotwordFieldTrialName);
140 EXPECT_TRUE(group ==hotword_internal::kHotwordFieldTrialDisabledGroupName); 137 EXPECT_TRUE(group == hotword_internal::kHotwordFieldTrialDisabledGroupName);
141 EXPECT_FALSE(HotwordServiceFactory::IsHotwordAllowed(profile.get())); 138 EXPECT_FALSE(HotwordServiceFactory::IsHotwordAllowed(profile.get()));
142 139
143 // Set a valid locale with invalid field trial to be sure it is 140 // Set a valid locale with invalid field trial to be sure it is
144 // still false. 141 // still false.
145 SetApplicationLocale(static_cast<Profile*>(profile.get()), "en"); 142 SetApplicationLocale(static_cast<Profile*>(profile.get()), "en");
146 EXPECT_FALSE(HotwordServiceFactory::IsHotwordAllowed(profile.get())); 143 EXPECT_FALSE(HotwordServiceFactory::IsHotwordAllowed(profile.get()));
147 144
148 // Test that incognito returns false as well. 145 // Test that incognito returns false as well.
149 EXPECT_FALSE(HotwordServiceFactory::IsHotwordAllowed( 146 EXPECT_FALSE(HotwordServiceFactory::IsHotwordAllowed(
150 profile->GetOffTheRecordProfile())); 147 profile->GetOffTheRecordProfile()));
151 } 148 }
152 149
153 TEST_P(HotwordServiceTest, IsHotwordAllowedLocale) { 150 TEST_P(HotwordServiceTest, IsHotwordAllowedLocale) {
154 TestingProfile::Builder profile_builder; 151 TestingProfile::Builder profile_builder;
155 scoped_ptr<TestingProfile> profile = profile_builder.Build(); 152 scoped_ptr<TestingProfile> profile = profile_builder.Build();
156 153
157 HotwordServiceFactory* hotword_service_factory =
158 HotwordServiceFactory::GetInstance();
159
160 // Check that the service exists so that a NULL service be ruled out in 154 // Check that the service exists so that a NULL service be ruled out in
161 // following tests. 155 // following tests.
162 HotwordService* hotword_service = 156 HotwordService* hotword_service =
163 hotword_service_factory->GetForProfile(profile.get()); 157 HotwordServiceFactory::GetForProfile(profile.get());
164 EXPECT_TRUE(hotword_service != NULL); 158 EXPECT_TRUE(hotword_service != NULL);
165 159
166 // Set the field trial to a valid one. 160 // Set the field trial to a valid one.
167 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( 161 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
168 hotword_internal::kHotwordFieldTrialName, "Good")); 162 hotword_internal::kHotwordFieldTrialName, "Good"));
169 163
170 // Set the language to an invalid one. 164 // Set the language to an invalid one.
171 SetApplicationLocale(static_cast<Profile*>(profile.get()), "non-valid"); 165 SetApplicationLocale(static_cast<Profile*>(profile.get()), "non-valid");
172 EXPECT_FALSE(HotwordServiceFactory::IsHotwordAllowed(profile.get())); 166 EXPECT_FALSE(HotwordServiceFactory::IsHotwordAllowed(profile.get()));
173 167
(...skipping 13 matching lines...) Expand all
187 // still returns false. 181 // still returns false.
188 Profile* otr_profile = profile->GetOffTheRecordProfile(); 182 Profile* otr_profile = profile->GetOffTheRecordProfile();
189 SetApplicationLocale(otr_profile, "en"); 183 SetApplicationLocale(otr_profile, "en");
190 EXPECT_FALSE(HotwordServiceFactory::IsHotwordAllowed(otr_profile)); 184 EXPECT_FALSE(HotwordServiceFactory::IsHotwordAllowed(otr_profile));
191 } 185 }
192 186
193 TEST_P(HotwordServiceTest, AudioLoggingPrefSetCorrectly) { 187 TEST_P(HotwordServiceTest, AudioLoggingPrefSetCorrectly) {
194 TestingProfile::Builder profile_builder; 188 TestingProfile::Builder profile_builder;
195 scoped_ptr<TestingProfile> profile = profile_builder.Build(); 189 scoped_ptr<TestingProfile> profile = profile_builder.Build();
196 190
197 HotwordServiceFactory* hotword_service_factory =
198 HotwordServiceFactory::GetInstance();
199 HotwordService* hotword_service = 191 HotwordService* hotword_service =
200 hotword_service_factory->GetForProfile(profile.get()); 192 HotwordServiceFactory::GetForProfile(profile.get());
201 EXPECT_TRUE(hotword_service != NULL); 193 EXPECT_TRUE(hotword_service != NULL);
202 194
203 // If it's a fresh profile, although the default value is true, 195 // If it's a fresh profile, although the default value is true,
204 // it should return false if the preference has never been set. 196 // it should return false if the preference has never been set.
205 EXPECT_FALSE(hotword_service->IsOptedIntoAudioLogging()); 197 EXPECT_FALSE(hotword_service->IsOptedIntoAudioLogging());
206 } 198 }
207 199
208 TEST_P(HotwordServiceTest, ShouldReinstallExtension) { 200 TEST_P(HotwordServiceTest, ShouldReinstallExtension) {
209 // Set the field trial to a valid one. 201 // Set the field trial to a valid one.
210 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( 202 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 EXPECT_FALSE(hotword_service->MaybeReinstallHotwordExtension()); 397 EXPECT_FALSE(hotword_service->MaybeReinstallHotwordExtension());
406 EXPECT_TRUE(hotword_service->IsAlwaysOnEnabled()); 398 EXPECT_TRUE(hotword_service->IsAlwaysOnEnabled());
407 399
408 // If the locale is set back to the last valid one, then an uninstall-install 400 // If the locale is set back to the last valid one, then an uninstall-install
409 // shouldn't be needed. 401 // shouldn't be needed.
410 SetApplicationLocale(profile(), "fr_fr"); 402 SetApplicationLocale(profile(), "fr_fr");
411 EXPECT_TRUE(HotwordServiceFactory::IsHotwordAllowed(profile())); 403 EXPECT_TRUE(HotwordServiceFactory::IsHotwordAllowed(profile()));
412 EXPECT_FALSE(hotword_service->MaybeReinstallHotwordExtension()); 404 EXPECT_FALSE(hotword_service->MaybeReinstallHotwordExtension());
413 EXPECT_TRUE(hotword_service->IsAlwaysOnEnabled()); 405 EXPECT_TRUE(hotword_service->IsAlwaysOnEnabled());
414 } 406 }
OLDNEW
« no previous file with comments | « chrome/browser/process_singleton_win.cc ('k') | chrome/browser/search/suggestions/suggestions_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698