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 #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" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 return static_cast<base::DictionaryValue*>(val); | 91 return static_cast<base::DictionaryValue*>(val); |
92 } | 92 } |
93 | 93 |
94 base::ListValue* ToList(base::Value* val) { | 94 base::ListValue* ToList(base::Value* val) { |
95 EXPECT_TRUE(val); | 95 EXPECT_TRUE(val); |
96 EXPECT_EQ(base::Value::TYPE_LIST, val->GetType()); | 96 EXPECT_EQ(base::Value::TYPE_LIST, val->GetType()); |
97 return static_cast<base::ListValue*>(val); | 97 return static_cast<base::ListValue*>(val); |
98 } | 98 } |
99 | 99 |
100 scoped_refptr<Extension> CreateEmptyExtension() { | 100 scoped_refptr<Extension> CreateEmptyExtension() { |
| 101 return CreateEmptyExtensionWithLocation(Extension::INTERNAL); |
| 102 } |
| 103 |
| 104 scoped_refptr<Extension> CreateEmptyExtensionWithLocation( |
| 105 Extension::Location location) { |
101 std::string error; | 106 std::string error; |
102 const FilePath test_extension_path; | 107 const FilePath test_extension_path; |
103 scoped_ptr<base::DictionaryValue> test_extension_value( | 108 scoped_ptr<base::DictionaryValue> test_extension_value( |
104 ParseDictionary("{\"name\": \"Test\", \"version\": \"1.0\"}")); | 109 ParseDictionary("{\"name\": \"Test\", \"version\": \"1.0\"}")); |
105 scoped_refptr<Extension> extension(Extension::Create( | 110 scoped_refptr<Extension> extension(Extension::Create( |
106 test_extension_path, | 111 test_extension_path, |
107 Extension::INTERNAL, | 112 location, |
108 *test_extension_value.get(), | 113 *test_extension_value.get(), |
109 Extension::NO_FLAGS, | 114 Extension::NO_FLAGS, |
110 &error)); | 115 &error)); |
111 EXPECT_TRUE(error.empty()) << "Could not parse test extension " << error; | 116 EXPECT_TRUE(error.empty()) << "Could not parse test extension " << error; |
112 return extension; | 117 return extension; |
113 } | 118 } |
114 | 119 |
115 std::string RunFunctionAndReturnError(UIThreadExtensionFunction* function, | 120 std::string RunFunctionAndReturnError(UIThreadExtensionFunction* function, |
116 const std::string& args, | 121 const std::string& args, |
117 Browser* browser) { | 122 Browser* browser) { |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 if (!response_delegate.HasResponse()) { | 213 if (!response_delegate.HasResponse()) { |
209 response_delegate.set_should_post_quit(true); | 214 response_delegate.set_should_post_quit(true); |
210 ui_test_utils::RunMessageLoop(); | 215 ui_test_utils::RunMessageLoop(); |
211 } | 216 } |
212 | 217 |
213 EXPECT_TRUE(response_delegate.HasResponse()); | 218 EXPECT_TRUE(response_delegate.HasResponse()); |
214 return response_delegate.GetResponse(); | 219 return response_delegate.GetResponse(); |
215 } | 220 } |
216 | 221 |
217 } // namespace extension_function_test_utils | 222 } // namespace extension_function_test_utils |
OLD | NEW |