| OLD | NEW | 
|---|
| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 72         :  m_willSendRequest(false) | 72         :  m_willSendRequest(false) | 
| 73         ,  m_didSendData(false) | 73         ,  m_didSendData(false) | 
| 74         ,  m_didReceiveResponse(false) | 74         ,  m_didReceiveResponse(false) | 
| 75         ,  m_didReceiveData(false) | 75         ,  m_didReceiveData(false) | 
| 76         ,  m_didReceiveCachedMetadata(false) | 76         ,  m_didReceiveCachedMetadata(false) | 
| 77         ,  m_didFinishLoading(false) | 77         ,  m_didFinishLoading(false) | 
| 78         ,  m_didFail(false) | 78         ,  m_didFail(false) | 
| 79         ,  m_runningMessageLoop(false) | 79         ,  m_runningMessageLoop(false) | 
| 80     { | 80     { | 
| 81         // Reuse one of the test files from WebFrameTest. | 81         // Reuse one of the test files from WebFrameTest. | 
| 82         std::string filePath = std::string(Platform::current()->unitTestSupport(
     )->webKitRootDir().utf8().data()); | 82         m_baseFilePath = Platform::current()->unitTestSupport()->webKitRootDir()
     ; | 
| 83         filePath += "/Source/WebKit/chromium/tests/data/iframes_test.html"; | 83         m_baseFilePath.append("/Source/WebKit/chromium/tests/data/"); | 
| 84         m_frameFilePath = WebString::fromUTF8(filePath.c_str()); | 84         m_frameFilePath = m_baseFilePath; | 
|  | 85         m_frameFilePath.append("iframes_test.html"); | 
|  | 86     } | 
|  | 87 | 
|  | 88     WebCore::KURL RegisterMockedUrl(const std::string& urlRoot, const WTF::Strin
     g& filename) | 
|  | 89     { | 
|  | 90         WebURLResponse response; | 
|  | 91         response.initialize(); | 
|  | 92         response.setMIMEType("text/html"); | 
|  | 93         WTF::String localPath = m_baseFilePath; | 
|  | 94         localPath.append(filename); | 
|  | 95         WebCore::KURL url = toKURL(urlRoot + filename.utf8().data()); | 
|  | 96         Platform::current()->unitTestSupport()->registerMockedURL(url, response,
      localPath); | 
|  | 97         return url; | 
| 85     } | 98     } | 
| 86 | 99 | 
| 87     void SetUp() | 100     void SetUp() | 
| 88     { | 101     { | 
| 89         m_webView = WebView::create(0); | 102         m_webView = WebView::create(0); | 
| 90         m_webView->initializeMainFrame(&m_webFrameClient); | 103         m_webView->initializeMainFrame(&m_webFrameClient); | 
| 91 | 104 | 
| 92         // Load the frame before trying to load resources. | 105         std::string urlRoot = "http://www.test.com/"; | 
| 93         WebCore::KURL url = toKURL("http://www.test.com/iframes_test.html"); | 106         WebCore::KURL url = RegisterMockedUrl(urlRoot, "iframes_test.html"); | 
| 94         WebURLResponse response; | 107         const char* iframeSupportFiles[] = { | 
| 95         response.initialize(); | 108             "invisible_iframe.html", | 
| 96         response.setMIMEType("text/html"); | 109             "visible_iframe.html", | 
| 97         Platform::current()->unitTestSupport()->registerMockedURL(url, response,
      m_frameFilePath); | 110             "zero_sized_iframe.html", | 
|  | 111         }; | 
|  | 112         for (size_t i = 0; i < arraysize(iframeSupportFiles); ++i) { | 
|  | 113             RegisterMockedUrl(urlRoot, iframeSupportFiles[i]); | 
|  | 114         } | 
| 98 | 115 | 
| 99         WebURLRequest request; | 116         WebURLRequest request; | 
| 100         request.initialize(); | 117         request.initialize(); | 
| 101         request.setURL(url); | 118         request.setURL(url); | 
| 102         m_webView->mainFrame()->loadRequest(request); | 119         m_webView->mainFrame()->loadRequest(request); | 
| 103         serveRequests(); | 120         serveRequests(); | 
| 104 | 121 | 
| 105         Platform::current()->unitTestSupport()->unregisterMockedURL(url); | 122         Platform::current()->unitTestSupport()->unregisterMockedURL(url); | 
| 106     } | 123     } | 
| 107 | 124 | 
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 255         m_expectedLoader->loadAsynchronously(request, this); | 272         m_expectedLoader->loadAsynchronously(request, this); | 
| 256         serveRequests(); | 273         serveRequests(); | 
| 257         EXPECT_TRUE(m_didReceiveResponse); | 274         EXPECT_TRUE(m_didReceiveResponse); | 
| 258         EXPECT_TRUE(m_didReceiveData); | 275         EXPECT_TRUE(m_didReceiveData); | 
| 259         EXPECT_TRUE(m_didFinishLoading); | 276         EXPECT_TRUE(m_didFinishLoading); | 
| 260 | 277 | 
| 261         return !m_actualResponse.httpHeaderField(headerNameString).isEmpty(); | 278         return !m_actualResponse.httpHeaderField(headerNameString).isEmpty(); | 
| 262     } | 279     } | 
| 263 | 280 | 
| 264 protected: | 281 protected: | 
| 265     WebString m_frameFilePath; | 282     WTF::String m_baseFilePath; | 
|  | 283     WTF::String m_frameFilePath; | 
| 266     TestWebFrameClient m_webFrameClient; | 284     TestWebFrameClient m_webFrameClient; | 
| 267     WebView* m_webView; | 285     WebView* m_webView; | 
| 268 | 286 | 
| 269     WebURLLoader* m_expectedLoader; | 287     WebURLLoader* m_expectedLoader; | 
| 270     WebURLResponse m_actualResponse; | 288     WebURLResponse m_actualResponse; | 
| 271     WebURLResponse m_expectedResponse; | 289     WebURLResponse m_expectedResponse; | 
| 272     WebURLRequest m_expectedNewRequest; | 290     WebURLRequest m_expectedNewRequest; | 
| 273     WebURLResponse m_expectedRedirectResponse; | 291     WebURLResponse m_expectedRedirectResponse; | 
| 274     bool m_willSendRequest; | 292     bool m_willSendRequest; | 
| 275     bool m_didSendData; | 293     bool m_didSendData; | 
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 613     m_expectedLoader->loadAsynchronously(request, this); | 631     m_expectedLoader->loadAsynchronously(request, this); | 
| 614     serveRequests(); | 632     serveRequests(); | 
| 615     EXPECT_TRUE(m_didReceiveResponse); | 633     EXPECT_TRUE(m_didReceiveResponse); | 
| 616     EXPECT_TRUE(m_didReceiveData); | 634     EXPECT_TRUE(m_didReceiveData); | 
| 617     EXPECT_TRUE(m_didFinishLoading); | 635     EXPECT_TRUE(m_didFinishLoading); | 
| 618 | 636 | 
| 619     EXPECT_FALSE(m_actualResponse.httpHeaderField(headerNameString).isEmpty()); | 637     EXPECT_FALSE(m_actualResponse.httpHeaderField(headerNameString).isEmpty()); | 
| 620 } | 638 } | 
| 621 | 639 | 
| 622 } | 640 } | 
| OLD | NEW | 
|---|