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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 UIThreadExtensionFunction* function, | 146 UIThreadExtensionFunction* function, |
147 const std::string& args, | 147 const std::string& args, |
148 Browser* browser, | 148 Browser* browser, |
149 RunFunctionFlags flags) { | 149 RunFunctionFlags flags) { |
150 scoped_refptr<ExtensionFunction> function_owner(function); | 150 scoped_refptr<ExtensionFunction> function_owner(function); |
151 // Without a callback the function will not generate a result. | 151 // Without a callback the function will not generate a result. |
152 function->set_has_callback(true); | 152 function->set_has_callback(true); |
153 RunFunction(function, args, browser, flags); | 153 RunFunction(function, args, browser, flags); |
154 EXPECT_TRUE(function->GetError().empty()) << "Unexpected error: " | 154 EXPECT_TRUE(function->GetError().empty()) << "Unexpected error: " |
155 << function->GetError(); | 155 << function->GetError(); |
156 base::Value* single_result = NULL; | 156 const base::Value* single_result = NULL; |
157 if (function->GetResultList() != NULL && | 157 if (function->GetResultList() != NULL && |
158 function->GetResultList()->Get(0, &single_result)) { | 158 function->GetResultList()->Get(0, &single_result)) { |
159 return single_result->DeepCopy(); | 159 return single_result->DeepCopy(); |
160 } | 160 } |
161 return NULL; | 161 return NULL; |
162 } | 162 } |
163 | 163 |
164 // This helps us be able to wait until an AsyncExtensionFunction calls | 164 // This helps us be able to wait until an AsyncExtensionFunction calls |
165 // SendResponse. | 165 // SendResponse. |
166 class SendResponseDelegate | 166 class SendResponseDelegate |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 if (!response_delegate.HasResponse()) { | 225 if (!response_delegate.HasResponse()) { |
226 response_delegate.set_should_post_quit(true); | 226 response_delegate.set_should_post_quit(true); |
227 content::RunMessageLoop(); | 227 content::RunMessageLoop(); |
228 } | 228 } |
229 | 229 |
230 EXPECT_TRUE(response_delegate.HasResponse()); | 230 EXPECT_TRUE(response_delegate.HasResponse()); |
231 return response_delegate.GetResponse(); | 231 return response_delegate.GetResponse(); |
232 } | 232 } |
233 | 233 |
234 } // namespace extension_function_test_utils | 234 } // namespace extension_function_test_utils |
OLD | NEW |