| 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; | |
| 54 using blink::URLTestHelpers::toKURL; | 53 using blink::URLTestHelpers::toKURL; |
| 55 using blink::URLTestHelpers::registerMockedURLLoad; | 54 using blink::URLTestHelpers::registerMockedURLLoad; |
| 56 | 55 |
| 57 namespace { | 56 namespace { |
| 58 | 57 |
| 59 class PageSerializerTest : public testing::Test { | 58 class PageSerializerTest : public testing::Test { |
| 60 public: | 59 public: |
| 61 PageSerializerTest() | 60 PageSerializerTest() |
| 62 : m_folder(WebString::fromUTF8("pageserializer/")) | 61 : m_folder(WebString::fromUTF8("pageserializer/")) |
| 63 , m_baseUrl(toKURL("http://www.test.com")) | 62 , m_baseUrl(toKURL("http://www.test.com")) |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 WebURLResponse response; | 99 WebURLResponse response; |
| 101 response.initialize(); | 100 response.initialize(); |
| 102 response.setMIMEType("text/html"); | 101 response.setMIMEType("text/html"); |
| 103 response.setHTTPStatusCode(statusCode); | 102 response.setHTTPStatusCode(statusCode); |
| 104 | 103 |
| 105 Platform::current()->unitTestSupport()->registerMockedErrorURL(KURL(m_ba
seUrl, file), response, error); | 104 Platform::current()->unitTestSupport()->registerMockedErrorURL(KURL(m_ba
seUrl, file), response, error); |
| 106 } | 105 } |
| 107 | 106 |
| 108 void serialize(const char* url) | 107 void serialize(const char* url) |
| 109 { | 108 { |
| 110 WebURLRequest urlRequest; | 109 FrameTestHelpers::loadFrame(m_helper.webView()->mainFrame(), KURL(m_base
Url, url).string().utf8().data()); |
| 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 | |
| 121 PageSerializer serializer(&m_resources); | 110 PageSerializer serializer(&m_resources); |
| 122 serializer.serialize(m_helper.webViewImpl()->mainFrameImpl()->frame()->p
age()); | 111 serializer.serialize(m_helper.webViewImpl()->mainFrameImpl()->frame()->p
age()); |
| 123 } | 112 } |
| 124 | 113 |
| 125 Vector<SerializedResource>& getResources() | 114 Vector<SerializedResource>& getResources() |
| 126 { | 115 { |
| 127 return m_resources; | 116 return m_resources; |
| 128 } | 117 } |
| 129 | 118 |
| 130 | 119 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 | 200 |
| 212 registerURL("font.html", "text/html"); | 201 registerURL("font.html", "text/html"); |
| 213 registerURL("font.ttf", "application/octet-stream"); | 202 registerURL("font.ttf", "application/octet-stream"); |
| 214 | 203 |
| 215 serialize("font.html"); | 204 serialize("font.html"); |
| 216 | 205 |
| 217 EXPECT_TRUE(isSerialized("font.ttf", "application/octet-stream")); | 206 EXPECT_TRUE(isSerialized("font.ttf", "application/octet-stream")); |
| 218 } | 207 } |
| 219 | 208 |
| 220 } | 209 } |
| OLD | NEW |