| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 | 95 |
| 96 WebPluginContainer* getWebPluginContainer(WebView* webView, const WebString& id) | 96 WebPluginContainer* getWebPluginContainer(WebView* webView, const WebString& id) |
| 97 { | 97 { |
| 98 WebElement element = webView->mainFrame()->document().getElementById(id); | 98 WebElement element = webView->mainFrame()->document().getElementById(id); |
| 99 return element.pluginContainer(); | 99 return element.pluginContainer(); |
| 100 } | 100 } |
| 101 | 101 |
| 102 TEST_F(WebPluginContainerTest, WindowToLocalPointTest) | 102 TEST_F(WebPluginContainerTest, WindowToLocalPointTest) |
| 103 { | 103 { |
| 104 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("plugin_container.html")); | 104 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("plugin_container.html")); |
| 105 WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "plugi
n_container.html", true, new TestPluginWebFrameClient()); | 105 FrameTestHelpers::WebViewHelper webViewHelper; |
| 106 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_conta
iner.html", true, new TestPluginWebFrameClient()); |
| 106 ASSERT(webView); | 107 ASSERT(webView); |
| 107 webView->settings()->setPluginsEnabled(true); | 108 webView->settings()->setPluginsEnabled(true); |
| 108 webView->resize(WebSize(300, 300)); | 109 webView->resize(WebSize(300, 300)); |
| 109 webView->layout(); | 110 webView->layout(); |
| 110 FrameTestHelpers::runPendingTasks(); | 111 FrameTestHelpers::runPendingTasks(); |
| 111 | 112 |
| 112 WebPluginContainer* pluginContainerOne = getWebPluginContainer(webView, WebS
tring::fromUTF8("translated-plugin")); | 113 WebPluginContainer* pluginContainerOne = getWebPluginContainer(webView, WebS
tring::fromUTF8("translated-plugin")); |
| 113 ASSERT(pluginContainerOne); | 114 ASSERT(pluginContainerOne); |
| 114 WebPoint point1 = pluginContainerOne->windowToLocalPoint(WebPoint(10, 10)); | 115 WebPoint point1 = pluginContainerOne->windowToLocalPoint(WebPoint(10, 10)); |
| 115 ASSERT_EQ(0, point1.x); | 116 ASSERT_EQ(0, point1.x); |
| 116 ASSERT_EQ(0, point1.y); | 117 ASSERT_EQ(0, point1.y); |
| 117 WebPoint point2 = pluginContainerOne->windowToLocalPoint(WebPoint(100, 100))
; | 118 WebPoint point2 = pluginContainerOne->windowToLocalPoint(WebPoint(100, 100))
; |
| 118 ASSERT_EQ(90, point2.x); | 119 ASSERT_EQ(90, point2.x); |
| 119 ASSERT_EQ(90, point2.y); | 120 ASSERT_EQ(90, point2.y); |
| 120 | 121 |
| 121 WebPluginContainer* pluginContainerTwo = getWebPluginContainer(webView, WebS
tring::fromUTF8("rotated-plugin")); | 122 WebPluginContainer* pluginContainerTwo = getWebPluginContainer(webView, WebS
tring::fromUTF8("rotated-plugin")); |
| 122 ASSERT(pluginContainerTwo); | 123 ASSERT(pluginContainerTwo); |
| 123 WebPoint point3 = pluginContainerTwo->windowToLocalPoint(WebPoint(0, 10)); | 124 WebPoint point3 = pluginContainerTwo->windowToLocalPoint(WebPoint(0, 10)); |
| 124 ASSERT_EQ(10, point3.x); | 125 ASSERT_EQ(10, point3.x); |
| 125 ASSERT_EQ(0, point3.y); | 126 ASSERT_EQ(0, point3.y); |
| 126 WebPoint point4 = pluginContainerTwo->windowToLocalPoint(WebPoint(-10, 10)); | 127 WebPoint point4 = pluginContainerTwo->windowToLocalPoint(WebPoint(-10, 10)); |
| 127 ASSERT_EQ(10, point4.x); | 128 ASSERT_EQ(10, point4.x); |
| 128 ASSERT_EQ(10, point4.y); | 129 ASSERT_EQ(10, point4.y); |
| 129 | |
| 130 webView->close(); | |
| 131 } | 130 } |
| 132 | 131 |
| 133 TEST_F(WebPluginContainerTest, LocalToWindowPointTest) | 132 TEST_F(WebPluginContainerTest, LocalToWindowPointTest) |
| 134 { | 133 { |
| 135 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("plugin_container.html")); | 134 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("plugin_container.html")); |
| 136 WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "plugi
n_container.html", true, new TestPluginWebFrameClient()); | 135 FrameTestHelpers::WebViewHelper webViewHelper; |
| 136 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_conta
iner.html", true, new TestPluginWebFrameClient()); |
| 137 ASSERT(webView); | 137 ASSERT(webView); |
| 138 webView->settings()->setPluginsEnabled(true); | 138 webView->settings()->setPluginsEnabled(true); |
| 139 webView->resize(WebSize(300, 300)); | 139 webView->resize(WebSize(300, 300)); |
| 140 webView->layout(); | 140 webView->layout(); |
| 141 FrameTestHelpers::runPendingTasks(); | 141 FrameTestHelpers::runPendingTasks(); |
| 142 | 142 |
| 143 WebPluginContainer* pluginContainerOne = getWebPluginContainer(webView, WebS
tring::fromUTF8("translated-plugin")); | 143 WebPluginContainer* pluginContainerOne = getWebPluginContainer(webView, WebS
tring::fromUTF8("translated-plugin")); |
| 144 ASSERT(pluginContainerOne); | 144 ASSERT(pluginContainerOne); |
| 145 WebPoint point1 = pluginContainerOne->localToWindowPoint(WebPoint(0, 0)); | 145 WebPoint point1 = pluginContainerOne->localToWindowPoint(WebPoint(0, 0)); |
| 146 ASSERT_EQ(10, point1.x); | 146 ASSERT_EQ(10, point1.x); |
| 147 ASSERT_EQ(10, point1.y); | 147 ASSERT_EQ(10, point1.y); |
| 148 WebPoint point2 = pluginContainerOne->localToWindowPoint(WebPoint(90, 90)); | 148 WebPoint point2 = pluginContainerOne->localToWindowPoint(WebPoint(90, 90)); |
| 149 ASSERT_EQ(100, point2.x); | 149 ASSERT_EQ(100, point2.x); |
| 150 ASSERT_EQ(100, point2.y); | 150 ASSERT_EQ(100, point2.y); |
| 151 | 151 |
| 152 WebPluginContainer* pluginContainerTwo = getWebPluginContainer(webView, WebS
tring::fromUTF8("rotated-plugin")); | 152 WebPluginContainer* pluginContainerTwo = getWebPluginContainer(webView, WebS
tring::fromUTF8("rotated-plugin")); |
| 153 ASSERT(pluginContainerTwo); | 153 ASSERT(pluginContainerTwo); |
| 154 WebPoint point3 = pluginContainerTwo->localToWindowPoint(WebPoint(10, 0)); | 154 WebPoint point3 = pluginContainerTwo->localToWindowPoint(WebPoint(10, 0)); |
| 155 ASSERT_EQ(0, point3.x); | 155 ASSERT_EQ(0, point3.x); |
| 156 ASSERT_EQ(10, point3.y); | 156 ASSERT_EQ(10, point3.y); |
| 157 WebPoint point4 = pluginContainerTwo->localToWindowPoint(WebPoint(10, 10)); | 157 WebPoint point4 = pluginContainerTwo->localToWindowPoint(WebPoint(10, 10)); |
| 158 ASSERT_EQ(-10, point4.x); | 158 ASSERT_EQ(-10, point4.x); |
| 159 ASSERT_EQ(10, point4.y); | 159 ASSERT_EQ(10, point4.y); |
| 160 | |
| 161 webView->close(); | |
| 162 } | 160 } |
| 163 | 161 |
| 164 // Verifies executing the command 'Copy' results in copying to the clipboard. | 162 // Verifies executing the command 'Copy' results in copying to the clipboard. |
| 165 TEST_F(WebPluginContainerTest, Copy) | 163 TEST_F(WebPluginContainerTest, Copy) |
| 166 { | 164 { |
| 167 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("plugin_container.html")); | 165 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("plugin_container.html")); |
| 168 WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "plugi
n_container.html", true, new TestPluginWebFrameClient()); | 166 FrameTestHelpers::WebViewHelper webViewHelper; |
| 167 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_conta
iner.html", true, new TestPluginWebFrameClient()); |
| 169 ASSERT(webView); | 168 ASSERT(webView); |
| 170 webView->settings()->setPluginsEnabled(true); | 169 webView->settings()->setPluginsEnabled(true); |
| 171 webView->resize(WebSize(300, 300)); | 170 webView->resize(WebSize(300, 300)); |
| 172 webView->layout(); | 171 webView->layout(); |
| 173 FrameTestHelpers::runPendingTasks(); | 172 FrameTestHelpers::runPendingTasks(); |
| 174 | 173 |
| 175 WebElement pluginContainerOneElement = webView->mainFrame()->document().getE
lementById(WebString::fromUTF8("translated-plugin")); | 174 WebElement pluginContainerOneElement = webView->mainFrame()->document().getE
lementById(WebString::fromUTF8("translated-plugin")); |
| 176 EXPECT_TRUE(webView->mainFrame()->executeCommand("Copy", pluginContainerOne
Element)); | 175 EXPECT_TRUE(webView->mainFrame()->executeCommand("Copy", pluginContainerOne
Element)); |
| 177 EXPECT_EQ(WebString("x"), Platform::current()->clipboard()->readPlainText(We
bClipboard::Buffer())); | 176 EXPECT_EQ(WebString("x"), Platform::current()->clipboard()->readPlainText(We
bClipboard::Buffer())); |
| 178 | |
| 179 webView->close(); | |
| 180 } | 177 } |
| 181 | 178 |
| 182 } | 179 } |
| OLD | NEW |