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 #include "base/string_util.h" | 5 #include "base/string_util.h" |
6 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
7 #include "webkit/glue/webframe.h" | 7 #include "webkit/glue/webframe.h" |
8 #include "webkit/glue/webview.h" | 8 #include "webkit/glue/webview.h" |
9 #include "webkit/tools/test_shell/test_shell_test.h" | 9 #include "webkit/tools/test_shell/test_shell_test.h" |
10 | 10 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 test_shell_->WaitTestFinished(); | 45 test_shell_->WaitTestFinished(); |
46 | 46 |
47 frame->GetContentAsPlainText(std::numeric_limits<int>::max(), &text); | 47 frame->GetContentAsPlainText(std::numeric_limits<int>::max(), &text); |
48 EXPECT_EQ("Hello world\n\nsub\ntext", WideToUTF8(text)); | 48 EXPECT_EQ("Hello world\n\nsub\ntext", WideToUTF8(text)); |
49 | 49 |
50 // Get the frame text where the subframe separator falls on the boundary of | 50 // Get the frame text where the subframe separator falls on the boundary of |
51 // what we'll take. There used to be a crash in this case. | 51 // what we'll take. There used to be a crash in this case. |
52 frame->GetContentAsPlainText(12, &text); | 52 frame->GetContentAsPlainText(12, &text); |
53 EXPECT_EQ("Hello world", WideToUTF8(text)); | 53 EXPECT_EQ("Hello world", WideToUTF8(text)); |
54 } | 54 } |
| 55 |
| 56 TEST_F(WebFrameTest, GetFullHtmlOfPage) { |
| 57 WebView* view = test_shell_->webView(); |
| 58 WebFrame* frame = view->GetMainFrame(); |
| 59 |
| 60 // Generate a simple test case. |
| 61 const char simple_source[] = "<p>Hello</p><p>World</p>"; |
| 62 GURL test_url("http://hello/"); |
| 63 frame->LoadHTMLString(simple_source, test_url); |
| 64 test_shell_->WaitTestFinished(); |
| 65 |
| 66 std::wstring text; |
| 67 frame->GetContentAsPlainText(std::numeric_limits<int>::max(), &text); |
| 68 EXPECT_EQ("Hello\n\nWorld", WideToUTF8(text)); |
| 69 |
| 70 const std::string html = frame->GetFullPageHtml(); |
| 71 |
| 72 // Load again with the output html. |
| 73 frame->LoadHTMLString(html, test_url); |
| 74 test_shell_->WaitTestFinished(); |
| 75 |
| 76 EXPECT_EQ(html, frame->GetFullPageHtml()); |
| 77 |
| 78 text = L""; |
| 79 frame->GetContentAsPlainText(std::numeric_limits<int>::max(), &text); |
| 80 EXPECT_EQ("Hello\n\nWorld", WideToUTF8(text)); |
| 81 |
| 82 // Test selection check |
| 83 EXPECT_FALSE(frame->HasSelection()); |
| 84 frame->SelectAll(); |
| 85 EXPECT_TRUE(frame->HasSelection()); |
| 86 frame->ClearSelection(); |
| 87 EXPECT_FALSE(frame->HasSelection()); |
| 88 } |
OLD | NEW |