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

Side by Side Diff: Source/web/tests/PageSerializerTest.cpp

Issue 1174283002: Fix unit test style in Source/web/. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: remove static Created 5 years, 6 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 | Annotate | Revision Log
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 #include "public/platform/WebURLRequest.h" 43 #include "public/platform/WebURLRequest.h"
44 #include "public/platform/WebURLResponse.h" 44 #include "public/platform/WebURLResponse.h"
45 #include "public/platform/WebUnitTestSupport.h" 45 #include "public/platform/WebUnitTestSupport.h"
46 #include "public/web/WebSettings.h" 46 #include "public/web/WebSettings.h"
47 #include "web/WebLocalFrameImpl.h" 47 #include "web/WebLocalFrameImpl.h"
48 #include "web/WebViewImpl.h" 48 #include "web/WebViewImpl.h"
49 #include "web/tests/FrameTestHelpers.h" 49 #include "web/tests/FrameTestHelpers.h"
50 #include "wtf/Vector.h" 50 #include "wtf/Vector.h"
51 #include <gtest/gtest.h> 51 #include <gtest/gtest.h>
52 52
53 using namespace blink;
54 using blink::URLTestHelpers::toKURL; 53 using blink::URLTestHelpers::toKURL;
55 using blink::URLTestHelpers::registerMockedURLLoad; 54 using blink::URLTestHelpers::registerMockedURLLoad;
56 55
57 namespace { 56 namespace blink {
58 57
59 class PageSerializerTest : public testing::Test { 58 class PageSerializerTest : public testing::Test {
60 public: 59 public:
61 PageSerializerTest() 60 PageSerializerTest()
62 : m_folder(WebString::fromUTF8("pageserializer/")) 61 : m_folder(WebString::fromUTF8("pageserializer/"))
63 , m_baseUrl(toKURL("http://www.test.com")) 62 , m_baseUrl(toKURL("http://www.test.com"))
64 { 63 {
65 } 64 }
66 65
67 protected: 66 protected:
68 virtual void SetUp() 67 void SetUp() override
69 { 68 {
70 // We want the images to load and JavaScript to be on. 69 // We want the images to load and JavaScript to be on.
71 m_helper.initialize(true, 0, 0, &configureSettings); 70 m_helper.initialize(true, 0, 0, &configureSettings);
72 } 71 }
73 72
74 virtual void TearDown() 73 void TearDown() override
75 { 74 {
76 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); 75 Platform::current()->unitTestSupport()->unregisterAllMockedURLs();
77 } 76 }
78 77
79 void setBaseFolder(const char* folder) 78 void setBaseFolder(const char* folder)
80 { 79 {
81 m_folder = WebString::fromUTF8(folder); 80 m_folder = WebString::fromUTF8(folder);
82 } 81 }
83 82
84 void registerURL(const char* url, const char* file, const char* mimeType) 83 void registerURL(const char* url, const char* file, const char* mimeType)
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 const SerializedResource* getResource(const char* url, const char* mimeType) 120 const SerializedResource* getResource(const char* url, const char* mimeType)
122 { 121 {
123 KURL kURL = KURL(m_baseUrl, url); 122 KURL kURL = KURL(m_baseUrl, url);
124 String mime(mimeType); 123 String mime(mimeType);
125 for (size_t i = 0; i < m_resources.size(); ++i) { 124 for (size_t i = 0; i < m_resources.size(); ++i) {
126 const SerializedResource& resource = m_resources[i]; 125 const SerializedResource& resource = m_resources[i];
127 if (resource.url == kURL && !resource.data->isEmpty() 126 if (resource.url == kURL && !resource.data->isEmpty()
128 && (mime.isNull() || equalIgnoringCase(resource.mimeType, mime)) ) 127 && (mime.isNull() || equalIgnoringCase(resource.mimeType, mime)) )
129 return &resource; 128 return &resource;
130 } 129 }
131 return 0; 130 return nullptr;
132 } 131 }
133 132
134 bool isSerialized(const char* url, const char* mimeType = 0) 133 bool isSerialized(const char* url, const char* mimeType = 0)
135 { 134 {
136 return getResource(url, mimeType); 135 return getResource(url, mimeType);
137 } 136 }
138 137
139 String getSerializedData(const char* url, const char* mimeType = 0) 138 String getSerializedData(const char* url, const char* mimeType = 0)
140 { 139 {
141 const SerializedResource* resource = getResource(url, mimeType); 140 const SerializedResource* resource = getResource(url, mimeType);
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 399
401 registerURL("namespace_element.html", "text/html"); 400 registerURL("namespace_element.html", "text/html");
402 401
403 serialize("namespace_element.html"); 402 serialize("namespace_element.html");
404 403
405 EXPECT_EQ(1U, getResources().size()); 404 EXPECT_EQ(1U, getResources().size());
406 EXPECT_TRUE(isSerialized("namespace_element.html", "text/html")); 405 EXPECT_TRUE(isSerialized("namespace_element.html", "text/html"));
407 EXPECT_GT(getSerializedData("namespace_element.html", "text/html").length(), 0U); 406 EXPECT_GT(getSerializedData("namespace_element.html", "text/html").length(), 0U);
408 } 407 }
409 408
410 } 409 } // namespace blink
OLDNEW
« no previous file with comments | « Source/web/tests/OpenTypeVerticalDataTest.cpp ('k') | Source/web/tests/ProgrammaticScrollTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698