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

Side by Side Diff: chrome/common/extensions/manifest_tests/extension_manifest_test.h

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 #ifndef CHROME_COMMON_EXTENSIONS_MANIFEST_TESTS_EXTENSION_MANIFEST_TEST_H_ 5 #ifndef CHROME_COMMON_EXTENSIONS_MANIFEST_TESTS_EXTENSION_MANIFEST_TEST_H_
6 #define CHROME_COMMON_EXTENSIONS_MANIFEST_TESTS_EXTENSION_MANIFEST_TEST_H_ 6 #define CHROME_COMMON_EXTENSIONS_MANIFEST_TESTS_EXTENSION_MANIFEST_TEST_H_
7 7
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "chrome/common/extensions/extension.h" 10 #include "chrome/common/extensions/extension.h"
11 #include "chrome/common/extensions/extension_manifest_constants.h" 11 #include "chrome/common/extensions/extension_manifest_constants.h"
12 #include "chrome/common/extensions/features/feature.h" 12 #include "chrome/common/extensions/features/feature.h"
13 #include "chrome/common/extensions/manifest.h"
13 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
14 15
15 namespace errors = extension_manifest_errors; 16 namespace errors = extension_manifest_errors;
16 namespace keys = extension_manifest_keys; 17 namespace keys = extension_manifest_keys;
17 18
18 class ExtensionManifestTest : public testing::Test { 19 class ExtensionManifestTest : public testing::Test {
19 public: 20 public:
20 ExtensionManifestTest(); 21 ExtensionManifestTest();
21 22
22 protected: 23 protected:
(...skipping 27 matching lines...) Expand all
50 51
51 private: 52 private:
52 const std::string name_; 53 const std::string name_;
53 mutable DictionaryValue* manifest_; 54 mutable DictionaryValue* manifest_;
54 mutable scoped_ptr<DictionaryValue> manifest_holder_; 55 mutable scoped_ptr<DictionaryValue> manifest_holder_;
55 }; 56 };
56 57
57 scoped_refptr<extensions::Extension> LoadExtension( 58 scoped_refptr<extensions::Extension> LoadExtension(
58 const Manifest& manifest, 59 const Manifest& manifest,
59 std::string* error, 60 std::string* error,
60 extensions::Extension::Location location = 61 extensions::Manifest::Location location =
61 extensions::Extension::INTERNAL, 62 extensions::Manifest::INTERNAL,
62 int flags = extensions::Extension::NO_FLAGS); 63 int flags = extensions::Extension::NO_FLAGS);
63 64
64 scoped_refptr<extensions::Extension> LoadAndExpectSuccess( 65 scoped_refptr<extensions::Extension> LoadAndExpectSuccess(
65 const Manifest& manifest, 66 const Manifest& manifest,
66 extensions::Extension::Location location = 67 extensions::Manifest::Location location =
67 extensions::Extension::INTERNAL, 68 extensions::Manifest::INTERNAL,
68 int flags = extensions::Extension::NO_FLAGS); 69 int flags = extensions::Extension::NO_FLAGS);
69 70
70 scoped_refptr<extensions::Extension> LoadAndExpectSuccess( 71 scoped_refptr<extensions::Extension> LoadAndExpectSuccess(
71 char const* manifest_name, 72 char const* manifest_name,
72 extensions::Extension::Location location = 73 extensions::Manifest::Location location =
73 extensions::Extension::INTERNAL, 74 extensions::Manifest::INTERNAL,
74 int flags = extensions::Extension::NO_FLAGS); 75 int flags = extensions::Extension::NO_FLAGS);
75 76
76 scoped_refptr<extensions::Extension> LoadAndExpectWarning( 77 scoped_refptr<extensions::Extension> LoadAndExpectWarning(
77 const Manifest& manifest, 78 const Manifest& manifest,
78 const std::string& expected_error, 79 const std::string& expected_error,
79 extensions::Extension::Location location = 80 extensions::Manifest::Location location =
80 extensions::Extension::INTERNAL, 81 extensions::Manifest::INTERNAL,
81 int flags = extensions::Extension::NO_FLAGS); 82 int flags = extensions::Extension::NO_FLAGS);
82 83
83 scoped_refptr<extensions::Extension> LoadAndExpectWarning( 84 scoped_refptr<extensions::Extension> LoadAndExpectWarning(
84 char const* manifest_name, 85 char const* manifest_name,
85 const std::string& expected_error, 86 const std::string& expected_error,
86 extensions::Extension::Location location = 87 extensions::Manifest::Location location =
87 extensions::Extension::INTERNAL, 88 extensions::Manifest::INTERNAL,
88 int flags = extensions::Extension::NO_FLAGS); 89 int flags = extensions::Extension::NO_FLAGS);
89 90
90 void VerifyExpectedError(extensions::Extension* extension, 91 void VerifyExpectedError(extensions::Extension* extension,
91 const std::string& name, 92 const std::string& name,
92 const std::string& error, 93 const std::string& error,
93 const std::string& expected_error); 94 const std::string& expected_error);
94 95
95 void LoadAndExpectError(char const* manifest_name, 96 void LoadAndExpectError(char const* manifest_name,
96 const std::string& expected_error, 97 const std::string& expected_error,
97 extensions::Extension::Location location = 98 extensions::Manifest::Location location =
98 extensions::Extension::INTERNAL, 99 extensions::Manifest::INTERNAL,
99 int flags = extensions::Extension::NO_FLAGS); 100 int flags = extensions::Extension::NO_FLAGS);
100 101
101 void LoadAndExpectError(const Manifest& manifest, 102 void LoadAndExpectError(const Manifest& manifest,
102 const std::string& expected_error, 103 const std::string& expected_error,
103 extensions::Extension::Location location = 104 extensions::Manifest::Location location =
104 extensions::Extension::INTERNAL, 105 extensions::Manifest::INTERNAL,
105 int flags = extensions::Extension::NO_FLAGS); 106 int flags = extensions::Extension::NO_FLAGS);
106 107
107 void AddPattern(extensions::URLPatternSet* extent, 108 void AddPattern(extensions::URLPatternSet* extent,
108 const std::string& pattern); 109 const std::string& pattern);
109 110
110 // used to differentiate between calls to LoadAndExpectError, 111 // used to differentiate between calls to LoadAndExpectError,
111 // LoadAndExpectWarning and LoadAndExpectSuccess via function RunTestcases. 112 // LoadAndExpectWarning and LoadAndExpectSuccess via function RunTestcases.
112 enum EXPECT_TYPE { 113 enum EXPECT_TYPE {
113 EXPECT_TYPE_ERROR, 114 EXPECT_TYPE_ERROR,
114 EXPECT_TYPE_WARNING, 115 EXPECT_TYPE_WARNING,
115 EXPECT_TYPE_SUCCESS 116 EXPECT_TYPE_SUCCESS
116 }; 117 };
117 118
118 struct Testcase { 119 struct Testcase {
119 std::string manifest_filename_; 120 std::string manifest_filename_;
120 std::string expected_error_; // only used for ExpectedError tests 121 std::string expected_error_; // only used for ExpectedError tests
121 extensions::Extension::Location location_; 122 extensions::Manifest::Location location_;
122 int flags_; 123 int flags_;
123 124
124 Testcase(std::string manifest_filename, std::string expected_error, 125 Testcase(std::string manifest_filename, std::string expected_error,
125 extensions::Extension::Location location, int flags); 126 extensions::Manifest::Location location, int flags);
126 127
127 Testcase(std::string manifest_filename, std::string expected_error); 128 Testcase(std::string manifest_filename, std::string expected_error);
128 129
129 explicit Testcase(std::string manifest_filename); 130 explicit Testcase(std::string manifest_filename);
130 131
131 Testcase(std::string manifest_filename, 132 Testcase(std::string manifest_filename,
132 extensions::Extension::Location location, 133 extensions::Manifest::Location location,
133 int flags); 134 int flags);
134 }; 135 };
135 136
136 void RunTestcases(const Testcase* testcases, size_t num_testcases, 137 void RunTestcases(const Testcase* testcases, size_t num_testcases,
137 EXPECT_TYPE type); 138 EXPECT_TYPE type);
138 139
139 bool enable_apps_; 140 bool enable_apps_;
140 141
141 // Force the manifest tests to run as though they are on trunk, since several 142 // Force the manifest tests to run as though they are on trunk, since several
142 // tests rely on manifest features being available that aren't on 143 // tests rely on manifest features being available that aren't on
143 // stable/beta. 144 // stable/beta.
144 // 145 //
145 // These objects nest, so if a test wants to explicitly test the behaviour 146 // These objects nest, so if a test wants to explicitly test the behaviour
146 // on stable or beta, declare it inside that test. 147 // on stable or beta, declare it inside that test.
147 extensions::Feature::ScopedCurrentChannel current_channel_; 148 extensions::Feature::ScopedCurrentChannel current_channel_;
148 }; 149 };
149 150
150 #endif // CHROME_COMMON_EXTENSIONS_MANIFEST_TESTS_EXTENSION_MANIFEST_TEST_H_ 151 #endif // CHROME_COMMON_EXTENSIONS_MANIFEST_TESTS_EXTENSION_MANIFEST_TEST_H_
OLDNEW
« no previous file with comments | « chrome/common/extensions/manifest_handler.cc ('k') | chrome/common/extensions/manifest_tests/extension_manifest_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698