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 <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 } | 114 } |
115 | 115 |
116 // Wraps the given JavaScript snippet in <html><body><script> tags, then | 116 // Wraps the given JavaScript snippet in <html><body><script> tags, then |
117 // loads it into a webframe so it is executed. | 117 // loads it into a webframe so it is executed. |
118 void ExecuteJavaScript(const std::string& javascript) { | 118 void ExecuteJavaScript(const std::string& javascript) { |
119 std::string html = "<html><body>"; | 119 std::string html = "<html><body>"; |
120 html.append("<script>"); | 120 html.append("<script>"); |
121 html.append(javascript); | 121 html.append(javascript); |
122 html.append("</script></body></html>"); | 122 html.append("</script></body></html>"); |
123 webframe()->loadHTMLString(html, GURL("about:blank")); | 123 webframe()->loadHTMLString(html, GURL("about:blank")); |
124 MessageLoop::current()->RunAllPending(); | 124 MessageLoop::current()->RunUntilIdle(); |
125 } | 125 } |
126 | 126 |
127 // Executes the specified JavaScript and checks to be sure that the resulting | 127 // Executes the specified JavaScript and checks to be sure that the resulting |
128 // document text is exactly "SUCCESS". | 128 // document text is exactly "SUCCESS". |
129 void CheckJavaScriptSuccess(const std::string& javascript) { | 129 void CheckJavaScriptSuccess(const std::string& javascript) { |
130 ExecuteJavaScript(javascript); | 130 ExecuteJavaScript(javascript); |
131 EXPECT_EQ("SUCCESS", | 131 EXPECT_EQ("SUCCESS", |
132 UTF16ToASCII(webkit_glue::DumpDocumentText(webframe()))); | 132 UTF16ToASCII(webkit_glue::DumpDocumentText(webframe()))); |
133 } | 133 } |
134 | 134 |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 | 297 |
298 // Ensures existent methods can be invoked successfully when the fallback method | 298 // Ensures existent methods can be invoked successfully when the fallback method |
299 // is used | 299 // is used |
300 TEST_F(CppBoundClassWithFallbackMethodTest, | 300 TEST_F(CppBoundClassWithFallbackMethodTest, |
301 InvokeExistentMethodsWithFallback) { | 301 InvokeExistentMethodsWithFallback) { |
302 std::string js = BuildJSCondition("example.echoValue(34)", "34"); | 302 std::string js = BuildJSCondition("example.echoValue(34)", "34"); |
303 CheckJavaScriptSuccess(js); | 303 CheckJavaScriptSuccess(js); |
304 } | 304 } |
305 | 305 |
306 } // namespace | 306 } // namespace |
OLD | NEW |