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

Side by Side Diff: chrome/browser/extensions/external_policy_loader_unittest.cc

Issue 12093036: Move Extension Location and Type enums to Manifest, and move InstallWarning to its own file. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <set> 5 #include <set>
6 #include <string> 6 #include <string>
7 7
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "base/version.h" 11 #include "base/version.h"
12 #include "chrome/browser/extensions/external_policy_loader.h" 12 #include "chrome/browser/extensions/external_policy_loader.h"
13 #include "chrome/browser/extensions/external_provider_impl.h" 13 #include "chrome/browser/extensions/external_provider_impl.h"
14 #include "chrome/browser/extensions/external_provider_interface.h" 14 #include "chrome/browser/extensions/external_provider_interface.h"
15 #include "chrome/common/extensions/extension.h" 15 #include "chrome/common/extensions/extension.h"
16 #include "chrome/common/extensions/manifest.h"
16 #include "chrome/common/pref_names.h" 17 #include "chrome/common/pref_names.h"
17 #include "chrome/test/base/testing_pref_service.h" 18 #include "chrome/test/base/testing_pref_service.h"
18 #include "chrome/test/base/testing_profile.h" 19 #include "chrome/test/base/testing_profile.h"
19 #include "content/public/test/test_browser_thread.h" 20 #include "content/public/test/test_browser_thread.h"
20 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
21 22
22 using content::BrowserThread; 23 using content::BrowserThread;
23 24
24 namespace extensions { 25 namespace extensions {
25 26
(...skipping 23 matching lines...) Expand all
49 // exactly the extensions specified in |expected_extensions|. 50 // exactly the extensions specified in |expected_extensions|.
50 void Visit(const base::DictionaryValue& policy_forcelist, 51 void Visit(const base::DictionaryValue& policy_forcelist,
51 const std::set<std::string>& expected_extensions) { 52 const std::set<std::string>& expected_extensions) {
52 profile_.reset(new TestingProfile); 53 profile_.reset(new TestingProfile);
53 profile_->GetTestingPrefService()->SetManagedPref( 54 profile_->GetTestingPrefService()->SetManagedPref(
54 prefs::kExtensionInstallForceList, 55 prefs::kExtensionInstallForceList,
55 policy_forcelist.DeepCopy()); 56 policy_forcelist.DeepCopy());
56 provider_.reset(new ExternalProviderImpl( 57 provider_.reset(new ExternalProviderImpl(
57 this, 58 this,
58 new ExternalPolicyLoader(profile_.get()), 59 new ExternalPolicyLoader(profile_.get()),
59 Extension::INVALID, 60 Manifest::INVALID_LOCATION,
60 Extension::EXTERNAL_POLICY_DOWNLOAD, 61 Manifest::EXTERNAL_POLICY_DOWNLOAD,
61 Extension::NO_FLAGS)); 62 Extension::NO_FLAGS));
62 63
63 // Extensions will be removed from this list as they visited, 64 // Extensions will be removed from this list as they visited,
64 // so it should be emptied by the end. 65 // so it should be emptied by the end.
65 expected_extensions_ = expected_extensions; 66 expected_extensions_ = expected_extensions;
66 provider_->VisitRegisteredExtension(); 67 provider_->VisitRegisteredExtension();
67 EXPECT_TRUE(expected_extensions_.empty()); 68 EXPECT_TRUE(expected_extensions_.empty());
68 } 69 }
69 70
70 virtual bool OnExternalExtensionFileFound(const std::string& id, 71 virtual bool OnExternalExtensionFileFound(const std::string& id,
71 const Version* version, 72 const Version* version,
72 const FilePath& path, 73 const FilePath& path,
73 Extension::Location unused, 74 Manifest::Location unused,
74 int unused2, 75 int unused2,
75 bool unused3) { 76 bool unused3) {
76 ADD_FAILURE() << "There should be no external extensions from files."; 77 ADD_FAILURE() << "There should be no external extensions from files.";
77 return false; 78 return false;
78 } 79 }
79 80
80 virtual bool OnExternalExtensionUpdateUrlFound( 81 virtual bool OnExternalExtensionUpdateUrlFound(
81 const std::string& id, const GURL& update_url, 82 const std::string& id, const GURL& update_url,
82 Extension::Location location) { 83 Manifest::Location location) {
83 // Extension has the correct location. 84 // Extension has the correct location.
84 EXPECT_EQ(Extension::EXTERNAL_POLICY_DOWNLOAD, location); 85 EXPECT_EQ(Manifest::EXTERNAL_POLICY_DOWNLOAD, location);
85 86
86 // Provider returns the correct location when asked. 87 // Provider returns the correct location when asked.
87 Extension::Location location1; 88 Manifest::Location location1;
88 scoped_ptr<Version> version1; 89 scoped_ptr<Version> version1;
89 provider_->GetExtensionDetails(id, &location1, &version1); 90 provider_->GetExtensionDetails(id, &location1, &version1);
90 EXPECT_EQ(Extension::EXTERNAL_POLICY_DOWNLOAD, location1); 91 EXPECT_EQ(Manifest::EXTERNAL_POLICY_DOWNLOAD, location1);
91 EXPECT_FALSE(version1.get()); 92 EXPECT_FALSE(version1.get());
92 93
93 // Remove the extension from our list. 94 // Remove the extension from our list.
94 EXPECT_EQ(1U, expected_extensions_.erase(id)); 95 EXPECT_EQ(1U, expected_extensions_.erase(id));
95 return true; 96 return true;
96 } 97 }
97 98
98 virtual void OnExternalProviderReady( 99 virtual void OnExternalProviderReady(
99 const ExternalProviderInterface* provider) { 100 const ExternalProviderInterface* provider) {
100 EXPECT_EQ(provider, provider_.get()); 101 EXPECT_EQ(provider, provider_.get());
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 // Add invalid entries. 140 // Add invalid entries.
140 forced_extensions.SetString("invalid", "http://www.example.com/crx"); 141 forced_extensions.SetString("invalid", "http://www.example.com/crx");
141 forced_extensions.SetString("dddddddddddddddddddddddddddddddd", ""); 142 forced_extensions.SetString("dddddddddddddddddddddddddddddddd", "");
142 forced_extensions.SetString("invalid", "bad"); 143 forced_extensions.SetString("invalid", "bad");
143 144
144 MockExternalPolicyProviderVisitor mv; 145 MockExternalPolicyProviderVisitor mv;
145 mv.Visit(forced_extensions, expected_extensions); 146 mv.Visit(forced_extensions, expected_extensions);
146 } 147 }
147 148
148 } // namespace extensions 149 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_webkit_preferences.cc ('k') | chrome/browser/extensions/external_provider_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698