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

Side by Side Diff: third_party/WebKit/Source/web/tests/FrameSerializerTest.cpp

Issue 2654933003: platform/testing/{URL|Unit}TestHelpers improvements (Closed)
Patch Set: header changes Created 3 years, 10 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) 2013, Opera Software ASA. All rights reserved. 2 * Copyright (c) 2013, Opera Software ASA. 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 12 matching lines...) Expand all
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
28 * OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "core/frame/FrameSerializer.h" 31 #include "core/frame/FrameSerializer.h"
32 32
33 #include <string>
33 #include "bindings/core/v8/V8Binding.h" 34 #include "bindings/core/v8/V8Binding.h"
34 #include "bindings/core/v8/V8BindingForTesting.h" 35 #include "bindings/core/v8/V8BindingForTesting.h"
35 #include "platform/SerializedResource.h" 36 #include "platform/SerializedResource.h"
36 #include "platform/testing/URLTestHelpers.h" 37 #include "platform/testing/URLTestHelpers.h"
38 #include "platform/testing/UnitTestHelpers.h"
37 #include "public/platform/Platform.h" 39 #include "public/platform/Platform.h"
38 #include "public/platform/WebString.h" 40 #include "public/platform/WebString.h"
39 #include "public/platform/WebThread.h" 41 #include "public/platform/WebThread.h"
40 #include "public/platform/WebURL.h" 42 #include "public/platform/WebURL.h"
41 #include "public/platform/WebURLLoaderMockFactory.h" 43 #include "public/platform/WebURLLoaderMockFactory.h"
42 #include "public/platform/WebURLRequest.h" 44 #include "public/platform/WebURLRequest.h"
43 #include "public/platform/WebURLResponse.h" 45 #include "public/platform/WebURLResponse.h"
44 #include "public/web/WebCache.h" 46 #include "public/web/WebCache.h"
45 #include "public/web/WebSettings.h" 47 #include "public/web/WebSettings.h"
46 #include "testing/gtest/include/gtest/gtest.h" 48 #include "testing/gtest/include/gtest/gtest.h"
47 #include "web/WebLocalFrameImpl.h" 49 #include "web/WebLocalFrameImpl.h"
48 #include "web/WebViewImpl.h" 50 #include "web/WebViewImpl.h"
49 #include "web/tests/FrameTestHelpers.h" 51 #include "web/tests/FrameTestHelpers.h"
50 #include "wtf/Assertions.h" 52 #include "wtf/Assertions.h"
51 #include "wtf/Deque.h" 53 #include "wtf/Deque.h"
52 #include "wtf/Vector.h" 54 #include "wtf/Vector.h"
53 55
54 using blink::URLTestHelpers::toKURL; 56 using blink::URLTestHelpers::toKURL;
55 using blink::URLTestHelpers::registerMockedURLLoad; 57 using blink::URLTestHelpers::registerMockedURLLoad;
56 58
57 namespace blink { 59 namespace blink {
58 60
59 class FrameSerializerTest : public testing::Test, 61 class FrameSerializerTest : public ::testing::Test,
60 public FrameSerializer::Delegate { 62 public FrameSerializer::Delegate {
61 public: 63 public:
62 FrameSerializerTest() 64 FrameSerializerTest()
63 : m_folder(WebString::fromUTF8("frameserializer/")), 65 : m_folder("frameserializer/"),
64 m_baseUrl(toKURL("http://www.test.com")) {} 66 m_baseUrl(toKURL("http://www.test.com")) {}
65 67
66 protected: 68 protected:
67 void SetUp() override { 69 void SetUp() override {
68 // We want the images to load and JavaScript to be on. 70 // We want the images to load and JavaScript to be on.
69 m_helper.initialize(true, nullptr, nullptr, nullptr, &configureSettings); 71 m_helper.initialize(true, nullptr, nullptr, nullptr, &configureSettings);
70 } 72 }
71 73
72 void TearDown() override { 74 void TearDown() override {
73 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs(); 75 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs();
74 WebCache::clear(); 76 WebCache::clear();
75 } 77 }
76 78
77 void setBaseFolder(const char* folder) { 79 void setBaseFolder(const char* folder) { m_folder = folder; }
78 m_folder = WebString::fromUTF8(folder);
79 }
80 80
81 void setRewriteURLFolder(const char* folder) { m_rewriteFolder = folder; } 81 void setRewriteURLFolder(const char* folder) { m_rewriteFolder = folder; }
82 82
83 void registerURL(const KURL& url, const char* file, const char* mimeType) { 83 void registerURL(const KURL& url, const char* file, const char* mimeType) {
84 registerMockedURLLoad(url, WebString::fromUTF8(file), m_folder, 84 registerMockedURLLoad(
85 WebString::fromUTF8(mimeType)); 85 url, testing::webTestDataPath(WebString::fromUTF8(m_folder + file)),
86 WebString::fromUTF8(mimeType));
86 } 87 }
87 88
88 void registerURL(const char* url, const char* file, const char* mimeType) { 89 void registerURL(const char* url, const char* file, const char* mimeType) {
89 registerURL(KURL(m_baseUrl, url), file, mimeType); 90 registerURL(KURL(m_baseUrl, url), file, mimeType);
90 } 91 }
91 92
92 void registerURL(const char* file, const char* mimeType) { 93 void registerURL(const char* file, const char* mimeType) {
93 registerURL(file, file, mimeType); 94 registerURL(file, file, mimeType);
94 } 95 }
95 96
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 uriBuilder.append(m_rewriteURLs.get(completeURL)); 182 uriBuilder.append(m_rewriteURLs.get(completeURL));
182 rewrittenLink = uriBuilder.toString(); 183 rewrittenLink = uriBuilder.toString();
183 return true; 184 return true;
184 } 185 }
185 186
186 bool shouldSkipResourceWithURL(const KURL& url) { 187 bool shouldSkipResourceWithURL(const KURL& url) {
187 return m_skipURLs.contains(url); 188 return m_skipURLs.contains(url);
188 } 189 }
189 190
190 FrameTestHelpers::WebViewHelper m_helper; 191 FrameTestHelpers::WebViewHelper m_helper;
191 WebString m_folder; 192 std::string m_folder;
192 KURL m_baseUrl; 193 KURL m_baseUrl;
193 Deque<SerializedResource> m_resources; 194 Deque<SerializedResource> m_resources;
194 HashMap<String, String> m_rewriteURLs; 195 HashMap<String, String> m_rewriteURLs;
195 Vector<String> m_skipURLs; 196 Vector<String> m_skipURLs;
196 String m_rewriteFolder; 197 String m_rewriteFolder;
197 }; 198 };
198 199
199 TEST_F(FrameSerializerTest, HTMLElements) { 200 TEST_F(FrameSerializerTest, HTMLElements) {
200 setBaseFolder("frameserializer/elements/"); 201 setBaseFolder("frameserializer/elements/");
201 202
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 KURL(ParsedURLString, "http://foo.com?--"))); 554 KURL(ParsedURLString, "http://foo.com?--")));
554 EXPECT_EQ("saved from url=(0020)http://foo.com/#-%2D", 555 EXPECT_EQ("saved from url=(0020)http://foo.com/#-%2D",
555 FrameSerializer::markOfTheWebDeclaration( 556 FrameSerializer::markOfTheWebDeclaration(
556 KURL(ParsedURLString, "http://foo.com#--"))); 557 KURL(ParsedURLString, "http://foo.com#--")));
557 EXPECT_EQ("saved from url=(0026)http://foo.com/#bar-%2Dbaz", 558 EXPECT_EQ("saved from url=(0026)http://foo.com/#bar-%2Dbaz",
558 FrameSerializer::markOfTheWebDeclaration( 559 FrameSerializer::markOfTheWebDeclaration(
559 KURL(ParsedURLString, "http://foo.com#bar--baz"))); 560 KURL(ParsedURLString, "http://foo.com#bar--baz")));
560 } 561 }
561 562
562 } // namespace blink 563 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/tests/DocumentLoaderTest.cpp ('k') | third_party/WebKit/Source/web/tests/ImeOnFocusTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698