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/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
6 #include "base/metrics/field_trial.h" | 6 #include "base/metrics/field_trial.h" |
7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
9 #include "chrome/browser/extensions/extension_service_test_base.h" | 9 #include "chrome/browser/extensions/extension_service_test_base.h" |
10 #include "chrome/browser/extensions/test_extension_service.h" | 10 #include "chrome/browser/extensions/test_extension_service.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 namespace { | 24 namespace { |
25 | 25 |
26 class MockHotwordService : public HotwordService { | 26 class MockHotwordService : public HotwordService { |
27 public: | 27 public: |
28 explicit MockHotwordService(Profile* profile) | 28 explicit MockHotwordService(Profile* profile) |
29 : HotwordService(profile), | 29 : HotwordService(profile), |
30 uninstall_count_(0) { | 30 uninstall_count_(0) { |
31 } | 31 } |
32 | 32 |
33 virtual bool UninstallHotwordExtension( | 33 virtual bool UninstallHotwordExtension( |
34 ExtensionService* extension_service) OVERRIDE { | 34 ExtensionService* extension_service) override { |
35 uninstall_count_++; | 35 uninstall_count_++; |
36 return HotwordService::UninstallHotwordExtension(extension_service); | 36 return HotwordService::UninstallHotwordExtension(extension_service); |
37 } | 37 } |
38 | 38 |
39 virtual void InstallHotwordExtensionFromWebstore() OVERRIDE{ | 39 virtual void InstallHotwordExtensionFromWebstore() override{ |
40 scoped_ptr<base::DictionaryValue> manifest = | 40 scoped_ptr<base::DictionaryValue> manifest = |
41 extensions::DictionaryBuilder() | 41 extensions::DictionaryBuilder() |
42 .Set("name", "Hotword Test Extension") | 42 .Set("name", "Hotword Test Extension") |
43 .Set("version", "1.0") | 43 .Set("version", "1.0") |
44 .Set("manifest_version", 2) | 44 .Set("manifest_version", 2) |
45 .Build(); | 45 .Build(); |
46 scoped_refptr<extensions::Extension> extension = | 46 scoped_refptr<extensions::Extension> extension = |
47 extensions::ExtensionBuilder().SetManifest(manifest.Pass()) | 47 extensions::ExtensionBuilder().SetManifest(manifest.Pass()) |
48 .AddFlags(extensions::Extension::FROM_WEBSTORE | 48 .AddFlags(extensions::Extension::FROM_WEBSTORE |
49 | extensions::Extension::WAS_INSTALLED_BY_DEFAULT) | 49 | extensions::Extension::WAS_INSTALLED_BY_DEFAULT) |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 EXPECT_EQ("fr_fr", | 300 EXPECT_EQ("fr_fr", |
301 profile()->GetPrefs()->GetString(prefs::kHotwordPreviousLanguage)); | 301 profile()->GetPrefs()->GetString(prefs::kHotwordPreviousLanguage)); |
302 | 302 |
303 // If the locale is set back to the last valid one, then an uninstall-install | 303 // If the locale is set back to the last valid one, then an uninstall-install |
304 // shouldn't be needed. | 304 // shouldn't be needed. |
305 SetApplicationLocale(profile(), "fr_fr"); | 305 SetApplicationLocale(profile(), "fr_fr"); |
306 EXPECT_TRUE(HotwordServiceFactory::IsHotwordAllowed(profile())); | 306 EXPECT_TRUE(HotwordServiceFactory::IsHotwordAllowed(profile())); |
307 EXPECT_FALSE(hotword_service->MaybeReinstallHotwordExtension()); | 307 EXPECT_FALSE(hotword_service->MaybeReinstallHotwordExtension()); |
308 EXPECT_EQ(1, hotword_service->uninstall_count()); // no change | 308 EXPECT_EQ(1, hotword_service->uninstall_count()); // no change |
309 } | 309 } |
OLD | NEW |