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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 public: | 61 public: |
62 WebAssociatedURLLoaderTest() | 62 WebAssociatedURLLoaderTest() |
63 : m_willFollowRedirect(false), | 63 : m_willFollowRedirect(false), |
64 m_didSendData(false), | 64 m_didSendData(false), |
65 m_didReceiveResponse(false), | 65 m_didReceiveResponse(false), |
66 m_didReceiveData(false), | 66 m_didReceiveData(false), |
67 m_didReceiveCachedMetadata(false), | 67 m_didReceiveCachedMetadata(false), |
68 m_didFinishLoading(false), | 68 m_didFinishLoading(false), |
69 m_didFail(false) { | 69 m_didFail(false) { |
70 // Reuse one of the test files from WebFrameTest. | 70 // Reuse one of the test files from WebFrameTest. |
71 m_baseFilePath = testing::blinkRootDir(); | 71 m_frameFilePath = testing::webTestDataPath("iframes_test.html"); |
72 m_baseFilePath.append("/Source/web/tests/data/"); | |
73 m_frameFilePath = m_baseFilePath; | |
74 m_frameFilePath.append("iframes_test.html"); | |
75 } | 72 } |
76 | 73 |
77 KURL RegisterMockedUrl(const std::string& urlRoot, | 74 KURL RegisterMockedUrl(const std::string& urlRoot, |
78 const WTF::String& filename) { | 75 const WTF::String& filename) { |
79 WebURLResponse response; | 76 WebURLResponse response; |
80 response.setMIMEType("text/html"); | 77 response.setMIMEType("text/html"); |
81 WTF::String localPath = m_baseFilePath; | |
82 localPath.append(filename); | |
83 KURL url = toKURL(urlRoot + filename.utf8().data()); | 78 KURL url = toKURL(urlRoot + filename.utf8().data()); |
84 Platform::current()->getURLLoaderMockFactory()->registerURL(url, response, | 79 Platform::current()->getURLLoaderMockFactory()->registerURL( |
85 localPath); | 80 url, response, testing::webTestDataPath(filename.utf8().data())); |
86 return url; | 81 return url; |
87 } | 82 } |
88 | 83 |
89 void SetUp() override { | 84 void SetUp() override { |
90 m_helper.initialize(); | 85 m_helper.initialize(); |
91 | 86 |
92 std::string urlRoot = "http://www.test.com/"; | 87 std::string urlRoot = "http://www.test.com/"; |
93 KURL url = RegisterMockedUrl(urlRoot, "iframes_test.html"); | 88 KURL url = RegisterMockedUrl(urlRoot, "iframes_test.html"); |
94 const char* iframeSupportFiles[] = { | 89 const char* iframeSupportFiles[] = { |
95 "invisible_iframe.html", "visible_iframe.html", | 90 "invisible_iframe.html", "visible_iframe.html", |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 EXPECT_TRUE(m_didReceiveResponse); | 234 EXPECT_TRUE(m_didReceiveResponse); |
240 EXPECT_TRUE(m_didReceiveData); | 235 EXPECT_TRUE(m_didReceiveData); |
241 EXPECT_TRUE(m_didFinishLoading); | 236 EXPECT_TRUE(m_didFinishLoading); |
242 | 237 |
243 return !m_actualResponse.httpHeaderField(headerNameString).isEmpty(); | 238 return !m_actualResponse.httpHeaderField(headerNameString).isEmpty(); |
244 } | 239 } |
245 | 240 |
246 WebFrame* mainFrame() const { return m_helper.webView()->mainFrame(); } | 241 WebFrame* mainFrame() const { return m_helper.webView()->mainFrame(); } |
247 | 242 |
248 protected: | 243 protected: |
249 String m_baseFilePath; | |
250 String m_frameFilePath; | 244 String m_frameFilePath; |
251 FrameTestHelpers::WebViewHelper m_helper; | 245 FrameTestHelpers::WebViewHelper m_helper; |
252 | 246 |
253 std::unique_ptr<WebAssociatedURLLoader> m_expectedLoader; | 247 std::unique_ptr<WebAssociatedURLLoader> m_expectedLoader; |
254 WebURLResponse m_actualResponse; | 248 WebURLResponse m_actualResponse; |
255 WebURLResponse m_expectedResponse; | 249 WebURLResponse m_expectedResponse; |
256 WebURLRequest m_expectedNewRequest; | 250 WebURLRequest m_expectedNewRequest; |
257 WebURLResponse m_expectedRedirectResponse; | 251 WebURLResponse m_expectedRedirectResponse; |
258 bool m_willFollowRedirect; | 252 bool m_willFollowRedirect; |
259 bool m_didSendData; | 253 bool m_didSendData; |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 m_expectedLoader->loadAsynchronously(request, this); | 671 m_expectedLoader->loadAsynchronously(request, this); |
678 serveRequests(); | 672 serveRequests(); |
679 EXPECT_TRUE(m_didReceiveResponse); | 673 EXPECT_TRUE(m_didReceiveResponse); |
680 EXPECT_TRUE(m_didReceiveData); | 674 EXPECT_TRUE(m_didReceiveData); |
681 EXPECT_TRUE(m_didFinishLoading); | 675 EXPECT_TRUE(m_didFinishLoading); |
682 | 676 |
683 EXPECT_FALSE(m_actualResponse.httpHeaderField(headerNameString).isEmpty()); | 677 EXPECT_FALSE(m_actualResponse.httpHeaderField(headerNameString).isEmpty()); |
684 } | 678 } |
685 | 679 |
686 } // namespace blink | 680 } // namespace blink |
OLD | NEW |