OLD | NEW |
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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 const std::string& name() const { return name_; }; | 47 const std::string& name() const { return name_; }; |
48 | 48 |
49 DictionaryValue* GetManifest(std::string* error) const; | 49 DictionaryValue* GetManifest(std::string* error) const; |
50 | 50 |
51 private: | 51 private: |
52 const std::string name_; | 52 const std::string name_; |
53 mutable DictionaryValue* manifest_; | 53 mutable DictionaryValue* manifest_; |
54 mutable scoped_ptr<DictionaryValue> manifest_holder_; | 54 mutable scoped_ptr<DictionaryValue> manifest_holder_; |
55 }; | 55 }; |
56 | 56 |
57 scoped_refptr<Extension> LoadExtension( | 57 scoped_refptr<extensions::Extension> LoadExtension( |
58 const Manifest& manifest, | 58 const Manifest& manifest, |
59 std::string* error, | 59 std::string* error, |
60 Extension::Location location = Extension::INTERNAL, | 60 extensions::Extension::Location location = |
61 int flags = Extension::NO_FLAGS); | 61 extensions::Extension::INTERNAL, |
| 62 int flags = extensions::Extension::NO_FLAGS); |
62 | 63 |
63 scoped_refptr<Extension> LoadAndExpectSuccess( | 64 scoped_refptr<extensions::Extension> LoadAndExpectSuccess( |
64 const Manifest& manifest, | 65 const Manifest& manifest, |
65 Extension::Location location = Extension::INTERNAL, | 66 extensions::Extension::Location location = |
66 int flags = Extension::NO_FLAGS); | 67 extensions::Extension::INTERNAL, |
| 68 int flags = extensions::Extension::NO_FLAGS); |
67 | 69 |
68 scoped_refptr<Extension> LoadAndExpectSuccess( | 70 scoped_refptr<extensions::Extension> LoadAndExpectSuccess( |
69 char const* manifest_name, | 71 char const* manifest_name, |
70 Extension::Location location = Extension::INTERNAL, | 72 extensions::Extension::Location location = |
71 int flags = Extension::NO_FLAGS); | 73 extensions::Extension::INTERNAL, |
| 74 int flags = extensions::Extension::NO_FLAGS); |
72 | 75 |
73 void VerifyExpectedError(Extension* extension, | 76 void VerifyExpectedError(extensions::Extension* extension, |
74 const std::string& name, | 77 const std::string& name, |
75 const std::string& error, | 78 const std::string& error, |
76 const std::string& expected_error); | 79 const std::string& expected_error); |
77 | 80 |
78 void LoadAndExpectError(char const* manifest_name, | 81 void LoadAndExpectError(char const* manifest_name, |
79 const std::string& expected_error, | 82 const std::string& expected_error, |
80 Extension::Location location = Extension::INTERNAL, | 83 extensions::Extension::Location location = |
81 int flags = Extension::NO_FLAGS); | 84 extensions::Extension::INTERNAL, |
| 85 int flags = extensions::Extension::NO_FLAGS); |
82 | 86 |
83 void LoadAndExpectError(const Manifest& manifest, | 87 void LoadAndExpectError(const Manifest& manifest, |
84 const std::string& expected_error, | 88 const std::string& expected_error, |
85 Extension::Location location = Extension::INTERNAL, | 89 extensions::Extension::Location location = |
86 int flags = Extension::NO_FLAGS); | 90 extensions::Extension::INTERNAL, |
| 91 int flags = extensions::Extension::NO_FLAGS); |
87 | 92 |
88 void AddPattern(URLPatternSet* extent, const std::string& pattern); | 93 void AddPattern(URLPatternSet* extent, const std::string& pattern); |
89 | 94 |
90 // used to differentiate between calls to LoadAndExpectError and | 95 // used to differentiate between calls to LoadAndExpectError and |
91 // LoadAndExpectSuccess via function RunTestcases | 96 // LoadAndExpectSuccess via function RunTestcases |
92 enum EXPECT_TYPE { EXPECT_TYPE_ERROR, EXPECT_TYPE_SUCCESS }; | 97 enum EXPECT_TYPE { EXPECT_TYPE_ERROR, EXPECT_TYPE_SUCCESS }; |
93 | 98 |
94 struct Testcase { | 99 struct Testcase { |
95 std::string manifest_filename_; | 100 std::string manifest_filename_; |
96 std::string expected_error_; // only used for ExpectedError tests | 101 std::string expected_error_; // only used for ExpectedError tests |
97 Extension::Location location_; | 102 extensions::Extension::Location location_; |
98 int flags_; | 103 int flags_; |
99 | 104 |
100 Testcase(std::string manifest_filename, std::string expected_error, | 105 Testcase(std::string manifest_filename, std::string expected_error, |
101 Extension::Location location, int flags); | 106 extensions::Extension::Location location, int flags); |
102 | 107 |
103 Testcase(std::string manifest_filename, std::string expected_error); | 108 Testcase(std::string manifest_filename, std::string expected_error); |
104 | 109 |
105 explicit Testcase(std::string manifest_filename); | 110 explicit Testcase(std::string manifest_filename); |
106 | 111 |
107 Testcase(std::string manifest_filename, Extension::Location location, | 112 Testcase(std::string manifest_filename, |
108 int flags); | 113 extensions::Extension::Location location, |
| 114 int flags); |
109 }; | 115 }; |
110 | 116 |
111 void RunTestcases(const Testcase* testcases, size_t num_testcases, | 117 void RunTestcases(const Testcase* testcases, size_t num_testcases, |
112 EXPECT_TYPE type); | 118 EXPECT_TYPE type); |
113 | 119 |
114 bool enable_apps_; | 120 bool enable_apps_; |
115 }; | 121 }; |
116 | 122 |
117 #endif // CHROME_COMMON_EXTENSIONS_MANIFEST_TESTS_EXTENSION_MANIFEST_TEST_H_ | 123 #endif // CHROME_COMMON_EXTENSIONS_MANIFEST_TESTS_EXTENSION_MANIFEST_TEST_H_ |
OLD | NEW |