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

Side by Side Diff: chrome/browser/extensions/extension_function_test_utils.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 "chrome/browser/extensions/extension_function_test_utils.h" 5 #include "chrome/browser/extensions/extension_function_test_utils.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" 12 #include "chrome/browser/extensions/api/tabs/tabs_constants.h"
13 #include "chrome/browser/extensions/extension_function.h" 13 #include "chrome/browser/extensions/extension_function.h"
14 #include "chrome/browser/extensions/extension_function_dispatcher.h" 14 #include "chrome/browser/extensions/extension_function_dispatcher.h"
15 #include "chrome/browser/ui/browser.h" 15 #include "chrome/browser/ui/browser.h"
16 #include "chrome/common/extensions/extension.h" 16 #include "chrome/common/extensions/extension.h"
17 #include "chrome/common/extensions/manifest.h"
17 #include "chrome/test/base/ui_test_utils.h" 18 #include "chrome/test/base/ui_test_utils.h"
18 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
19 20
20 using content::WebContents; 21 using content::WebContents;
21 using extensions::Extension; 22 using extensions::Extension;
23 using extensions::Manifest;
22 namespace keys = extensions::tabs_constants; 24 namespace keys = extensions::tabs_constants;
23 25
24 namespace { 26 namespace {
25 27
26 class TestFunctionDispatcherDelegate 28 class TestFunctionDispatcherDelegate
27 : public ExtensionFunctionDispatcher::Delegate { 29 : public ExtensionFunctionDispatcher::Delegate {
28 public: 30 public:
29 explicit TestFunctionDispatcherDelegate(Browser* browser) : 31 explicit TestFunctionDispatcherDelegate(Browser* browser) :
30 browser_(browser) {} 32 browser_(browser) {}
31 virtual ~TestFunctionDispatcherDelegate() {} 33 virtual ~TestFunctionDispatcherDelegate() {}
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 return static_cast<base::DictionaryValue*>(val); 97 return static_cast<base::DictionaryValue*>(val);
96 } 98 }
97 99
98 base::ListValue* ToList(base::Value* val) { 100 base::ListValue* ToList(base::Value* val) {
99 EXPECT_TRUE(val); 101 EXPECT_TRUE(val);
100 EXPECT_EQ(base::Value::TYPE_LIST, val->GetType()); 102 EXPECT_EQ(base::Value::TYPE_LIST, val->GetType());
101 return static_cast<base::ListValue*>(val); 103 return static_cast<base::ListValue*>(val);
102 } 104 }
103 105
104 scoped_refptr<Extension> CreateEmptyExtension() { 106 scoped_refptr<Extension> CreateEmptyExtension() {
105 return CreateEmptyExtensionWithLocation(Extension::INTERNAL); 107 return CreateEmptyExtensionWithLocation(Manifest::INTERNAL);
106 } 108 }
107 109
108 scoped_refptr<Extension> CreateEmptyExtensionWithLocation( 110 scoped_refptr<Extension> CreateEmptyExtensionWithLocation(
109 Extension::Location location) { 111 Manifest::Location location) {
110 scoped_ptr<base::DictionaryValue> test_extension_value( 112 scoped_ptr<base::DictionaryValue> test_extension_value(
111 ParseDictionary("{\"name\": \"Test\", \"version\": \"1.0\"}")); 113 ParseDictionary("{\"name\": \"Test\", \"version\": \"1.0\"}"));
112 return CreateExtension(location, test_extension_value.get(), std::string()); 114 return CreateExtension(location, test_extension_value.get(), std::string());
113 } 115 }
114 116
115 scoped_refptr<Extension> CreateEmptyExtension( 117 scoped_refptr<Extension> CreateEmptyExtension(
116 const std::string& id_input) { 118 const std::string& id_input) {
117 scoped_ptr<base::DictionaryValue> test_extension_value( 119 scoped_ptr<base::DictionaryValue> test_extension_value(
118 ParseDictionary("{\"name\": \"Test\", \"version\": \"1.0\"}")); 120 ParseDictionary("{\"name\": \"Test\", \"version\": \"1.0\"}"));
119 return CreateExtension(Extension::INTERNAL, test_extension_value.get(), 121 return CreateExtension(Manifest::INTERNAL, test_extension_value.get(),
120 id_input); 122 id_input);
121 } 123 }
122 124
123 scoped_refptr<Extension> CreateExtension( 125 scoped_refptr<Extension> CreateExtension(
124 base::DictionaryValue* test_extension_value) { 126 base::DictionaryValue* test_extension_value) {
125 return CreateExtension(Extension::INTERNAL, test_extension_value, 127 return CreateExtension(Manifest::INTERNAL, test_extension_value,
126 std::string()); 128 std::string());
127 } 129 }
128 130
129 scoped_refptr<Extension> CreateExtension( 131 scoped_refptr<Extension> CreateExtension(
130 Extension::Location location, 132 Manifest::Location location,
131 base::DictionaryValue* test_extension_value, 133 base::DictionaryValue* test_extension_value,
132 const std::string& id_input) { 134 const std::string& id_input) {
133 std::string error; 135 std::string error;
134 const FilePath test_extension_path; 136 const FilePath test_extension_path;
135 std::string id; 137 std::string id;
136 if (!id_input.empty()) 138 if (!id_input.empty())
137 CHECK(Extension::GenerateId(id_input, &id)); 139 CHECK(Extension::GenerateId(id_input, &id));
138 scoped_refptr<Extension> extension(Extension::Create( 140 scoped_refptr<Extension> extension(Extension::Create(
139 test_extension_path, 141 test_extension_path,
140 location, 142 location,
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 if (!response_delegate.HasResponse()) { 263 if (!response_delegate.HasResponse()) {
262 response_delegate.set_should_post_quit(true); 264 response_delegate.set_should_post_quit(true);
263 content::RunMessageLoop(); 265 content::RunMessageLoop();
264 } 266 }
265 267
266 EXPECT_TRUE(response_delegate.HasResponse()); 268 EXPECT_TRUE(response_delegate.HasResponse());
267 return response_delegate.GetResponse(); 269 return response_delegate.GetResponse();
268 } 270 }
269 271
270 } // namespace extension_function_test_utils 272 } // namespace extension_function_test_utils
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698