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/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 14 matching lines...) Expand all Loading... |
25 | 25 |
26 namespace { | 26 namespace { |
27 | 27 |
28 class MockHotwordService : public HotwordService { | 28 class MockHotwordService : public HotwordService { |
29 public: | 29 public: |
30 explicit MockHotwordService(Profile* profile) | 30 explicit MockHotwordService(Profile* profile) |
31 : HotwordService(profile), | 31 : HotwordService(profile), |
32 uninstall_count_(0) { | 32 uninstall_count_(0) { |
33 } | 33 } |
34 | 34 |
35 virtual bool UninstallHotwordExtension( | 35 bool UninstallHotwordExtension(ExtensionService* extension_service) override { |
36 ExtensionService* extension_service) override { | |
37 uninstall_count_++; | 36 uninstall_count_++; |
38 return HotwordService::UninstallHotwordExtension(extension_service); | 37 return HotwordService::UninstallHotwordExtension(extension_service); |
39 } | 38 } |
40 | 39 |
41 virtual void InstallHotwordExtensionFromWebstore() override{ | 40 void InstallHotwordExtensionFromWebstore() override { |
42 scoped_ptr<base::DictionaryValue> manifest = | 41 scoped_ptr<base::DictionaryValue> manifest = |
43 extensions::DictionaryBuilder() | 42 extensions::DictionaryBuilder() |
44 .Set("name", "Hotword Test Extension") | 43 .Set("name", "Hotword Test Extension") |
45 .Set("version", "1.0") | 44 .Set("version", "1.0") |
46 .Set("manifest_version", 2) | 45 .Set("manifest_version", 2) |
47 .Build(); | 46 .Build(); |
48 scoped_refptr<extensions::Extension> extension = | 47 scoped_refptr<extensions::Extension> extension = |
49 extensions::ExtensionBuilder().SetManifest(manifest.Pass()) | 48 extensions::ExtensionBuilder().SetManifest(manifest.Pass()) |
50 .AddFlags(extensions::Extension::FROM_WEBSTORE | 49 .AddFlags(extensions::Extension::FROM_WEBSTORE |
51 | extensions::Extension::WAS_INSTALLED_BY_DEFAULT) | 50 | extensions::Extension::WAS_INSTALLED_BY_DEFAULT) |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 EXPECT_EQ("fr_fr", | 335 EXPECT_EQ("fr_fr", |
337 profile()->GetPrefs()->GetString(prefs::kHotwordPreviousLanguage)); | 336 profile()->GetPrefs()->GetString(prefs::kHotwordPreviousLanguage)); |
338 | 337 |
339 // If the locale is set back to the last valid one, then an uninstall-install | 338 // If the locale is set back to the last valid one, then an uninstall-install |
340 // shouldn't be needed. | 339 // shouldn't be needed. |
341 SetApplicationLocale(profile(), "fr_fr"); | 340 SetApplicationLocale(profile(), "fr_fr"); |
342 EXPECT_TRUE(HotwordServiceFactory::IsHotwordAllowed(profile())); | 341 EXPECT_TRUE(HotwordServiceFactory::IsHotwordAllowed(profile())); |
343 EXPECT_FALSE(hotword_service->MaybeReinstallHotwordExtension()); | 342 EXPECT_FALSE(hotword_service->MaybeReinstallHotwordExtension()); |
344 EXPECT_EQ(1, hotword_service->uninstall_count()); // no change | 343 EXPECT_EQ(1, hotword_service->uninstall_count()); // no change |
345 } | 344 } |
OLD | NEW |