| 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 WTF::String localPath = m_baseFilePath; | 84 WTF::String localPath = m_baseFilePath; |
| 85 localPath.append(filename); | 85 localPath.append(filename); |
| 86 WebCore::KURL url = toKURL(urlRoot + filename.utf8().data()); | 86 WebCore::KURL url = toKURL(urlRoot + filename.utf8().data()); |
| 87 Platform::current()->unitTestSupport()->registerMockedURL(url, response,
localPath); | 87 Platform::current()->unitTestSupport()->registerMockedURL(url, response,
localPath); |
| 88 return url; | 88 return url; |
| 89 } | 89 } |
| 90 | 90 |
| 91 void SetUp() | 91 void SetUp() |
| 92 { | 92 { |
| 93 m_webView = WebView::create(0); | 93 m_webView = WebView::create(0); |
| 94 m_webView->initializeMainFrame(&m_webFrameClient); | 94 m_mainFrame = WebFrame::create(&m_webFrameClient); |
| 95 m_webView->initializeMainFrame(m_mainFrame); |
| 95 | 96 |
| 96 std::string urlRoot = "http://www.test.com/"; | 97 std::string urlRoot = "http://www.test.com/"; |
| 97 WebCore::KURL url = RegisterMockedUrl(urlRoot, "iframes_test.html"); | 98 WebCore::KURL url = RegisterMockedUrl(urlRoot, "iframes_test.html"); |
| 98 const char* iframeSupportFiles[] = { | 99 const char* iframeSupportFiles[] = { |
| 99 "invisible_iframe.html", | 100 "invisible_iframe.html", |
| 100 "visible_iframe.html", | 101 "visible_iframe.html", |
| 101 "zero_sized_iframe.html", | 102 "zero_sized_iframe.html", |
| 102 }; | 103 }; |
| 103 for (size_t i = 0; i < arraysize(iframeSupportFiles); ++i) { | 104 for (size_t i = 0; i < arraysize(iframeSupportFiles); ++i) { |
| 104 RegisterMockedUrl(urlRoot, iframeSupportFiles[i]); | 105 RegisterMockedUrl(urlRoot, iframeSupportFiles[i]); |
| 105 } | 106 } |
| 106 | 107 |
| 107 WebURLRequest request; | 108 WebURLRequest request; |
| 108 request.initialize(); | 109 request.initialize(); |
| 109 request.setURL(url); | 110 request.setURL(url); |
| 110 m_webView->mainFrame()->loadRequest(request); | 111 m_webView->mainFrame()->loadRequest(request); |
| 111 serveRequests(); | 112 serveRequests(); |
| 112 | 113 |
| 113 Platform::current()->unitTestSupport()->unregisterMockedURL(url); | 114 Platform::current()->unitTestSupport()->unregisterMockedURL(url); |
| 114 } | 115 } |
| 115 | 116 |
| 116 void TearDown() | 117 void TearDown() |
| 117 { | 118 { |
| 118 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); | 119 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); |
| 119 m_webView->close(); | 120 m_webView->close(); |
| 121 m_mainFrame->close(); |
| 120 } | 122 } |
| 121 | 123 |
| 122 void serveRequests() | 124 void serveRequests() |
| 123 { | 125 { |
| 124 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(
); | 126 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(
); |
| 125 } | 127 } |
| 126 | 128 |
| 127 WebURLLoader* createAssociatedURLLoader(const WebURLLoaderOptions options =
WebURLLoaderOptions()) | 129 WebURLLoader* createAssociatedURLLoader(const WebURLLoaderOptions options =
WebURLLoaderOptions()) |
| 128 { | 130 { |
| 129 return m_webView->mainFrame()->createAssociatedURLLoader(options); | 131 return m_webView->mainFrame()->createAssociatedURLLoader(options); |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 EXPECT_TRUE(m_didFinishLoading); | 269 EXPECT_TRUE(m_didFinishLoading); |
| 268 | 270 |
| 269 return !m_actualResponse.httpHeaderField(headerNameString).isEmpty(); | 271 return !m_actualResponse.httpHeaderField(headerNameString).isEmpty(); |
| 270 } | 272 } |
| 271 | 273 |
| 272 protected: | 274 protected: |
| 273 WTF::String m_baseFilePath; | 275 WTF::String m_baseFilePath; |
| 274 WTF::String m_frameFilePath; | 276 WTF::String m_frameFilePath; |
| 275 TestWebFrameClient m_webFrameClient; | 277 TestWebFrameClient m_webFrameClient; |
| 276 WebView* m_webView; | 278 WebView* m_webView; |
| 279 WebFrame* m_mainFrame; |
| 277 | 280 |
| 278 WebURLLoader* m_expectedLoader; | 281 WebURLLoader* m_expectedLoader; |
| 279 WebURLResponse m_actualResponse; | 282 WebURLResponse m_actualResponse; |
| 280 WebURLResponse m_expectedResponse; | 283 WebURLResponse m_expectedResponse; |
| 281 WebURLRequest m_expectedNewRequest; | 284 WebURLRequest m_expectedNewRequest; |
| 282 WebURLResponse m_expectedRedirectResponse; | 285 WebURLResponse m_expectedRedirectResponse; |
| 283 bool m_willSendRequest; | 286 bool m_willSendRequest; |
| 284 bool m_didSendData; | 287 bool m_didSendData; |
| 285 bool m_didReceiveResponse; | 288 bool m_didReceiveResponse; |
| 286 bool m_didDownloadData; | 289 bool m_didDownloadData; |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 m_expectedLoader->loadAsynchronously(request, this); | 625 m_expectedLoader->loadAsynchronously(request, this); |
| 623 serveRequests(); | 626 serveRequests(); |
| 624 EXPECT_TRUE(m_didReceiveResponse); | 627 EXPECT_TRUE(m_didReceiveResponse); |
| 625 EXPECT_TRUE(m_didReceiveData); | 628 EXPECT_TRUE(m_didReceiveData); |
| 626 EXPECT_TRUE(m_didFinishLoading); | 629 EXPECT_TRUE(m_didFinishLoading); |
| 627 | 630 |
| 628 EXPECT_FALSE(m_actualResponse.httpHeaderField(headerNameString).isEmpty()); | 631 EXPECT_FALSE(m_actualResponse.httpHeaderField(headerNameString).isEmpty()); |
| 629 } | 632 } |
| 630 | 633 |
| 631 } | 634 } |
| OLD | NEW |