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/common/url_constants.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 } | 52 } |
53 | 53 |
54 private: | 54 private: |
55 CppBindingExampleSubObject sub_object_; | 55 CppBindingExampleSubObject sub_object_; |
56 }; | 56 }; |
57 | 57 |
58 class TestObserver : public RenderViewObserver { | 58 class TestObserver : public RenderViewObserver { |
59 public: | 59 public: |
60 explicit TestObserver(RenderView* render_view) | 60 explicit TestObserver(RenderView* render_view) |
61 : RenderViewObserver(render_view) {} | 61 : RenderViewObserver(render_view) {} |
62 virtual void DidClearWindowObject(WebKit::WebFrame* frame) OVERRIDE { | 62 virtual void DidClearWindowObject(blink::WebFrame* frame) OVERRIDE { |
63 example_bound_class_.BindToJavascript(frame, "example"); | 63 example_bound_class_.BindToJavascript(frame, "example"); |
64 } | 64 } |
65 void set_fallback_method_enabled(bool use_fallback) { | 65 void set_fallback_method_enabled(bool use_fallback) { |
66 example_bound_class_.set_fallback_method_enabled(use_fallback); | 66 example_bound_class_.set_fallback_method_enabled(use_fallback); |
67 } | 67 } |
68 private: | 68 private: |
69 CppBindingExampleWithOptionalFallback example_bound_class_; | 69 CppBindingExampleWithOptionalFallback example_bound_class_; |
70 }; | 70 }; |
71 | 71 |
72 } // namespace | 72 } // namespace |
73 | 73 |
74 class CppBoundClassTest : public RenderViewTest { | 74 class CppBoundClassTest : public RenderViewTest { |
75 public: | 75 public: |
76 CppBoundClassTest() {} | 76 CppBoundClassTest() {} |
77 | 77 |
78 virtual void SetUp() OVERRIDE { | 78 virtual void SetUp() OVERRIDE { |
79 RenderViewTest::SetUp(); | 79 RenderViewTest::SetUp(); |
80 observer_.reset(new TestObserver(view_)); | 80 observer_.reset(new TestObserver(view_)); |
81 observer_->set_fallback_method_enabled(useFallback()); | 81 observer_->set_fallback_method_enabled(useFallback()); |
82 | 82 |
83 WebKit::WebURLRequest url_request; | 83 blink::WebURLRequest url_request; |
84 url_request.initialize(); | 84 url_request.initialize(); |
85 url_request.setURL(GURL(kAboutBlankURL)); | 85 url_request.setURL(GURL(kAboutBlankURL)); |
86 | 86 |
87 GetMainFrame()->loadRequest(url_request); | 87 GetMainFrame()->loadRequest(url_request); |
88 ProcessPendingMessages(); | 88 ProcessPendingMessages(); |
89 } | 89 } |
90 | 90 |
91 virtual void TearDown() OVERRIDE { | 91 virtual void TearDown() OVERRIDE { |
92 observer_.reset(); | 92 observer_.reset(); |
93 RenderViewTest::TearDown(); | 93 RenderViewTest::TearDown(); |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 } | 232 } |
233 | 233 |
234 // Ensures existent methods can be invoked successfully when the fallback method | 234 // Ensures existent methods can be invoked successfully when the fallback method |
235 // is used | 235 // is used |
236 TEST_F(CppBoundClassWithFallbackMethodTest, | 236 TEST_F(CppBoundClassWithFallbackMethodTest, |
237 InvokeExistentMethodsWithFallback) { | 237 InvokeExistentMethodsWithFallback) { |
238 CheckTrue("example.echoValue(34) == 34"); | 238 CheckTrue("example.echoValue(34) == 34"); |
239 } | 239 } |
240 | 240 |
241 } // namespace content | 241 } // namespace content |
OLD | NEW |