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 14 matching lines...) Expand all Loading... |
25 using extensions::Manifest; | 25 using extensions::Manifest; |
26 namespace keys = extensions::tabs_constants; | 26 namespace keys = extensions::tabs_constants; |
27 | 27 |
28 namespace { | 28 namespace { |
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 ~TestFunctionDispatcherDelegate() override {} |
36 | 36 |
37 private: | 37 private: |
38 virtual extensions::WindowController* GetExtensionWindowController() | 38 extensions::WindowController* GetExtensionWindowController() const override { |
39 const override { | |
40 return browser_->extension_window_controller(); | 39 return browser_->extension_window_controller(); |
41 } | 40 } |
42 | 41 |
43 virtual WebContents* GetAssociatedWebContents() const override { | 42 WebContents* GetAssociatedWebContents() const override { return NULL; } |
44 return NULL; | |
45 } | |
46 | 43 |
47 Browser* browser_; | 44 Browser* browser_; |
48 }; | 45 }; |
49 | 46 |
50 } // namespace | 47 } // namespace |
51 | 48 |
52 namespace extension_function_test_utils { | 49 namespace extension_function_test_utils { |
53 | 50 |
54 base::Value* ParseJSON(const std::string& data) { | 51 base::Value* ParseJSON(const std::string& data) { |
55 return base::JSONReader::Read(data); | 52 return base::JSONReader::Read(data); |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 | 199 |
203 bool HasResponse() { | 200 bool HasResponse() { |
204 return response_.get() != NULL; | 201 return response_.get() != NULL; |
205 } | 202 } |
206 | 203 |
207 bool GetResponse() { | 204 bool GetResponse() { |
208 EXPECT_TRUE(HasResponse()); | 205 EXPECT_TRUE(HasResponse()); |
209 return *response_.get(); | 206 return *response_.get(); |
210 } | 207 } |
211 | 208 |
212 virtual void OnSendResponse(UIThreadExtensionFunction* function, | 209 void OnSendResponse(UIThreadExtensionFunction* function, |
213 bool success, | 210 bool success, |
214 bool bad_message) override { | 211 bool bad_message) override { |
215 ASSERT_FALSE(bad_message); | 212 ASSERT_FALSE(bad_message); |
216 ASSERT_FALSE(HasResponse()); | 213 ASSERT_FALSE(HasResponse()); |
217 response_.reset(new bool); | 214 response_.reset(new bool); |
218 *response_ = success; | 215 *response_ = success; |
219 if (should_post_quit_) { | 216 if (should_post_quit_) { |
220 base::MessageLoopForUI::current()->Quit(); | 217 base::MessageLoopForUI::current()->Quit(); |
221 } | 218 } |
222 } | 219 } |
223 | 220 |
224 private: | 221 private: |
(...skipping 23 matching lines...) Expand all Loading... |
248 // only one place. See crbug.com/394840. | 245 // only one place. See crbug.com/394840. |
249 return extensions::api_test_utils::RunFunction( | 246 return extensions::api_test_utils::RunFunction( |
250 function, | 247 function, |
251 args.Pass(), | 248 args.Pass(), |
252 browser->profile(), | 249 browser->profile(), |
253 dispatcher.Pass(), | 250 dispatcher.Pass(), |
254 static_cast<extensions::api_test_utils::RunFunctionFlags>(flags)); | 251 static_cast<extensions::api_test_utils::RunFunctionFlags>(flags)); |
255 } | 252 } |
256 | 253 |
257 } // namespace extension_function_test_utils | 254 } // namespace extension_function_test_utils |
OLD | NEW |