| 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/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 class TestFunctionDispatcherDelegate | 30 class TestFunctionDispatcherDelegate |
| 31 : public extensions::ExtensionFunctionDispatcher::Delegate { | 31 : public extensions::ExtensionFunctionDispatcher::Delegate { |
| 32 public: | 32 public: |
| 33 explicit TestFunctionDispatcherDelegate(Browser* browser) : | 33 explicit TestFunctionDispatcherDelegate(Browser* browser) : |
| 34 browser_(browser) {} | 34 browser_(browser) {} |
| 35 virtual ~TestFunctionDispatcherDelegate() {} | 35 virtual ~TestFunctionDispatcherDelegate() {} |
| 36 | 36 |
| 37 private: | 37 private: |
| 38 virtual extensions::WindowController* GetExtensionWindowController() | 38 virtual extensions::WindowController* GetExtensionWindowController() |
| 39 const OVERRIDE { | 39 const override { |
| 40 return browser_->extension_window_controller(); | 40 return browser_->extension_window_controller(); |
| 41 } | 41 } |
| 42 | 42 |
| 43 virtual WebContents* GetAssociatedWebContents() const OVERRIDE { | 43 virtual WebContents* GetAssociatedWebContents() const override { |
| 44 return NULL; | 44 return NULL; |
| 45 } | 45 } |
| 46 | 46 |
| 47 Browser* browser_; | 47 Browser* browser_; |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 } // namespace | 50 } // namespace |
| 51 | 51 |
| 52 namespace extension_function_test_utils { | 52 namespace extension_function_test_utils { |
| 53 | 53 |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 return response_.get() != NULL; | 204 return response_.get() != NULL; |
| 205 } | 205 } |
| 206 | 206 |
| 207 bool GetResponse() { | 207 bool GetResponse() { |
| 208 EXPECT_TRUE(HasResponse()); | 208 EXPECT_TRUE(HasResponse()); |
| 209 return *response_.get(); | 209 return *response_.get(); |
| 210 } | 210 } |
| 211 | 211 |
| 212 virtual void OnSendResponse(UIThreadExtensionFunction* function, | 212 virtual void OnSendResponse(UIThreadExtensionFunction* function, |
| 213 bool success, | 213 bool success, |
| 214 bool bad_message) OVERRIDE { | 214 bool bad_message) override { |
| 215 ASSERT_FALSE(bad_message); | 215 ASSERT_FALSE(bad_message); |
| 216 ASSERT_FALSE(HasResponse()); | 216 ASSERT_FALSE(HasResponse()); |
| 217 response_.reset(new bool); | 217 response_.reset(new bool); |
| 218 *response_ = success; | 218 *response_ = success; |
| 219 if (should_post_quit_) { | 219 if (should_post_quit_) { |
| 220 base::MessageLoopForUI::current()->Quit(); | 220 base::MessageLoopForUI::current()->Quit(); |
| 221 } | 221 } |
| 222 } | 222 } |
| 223 | 223 |
| 224 private: | 224 private: |
| (...skipping 23 matching lines...) Expand all Loading... |
| 248 // only one place. See crbug.com/394840. | 248 // only one place. See crbug.com/394840. |
| 249 return extensions::api_test_utils::RunFunction( | 249 return extensions::api_test_utils::RunFunction( |
| 250 function, | 250 function, |
| 251 args.Pass(), | 251 args.Pass(), |
| 252 browser->profile(), | 252 browser->profile(), |
| 253 dispatcher.Pass(), | 253 dispatcher.Pass(), |
| 254 static_cast<extensions::api_test_utils::RunFunctionFlags>(flags)); | 254 static_cast<extensions::api_test_utils::RunFunctionFlags>(flags)); |
| 255 } | 255 } |
| 256 | 256 |
| 257 } // namespace extension_function_test_utils | 257 } // namespace extension_function_test_utils |
| OLD | NEW |