Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Side by Side Diff: Source/web/tests/WebPageNewSerializerTest.cpp

Issue 23506013: Make the embedder responsible for creating the WebFrame (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix lifetime on frame detach Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 , m_pngMimeType(WebString::fromUTF8("image/png")) 108 , m_pngMimeType(WebString::fromUTF8("image/png"))
109 , m_svgMimeType(WebString::fromUTF8("image/svg+xml")) 109 , m_svgMimeType(WebString::fromUTF8("image/svg+xml"))
110 { 110 {
111 } 111 }
112 112
113 protected: 113 protected:
114 virtual void SetUp() 114 virtual void SetUp()
115 { 115 {
116 // Create and initialize the WebView. 116 // Create and initialize the WebView.
117 m_webView = WebView::create(0); 117 m_webView = WebView::create(0);
118 m_mainFrame = WebFrame::create(&m_webFrameClient);
118 119
119 // We want the images to load and JavaScript to be on. 120 // We want the images to load and JavaScript to be on.
120 WebSettings* settings = m_webView->settings(); 121 WebSettings* settings = m_webView->settings();
121 settings->setImagesEnabled(true); 122 settings->setImagesEnabled(true);
122 settings->setLoadsImagesAutomatically(true); 123 settings->setLoadsImagesAutomatically(true);
123 settings->setJavaScriptEnabled(true); 124 settings->setJavaScriptEnabled(true);
124 125
125 m_webView->initializeMainFrame(&m_webFrameClient); 126 m_webView->setMainFrame(m_mainFrame);
126 } 127 }
127 128
128 virtual void TearDown() 129 virtual void TearDown()
129 { 130 {
130 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); 131 Platform::current()->unitTestSupport()->unregisterAllMockedURLs();
131 m_webView->close(); 132 m_webView->close();
133 m_mainFrame->close();
132 } 134 }
133 135
134 WebURL setUpCSSTestPage() 136 WebURL setUpCSSTestPage()
135 { 137 {
136 WebURL topFrameURL = toKURL("http://www.test.com"); 138 WebURL topFrameURL = toKURL("http://www.test.com");
137 registerMockedURLLoad(topFrameURL, WebString::fromUTF8("css_test_page.ht ml"), WebString::fromUTF8("pageserializer/"), htmlMimeType()); 139 registerMockedURLLoad(topFrameURL, WebString::fromUTF8("css_test_page.ht ml"), WebString::fromUTF8("pageserializer/"), htmlMimeType());
138 registerMockedURLLoad(toKURL("http://www.test.com/link_styles.css"), Web String::fromUTF8("link_styles.css"), WebString::fromUTF8("pageserializer/"), css MimeType()); 140 registerMockedURLLoad(toKURL("http://www.test.com/link_styles.css"), Web String::fromUTF8("link_styles.css"), WebString::fromUTF8("pageserializer/"), css MimeType());
139 registerMockedURLLoad(toKURL("http://www.test.com/import_style_from_link .css"), WebString::fromUTF8("import_style_from_link.css"), WebString::fromUTF8(" pageserializer/"), cssMimeType()); 141 registerMockedURLLoad(toKURL("http://www.test.com/import_style_from_link .css"), WebString::fromUTF8("import_style_from_link.css"), WebString::fromUTF8(" pageserializer/"), cssMimeType());
140 registerMockedURLLoad(toKURL("http://www.test.com/import_styles.css"), W ebString::fromUTF8("import_styles.css"), WebString::fromUTF8("pageserializer/"), cssMimeType()); 142 registerMockedURLLoad(toKURL("http://www.test.com/import_styles.css"), W ebString::fromUTF8("import_styles.css"), WebString::fromUTF8("pageserializer/"), cssMimeType());
141 registerMockedURLLoad(toKURL("http://www.test.com/red_background.png"), WebString::fromUTF8("red_background.png"), WebString::fromUTF8("pageserializer/" ), pngMimeType()); 143 registerMockedURLLoad(toKURL("http://www.test.com/red_background.png"), WebString::fromUTF8("red_background.png"), WebString::fromUTF8("pageserializer/" ), pngMimeType());
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 184
183 WebView* m_webView; 185 WebView* m_webView;
184 186
185 private: 187 private:
186 WebString m_htmlMimeType; 188 WebString m_htmlMimeType;
187 WebString m_xhtmlMimeType; 189 WebString m_xhtmlMimeType;
188 WebString m_cssMimeType; 190 WebString m_cssMimeType;
189 WebString m_pngMimeType; 191 WebString m_pngMimeType;
190 WebString m_svgMimeType; 192 WebString m_svgMimeType;
191 TestWebFrameClient m_webFrameClient; 193 TestWebFrameClient m_webFrameClient;
194 WebFrame* m_mainFrame;
192 }; 195 };
193 196
194 // Tests that a page with resources and sub-frame is reported with all its resou rces. 197 // Tests that a page with resources and sub-frame is reported with all its resou rces.
195 TEST_F(WebPageNewSerializeTest, PageWithFrames) 198 TEST_F(WebPageNewSerializeTest, PageWithFrames)
196 { 199 {
197 // Register the mocked frames. 200 // Register the mocked frames.
198 WebURL topFrameURL = toKURL("http://www.test.com"); 201 WebURL topFrameURL = toKURL("http://www.test.com");
199 registerMockedURLLoad(topFrameURL, WebString::fromUTF8("top_frame.html"), We bString::fromUTF8("pageserializer/"), htmlMimeType()); 202 registerMockedURLLoad(topFrameURL, WebString::fromUTF8("top_frame.html"), We bString::fromUTF8("pageserializer/"), htmlMimeType());
200 registerMockedURLLoad(toKURL("http://www.test.com/iframe.html"), WebString:: fromUTF8("iframe.html"), WebString::fromUTF8("pageserializer/"), htmlMimeType()) ; 203 registerMockedURLLoad(toKURL("http://www.test.com/iframe.html"), WebString:: fromUTF8("iframe.html"), WebString::fromUTF8("pageserializer/"), htmlMimeType()) ;
201 registerMockedURLLoad(toKURL("http://www.test.com/iframe2.html"), WebString: :fromUTF8("iframe2.html"), WebString::fromUTF8("pageserializer/"), htmlMimeType( )); 204 registerMockedURLLoad(toKURL("http://www.test.com/iframe2.html"), WebString: :fromUTF8("iframe2.html"), WebString::fromUTF8("pageserializer/"), htmlMimeType( ));
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 // exactly two times. 431 // exactly two times.
429 size_t nbDataURLs = 0; 432 size_t nbDataURLs = 0;
430 LineReader lineReader(std::string(mhtmlData.data())); 433 LineReader lineReader(std::string(mhtmlData.data()));
431 std::string line; 434 std::string line;
432 while (lineReader.getNextLine(&line)) { 435 while (lineReader.getNextLine(&line)) {
433 if (line.find("data:text") != std::string::npos) 436 if (line.find("data:text") != std::string::npos)
434 nbDataURLs++; 437 nbDataURLs++;
435 } 438 }
436 EXPECT_EQ(2u, nbDataURLs); 439 EXPECT_EQ(2u, nbDataURLs);
437 } 440 }
OLDNEW
« no previous file with comments | « Source/web/tests/WebInputEventConversionTest.cpp ('k') | Source/web/tests/WebPageSerializerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698