Changeset 99661 in webkit
- Timestamp:
- Nov 9, 2011 12:06:11 AM (12 years ago)
- Location:
- trunk/Source/WebKit/chromium
- Files:
-
- 8 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/chromium/ChangeLog
r99659 r99661 1 2011-11-08 Jay Civelli <jcivelli@chromium.org> 2 3 Fixes and reenables the WebPageSerializer tests. 4 https://bugs.webkit.org/show_bug.cgi?id=71874 5 6 Reviewed by Adam Barth. 7 8 * WebKit.gypi: 9 * tests/WebPageNewSerializerTest.cpp: 10 (WebKit::TestWebFrameClient::~TestWebFrameClient): 11 (WebKit::WebPageNewSerializeTest::SetUp): 12 (WebKit::WebPageNewSerializeTest::resourceVectorContains): 13 (WebKit::TEST_F): 14 * tests/WebPageSerializerTest.cpp: 15 (WebKit::WebPageSerializerTest::WebPageSerializerTest): 16 (WebKit::WebPageSerializerTest::webVectorContains): 17 (WebKit::TEST_F): 18 1 19 2011-11-07 Adam Barth <abarth@webkit.org> 2 20 -
trunk/Source/WebKit/chromium/WebKit.gypi
r99020 r99661 89 89 'tests/WebFrameTest.cpp', 90 90 'tests/WebLayerTest.cpp', 91 'tests/WebPageNewSerializerTest.cpp', 92 'tests/WebPageSerializerTest.cpp', 91 93 'tests/WebURLRequestTest.cpp', 92 94 'tests/WebViewTest.cpp', -
trunk/Source/WebKit/chromium/tests/WebPageNewSerializerTest.cpp
r95901 r99661 52 52 class TestWebFrameClient : public WebFrameClient { 53 53 public: 54 TestWebFrameClient() : m_scriptEnabled(false) { } 55 virtual bool allowScript(WebFrame*, bool /* enabledPerSettings */) { return m_scriptEnabled; } 56 bool m_scriptEnabled; 54 virtual ~TestWebFrameClient() { } 57 55 }; 58 56 … … 73 71 m_webView = WebView::create(0); 74 72 75 // We want the images to load .73 // We want the images to load and JavaScript to be on. 76 74 WebSettings* settings = m_webView->settings(); 77 75 settings->setImagesEnabled(true); 78 76 settings->setLoadsImagesAutomatically(true); 77 settings->setJavaScriptEnabled(true); 79 78 80 79 m_webView->initializeMainFrame(&m_webFrameClient); … … 113 112 } 114 113 115 void enableJS()116 {117 m_webFrameClient.m_scriptEnabled = true;118 }119 120 void runOnLoad()121 {122 m_webView->mainFrame()->executeScript(WebScriptSource(WebString::fromUTF8("onLoad()")));123 }124 125 114 const WebString& htmlMimeType() const { return m_htmlMimeType; } 126 115 const WebString& xhtmlMimeType() const { return m_xhtmlMimeType; } 127 116 const WebString& cssMimeType() const { return m_cssMimeType; } 128 117 const WebString& pngMimeType() const { return m_pngMimeType; } 129 130 static bool resourceVectorContains(const WebVector<WebPageSerializer::Resource>& resources, c har* url,char* mimeType)118 119 static bool resourceVectorContains(const WebVector<WebPageSerializer::Resource>& resources, const char* url, const char* mimeType) 131 120 { 132 121 WebURL webURL = WebURL(GURL(url)); … … 138 127 return false; 139 128 } 140 129 141 130 WebView* m_webView; 142 131 … … 150 139 151 140 // Tests that a page with resources and sub-frame is reported with all its resources. 152 // FIXME: reenable these tests once the Chromium part of the test_webkit_client have landed. 153 TEST_F(WebPageNewSerializeTest, DISABLED_PageWithFrames) 141 TEST_F(WebPageNewSerializeTest, PageWithFrames) 154 142 { 155 143 // Register the mocked frames. … … 167 155 WebPageSerializer::serialize(m_webView, &resources); 168 156 ASSERT_FALSE(resources.isEmpty()); 169 157 170 158 // The first resource should be the main-frame. 171 159 const WebPageSerializer::Resource& resource = resources[0]; … … 174 162 EXPECT_FALSE(resource.data.isEmpty()); 175 163 176 EXPECT_EQ(6 , resources.size()); // There should be no duplicates.164 EXPECT_EQ(6U, resources.size()); // There should be no duplicates. 177 165 EXPECT_TRUE(resourceVectorContains(resources, "http://www.test.com/red_background.png", "image/png")); 178 166 EXPECT_TRUE(resourceVectorContains(resources, "http://www.test.com/green_background.png", "image/png")); … … 185 173 // and imports and links. Note that we don't test the resources contents, we only make sure 186 174 // they are all reported with the right mime type and that they contain some data. 187 TEST_F(WebPageNewSerializeTest, DISABLED_CSSResources)175 TEST_F(WebPageNewSerializeTest, CSSResources) 188 176 { 189 177 // Register the mocked frame and load it. … … 202 190 registerMockedURLLoad(GURL("http://www.test.com/ol-dot.png"), WebString::fromUTF8("ol-dot.png"), pngMimeType()); 203 191 204 enableJS(); 205 loadURLInTopFrame(topFrameURL); 206 runOnLoad(); 207 208 WebVector<WebPageSerializer::Resource> resources; 209 WebPageSerializer::serialize(m_webView, &resources); 210 ASSERT_FALSE(resources.isEmpty()); 211 192 loadURLInTopFrame(topFrameURL); 193 194 WebVector<WebPageSerializer::Resource> resources; 195 WebPageSerializer::serialize(m_webView, &resources); 196 ASSERT_FALSE(resources.isEmpty()); 197 212 198 // The first resource should be the main-frame. 213 199 const WebPageSerializer::Resource& resource = resources[0]; … … 216 202 EXPECT_FALSE(resource.data.isEmpty()); 217 203 218 EXPECT_EQ(12 , resources.size()); // There should be no duplicates.204 EXPECT_EQ(12U, resources.size()); // There should be no duplicates. 219 205 EXPECT_TRUE(resourceVectorContains(resources, "http://www.test.com/link_styles.css", "text/css")); 220 206 EXPECT_TRUE(resourceVectorContains(resources, "http://www.test.com/import_styles.css", "text/css")); … … 231 217 232 218 // Tests that when serializing a page with blank frames these are reported with their resources. 233 TEST_F(WebPageNewSerializeTest, DISABLED_BlankFrames)219 TEST_F(WebPageNewSerializeTest, BlankFrames) 234 220 { 235 221 // Register the mocked frame and load it. … … 240 226 registerMockedURLLoad(GURL("http://www.test.com/blue_background.png"), WebString::fromUTF8("blue_background.png"), pngMimeType()); 241 227 242 enableJS(); 243 loadURLInTopFrame(topFrameURL); 244 runOnLoad(); 245 246 WebVector<WebPageSerializer::Resource> resources; 247 WebPageSerializer::serialize(m_webView, &resources); 248 ASSERT_FALSE(resources.isEmpty()); 249 228 loadURLInTopFrame(topFrameURL); 229 230 WebVector<WebPageSerializer::Resource> resources; 231 WebPageSerializer::serialize(m_webView, &resources); 232 ASSERT_FALSE(resources.isEmpty()); 233 250 234 // The first resource should be the main-frame. 251 235 const WebPageSerializer::Resource& resource = resources[0]; … … 254 238 EXPECT_FALSE(resource.data.isEmpty()); 255 239 256 EXPECT_EQ(7 , resources.size()); // There should be no duplicates.240 EXPECT_EQ(7U, resources.size()); // There should be no duplicates. 257 241 EXPECT_TRUE(resourceVectorContains(resources, "http://www.test.com/red_background.png", "image/png")); 258 242 EXPECT_TRUE(resourceVectorContains(resources, "http://www.test.com/orange_background.png", "image/png")); … … 264 248 } 265 249 266 TEST_F(WebPageNewSerializeTest, DISABLED_SerializeXMLHasRightDeclaration)250 TEST_F(WebPageNewSerializeTest, SerializeXMLHasRightDeclaration) 267 251 { 268 252 WebURL topFrameURL = GURL("http://www.test.com/simple.xhtml"); … … 274 258 WebPageSerializer::serialize(m_webView, &resources); 275 259 ASSERT_FALSE(resources.isEmpty()); 276 260 277 261 // We expect only one resource, the XML. 278 ASSERT_EQ(1 , resources.size());262 ASSERT_EQ(1U, resources.size()); 279 263 std::string xml = resources[0].data; 280 264 -
trunk/Source/WebKit/chromium/tests/WebPageSerializerTest.cpp
r95901 r99661 53 53 class WebPageSerializerTest : public testing::Test { 54 54 public: 55 WebPageSerializerTest() : m_webView(0), m_supportedSchemes( 3U)55 WebPageSerializerTest() : m_webView(0), m_supportedSchemes(static_cast<size_t>(3)) 56 56 { 57 57 m_supportedSchemes[0] = "http"; … … 95 95 } 96 96 97 static bool webVectorContains(const WebVector<WebURL>& vector, c har* url)97 static bool webVectorContains(const WebVector<WebURL>& vector, const char* url) 98 98 { 99 99 return vector.contains(WebURL(GURL(url))); … … 125 125 WebVector<WebURL> resources; 126 126 ASSERT_TRUE(WebPageSerializer::retrieveAllResources( 127 m_webView, m_supportedSchemes, &resources, &frames)); 127 m_webView, m_supportedSchemes, &resources, &frames)); 128 128 129 129 // Tests that all resources from the frame have been retrieved. 130 EXPECT_EQ(1 , frames.size()); // There should be no duplicates.130 EXPECT_EQ(1U, frames.size()); // There should be no duplicates. 131 131 EXPECT_TRUE(webVectorContains(frames, "http://www.test.com")); 132 132 133 EXPECT_EQ(14 , resources.size()); // There should be no duplicates.133 EXPECT_EQ(14U, resources.size()); // There should be no duplicates. 134 134 EXPECT_TRUE(webVectorContains(resources, "http://www.example.com/beautifull.css")); 135 135 EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/awesome.js")); … … 171 171 WebVector<WebURL> resources; 172 172 ASSERT_TRUE(WebPageSerializer::retrieveAllResources( 173 m_webView, m_supportedSchemes, &resources, &frames)); 173 m_webView, m_supportedSchemes, &resources, &frames)); 174 174 175 175 // Tests that all resources from the frame have been retrieved. 176 EXPECT_EQ(4 , frames.size()); // There should be no duplicates.176 EXPECT_EQ(4U, frames.size()); // There should be no duplicates. 177 177 EXPECT_TRUE(webVectorContains(frames, "http://www.test.com")); 178 178 EXPECT_TRUE(webVectorContains(frames, "http://www.test.com/simple_iframe.html")); … … 180 180 EXPECT_TRUE(webVectorContains(frames, "http://www.test.com/embed_iframe.html")); 181 181 182 EXPECT_EQ(5 , resources.size()); // There should be no duplicates.182 EXPECT_EQ(5U, resources.size()); // There should be no duplicates. 183 183 EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/awesome.png")); 184 184 EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/innerFrame.png"));
Note: See TracChangeset
for help on using the changeset viewer.