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

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

Issue 164225: Switch to WebFrame from the WebKit API.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 4 months 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/dom_serializer.cc ('k') | webkit/glue/editor_client_impl.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 #include "config.h" 5 #include "config.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 8
9 MSVC_PUSH_WARNING_LEVEL(0); 9 MSVC_PUSH_WARNING_LEVEL(0);
10 #include "Document.h" 10 #include "Document.h"
(...skipping 18 matching lines...) Expand all
29 #include "base/string_util.h" 29 #include "base/string_util.h"
30 #include "net/base/net_util.h" 30 #include "net/base/net_util.h"
31 #include "net/url_request/url_request_context.h" 31 #include "net/url_request/url_request_context.h"
32 #include "webkit/api/public/WebData.h" 32 #include "webkit/api/public/WebData.h"
33 #include "webkit/api/public/WebURL.h" 33 #include "webkit/api/public/WebURL.h"
34 #include "webkit/glue/dom_operations.h" 34 #include "webkit/glue/dom_operations.h"
35 #include "webkit/glue/dom_operations_private.h" 35 #include "webkit/glue/dom_operations_private.h"
36 #include "webkit/glue/dom_serializer.h" 36 #include "webkit/glue/dom_serializer.h"
37 #include "webkit/glue/dom_serializer_delegate.h" 37 #include "webkit/glue/dom_serializer_delegate.h"
38 #include "webkit/glue/glue_util.h" 38 #include "webkit/glue/glue_util.h"
39 #include "webkit/glue/webframe.h"
40 #include "webkit/glue/webframe_impl.h" 39 #include "webkit/glue/webframe_impl.h"
41 #include "webkit/glue/webview.h" 40 #include "webkit/glue/webview.h"
42 #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" 41 #include "webkit/tools/test_shell/simple_resource_loader_bridge.h"
43 #include "webkit/tools/test_shell/test_shell_test.h" 42 #include "webkit/tools/test_shell/test_shell_test.h"
44 43
45 namespace { 44 namespace {
46 45
47 class DomSerializerTests : public TestShellTest, 46 class DomSerializerTests : public TestShellTest,
48 public webkit_glue::DomSerializerDelegate { 47 public webkit_glue::DomSerializerDelegate {
49 public: 48 public:
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 } 101 }
103 102
104 // Load web page according to input content and relative URLs within 103 // Load web page according to input content and relative URLs within
105 // the document. 104 // the document.
106 void LoadContents(const std::string& contents, 105 void LoadContents(const std::string& contents,
107 const GURL& base_url, 106 const GURL& base_url,
108 const WebCore::String encoding_info) { 107 const WebCore::String encoding_info) {
109 test_shell_->ResetTestController(); 108 test_shell_->ResetTestController();
110 // If input encoding is empty, use UTF-8 as default encoding. 109 // If input encoding is empty, use UTF-8 as default encoding.
111 if (encoding_info.isEmpty()) { 110 if (encoding_info.isEmpty()) {
112 test_shell_->webView()->GetMainFrame()->LoadHTMLString(contents, 111 test_shell_->webView()->GetMainFrame()->loadHTMLString(contents,
113 base_url); 112 base_url);
114 } else { 113 } else {
115 // Do not use WebFrame.LoadHTMLString because it assumes that input 114 // Do not use WebFrame.LoadHTMLString because it assumes that input
116 // html contents use UTF-8 encoding. 115 // html contents use UTF-8 encoding.
116 // TODO(darin): This should use WebFrame::loadData.
117 WebFrameImpl* web_frame = 117 WebFrameImpl* web_frame =
118 static_cast<WebFrameImpl*>(test_shell_->webView()->GetMainFrame()); 118 static_cast<WebFrameImpl*>(test_shell_->webView()->GetMainFrame());
119 ASSERT_TRUE(web_frame != NULL); 119 ASSERT_TRUE(web_frame != NULL);
120 int len = static_cast<int>(contents.size()); 120 int len = static_cast<int>(contents.size());
121 RefPtr<WebCore::SharedBuffer> buf( 121 RefPtr<WebCore::SharedBuffer> buf(
122 WebCore::SharedBuffer::create(contents.data(), len)); 122 WebCore::SharedBuffer::create(contents.data(), len));
123 123
124 WebCore::SubstituteData subst_data( 124 WebCore::SubstituteData subst_data(
125 buf, WebCore::String("text/html"), encoding_info, WebCore::KURL()); 125 buf, WebCore::String("text/html"), encoding_info, WebCore::KURL());
126 WebCore::ResourceRequest request(webkit_glue::GURLToKURL(base_url), 126 WebCore::ResourceRequest request(webkit_glue::GURLToKURL(base_url),
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 // "hello world" 812 // "hello world"
813 WebCore::HTMLElement* body_ele = doc->body(); 813 WebCore::HTMLElement* body_ele = doc->body();
814 ASSERT_TRUE(body_ele != NULL); 814 ASSERT_TRUE(body_ele != NULL);
815 WebCore::Node* text_node = body_ele->firstChild(); 815 WebCore::Node* text_node = body_ele->firstChild();
816 ASSERT_TRUE(text_node->isTextNode()); 816 ASSERT_TRUE(text_node->isTextNode());
817 const WebCore::String& text_node_contents = text_node->nodeValue(); 817 const WebCore::String& text_node_contents = text_node->nodeValue();
818 ASSERT_TRUE(text_node_contents == WebCore::String("hello world")); 818 ASSERT_TRUE(text_node_contents == WebCore::String("hello world"));
819 } 819 }
820 820
821 } // namespace 821 } // namespace
OLDNEW
« no previous file with comments | « webkit/glue/dom_serializer.cc ('k') | webkit/glue/editor_client_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698