OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 12 matching lines...) Expand all Loading... |
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 #include "config.h" | 30 #include "config.h" |
31 | 31 |
32 #include "core/testing/URLTestHelpers.h" | 32 #include "core/testing/URLTestHelpers.h" |
| 33 #include "core/testing/UnitTestHelpers.h" |
33 #include "public/platform/Platform.h" | 34 #include "public/platform/Platform.h" |
34 #include "public/platform/WebString.h" | 35 #include "public/platform/WebString.h" |
35 #include "public/platform/WebThread.h" | 36 #include "public/platform/WebThread.h" |
36 #include "public/platform/WebURL.h" | 37 #include "public/platform/WebURL.h" |
37 #include "public/platform/WebURLRequest.h" | 38 #include "public/platform/WebURLRequest.h" |
38 #include "public/platform/WebURLResponse.h" | 39 #include "public/platform/WebURLResponse.h" |
39 #include "public/platform/WebUnitTestSupport.h" | 40 #include "public/platform/WebUnitTestSupport.h" |
40 #include "public/web/WebDocument.h" | 41 #include "public/web/WebDocument.h" |
41 #include "public/web/WebFrame.h" | 42 #include "public/web/WebFrame.h" |
42 #include "public/web/WebPageSerializer.h" | 43 #include "public/web/WebPageSerializer.h" |
43 #include "public/web/WebPageSerializerClient.h" | 44 #include "public/web/WebPageSerializerClient.h" |
44 #include "public/web/WebScriptSource.h" | 45 #include "public/web/WebScriptSource.h" |
45 #include "public/web/WebSettings.h" | 46 #include "public/web/WebSettings.h" |
46 #include "public/web/WebView.h" | 47 #include "public/web/WebView.h" |
47 #include "web/tests/FrameTestHelpers.h" | 48 #include "web/tests/FrameTestHelpers.h" |
48 #include <gtest/gtest.h> | 49 #include <gtest/gtest.h> |
49 | 50 |
50 namespace { | 51 namespace { |
51 | 52 |
52 using blink::FrameTestHelpers::runPendingTasks; | |
53 using blink::URLTestHelpers::toKURL; | 53 using blink::URLTestHelpers::toKURL; |
54 using blink::URLTestHelpers::registerMockedURLLoad; | 54 using blink::URLTestHelpers::registerMockedURLLoad; |
| 55 using blink::testing::runPendingTasks; |
55 using namespace blink; | 56 using namespace blink; |
56 | 57 |
57 class LineReader { | 58 class LineReader { |
58 public: | 59 public: |
59 LineReader(const std::string& text) : m_text(text), m_index(0) { } | 60 LineReader(const std::string& text) : m_text(text), m_index(0) { } |
60 bool getNextLine(std::string* line) | 61 bool getNextLine(std::string* line) |
61 { | 62 { |
62 line->clear(); | 63 line->clear(); |
63 if (m_index >= m_text.length()) | 64 if (m_index >= m_text.length()) |
64 return false; | 65 return false; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 if (frameURL != m_frameURL) | 108 if (frameURL != m_frameURL) |
108 return; | 109 return; |
109 *m_serializationData = data.utf16(); | 110 *m_serializationData = data.utf16(); |
110 } | 111 } |
111 | 112 |
112 private: | 113 private: |
113 WebURL m_frameURL; | 114 WebURL m_frameURL; |
114 WebString* m_serializationData; | 115 WebString* m_serializationData; |
115 }; | 116 }; |
116 | 117 |
117 class WebPageNewSerializeTest : public testing::Test { | 118 class WebPageNewSerializeTest : public ::testing::Test { |
118 public: | 119 public: |
119 WebPageNewSerializeTest() | 120 WebPageNewSerializeTest() |
120 : m_baseURL("http://internal.test/") | 121 : m_baseURL("http://internal.test/") |
121 , m_htmlMimeType(WebString::fromUTF8("text/html")) | 122 , m_htmlMimeType(WebString::fromUTF8("text/html")) |
122 , m_xhtmlMimeType(WebString::fromUTF8("application/xhtml+xml")) | 123 , m_xhtmlMimeType(WebString::fromUTF8("application/xhtml+xml")) |
123 , m_cssMimeType(WebString::fromUTF8("text/css")) | 124 , m_cssMimeType(WebString::fromUTF8("text/css")) |
124 , m_pngMimeType(WebString::fromUTF8("image/png")) | 125 , m_pngMimeType(WebString::fromUTF8("image/png")) |
125 , m_svgMimeType(WebString::fromUTF8("image/svg+xml")) | 126 , m_svgMimeType(WebString::fromUTF8("image/svg+xml")) |
126 { | 127 { |
127 } | 128 } |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 // exactly two times. | 496 // exactly two times. |
496 size_t nbDataURLs = 0; | 497 size_t nbDataURLs = 0; |
497 LineReader lineReader(std::string(mhtmlData.data())); | 498 LineReader lineReader(std::string(mhtmlData.data())); |
498 std::string line; | 499 std::string line; |
499 while (lineReader.getNextLine(&line)) { | 500 while (lineReader.getNextLine(&line)) { |
500 if (line.find("data:text") != std::string::npos) | 501 if (line.find("data:text") != std::string::npos) |
501 nbDataURLs++; | 502 nbDataURLs++; |
502 } | 503 } |
503 EXPECT_EQ(2u, nbDataURLs); | 504 EXPECT_EQ(2u, nbDataURLs); |
504 } | 505 } |
OLD | NEW |