OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013, Opera Software ASA. All rights reserved. | 2 * Copyright (c) 2013, Opera Software ASA. 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 #include "public/web/WebSettings.h" | 43 #include "public/web/WebSettings.h" |
44 #include "web/WebLocalFrameImpl.h" | 44 #include "web/WebLocalFrameImpl.h" |
45 #include "web/WebViewImpl.h" | 45 #include "web/WebViewImpl.h" |
46 #include "web/tests/FrameTestHelpers.h" | 46 #include "web/tests/FrameTestHelpers.h" |
47 #include "web/tests/URLTestHelpers.h" | 47 #include "web/tests/URLTestHelpers.h" |
48 #include "wtf/Vector.h" | 48 #include "wtf/Vector.h" |
49 #include <gtest/gtest.h> | 49 #include <gtest/gtest.h> |
50 | 50 |
51 using namespace WebCore; | 51 using namespace WebCore; |
52 using namespace blink; | 52 using namespace blink; |
| 53 using blink::FrameTestHelpers::runPendingTasks; |
53 using blink::URLTestHelpers::toKURL; | 54 using blink::URLTestHelpers::toKURL; |
54 using blink::URLTestHelpers::registerMockedURLLoad; | 55 using blink::URLTestHelpers::registerMockedURLLoad; |
55 | 56 |
56 namespace { | 57 namespace { |
57 | 58 |
58 class PageSerializerTest : public testing::Test { | 59 class PageSerializerTest : public testing::Test { |
59 public: | 60 public: |
60 PageSerializerTest() | 61 PageSerializerTest() |
61 : m_folder(WebString::fromUTF8("pageserializer/")) | 62 : m_folder(WebString::fromUTF8("pageserializer/")) |
62 , m_baseUrl(toKURL("http://www.test.com")) | 63 , m_baseUrl(toKURL("http://www.test.com")) |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 WebURLResponse response; | 100 WebURLResponse response; |
100 response.initialize(); | 101 response.initialize(); |
101 response.setMIMEType("text/html"); | 102 response.setMIMEType("text/html"); |
102 response.setHTTPStatusCode(statusCode); | 103 response.setHTTPStatusCode(statusCode); |
103 | 104 |
104 Platform::current()->unitTestSupport()->registerMockedErrorURL(KURL(m_ba
seUrl, file), response, error); | 105 Platform::current()->unitTestSupport()->registerMockedErrorURL(KURL(m_ba
seUrl, file), response, error); |
105 } | 106 } |
106 | 107 |
107 void serialize(const char* url) | 108 void serialize(const char* url) |
108 { | 109 { |
109 FrameTestHelpers::loadFrame(m_helper.webView()->mainFrame(), KURL(m_base
Url, url).string().utf8().data()); | 110 WebURLRequest urlRequest; |
| 111 urlRequest.initialize(); |
| 112 urlRequest.setURL(KURL(m_baseUrl, url)); |
| 113 m_helper.webView()->mainFrame()->loadRequest(urlRequest); |
| 114 // Make sure any pending request get served. |
| 115 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(
); |
| 116 // Some requests get delayed, run the timer. |
| 117 runPendingTasks(); |
| 118 // Server the delayed resources. |
| 119 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(
); |
| 120 |
110 PageSerializer serializer(&m_resources); | 121 PageSerializer serializer(&m_resources); |
111 serializer.serialize(m_helper.webViewImpl()->mainFrameImpl()->frame()->p
age()); | 122 serializer.serialize(m_helper.webViewImpl()->mainFrameImpl()->frame()->p
age()); |
112 } | 123 } |
113 | 124 |
114 Vector<SerializedResource>& getResources() | 125 Vector<SerializedResource>& getResources() |
115 { | 126 { |
116 return m_resources; | 127 return m_resources; |
117 } | 128 } |
118 | 129 |
119 | 130 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 | 211 |
201 registerURL("font.html", "text/html"); | 212 registerURL("font.html", "text/html"); |
202 registerURL("font.ttf", "application/octet-stream"); | 213 registerURL("font.ttf", "application/octet-stream"); |
203 | 214 |
204 serialize("font.html"); | 215 serialize("font.html"); |
205 | 216 |
206 EXPECT_TRUE(isSerialized("font.ttf", "application/octet-stream")); | 217 EXPECT_TRUE(isSerialized("font.ttf", "application/octet-stream")); |
207 } | 218 } |
208 | 219 |
209 } | 220 } |
OLD | NEW |