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/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
6 #include "base/metrics/field_trial.h" | 7 #include "base/metrics/field_trial.h" |
7 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
8 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
9 #include "chrome/browser/extensions/extension_service_test_base.h" | 10 #include "chrome/browser/extensions/extension_service_test_base.h" |
10 #include "chrome/browser/extensions/test_extension_service.h" | 11 #include "chrome/browser/extensions/test_extension_service.h" |
11 #include "chrome/browser/search/hotword_service.h" | 12 #include "chrome/browser/search/hotword_service.h" |
12 #include "chrome/browser/search/hotword_service_factory.h" | 13 #include "chrome/browser/search/hotword_service_factory.h" |
| 14 #include "chrome/common/chrome_switches.h" |
13 #include "chrome/common/extensions/extension_constants.h" | 15 #include "chrome/common/extensions/extension_constants.h" |
14 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
15 #include "chrome/test/base/testing_profile.h" | 17 #include "chrome/test/base/testing_profile.h" |
16 #include "content/public/test/test_browser_thread_bundle.h" | 18 #include "content/public/test/test_browser_thread_bundle.h" |
17 #include "extensions/browser/extension_system.h" | 19 #include "extensions/browser/extension_system.h" |
18 #include "extensions/common/extension.h" | 20 #include "extensions/common/extension.h" |
19 #include "extensions/common/extension_builder.h" | 21 #include "extensions/common/extension_builder.h" |
20 #include "extensions/common/manifest.h" | 22 #include "extensions/common/manifest.h" |
21 #include "extensions/common/one_shot_event.h" | 23 #include "extensions/common/one_shot_event.h" |
22 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 17 matching lines...) Expand all Loading... |
40 scoped_ptr<base::DictionaryValue> manifest = | 42 scoped_ptr<base::DictionaryValue> manifest = |
41 extensions::DictionaryBuilder() | 43 extensions::DictionaryBuilder() |
42 .Set("name", "Hotword Test Extension") | 44 .Set("name", "Hotword Test Extension") |
43 .Set("version", "1.0") | 45 .Set("version", "1.0") |
44 .Set("manifest_version", 2) | 46 .Set("manifest_version", 2) |
45 .Build(); | 47 .Build(); |
46 scoped_refptr<extensions::Extension> extension = | 48 scoped_refptr<extensions::Extension> extension = |
47 extensions::ExtensionBuilder().SetManifest(manifest.Pass()) | 49 extensions::ExtensionBuilder().SetManifest(manifest.Pass()) |
48 .AddFlags(extensions::Extension::FROM_WEBSTORE | 50 .AddFlags(extensions::Extension::FROM_WEBSTORE |
49 | extensions::Extension::WAS_INSTALLED_BY_DEFAULT) | 51 | extensions::Extension::WAS_INSTALLED_BY_DEFAULT) |
50 .SetID(extension_misc::kHotwordExtensionId) | 52 .SetID(extension_id_) |
51 .SetLocation(extensions::Manifest::EXTERNAL_COMPONENT) | 53 .SetLocation(extensions::Manifest::EXTERNAL_COMPONENT) |
52 .Build(); | 54 .Build(); |
53 ASSERT_TRUE(extension.get()); | 55 ASSERT_TRUE(extension.get()); |
54 service_->OnExtensionInstalled(extension.get(), syncer::StringOrdinal()); | 56 service_->OnExtensionInstalled(extension.get(), syncer::StringOrdinal()); |
55 } | 57 } |
56 | 58 |
57 | 59 |
58 int uninstall_count() { return uninstall_count_; } | 60 int uninstall_count() { return uninstall_count_; } |
59 | 61 |
60 void SetExtensionService(ExtensionService* service) { service_ = service; } | 62 void SetExtensionService(ExtensionService* service) { service_ = service; } |
| 63 void SetExtensionId(const std::string& extension_id) { |
| 64 extension_id_ = extension_id; |
| 65 } |
61 | 66 |
62 ExtensionService* extension_service() { return service_; } | 67 ExtensionService* extension_service() { return service_; } |
63 | 68 |
64 private: | 69 private: |
65 ExtensionService* service_; | 70 ExtensionService* service_; |
66 int uninstall_count_; | 71 int uninstall_count_; |
| 72 std::string extension_id_; |
67 }; | 73 }; |
68 | 74 |
69 KeyedService* BuildMockHotwordService(content::BrowserContext* context) { | 75 KeyedService* BuildMockHotwordService(content::BrowserContext* context) { |
70 return new MockHotwordService(static_cast<Profile*>(context)); | 76 return new MockHotwordService(static_cast<Profile*>(context)); |
71 } | 77 } |
72 | 78 |
73 } // namespace | 79 } // namespace |
74 | 80 |
75 class HotwordServiceTest : public extensions::ExtensionServiceTestBase { | 81 class HotwordServiceTest : |
| 82 public extensions::ExtensionServiceTestBase, |
| 83 public ::testing::WithParamInterface<const char*> { |
76 protected: | 84 protected: |
77 HotwordServiceTest() : field_trial_list_(NULL) {} | 85 HotwordServiceTest() : field_trial_list_(NULL) {} |
78 virtual ~HotwordServiceTest() {} | 86 virtual ~HotwordServiceTest() {} |
79 | 87 |
80 void SetApplicationLocale(Profile* profile, const std::string& new_locale) { | 88 void SetApplicationLocale(Profile* profile, const std::string& new_locale) { |
81 #if defined(OS_CHROMEOS) | 89 #if defined(OS_CHROMEOS) |
82 // On ChromeOS locale is per-profile. | 90 // On ChromeOS locale is per-profile. |
83 profile->GetPrefs()->SetString(prefs::kApplicationLocale, new_locale); | 91 profile->GetPrefs()->SetString(prefs::kApplicationLocale, new_locale); |
84 #else | 92 #else |
85 g_browser_process->SetApplicationLocale(new_locale); | 93 g_browser_process->SetApplicationLocale(new_locale); |
86 #endif | 94 #endif |
87 } | 95 } |
88 | 96 |
89 private: | 97 virtual void SetUp() { |
| 98 extension_id_ = GetParam(); |
| 99 if (extension_id_ == extension_misc::kHotwordSharedModuleId) { |
| 100 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 101 switches::kEnableExperimentalHotwording); |
| 102 } |
| 103 |
| 104 extensions::ExtensionServiceTestBase::SetUp(); |
| 105 } |
| 106 |
90 base::FieldTrialList field_trial_list_; | 107 base::FieldTrialList field_trial_list_; |
| 108 std::string extension_id_; |
91 }; | 109 }; |
92 | 110 |
93 TEST_F(HotwordServiceTest, IsHotwordAllowedBadFieldTrial) { | 111 INSTANTIATE_TEST_CASE_P(HotwordServiceTests, |
| 112 HotwordServiceTest, |
| 113 ::testing::Values( |
| 114 extension_misc::kHotwordExtensionId, |
| 115 extension_misc::kHotwordSharedModuleId)); |
| 116 |
| 117 TEST_P(HotwordServiceTest, IsHotwordAllowedBadFieldTrial) { |
94 TestingProfile::Builder profile_builder; | 118 TestingProfile::Builder profile_builder; |
95 scoped_ptr<TestingProfile> profile = profile_builder.Build(); | 119 scoped_ptr<TestingProfile> profile = profile_builder.Build(); |
96 | 120 |
97 HotwordServiceFactory* hotword_service_factory = | 121 HotwordServiceFactory* hotword_service_factory = |
98 HotwordServiceFactory::GetInstance(); | 122 HotwordServiceFactory::GetInstance(); |
99 | 123 |
100 // Check that the service exists so that a NULL service be ruled out in | 124 // Check that the service exists so that a NULL service be ruled out in |
101 // following tests. | 125 // following tests. |
102 HotwordService* hotword_service = | 126 HotwordService* hotword_service = |
103 hotword_service_factory->GetForProfile(profile.get()); | 127 hotword_service_factory->GetForProfile(profile.get()); |
(...skipping 16 matching lines...) Expand all Loading... |
120 // Set a valid locale with invalid field trial to be sure it is | 144 // Set a valid locale with invalid field trial to be sure it is |
121 // still false. | 145 // still false. |
122 SetApplicationLocale(static_cast<Profile*>(profile.get()), "en"); | 146 SetApplicationLocale(static_cast<Profile*>(profile.get()), "en"); |
123 EXPECT_FALSE(HotwordServiceFactory::IsHotwordAllowed(profile.get())); | 147 EXPECT_FALSE(HotwordServiceFactory::IsHotwordAllowed(profile.get())); |
124 | 148 |
125 // Test that incognito returns false as well. | 149 // Test that incognito returns false as well. |
126 EXPECT_FALSE(HotwordServiceFactory::IsHotwordAllowed( | 150 EXPECT_FALSE(HotwordServiceFactory::IsHotwordAllowed( |
127 profile->GetOffTheRecordProfile())); | 151 profile->GetOffTheRecordProfile())); |
128 } | 152 } |
129 | 153 |
130 TEST_F(HotwordServiceTest, IsHotwordAllowedLocale) { | 154 TEST_P(HotwordServiceTest, IsHotwordAllowedLocale) { |
131 TestingProfile::Builder profile_builder; | 155 TestingProfile::Builder profile_builder; |
132 scoped_ptr<TestingProfile> profile = profile_builder.Build(); | 156 scoped_ptr<TestingProfile> profile = profile_builder.Build(); |
133 | 157 |
134 HotwordServiceFactory* hotword_service_factory = | 158 HotwordServiceFactory* hotword_service_factory = |
135 HotwordServiceFactory::GetInstance(); | 159 HotwordServiceFactory::GetInstance(); |
136 | 160 |
137 // Check that the service exists so that a NULL service be ruled out in | 161 // Check that the service exists so that a NULL service be ruled out in |
138 // following tests. | 162 // following tests. |
139 HotwordService* hotword_service = | 163 HotwordService* hotword_service = |
140 hotword_service_factory->GetForProfile(profile.get()); | 164 hotword_service_factory->GetForProfile(profile.get()); |
(...skipping 19 matching lines...) Expand all Loading... |
160 SetApplicationLocale(static_cast<Profile*>(profile.get()), "fr_fr"); | 184 SetApplicationLocale(static_cast<Profile*>(profile.get()), "fr_fr"); |
161 EXPECT_TRUE(HotwordServiceFactory::IsHotwordAllowed(profile.get())); | 185 EXPECT_TRUE(HotwordServiceFactory::IsHotwordAllowed(profile.get())); |
162 | 186 |
163 // Test that incognito even with a valid locale and valid field trial | 187 // Test that incognito even with a valid locale and valid field trial |
164 // still returns false. | 188 // still returns false. |
165 Profile* otr_profile = profile->GetOffTheRecordProfile(); | 189 Profile* otr_profile = profile->GetOffTheRecordProfile(); |
166 SetApplicationLocale(otr_profile, "en"); | 190 SetApplicationLocale(otr_profile, "en"); |
167 EXPECT_FALSE(HotwordServiceFactory::IsHotwordAllowed(otr_profile)); | 191 EXPECT_FALSE(HotwordServiceFactory::IsHotwordAllowed(otr_profile)); |
168 } | 192 } |
169 | 193 |
170 TEST_F(HotwordServiceTest, AudioLoggingPrefSetCorrectly) { | 194 TEST_P(HotwordServiceTest, AudioLoggingPrefSetCorrectly) { |
171 TestingProfile::Builder profile_builder; | 195 TestingProfile::Builder profile_builder; |
172 scoped_ptr<TestingProfile> profile = profile_builder.Build(); | 196 scoped_ptr<TestingProfile> profile = profile_builder.Build(); |
173 | 197 |
174 HotwordServiceFactory* hotword_service_factory = | 198 HotwordServiceFactory* hotword_service_factory = |
175 HotwordServiceFactory::GetInstance(); | 199 HotwordServiceFactory::GetInstance(); |
176 HotwordService* hotword_service = | 200 HotwordService* hotword_service = |
177 hotword_service_factory->GetForProfile(profile.get()); | 201 hotword_service_factory->GetForProfile(profile.get()); |
178 EXPECT_TRUE(hotword_service != NULL); | 202 EXPECT_TRUE(hotword_service != NULL); |
179 | 203 |
180 // If it's a fresh profile, although the default value is true, | 204 // If it's a fresh profile, although the default value is true, |
181 // it should return false if the preference has never been set. | 205 // it should return false if the preference has never been set. |
182 EXPECT_FALSE(hotword_service->IsOptedIntoAudioLogging()); | 206 EXPECT_FALSE(hotword_service->IsOptedIntoAudioLogging()); |
183 } | 207 } |
184 | 208 |
185 TEST_F(HotwordServiceTest, ShouldReinstallExtension) { | 209 TEST_P(HotwordServiceTest, ShouldReinstallExtension) { |
186 // Set the field trial to a valid one. | 210 // Set the field trial to a valid one. |
187 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | 211 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( |
188 hotword_internal::kHotwordFieldTrialName, "Install")); | 212 hotword_internal::kHotwordFieldTrialName, "Install")); |
189 | 213 |
190 InitializeEmptyExtensionService(); | 214 InitializeEmptyExtensionService(); |
191 | 215 |
192 HotwordServiceFactory* hotword_service_factory = | 216 HotwordServiceFactory* hotword_service_factory = |
193 HotwordServiceFactory::GetInstance(); | 217 HotwordServiceFactory::GetInstance(); |
194 | 218 |
195 MockHotwordService* hotword_service = static_cast<MockHotwordService*>( | 219 MockHotwordService* hotword_service = static_cast<MockHotwordService*>( |
196 hotword_service_factory->SetTestingFactoryAndUse( | 220 hotword_service_factory->SetTestingFactoryAndUse( |
197 profile(), BuildMockHotwordService)); | 221 profile(), BuildMockHotwordService)); |
198 EXPECT_TRUE(hotword_service != NULL); | 222 EXPECT_TRUE(hotword_service != NULL); |
| 223 hotword_service->SetExtensionId(extension_id_); |
199 | 224 |
200 // If no locale has been set, no reason to uninstall. | 225 // If no locale has been set, no reason to uninstall. |
201 EXPECT_FALSE(hotword_service->ShouldReinstallHotwordExtension()); | 226 EXPECT_FALSE(hotword_service->ShouldReinstallHotwordExtension()); |
202 | 227 |
203 SetApplicationLocale(profile(), "en"); | 228 SetApplicationLocale(profile(), "en"); |
204 hotword_service->SetPreviousLanguagePref(); | 229 hotword_service->SetPreviousLanguagePref(); |
205 | 230 |
206 // Now a locale is set, but it hasn't changed. | 231 // Now a locale is set, but it hasn't changed. |
207 EXPECT_FALSE(hotword_service->ShouldReinstallHotwordExtension()); | 232 EXPECT_FALSE(hotword_service->ShouldReinstallHotwordExtension()); |
208 | 233 |
209 SetApplicationLocale(profile(), "fr_fr"); | 234 SetApplicationLocale(profile(), "fr_fr"); |
210 | 235 |
211 // Now it's a different locale so it should uninstall. | 236 // Now it's a different locale so it should uninstall. |
212 EXPECT_TRUE(hotword_service->ShouldReinstallHotwordExtension()); | 237 EXPECT_TRUE(hotword_service->ShouldReinstallHotwordExtension()); |
213 } | 238 } |
214 | 239 |
215 TEST_F(HotwordServiceTest, PreviousLanguageSetOnInstall) { | 240 TEST_P(HotwordServiceTest, PreviousLanguageSetOnInstall) { |
216 // Set the field trial to a valid one. | 241 // Set the field trial to a valid one. |
217 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | 242 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( |
218 hotword_internal::kHotwordFieldTrialName, "Install")); | 243 hotword_internal::kHotwordFieldTrialName, "Install")); |
219 | 244 |
220 InitializeEmptyExtensionService(); | 245 InitializeEmptyExtensionService(); |
221 service_->Init(); | 246 service_->Init(); |
222 | 247 |
223 HotwordServiceFactory* hotword_service_factory = | 248 HotwordServiceFactory* hotword_service_factory = |
224 HotwordServiceFactory::GetInstance(); | 249 HotwordServiceFactory::GetInstance(); |
225 | 250 |
226 MockHotwordService* hotword_service = static_cast<MockHotwordService*>( | 251 MockHotwordService* hotword_service = static_cast<MockHotwordService*>( |
227 hotword_service_factory->SetTestingFactoryAndUse( | 252 hotword_service_factory->SetTestingFactoryAndUse( |
228 profile(), BuildMockHotwordService)); | 253 profile(), BuildMockHotwordService)); |
229 EXPECT_TRUE(hotword_service != NULL); | 254 EXPECT_TRUE(hotword_service != NULL); |
230 hotword_service->SetExtensionService(service()); | 255 hotword_service->SetExtensionService(service()); |
| 256 hotword_service->SetExtensionId(extension_id_); |
231 | 257 |
232 // If no locale has been set, no reason to uninstall. | 258 // If no locale has been set, no reason to uninstall. |
233 EXPECT_FALSE(hotword_service->ShouldReinstallHotwordExtension()); | 259 EXPECT_FALSE(hotword_service->ShouldReinstallHotwordExtension()); |
234 | 260 |
235 SetApplicationLocale(profile(), "test_locale"); | 261 SetApplicationLocale(profile(), "test_locale"); |
236 | 262 |
237 hotword_service->InstallHotwordExtensionFromWebstore(); | 263 hotword_service->InstallHotwordExtensionFromWebstore(); |
238 base::MessageLoop::current()->RunUntilIdle(); | 264 base::MessageLoop::current()->RunUntilIdle(); |
239 | 265 |
240 EXPECT_EQ("test_locale", | 266 EXPECT_EQ("test_locale", |
241 profile()->GetPrefs()->GetString(prefs::kHotwordPreviousLanguage)); | 267 profile()->GetPrefs()->GetString(prefs::kHotwordPreviousLanguage)); |
242 } | 268 } |
243 | 269 |
244 TEST_F(HotwordServiceTest, UninstallReinstallTriggeredCorrectly) { | 270 TEST_P(HotwordServiceTest, UninstallReinstallTriggeredCorrectly) { |
245 // Set the field trial to a valid one. | 271 // Set the field trial to a valid one. |
246 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | 272 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( |
247 hotword_internal::kHotwordFieldTrialName, "Install")); | 273 hotword_internal::kHotwordFieldTrialName, "Install")); |
248 | 274 |
249 InitializeEmptyExtensionService(); | 275 InitializeEmptyExtensionService(); |
250 service_->Init(); | 276 service_->Init(); |
251 | 277 |
252 HotwordServiceFactory* hotword_service_factory = | 278 HotwordServiceFactory* hotword_service_factory = |
253 HotwordServiceFactory::GetInstance(); | 279 HotwordServiceFactory::GetInstance(); |
254 | 280 |
255 MockHotwordService* hotword_service = static_cast<MockHotwordService*>( | 281 MockHotwordService* hotword_service = static_cast<MockHotwordService*>( |
256 hotword_service_factory->SetTestingFactoryAndUse( | 282 hotword_service_factory->SetTestingFactoryAndUse( |
257 profile(), BuildMockHotwordService)); | 283 profile(), BuildMockHotwordService)); |
258 EXPECT_TRUE(hotword_service != NULL); | 284 EXPECT_TRUE(hotword_service != NULL); |
259 hotword_service->SetExtensionService(service()); | 285 hotword_service->SetExtensionService(service()); |
| 286 hotword_service->SetExtensionId(extension_id_); |
260 | 287 |
261 // Initialize the locale to "en". | 288 // Initialize the locale to "en". |
262 SetApplicationLocale(profile(), "en"); | 289 SetApplicationLocale(profile(), "en"); |
263 | 290 |
264 // The previous locale should not be set. No reason to uninstall. | 291 // The previous locale should not be set. No reason to uninstall. |
265 EXPECT_FALSE(hotword_service->MaybeReinstallHotwordExtension()); | 292 EXPECT_FALSE(hotword_service->MaybeReinstallHotwordExtension()); |
266 | 293 |
267 // Do an initial installation. | 294 // Do an initial installation. |
268 hotword_service->InstallHotwordExtensionFromWebstore(); | 295 hotword_service->InstallHotwordExtensionFromWebstore(); |
269 base::MessageLoop::current()->RunUntilIdle(); | 296 base::MessageLoop::current()->RunUntilIdle(); |
270 EXPECT_EQ("en", | 297 EXPECT_EQ("en", |
271 profile()->GetPrefs()->GetString(prefs::kHotwordPreviousLanguage)); | 298 profile()->GetPrefs()->GetString(prefs::kHotwordPreviousLanguage)); |
272 | 299 |
273 // Verify the extension is installed but disabled. | 300 if (extension_id_ == extension_misc::kHotwordSharedModuleId) { |
274 EXPECT_EQ(1U, registry()->disabled_extensions().size()); | 301 // Shared module is installed and enabled. |
275 EXPECT_TRUE(registry()->disabled_extensions().Contains( | 302 EXPECT_EQ(0U, registry()->disabled_extensions().size()); |
276 extension_misc::kHotwordExtensionId)); | 303 EXPECT_TRUE(registry()->enabled_extensions().Contains(extension_id_)); |
| 304 } else { |
| 305 // Verify the extension is installed but disabled. |
| 306 EXPECT_EQ(1U, registry()->disabled_extensions().size()); |
| 307 EXPECT_TRUE(registry()->disabled_extensions().Contains(extension_id_)); |
| 308 } |
277 | 309 |
278 // The previous locale should be set but should match the current | 310 // The previous locale should be set but should match the current |
279 // locale. No reason to uninstall. | 311 // locale. No reason to uninstall. |
280 EXPECT_FALSE(hotword_service->MaybeReinstallHotwordExtension()); | 312 EXPECT_FALSE(hotword_service->MaybeReinstallHotwordExtension()); |
281 | 313 |
282 // Switch the locale to a valid but different one. | 314 // Switch the locale to a valid but different one. |
283 SetApplicationLocale(profile(), "fr_fr"); | 315 SetApplicationLocale(profile(), "fr_fr"); |
284 EXPECT_TRUE(HotwordServiceFactory::IsHotwordAllowed(profile())); | 316 EXPECT_TRUE(HotwordServiceFactory::IsHotwordAllowed(profile())); |
285 | 317 |
286 // Different but valid locale so expect uninstall. | 318 // Different but valid locale so expect uninstall. |
287 EXPECT_TRUE(hotword_service->MaybeReinstallHotwordExtension()); | 319 EXPECT_TRUE(hotword_service->MaybeReinstallHotwordExtension()); |
288 EXPECT_EQ(1, hotword_service->uninstall_count()); | 320 EXPECT_EQ(1, hotword_service->uninstall_count()); |
289 EXPECT_EQ("fr_fr", | 321 EXPECT_EQ("fr_fr", |
290 profile()->GetPrefs()->GetString(prefs::kHotwordPreviousLanguage)); | 322 profile()->GetPrefs()->GetString(prefs::kHotwordPreviousLanguage)); |
291 | 323 |
292 // Verify the extension is installed. It's still disabled. | 324 if (extension_id_ == extension_misc::kHotwordSharedModuleId) { |
293 EXPECT_TRUE(registry()->disabled_extensions().Contains( | 325 // Shared module is installed and enabled. |
294 extension_misc::kHotwordExtensionId)); | 326 EXPECT_TRUE(registry()->enabled_extensions().Contains(extension_id_)); |
| 327 } else { |
| 328 // Verify the extension is installed. It's still disabled. |
| 329 EXPECT_TRUE(registry()->disabled_extensions().Contains(extension_id_)); |
| 330 } |
295 | 331 |
296 // Switch the locale to an invalid one. | 332 // Switch the locale to an invalid one. |
297 SetApplicationLocale(profile(), "invalid"); | 333 SetApplicationLocale(profile(), "invalid"); |
298 EXPECT_FALSE(HotwordServiceFactory::IsHotwordAllowed(profile())); | 334 EXPECT_FALSE(HotwordServiceFactory::IsHotwordAllowed(profile())); |
299 EXPECT_FALSE(hotword_service->MaybeReinstallHotwordExtension()); | 335 EXPECT_FALSE(hotword_service->MaybeReinstallHotwordExtension()); |
300 EXPECT_EQ("fr_fr", | 336 EXPECT_EQ("fr_fr", |
301 profile()->GetPrefs()->GetString(prefs::kHotwordPreviousLanguage)); | 337 profile()->GetPrefs()->GetString(prefs::kHotwordPreviousLanguage)); |
302 | 338 |
303 // If the locale is set back to the last valid one, then an uninstall-install | 339 // If the locale is set back to the last valid one, then an uninstall-install |
304 // shouldn't be needed. | 340 // shouldn't be needed. |
305 SetApplicationLocale(profile(), "fr_fr"); | 341 SetApplicationLocale(profile(), "fr_fr"); |
306 EXPECT_TRUE(HotwordServiceFactory::IsHotwordAllowed(profile())); | 342 EXPECT_TRUE(HotwordServiceFactory::IsHotwordAllowed(profile())); |
307 EXPECT_FALSE(hotword_service->MaybeReinstallHotwordExtension()); | 343 EXPECT_FALSE(hotword_service->MaybeReinstallHotwordExtension()); |
308 EXPECT_EQ(1, hotword_service->uninstall_count()); // no change | 344 EXPECT_EQ(1, hotword_service->uninstall_count()); // no change |
309 } | 345 } |
OLD | NEW |