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

Unified Diff: webkit/glue/webframe_unittest.cc

Issue 119043: Add functions to glue to get the full html of the page and also to check if t... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 7 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 side-by-side diff with in-line comments
Download patch
« webkit/glue/webframe_impl.cc ('K') | « webkit/glue/webframe_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/glue/webframe_unittest.cc
===================================================================
--- webkit/glue/webframe_unittest.cc (revision 17400)
+++ webkit/glue/webframe_unittest.cc (working copy)
@@ -52,3 +52,37 @@
frame->GetContentAsPlainText(12, &text);
EXPECT_EQ("Hello world", WideToUTF8(text));
}
+
+TEST_F(WebFrameTest, GetFullHtmlOfPage) {
+ WebView* view = test_shell_->webView();
+ WebFrame* frame = view->GetMainFrame();
+
+ // Generate a simple test case.
+ const char simple_source[] = "<p>Hello</p><p>World</p>";
+ GURL test_url("http://hello/");
+ frame->LoadHTMLString(simple_source, test_url);
+ test_shell_->WaitTestFinished();
+
+ std::wstring text;
+ frame->GetContentAsPlainText(std::numeric_limits<int>::max(), &text);
+ EXPECT_EQ("Hello\n\nWorld", WideToUTF8(text));
+
+ const std::string html = frame->GetFullPageHtml();
+
+ // Load again with the output html.
+ frame->LoadHTMLString(html, test_url);
+ test_shell_->WaitTestFinished();
+
+ EXPECT_EQ(html, frame->GetFullPageHtml());
+
+ text = L"";
+ frame->GetContentAsPlainText(std::numeric_limits<int>::max(), &text);
+ EXPECT_EQ("Hello\n\nWorld", WideToUTF8(text));
+
+ // Test selection check
+ EXPECT_FALSE(frame->HasSelection());
+ frame->SelectAll();
+ EXPECT_TRUE(frame->HasSelection());
+ frame->ClearSelection();
+ EXPECT_FALSE(frame->HasSelection());
+}
« webkit/glue/webframe_impl.cc ('K') | « webkit/glue/webframe_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698