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

Side by Side Diff: extensions/common/manifest_handler_unittest.cc

Issue 664933004: Standardize usage of virtual/override/final in extensions/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 <string> 5 #include <string>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 76
77 class TestManifestHandler : public ManifestHandler { 77 class TestManifestHandler : public ManifestHandler {
78 public: 78 public:
79 TestManifestHandler(const std::string& name, 79 TestManifestHandler(const std::string& name,
80 const std::vector<std::string>& keys, 80 const std::vector<std::string>& keys,
81 const std::vector<std::string>& prereqs, 81 const std::vector<std::string>& prereqs,
82 ParsingWatcher* watcher) 82 ParsingWatcher* watcher)
83 : name_(name), keys_(keys), prereqs_(prereqs), watcher_(watcher) { 83 : name_(name), keys_(keys), prereqs_(prereqs), watcher_(watcher) {
84 } 84 }
85 85
86 virtual bool Parse(Extension* extension, base::string16* error) override { 86 bool Parse(Extension* extension, base::string16* error) override {
87 watcher_->Record(name_); 87 watcher_->Record(name_);
88 return true; 88 return true;
89 } 89 }
90 90
91 virtual const std::vector<std::string> PrerequisiteKeys() const override { 91 const std::vector<std::string> PrerequisiteKeys() const override {
92 return prereqs_; 92 return prereqs_;
93 } 93 }
94 94
95 protected: 95 protected:
96 std::string name_; 96 std::string name_;
97 std::vector<std::string> keys_; 97 std::vector<std::string> keys_;
98 std::vector<std::string> prereqs_; 98 std::vector<std::string> prereqs_;
99 ParsingWatcher* watcher_; 99 ParsingWatcher* watcher_;
100 100
101 virtual const std::vector<std::string> Keys() const override { 101 const std::vector<std::string> Keys() const override { return keys_; }
102 return keys_;
103 }
104 }; 102 };
105 103
106 class FailingTestManifestHandler : public TestManifestHandler { 104 class FailingTestManifestHandler : public TestManifestHandler {
107 public: 105 public:
108 FailingTestManifestHandler(const std::string& name, 106 FailingTestManifestHandler(const std::string& name,
109 const std::vector<std::string>& keys, 107 const std::vector<std::string>& keys,
110 const std::vector<std::string>& prereqs, 108 const std::vector<std::string>& prereqs,
111 ParsingWatcher* watcher) 109 ParsingWatcher* watcher)
112 : TestManifestHandler(name, keys, prereqs, watcher) { 110 : TestManifestHandler(name, keys, prereqs, watcher) {
113 } 111 }
114 virtual bool Parse(Extension* extension, base::string16* error) override { 112 bool Parse(Extension* extension, base::string16* error) override {
115 *error = base::ASCIIToUTF16(name_); 113 *error = base::ASCIIToUTF16(name_);
116 return false; 114 return false;
117 } 115 }
118 }; 116 };
119 117
120 class AlwaysParseTestManifestHandler : public TestManifestHandler { 118 class AlwaysParseTestManifestHandler : public TestManifestHandler {
121 public: 119 public:
122 AlwaysParseTestManifestHandler(const std::string& name, 120 AlwaysParseTestManifestHandler(const std::string& name,
123 const std::vector<std::string>& keys, 121 const std::vector<std::string>& keys,
124 const std::vector<std::string>& prereqs, 122 const std::vector<std::string>& prereqs,
125 ParsingWatcher* watcher) 123 ParsingWatcher* watcher)
126 : TestManifestHandler(name, keys, prereqs, watcher) { 124 : TestManifestHandler(name, keys, prereqs, watcher) {
127 } 125 }
128 126
129 virtual bool AlwaysParseForType(Manifest::Type type) const override { 127 bool AlwaysParseForType(Manifest::Type type) const override { return true; }
130 return true;
131 }
132 }; 128 };
133 129
134 class TestManifestValidator : public ManifestHandler { 130 class TestManifestValidator : public ManifestHandler {
135 public: 131 public:
136 TestManifestValidator(bool return_value, 132 TestManifestValidator(bool return_value,
137 bool always_validate, 133 bool always_validate,
138 std::vector<std::string> keys) 134 std::vector<std::string> keys)
139 : return_value_(return_value), 135 : return_value_(return_value),
140 always_validate_(always_validate), 136 always_validate_(always_validate),
141 keys_(keys) { 137 keys_(keys) {
142 } 138 }
143 139
144 virtual bool Parse(Extension* extension, base::string16* error) override { 140 bool Parse(Extension* extension, base::string16* error) override {
145 return true; 141 return true;
146 } 142 }
147 143
148 virtual bool Validate( 144 bool Validate(const Extension* extension,
149 const Extension* extension, 145 std::string* error,
150 std::string* error, 146 std::vector<InstallWarning>* warnings) const override {
151 std::vector<InstallWarning>* warnings) const override {
152 return return_value_; 147 return return_value_;
153 } 148 }
154 149
155 virtual bool AlwaysValidateForType(Manifest::Type type) const override { 150 bool AlwaysValidateForType(Manifest::Type type) const override {
156 return always_validate_; 151 return always_validate_;
157 } 152 }
158 153
159 private: 154 private:
160 virtual const std::vector<std::string> Keys() const override { 155 const std::vector<std::string> Keys() const override { return keys_; }
161 return keys_;
162 }
163 156
164 protected: 157 protected:
165 bool return_value_; 158 bool return_value_;
166 bool always_validate_; 159 bool always_validate_;
167 std::vector<std::string> keys_; 160 std::vector<std::string> keys_;
168 }; 161 };
169 }; 162 };
170 163
171 TEST_F(ManifestHandlerTest, DependentHandlers) { 164 TEST_F(ManifestHandlerTest, DependentHandlers) {
172 ScopedTestingManifestHandlerRegistry registry; 165 ScopedTestingManifestHandlerRegistry registry;
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 EXPECT_TRUE( 265 EXPECT_TRUE(
273 ManifestHandler::ValidateExtension(extension.get(), &error, &warnings)); 266 ManifestHandler::ValidateExtension(extension.get(), &error, &warnings));
274 267
275 // Validates "a" and fails. 268 // Validates "a" and fails.
276 (new TestManifestValidator(false, true, SingleKey("a")))->Register(); 269 (new TestManifestValidator(false, true, SingleKey("a")))->Register();
277 EXPECT_FALSE( 270 EXPECT_FALSE(
278 ManifestHandler::ValidateExtension(extension.get(), &error, &warnings)); 271 ManifestHandler::ValidateExtension(extension.get(), &error, &warnings));
279 } 272 }
280 273
281 } // namespace extensions 274 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/common/features/simple_feature.h ('k') | extensions/common/manifest_handlers/background_info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698