| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 return RunFunctionAndReturnResult(function, args, browser, NONE); | 131 return RunFunctionAndReturnResult(function, args, browser, NONE); |
| 132 } | 132 } |
| 133 base::Value* RunFunctionAndReturnResult(UIThreadExtensionFunction* function, | 133 base::Value* RunFunctionAndReturnResult(UIThreadExtensionFunction* function, |
| 134 const std::string& args, | 134 const std::string& args, |
| 135 Browser* browser, | 135 Browser* browser, |
| 136 RunFunctionFlags flags) { | 136 RunFunctionFlags flags) { |
| 137 scoped_refptr<ExtensionFunction> function_owner(function); | 137 scoped_refptr<ExtensionFunction> function_owner(function); |
| 138 RunFunction(function, args, browser, flags); | 138 RunFunction(function, args, browser, flags); |
| 139 EXPECT_TRUE(function->GetError().empty()) << "Unexpected error: " | 139 EXPECT_TRUE(function->GetError().empty()) << "Unexpected error: " |
| 140 << function->GetError(); | 140 << function->GetError(); |
| 141 return (function->GetResultValue() == NULL) ? NULL : | 141 EXPECT_TRUE(function->GetResultValue()) << "No result value found"; |
| 142 function->GetResultValue()->DeepCopy(); | 142 return function->GetResultValue()->DeepCopy(); |
| 143 } | 143 } |
| 144 | 144 |
| 145 // This helps us be able to wait until an AsyncExtensionFunction calls | 145 // This helps us be able to wait until an AsyncExtensionFunction calls |
| 146 // SendResponse. | 146 // SendResponse. |
| 147 class SendResponseDelegate | 147 class SendResponseDelegate |
| 148 : public UIThreadExtensionFunction::DelegateForTests { | 148 : public UIThreadExtensionFunction::DelegateForTests { |
| 149 public: | 149 public: |
| 150 SendResponseDelegate() : should_post_quit_(false) {} | 150 SendResponseDelegate() : should_post_quit_(false) {} |
| 151 | 151 |
| 152 virtual ~SendResponseDelegate() {} | 152 virtual ~SendResponseDelegate() {} |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 if (!response_delegate.HasResponse()) { | 204 if (!response_delegate.HasResponse()) { |
| 205 response_delegate.set_should_post_quit(true); | 205 response_delegate.set_should_post_quit(true); |
| 206 ui_test_utils::RunMessageLoop(); | 206 ui_test_utils::RunMessageLoop(); |
| 207 } | 207 } |
| 208 | 208 |
| 209 EXPECT_TRUE(response_delegate.HasResponse()); | 209 EXPECT_TRUE(response_delegate.HasResponse()); |
| 210 return response_delegate.GetResponse(); | 210 return response_delegate.GetResponse(); |
| 211 } | 211 } |
| 212 | 212 |
| 213 } // namespace extension_function_test_utils | 213 } // namespace extension_function_test_utils |
| OLD | NEW |