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

Unified Diff: third_party/WebKit/Source/web/tests/WebPluginContainerTest.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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/web/tests/WebPluginContainerTest.cpp
diff --git a/third_party/WebKit/Source/web/tests/WebPluginContainerTest.cpp b/third_party/WebKit/Source/web/tests/WebPluginContainerTest.cpp
index 5143989e24e7f36a1beb7da96d037591e2413963..909e304ebf07c73ae8e56af96272dc29b6efdb00 100644
--- a/third_party/WebKit/Source/web/tests/WebPluginContainerTest.cpp
+++ b/third_party/WebKit/Source/web/tests/WebPluginContainerTest.cpp
@@ -30,6 +30,8 @@
#include "public/web/WebPluginContainer.h"
+#include <memory>
+#include <string>
#include "core/dom/Element.h"
#include "core/events/KeyboardEvent.h"
#include "core/frame/EventHandlerRegistry.h"
@@ -67,7 +69,6 @@
#include "web/WebViewImpl.h"
#include "web/tests/FakeWebPlugin.h"
#include "web/tests/FrameTestHelpers.h"
-#include <memory>
using blink::testing::runPendingTasks;
@@ -91,6 +92,14 @@ class WebPluginContainerTest : public ::testing::Test {
cutOutRects);
}
+ void registerMockedURL(
+ const std::string& fileName,
+ const std::string& mimeType = std::string("text/html")) {
+ URLTestHelpers::registerMockedURLLoadFromBase(
+ WebString::fromUTF8(m_baseURL), testing::webTestDataPath(),
+ WebString::fromUTF8(fileName), WebString::fromUTF8(mimeType));
+ }
+
protected:
std::string m_baseURL;
};
@@ -161,9 +170,7 @@ WebPluginContainer* getWebPluginContainer(WebView* webView,
} // namespace
TEST_F(WebPluginContainerTest, WindowToLocalPointTest) {
- URLTestHelpers::registerMockedURLFromBaseURL(
- WebString::fromUTF8(m_baseURL.c_str()),
- WebString::fromUTF8("plugin_container.html"));
+ registerMockedURL("plugin_container.html");
TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper.
FrameTestHelpers::WebViewHelper webViewHelper;
WebView* webView = webViewHelper.initializeAndLoad(
@@ -198,9 +205,7 @@ TEST_F(WebPluginContainerTest, WindowToLocalPointTest) {
}
TEST_F(WebPluginContainerTest, PluginDocumentPluginIsFocused) {
- URLTestHelpers::registerMockedURLFromBaseURL(
- WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("test.pdf"),
- WebString::fromUTF8("application/pdf"));
+ registerMockedURL("test.pdf", "application/pdf");
TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper.
FrameTestHelpers::WebViewHelper webViewHelper;
@@ -217,12 +222,8 @@ TEST_F(WebPluginContainerTest, PluginDocumentPluginIsFocused) {
}
TEST_F(WebPluginContainerTest, IFramePluginDocumentNotFocused) {
- URLTestHelpers::registerMockedURLFromBaseURL(
- WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("test.pdf"),
- WebString::fromUTF8("application/pdf"));
- URLTestHelpers::registerMockedURLFromBaseURL(
- WebString::fromUTF8(m_baseURL.c_str()),
- WebString::fromUTF8("iframe_pdf.html"), WebString::fromUTF8("text/html"));
+ registerMockedURL("test.pdf", "application/pdf");
+ registerMockedURL("iframe_pdf.html", "text/html");
TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper.
FrameTestHelpers::WebViewHelper webViewHelper;
@@ -241,9 +242,7 @@ TEST_F(WebPluginContainerTest, IFramePluginDocumentNotFocused) {
}
TEST_F(WebPluginContainerTest, PrintOnePage) {
- URLTestHelpers::registerMockedURLFromBaseURL(
- WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("test.pdf"),
- WebString::fromUTF8("application/pdf"));
+ registerMockedURL("test.pdf", "application/pdf");
TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper.
FrameTestHelpers::WebViewHelper webViewHelper;
@@ -266,9 +265,7 @@ TEST_F(WebPluginContainerTest, PrintOnePage) {
}
TEST_F(WebPluginContainerTest, PrintAllPages) {
- URLTestHelpers::registerMockedURLFromBaseURL(
- WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("test.pdf"),
- WebString::fromUTF8("application/pdf"));
+ registerMockedURL("test.pdf", "application/pdf");
TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper.
FrameTestHelpers::WebViewHelper webViewHelper;
@@ -292,9 +289,7 @@ TEST_F(WebPluginContainerTest, PrintAllPages) {
}
TEST_F(WebPluginContainerTest, LocalToWindowPointTest) {
- URLTestHelpers::registerMockedURLFromBaseURL(
- WebString::fromUTF8(m_baseURL.c_str()),
- WebString::fromUTF8("plugin_container.html"));
+ registerMockedURL("plugin_container.html");
TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper.
FrameTestHelpers::WebViewHelper webViewHelper;
WebView* webView = webViewHelper.initializeAndLoad(
@@ -328,9 +323,7 @@ TEST_F(WebPluginContainerTest, LocalToWindowPointTest) {
// Verifies executing the command 'Copy' results in copying to the clipboard.
TEST_F(WebPluginContainerTest, Copy) {
- URLTestHelpers::registerMockedURLFromBaseURL(
- WebString::fromUTF8(m_baseURL.c_str()),
- WebString::fromUTF8("plugin_container.html"));
+ registerMockedURL("plugin_container.html");
TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper.
FrameTestHelpers::WebViewHelper webViewHelper;
WebView* webView = webViewHelper.initializeAndLoad(
@@ -353,9 +346,7 @@ TEST_F(WebPluginContainerTest, Copy) {
}
TEST_F(WebPluginContainerTest, CopyFromContextMenu) {
- URLTestHelpers::registerMockedURLFromBaseURL(
- WebString::fromUTF8(m_baseURL.c_str()),
- WebString::fromUTF8("plugin_container.html"));
+ registerMockedURL("plugin_container.html");
TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper.
FrameTestHelpers::WebViewHelper webViewHelper;
WebView* webView = webViewHelper.initializeAndLoad(
@@ -397,9 +388,7 @@ TEST_F(WebPluginContainerTest, CopyFromContextMenu) {
// Verifies |Ctrl-C| and |Ctrl-Insert| keyboard events, results in copying to
// the clipboard.
TEST_F(WebPluginContainerTest, CopyInsertKeyboardEventsTest) {
- URLTestHelpers::registerMockedURLFromBaseURL(
- WebString::fromUTF8(m_baseURL.c_str()),
- WebString::fromUTF8("plugin_container.html"));
+ registerMockedURL("plugin_container.html");
TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper.
FrameTestHelpers::WebViewHelper webViewHelper;
WebView* webView = webViewHelper.initializeAndLoad(
@@ -476,9 +465,7 @@ class EventTestPlugin : public FakeWebPlugin {
};
TEST_F(WebPluginContainerTest, GestureLongPressReachesPlugin) {
- URLTestHelpers::registerMockedURLFromBaseURL(
- WebString::fromUTF8(m_baseURL.c_str()),
- WebString::fromUTF8("plugin_container.html"));
+ registerMockedURL("plugin_container.html");
CustomPluginWebFrameClient<EventTestPlugin>
pluginWebFrameClient; // Must outlive webViewHelper.
FrameTestHelpers::WebViewHelper webViewHelper;
@@ -527,9 +514,7 @@ TEST_F(WebPluginContainerTest, GestureLongPressReachesPlugin) {
}
TEST_F(WebPluginContainerTest, MouseWheelEventTranslated) {
- URLTestHelpers::registerMockedURLFromBaseURL(
- WebString::fromUTF8(m_baseURL.c_str()),
- WebString::fromUTF8("plugin_container.html"));
+ registerMockedURL("plugin_container.html");
CustomPluginWebFrameClient<EventTestPlugin>
pluginWebFrameClient; // Must outlive webViewHelper.
FrameTestHelpers::WebViewHelper webViewHelper;
@@ -567,9 +552,7 @@ TEST_F(WebPluginContainerTest, MouseWheelEventTranslated) {
// Verify that isRectTopmost returns false when the document is detached.
TEST_F(WebPluginContainerTest, IsRectTopmostTest) {
- URLTestHelpers::registerMockedURLFromBaseURL(
- WebString::fromUTF8(m_baseURL.c_str()),
- WebString::fromUTF8("plugin_container.html"));
+ registerMockedURL("plugin_container.html");
TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper.
FrameTestHelpers::WebViewHelper webViewHelper;
WebView* webView = webViewHelper.initializeAndLoad(
@@ -603,12 +586,8 @@ TEST_F(WebPluginContainerTest, IsRectTopmostTest) {
} while (false)
TEST_F(WebPluginContainerTest, ClippedRectsForIframedElement) {
- URLTestHelpers::registerMockedURLFromBaseURL(
- WebString::fromUTF8(m_baseURL.c_str()),
- WebString::fromUTF8("plugin_container.html"));
- URLTestHelpers::registerMockedURLFromBaseURL(
- WebString::fromUTF8(m_baseURL.c_str()),
- WebString::fromUTF8("plugin_containing_page.html"));
+ registerMockedURL("plugin_container.html");
+ registerMockedURL("plugin_containing_page.html");
TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper.
FrameTestHelpers::WebViewHelper webViewHelper;
@@ -641,9 +620,7 @@ TEST_F(WebPluginContainerTest, ClippedRectsForIframedElement) {
}
TEST_F(WebPluginContainerTest, ClippedRectsForSubpixelPositionedPlugin) {
- URLTestHelpers::registerMockedURLFromBaseURL(
- WebString::fromUTF8(m_baseURL.c_str()),
- WebString::fromUTF8("plugin_container.html"));
+ registerMockedURL("plugin_container.html");
TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper.
FrameTestHelpers::WebViewHelper webViewHelper;
@@ -693,9 +670,7 @@ TEST_F(WebPluginContainerTest, TopmostAfterDetachTest) {
}
};
- URLTestHelpers::registerMockedURLFromBaseURL(
- WebString::fromUTF8(m_baseURL.c_str()),
- WebString::fromUTF8("plugin_container.html"));
+ registerMockedURL("plugin_container.html");
CustomPluginWebFrameClient<TopmostPlugin>
pluginWebFrameClient; // Must outlive webViewHelper.
FrameTestHelpers::WebViewHelper webViewHelper;
@@ -755,9 +730,7 @@ class CompositedPlugin : public FakeWebPlugin {
TEST_F(WebPluginContainerTest, CompositedPluginSPv2) {
ScopedSlimmingPaintV2ForTest enableSPv2(true);
- URLTestHelpers::registerMockedURLFromBaseURL(
- WebString::fromUTF8(m_baseURL.c_str()),
- WebString::fromUTF8("plugin.html"));
+ registerMockedURL("plugin.html");
CustomPluginWebFrameClient<CompositedPlugin> webFrameClient;
FrameTestHelpers::WebViewHelper webViewHelper;
WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin.html",
@@ -797,9 +770,7 @@ TEST_F(WebPluginContainerTest, CompositedPluginSPv2) {
}
TEST_F(WebPluginContainerTest, NeedsWheelEvents) {
- URLTestHelpers::registerMockedURLFromBaseURL(
- WebString::fromUTF8(m_baseURL.c_str()),
- WebString::fromUTF8("plugin_container.html"));
+ registerMockedURL("plugin_container.html");
TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper
FrameTestHelpers::WebViewHelper webViewHelper;
WebViewImpl* webView = webViewHelper.initializeAndLoad(

Powered by Google App Engine
This is Rietveld 408576698