| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 #include "public/web/WebCache.h" | 52 #include "public/web/WebCache.h" |
| 53 #include "public/web/WebDocument.h" | 53 #include "public/web/WebDocument.h" |
| 54 #include "public/web/WebElement.h" | 54 #include "public/web/WebElement.h" |
| 55 #include "public/web/WebFrame.h" | 55 #include "public/web/WebFrame.h" |
| 56 #include "public/web/WebFrameClient.h" | 56 #include "public/web/WebFrameClient.h" |
| 57 #include "public/web/WebPluginParams.h" | 57 #include "public/web/WebPluginParams.h" |
| 58 #include "public/web/WebPrintParams.h" | 58 #include "public/web/WebPrintParams.h" |
| 59 #include "public/web/WebSettings.h" | 59 #include "public/web/WebSettings.h" |
| 60 #include "public/web/WebView.h" | 60 #include "public/web/WebView.h" |
| 61 #include "testing/gtest/include/gtest/gtest.h" | 61 #include "testing/gtest/include/gtest/gtest.h" |
| 62 #include "third_party/skia/include/core/SkPictureRecorder.h" | 62 #include "skia/ext/cdl_picture_recorder.h" |
| 63 #include "web/WebLocalFrameImpl.h" | 63 #include "web/WebLocalFrameImpl.h" |
| 64 #include "web/WebPluginContainerImpl.h" | 64 #include "web/WebPluginContainerImpl.h" |
| 65 #include "web/WebViewImpl.h" | 65 #include "web/WebViewImpl.h" |
| 66 #include "web/tests/FakeWebPlugin.h" | 66 #include "web/tests/FakeWebPlugin.h" |
| 67 #include "web/tests/FrameTestHelpers.h" | 67 #include "web/tests/FrameTestHelpers.h" |
| 68 #include <memory> | 68 #include <memory> |
| 69 | 69 |
| 70 using blink::testing::runPendingTasks; | 70 using blink::testing::runPendingTasks; |
| 71 | 71 |
| 72 namespace blink { | 72 namespace blink { |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 DCHECK(webView); | 250 DCHECK(webView); |
| 251 webView->updateAllLifecyclePhases(); | 251 webView->updateAllLifecyclePhases(); |
| 252 runPendingTasks(); | 252 runPendingTasks(); |
| 253 WebFrame* frame = webView->mainFrame(); | 253 WebFrame* frame = webView->mainFrame(); |
| 254 | 254 |
| 255 WebPrintParams printParams; | 255 WebPrintParams printParams; |
| 256 printParams.printContentArea.width = 500; | 256 printParams.printContentArea.width = 500; |
| 257 printParams.printContentArea.height = 500; | 257 printParams.printContentArea.height = 500; |
| 258 | 258 |
| 259 frame->printBegin(printParams); | 259 frame->printBegin(printParams); |
| 260 SkPictureRecorder recorder; | 260 CdlPictureRecorder recorder; |
| 261 frame->printPage(0, recorder.beginRecording(IntRect())); | 261 frame->printPage(0, recorder.beginRecording(IntRect())); |
| 262 frame->printEnd(); | 262 frame->printEnd(); |
| 263 DCHECK(pluginWebFrameClient.printedAtLeastOnePage()); | 263 DCHECK(pluginWebFrameClient.printedAtLeastOnePage()); |
| 264 } | 264 } |
| 265 | 265 |
| 266 TEST_F(WebPluginContainerTest, PrintAllPages) { | 266 TEST_F(WebPluginContainerTest, PrintAllPages) { |
| 267 URLTestHelpers::registerMockedURLFromBaseURL( | 267 URLTestHelpers::registerMockedURLFromBaseURL( |
| 268 WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("test.pdf"), | 268 WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("test.pdf"), |
| 269 WebString::fromUTF8("application/pdf")); | 269 WebString::fromUTF8("application/pdf")); |
| 270 | 270 |
| 271 TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper. | 271 TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper. |
| 272 FrameTestHelpers::WebViewHelper webViewHelper; | 272 FrameTestHelpers::WebViewHelper webViewHelper; |
| 273 WebView* webView = webViewHelper.initializeAndLoad( | 273 WebView* webView = webViewHelper.initializeAndLoad( |
| 274 m_baseURL + "test.pdf", true, &pluginWebFrameClient); | 274 m_baseURL + "test.pdf", true, &pluginWebFrameClient); |
| 275 DCHECK(webView); | 275 DCHECK(webView); |
| 276 webView->updateAllLifecyclePhases(); | 276 webView->updateAllLifecyclePhases(); |
| 277 runPendingTasks(); | 277 runPendingTasks(); |
| 278 WebFrame* frame = webView->mainFrame(); | 278 WebFrame* frame = webView->mainFrame(); |
| 279 | 279 |
| 280 WebPrintParams printParams; | 280 WebPrintParams printParams; |
| 281 printParams.printContentArea.width = 500; | 281 printParams.printContentArea.width = 500; |
| 282 printParams.printContentArea.height = 500; | 282 printParams.printContentArea.height = 500; |
| 283 | 283 |
| 284 frame->printBegin(printParams); | 284 frame->printBegin(printParams); |
| 285 SkPictureRecorder recorder; | 285 CdlPictureRecorder recorder; |
| 286 frame->printPagesWithBoundaries(recorder.beginRecording(IntRect()), | 286 frame->printPagesWithBoundaries(recorder.beginRecording(IntRect()), |
| 287 WebSize()); | 287 WebSize()); |
| 288 frame->printEnd(); | 288 frame->printEnd(); |
| 289 DCHECK(pluginWebFrameClient.printedAtLeastOnePage()); | 289 DCHECK(pluginWebFrameClient.printedAtLeastOnePage()); |
| 290 } | 290 } |
| 291 | 291 |
| 292 TEST_F(WebPluginContainerTest, LocalToWindowPointTest) { | 292 TEST_F(WebPluginContainerTest, LocalToWindowPointTest) { |
| 293 URLTestHelpers::registerMockedURLFromBaseURL( | 293 URLTestHelpers::registerMockedURLFromBaseURL( |
| 294 WebString::fromUTF8(m_baseURL.c_str()), | 294 WebString::fromUTF8(m_baseURL.c_str()), |
| 295 WebString::fromUTF8("plugin_container.html")); | 295 WebString::fromUTF8("plugin_container.html")); |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 773 WebString::fromUTF8("translated-plugin")); | 773 WebString::fromUTF8("translated-plugin")); |
| 774 pluginContainerOneElement.pluginContainer()->setWantsWheelEvents(true); | 774 pluginContainerOneElement.pluginContainer()->setWantsWheelEvents(true); |
| 775 | 775 |
| 776 runPendingTasks(); | 776 runPendingTasks(); |
| 777 EXPECT_TRUE( | 777 EXPECT_TRUE( |
| 778 webView->page()->frameHost().eventHandlerRegistry().hasEventHandlers( | 778 webView->page()->frameHost().eventHandlerRegistry().hasEventHandlers( |
| 779 EventHandlerRegistry::WheelEventBlocking)); | 779 EventHandlerRegistry::WheelEventBlocking)); |
| 780 } | 780 } |
| 781 | 781 |
| 782 } // namespace blink | 782 } // namespace blink |
| OLD | NEW |