Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Side by Side Diff: webkit/glue/cpp_bound_class_unittest.cc

Issue 5591004: glue: use string16 in place of wstring for Unicode text (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/glue/bookmarklet_unittest.cc ('k') | webkit/glue/mimetype_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 #include "base/message_loop.h" 11 #include "base/message_loop.h"
12 #include "base/string_util.h"
12 #include "third_party/WebKit/WebKit/chromium/public/WebData.h" 13 #include "third_party/WebKit/WebKit/chromium/public/WebData.h"
13 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" 14 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h"
14 #include "third_party/WebKit/WebKit/chromium/public/WebURL.h" 15 #include "third_party/WebKit/WebKit/chromium/public/WebURL.h"
15 #include "third_party/WebKit/WebKit/chromium/public/WebView.h" 16 #include "third_party/WebKit/WebKit/chromium/public/WebView.h"
16 #include "webkit/glue/cpp_binding_example.h" 17 #include "webkit/glue/cpp_binding_example.h"
17 #include "webkit/glue/webkit_glue.h" 18 #include "webkit/glue/webkit_glue.h"
18 #include "webkit/tools/test_shell/test_shell_test.h" 19 #include "webkit/tools/test_shell/test_shell_test.h"
19 20
20 using WebKit::WebFrame; 21 using WebKit::WebFrame;
21 22
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 // The base URL doesn't matter. 107 // The base URL doesn't matter.
107 webframe_->loadHTMLString(html, GURL("about:blank")); 108 webframe_->loadHTMLString(html, GURL("about:blank"));
108 109
109 test_shell_->WaitTestFinished(); 110 test_shell_->WaitTestFinished();
110 } 111 }
111 112
112 // Executes the specified JavaScript and checks to be sure that the resulting 113 // Executes the specified JavaScript and checks to be sure that the resulting
113 // document text is exactly "SUCCESS". 114 // document text is exactly "SUCCESS".
114 void CheckJavaScriptSuccess(const std::string& javascript) { 115 void CheckJavaScriptSuccess(const std::string& javascript) {
115 ExecuteJavaScript(javascript); 116 ExecuteJavaScript(javascript);
116 EXPECT_EQ(L"SUCCESS", webkit_glue::DumpDocumentText(webframe_)); 117 EXPECT_EQ("SUCCESS",
118 UTF16ToASCII(webkit_glue::DumpDocumentText(webframe_)));
117 } 119 }
118 120
119 // Executes the specified JavaScript and checks that the resulting document 121 // Executes the specified JavaScript and checks that the resulting document
120 // text is empty. 122 // text is empty.
121 void CheckJavaScriptFailure(const std::string& javascript) { 123 void CheckJavaScriptFailure(const std::string& javascript) {
122 ExecuteJavaScript(javascript); 124 ExecuteJavaScript(javascript);
123 EXPECT_EQ(L"", webkit_glue::DumpDocumentText(webframe_)); 125 EXPECT_EQ("", UTF16ToASCII(webkit_glue::DumpDocumentText(webframe_)));
124 } 126 }
125 127
126 // Constructs a JavaScript snippet that evaluates and compares the left and 128 // Constructs a JavaScript snippet that evaluates and compares the left and
127 // right expressions, printing "SUCCESS" to the page if they are equal and 129 // right expressions, printing "SUCCESS" to the page if they are equal and
128 // printing their actual values if they are not. Any strings in the 130 // printing their actual values if they are not. Any strings in the
129 // expressions should be enclosed in single quotes, and no double quotes 131 // expressions should be enclosed in single quotes, and no double quotes
130 // should appear in either expression (even if escaped). (If a test case 132 // should appear in either expression (even if escaped). (If a test case
131 // is added that needs fancier quoting, Json::valueToQuotedString could be 133 // is added that needs fancier quoting, Json::valueToQuotedString could be
132 // used here. For now, it's not worth adding the dependency.) 134 // used here. For now, it's not worth adding the dependency.)
133 std::string BuildJSCondition(std::string left, std::string right) { 135 std::string BuildJSCondition(std::string left, std::string right) {
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 281
280 // Ensures existent methods can be invoked successfully when the fallback method 282 // Ensures existent methods can be invoked successfully when the fallback method
281 // is used 283 // is used
282 TEST_F(CppBoundClassWithFallbackMethodTest, 284 TEST_F(CppBoundClassWithFallbackMethodTest,
283 InvokeExistentMethodsWithFallback) { 285 InvokeExistentMethodsWithFallback) {
284 std::string js = BuildJSCondition("example.echoValue(34)", "34"); 286 std::string js = BuildJSCondition("example.echoValue(34)", "34");
285 CheckJavaScriptSuccess(js); 287 CheckJavaScriptSuccess(js);
286 } 288 }
287 289
288 } // namespace 290 } // namespace
OLDNEW
« no previous file with comments | « webkit/glue/bookmarklet_unittest.cc ('k') | webkit/glue/mimetype_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698