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 // Tests for CppBoundClass, in conjunction with CppBindingExample. Binds | 5 // Tests for CppBoundClass, in conjunction with CppBindingExample. Binds |
6 // a CppBindingExample class into JavaScript in a custom test shell and tests | 6 // a CppBindingExample class into JavaScript in a custom test shell and tests |
7 // the binding from the outside by loading JS into the shell. | 7 // the binding from the outside by loading JS into the shell. |
8 | 8 |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "content/public/common/url_constants.h" |
10 #include "content/public/renderer/render_view_observer.h" | 11 #include "content/public/renderer/render_view_observer.h" |
11 #include "content/public/test/render_view_test.h" | 12 #include "content/public/test/render_view_test.h" |
12 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 13 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
13 #include "third_party/WebKit/public/web/WebDocument.h" | 14 #include "third_party/WebKit/public/web/WebDocument.h" |
14 #include "third_party/WebKit/public/web/WebElement.h" | 15 #include "third_party/WebKit/public/web/WebElement.h" |
15 #include "webkit/renderer/cpp_binding_example.h" | 16 #include "webkit/renderer/cpp_binding_example.h" |
16 | 17 |
17 using webkit_glue::CppArgumentList; | 18 using webkit_glue::CppArgumentList; |
18 using webkit_glue::CppBindingExample; | 19 using webkit_glue::CppBindingExample; |
19 using webkit_glue::CppVariant; | 20 using webkit_glue::CppVariant; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 virtual void DidClearWindowObject(WebKit::WebFrame* frame) OVERRIDE { | 63 virtual void DidClearWindowObject(WebKit::WebFrame* frame) OVERRIDE { |
63 example_bound_class_.BindToJavascript(frame, "example"); | 64 example_bound_class_.BindToJavascript(frame, "example"); |
64 } | 65 } |
65 void set_fallback_method_enabled(bool use_fallback) { | 66 void set_fallback_method_enabled(bool use_fallback) { |
66 example_bound_class_.set_fallback_method_enabled(use_fallback); | 67 example_bound_class_.set_fallback_method_enabled(use_fallback); |
67 } | 68 } |
68 private: | 69 private: |
69 CppBindingExampleWithOptionalFallback example_bound_class_; | 70 CppBindingExampleWithOptionalFallback example_bound_class_; |
70 }; | 71 }; |
71 | 72 |
72 } // namespace anonymous | 73 } // namespace |
73 | 74 |
74 class CppBoundClassTest : public RenderViewTest { | 75 class CppBoundClassTest : public RenderViewTest { |
75 public: | 76 public: |
76 CppBoundClassTest() {} | 77 CppBoundClassTest() {} |
77 | 78 |
78 virtual void SetUp() OVERRIDE { | 79 virtual void SetUp() OVERRIDE { |
79 RenderViewTest::SetUp(); | 80 RenderViewTest::SetUp(); |
80 observer_.reset(new TestObserver(view_)); | 81 observer_.reset(new TestObserver(view_)); |
81 observer_->set_fallback_method_enabled(useFallback()); | 82 observer_->set_fallback_method_enabled(useFallback()); |
82 | 83 |
83 WebKit::WebURLRequest url_request; | 84 WebKit::WebURLRequest url_request; |
84 url_request.initialize(); | 85 url_request.initialize(); |
85 url_request.setURL(GURL("about:blank")); | 86 url_request.setURL(GURL(kAboutBlankURL)); |
86 | 87 |
87 GetMainFrame()->loadRequest(url_request); | 88 GetMainFrame()->loadRequest(url_request); |
88 ProcessPendingMessages(); | 89 ProcessPendingMessages(); |
89 } | 90 } |
90 | 91 |
91 virtual void TearDown() OVERRIDE { | 92 virtual void TearDown() OVERRIDE { |
92 observer_.reset(); | 93 observer_.reset(); |
93 RenderViewTest::TearDown(); | 94 RenderViewTest::TearDown(); |
94 } | 95 } |
95 | 96 |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 } | 233 } |
233 | 234 |
234 // Ensures existent methods can be invoked successfully when the fallback method | 235 // Ensures existent methods can be invoked successfully when the fallback method |
235 // is used | 236 // is used |
236 TEST_F(CppBoundClassWithFallbackMethodTest, | 237 TEST_F(CppBoundClassWithFallbackMethodTest, |
237 InvokeExistentMethodsWithFallback) { | 238 InvokeExistentMethodsWithFallback) { |
238 CheckTrue("example.echoValue(34) == 34"); | 239 CheckTrue("example.echoValue(34) == 34"); |
239 } | 240 } |
240 | 241 |
241 } // namespace content | 242 } // namespace content |
OLD | NEW |