OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 // When called by WebViewDelegate::WindowObjectCleared method, this binds a | 63 // When called by WebViewDelegate::WindowObjectCleared method, this binds a |
64 // CppExampleObject to window.example. | 64 // CppExampleObject to window.example. |
65 virtual void BindJSObjectsToWindow(WebFrame* frame) { | 65 virtual void BindJSObjectsToWindow(WebFrame* frame) { |
66 example_bound_class_.BindToJavascript(frame, L"example"); | 66 example_bound_class_.BindToJavascript(frame, L"example"); |
67 // We use the layoutTestController binding for notifyDone. | 67 // We use the layoutTestController binding for notifyDone. |
68 TestShell::BindJSObjectsToWindow(frame); | 68 TestShell::BindJSObjectsToWindow(frame); |
69 } | 69 } |
70 | 70 |
71 // This is a public interface to TestShell's protected method, so it | 71 // This is a public interface to TestShell's protected method, so it |
72 // can be called by our CreateEmptyWindow. | 72 // can be called by our CreateEmptyWindow. |
73 bool PublicInitialize(const std::wstring& startingURL) { | 73 bool PublicInitialize(const std::string& starting_url) { |
74 return Initialize(startingURL); | 74 return Initialize(GURL(starting_url)); |
75 } | 75 } |
76 | 76 |
77 CppBindingExampleWithOptionalFallback example_bound_class_; | 77 CppBindingExampleWithOptionalFallback example_bound_class_; |
78 }; | 78 }; |
79 | 79 |
80 class CppBoundClassTest : public TestShellTest { | 80 class CppBoundClassTest : public TestShellTest { |
81 protected: | 81 protected: |
82 // Adapted from TestShell::CreateNewWindow, this creates an | 82 // Adapted from TestShell::CreateNewWindow, this creates an |
83 // ExampleTestShellWindow rather than a regular TestShell. | 83 // ExampleTestShellWindow rather than a regular TestShell. |
84 virtual void CreateEmptyWindow() { | 84 virtual void CreateEmptyWindow() { |
85 ExampleTestShell* host = new ExampleTestShell(useFallback()); | 85 ExampleTestShell* host = new ExampleTestShell(useFallback()); |
86 ASSERT_TRUE(host != NULL); | 86 ASSERT_TRUE(host != NULL); |
87 bool rv = host->PublicInitialize(L"about:blank"); | 87 bool rv = host->PublicInitialize("about:blank"); |
88 if (rv) { | 88 if (rv) { |
89 test_shell_ = host; | 89 test_shell_ = host; |
90 TestShell::windowList()->push_back(host->mainWnd()); | 90 TestShell::windowList()->push_back(host->mainWnd()); |
91 webframe_ = test_shell_->webView()->GetMainFrame(); | 91 webframe_ = test_shell_->webView()->GetMainFrame(); |
92 ASSERT_TRUE(webframe_ != NULL); | 92 ASSERT_TRUE(webframe_ != NULL); |
93 } else { | 93 } else { |
94 delete host; | 94 delete host; |
95 } | 95 } |
96 } | 96 } |
97 | 97 |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 | 260 |
261 // Ensures existent methods can be invoked successfully when the fallback method | 261 // Ensures existent methods can be invoked successfully when the fallback method |
262 // is used | 262 // is used |
263 TEST_F(CppBoundClassWithFallbackMethodTest, | 263 TEST_F(CppBoundClassWithFallbackMethodTest, |
264 InvokeExistentMethodsWithFallback) { | 264 InvokeExistentMethodsWithFallback) { |
265 std::string js = BuildJSCondition("example.echoValue(34)", "34"); | 265 std::string js = BuildJSCondition("example.echoValue(34)", "34"); |
266 CheckJavaScriptSuccess(js); | 266 CheckJavaScriptSuccess(js); |
267 } | 267 } |
268 | 268 |
269 } // namespace | 269 } // namespace |
OLD | NEW |