Changeset 99661 in webkit


Ignore:
Timestamp:
Nov 9, 2011 12:06:11 AM (12 years ago)
Author:
jcivelli@chromium.org
Message:

Fixes and reenables the WebPageSerializer tests.
https://bugs.webkit.org/show_bug.cgi?id=71874

Reviewed by Adam Barth.

  • WebKit.gypi:
  • tests/WebPageNewSerializerTest.cpp:

(WebKit::TestWebFrameClient::~TestWebFrameClient):
(WebKit::WebPageNewSerializeTest::SetUp):
(WebKit::WebPageNewSerializeTest::resourceVectorContains):
(WebKit::TEST_F):

  • tests/WebPageSerializerTest.cpp:

(WebKit::WebPageSerializerTest::WebPageSerializerTest):
(WebKit::WebPageSerializerTest::webVectorContains):
(WebKit::TEST_F):

Location:
trunk/Source/WebKit/chromium
Files:
8 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/chromium/ChangeLog

    r99659 r99661  
     12011-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
    1192011-11-07  Adam Barth  <abarth@webkit.org>
    220
  • trunk/Source/WebKit/chromium/WebKit.gypi

    r99020 r99661  
    8989            'tests/WebFrameTest.cpp',
    9090            'tests/WebLayerTest.cpp',
     91            'tests/WebPageNewSerializerTest.cpp',
     92            'tests/WebPageSerializerTest.cpp',
    9193            'tests/WebURLRequestTest.cpp',
    9294            'tests/WebViewTest.cpp',
  • trunk/Source/WebKit/chromium/tests/WebPageNewSerializerTest.cpp

    r95901 r99661  
    5252class TestWebFrameClient : public WebFrameClient {
    5353public:
    54     TestWebFrameClient() : m_scriptEnabled(false) { }
    55     virtual bool allowScript(WebFrame*, bool /* enabledPerSettings */) { return m_scriptEnabled; }
    56     bool m_scriptEnabled;
     54    virtual ~TestWebFrameClient() { }
    5755};
    5856
     
    7371        m_webView = WebView::create(0);
    7472
    75         // We want the images to load.
     73        // We want the images to load and JavaScript to be on.
    7674        WebSettings* settings = m_webView->settings();
    7775        settings->setImagesEnabled(true);
    7876        settings->setLoadsImagesAutomatically(true);
     77        settings->setJavaScriptEnabled(true);
    7978
    8079        m_webView->initializeMainFrame(&m_webFrameClient);
     
    113112    }
    114113
    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 
    125114    const WebString& htmlMimeType() const { return m_htmlMimeType; }
    126115    const WebString& xhtmlMimeType() const { return m_xhtmlMimeType; }
    127116    const WebString& cssMimeType() const { return m_cssMimeType; }
    128117    const WebString& pngMimeType() const { return m_pngMimeType; }
    129    
    130     static bool resourceVectorContains(const WebVector<WebPageSerializer::Resource>& resources, char* url, char* mimeType)
     118
     119    static bool resourceVectorContains(const WebVector<WebPageSerializer::Resource>& resources, const char* url, const char* mimeType)
    131120    {
    132121        WebURL webURL = WebURL(GURL(url));
     
    138127        return false;
    139128    }
    140    
     129
    141130    WebView* m_webView;
    142131
     
    150139
    151140// 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)
     141TEST_F(WebPageNewSerializeTest, PageWithFrames)
    154142{
    155143    // Register the mocked frames.
     
    167155    WebPageSerializer::serialize(m_webView, &resources);
    168156    ASSERT_FALSE(resources.isEmpty());
    169    
     157
    170158    // The first resource should be the main-frame.
    171159    const WebPageSerializer::Resource& resource = resources[0];
     
    174162    EXPECT_FALSE(resource.data.isEmpty());
    175163
    176     EXPECT_EQ(6, resources.size()); // There should be no duplicates.
     164    EXPECT_EQ(6U, resources.size()); // There should be no duplicates.
    177165    EXPECT_TRUE(resourceVectorContains(resources, "http://www.test.com/red_background.png", "image/png"));
    178166    EXPECT_TRUE(resourceVectorContains(resources, "http://www.test.com/green_background.png", "image/png"));
     
    185173// and imports and links. Note that we don't test the resources contents, we only make sure
    186174// they are all reported with the right mime type and that they contain some data.
    187 TEST_F(WebPageNewSerializeTest, DISABLED_CSSResources)
     175TEST_F(WebPageNewSerializeTest, CSSResources)
    188176{
    189177    // Register the mocked frame and load it.
     
    202190    registerMockedURLLoad(GURL("http://www.test.com/ol-dot.png"), WebString::fromUTF8("ol-dot.png"), pngMimeType());
    203191
    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
    212198    // The first resource should be the main-frame.
    213199    const WebPageSerializer::Resource& resource = resources[0];
     
    216202    EXPECT_FALSE(resource.data.isEmpty());
    217203
    218     EXPECT_EQ(12, resources.size()); // There should be no duplicates.
     204    EXPECT_EQ(12U, resources.size()); // There should be no duplicates.
    219205    EXPECT_TRUE(resourceVectorContains(resources, "http://www.test.com/link_styles.css", "text/css"));
    220206    EXPECT_TRUE(resourceVectorContains(resources, "http://www.test.com/import_styles.css", "text/css"));
     
    231217
    232218// Tests that when serializing a page with blank frames these are reported with their resources.
    233 TEST_F(WebPageNewSerializeTest, DISABLED_BlankFrames)
     219TEST_F(WebPageNewSerializeTest, BlankFrames)
    234220{
    235221    // Register the mocked frame and load it.
     
    240226    registerMockedURLLoad(GURL("http://www.test.com/blue_background.png"), WebString::fromUTF8("blue_background.png"), pngMimeType());
    241227
    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
    250234    // The first resource should be the main-frame.
    251235    const WebPageSerializer::Resource& resource = resources[0];
     
    254238    EXPECT_FALSE(resource.data.isEmpty());
    255239
    256     EXPECT_EQ(7, resources.size()); // There should be no duplicates.
     240    EXPECT_EQ(7U, resources.size()); // There should be no duplicates.
    257241    EXPECT_TRUE(resourceVectorContains(resources, "http://www.test.com/red_background.png", "image/png"));
    258242    EXPECT_TRUE(resourceVectorContains(resources, "http://www.test.com/orange_background.png", "image/png"));
     
    264248}
    265249
    266 TEST_F(WebPageNewSerializeTest, DISABLED_SerializeXMLHasRightDeclaration)
     250TEST_F(WebPageNewSerializeTest, SerializeXMLHasRightDeclaration)
    267251{
    268252    WebURL topFrameURL = GURL("http://www.test.com/simple.xhtml");
     
    274258    WebPageSerializer::serialize(m_webView, &resources);
    275259    ASSERT_FALSE(resources.isEmpty());
    276    
     260
    277261    // We expect only one resource, the XML.
    278     ASSERT_EQ(1, resources.size());
     262    ASSERT_EQ(1U, resources.size());
    279263    std::string xml = resources[0].data;
    280264
  • trunk/Source/WebKit/chromium/tests/WebPageSerializerTest.cpp

    r95901 r99661  
    5353class WebPageSerializerTest : public testing::Test {
    5454public:
    55     WebPageSerializerTest() : m_webView(0), m_supportedSchemes(3U)
     55    WebPageSerializerTest() : m_webView(0), m_supportedSchemes(static_cast<size_t>(3))
    5656    {
    5757        m_supportedSchemes[0] = "http";
     
    9595    }
    9696
    97     static bool webVectorContains(const WebVector<WebURL>& vector, char* url)
     97    static bool webVectorContains(const WebVector<WebURL>& vector, const char* url)
    9898    {
    9999        return vector.contains(WebURL(GURL(url)));
     
    125125    WebVector<WebURL> resources;
    126126    ASSERT_TRUE(WebPageSerializer::retrieveAllResources(
    127         m_webView, m_supportedSchemes, &resources, &frames));   
     127        m_webView, m_supportedSchemes, &resources, &frames));
    128128
    129129    // 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.
    131131    EXPECT_TRUE(webVectorContains(frames, "http://www.test.com"));
    132132
    133     EXPECT_EQ(14, resources.size()); // There should be no duplicates.
     133    EXPECT_EQ(14U, resources.size()); // There should be no duplicates.
    134134    EXPECT_TRUE(webVectorContains(resources, "http://www.example.com/beautifull.css"));
    135135    EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/awesome.js"));
     
    171171    WebVector<WebURL> resources;
    172172    ASSERT_TRUE(WebPageSerializer::retrieveAllResources(
    173         m_webView, m_supportedSchemes, &resources, &frames));   
     173        m_webView, m_supportedSchemes, &resources, &frames));
    174174
    175175    // 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.
    177177    EXPECT_TRUE(webVectorContains(frames, "http://www.test.com"));
    178178    EXPECT_TRUE(webVectorContains(frames, "http://www.test.com/simple_iframe.html"));
     
    180180    EXPECT_TRUE(webVectorContains(frames, "http://www.test.com/embed_iframe.html"));
    181181
    182     EXPECT_EQ(5, resources.size()); // There should be no duplicates.
     182    EXPECT_EQ(5U, resources.size()); // There should be no duplicates.
    183183    EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/awesome.png"));
    184184    EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/innerFrame.png"));
Note: See TracChangeset for help on using the changeset viewer.