| 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 : FakeWebPlugin(frame, params) | 86 : FakeWebPlugin(frame, params) |
| 87 { | 87 { |
| 88 m_testClient = testClient; | 88 m_testClient = testClient; |
| 89 } | 89 } |
| 90 | 90 |
| 91 bool hasSelection() const override { return true; } | 91 bool hasSelection() const override { return true; } |
| 92 WebString selectionAsText() const override { return WebString("x"); } | 92 WebString selectionAsText() const override { return WebString("x"); } |
| 93 WebString selectionAsMarkup() const override { return WebString("y"); } | 93 WebString selectionAsMarkup() const override { return WebString("y"); } |
| 94 bool supportsPaginatedPrint() override { return true; } | 94 bool supportsPaginatedPrint() override { return true; } |
| 95 int printBegin(const WebPrintParams& printParams) override { return 1; } | 95 int printBegin(const WebPrintParams& printParams) override { return 1; } |
| 96 bool printPage(int pageNumber, WebCanvas*) override; | 96 void printPage(int pageNumber, WebCanvas*, bool unused) override; |
| 97 | |
| 98 private: | 97 private: |
| 99 TestPluginWebFrameClient* m_testClient; | 98 TestPluginWebFrameClient* m_testClient; |
| 100 }; | 99 }; |
| 101 | 100 |
| 102 class TestPluginWebFrameClient : public FrameTestHelpers::TestWebFrameClient { | 101 class TestPluginWebFrameClient : public FrameTestHelpers::TestWebFrameClient { |
| 103 WebPlugin* createPlugin(WebLocalFrame* frame, const WebPluginParams& params)
override | 102 WebPlugin* createPlugin(WebLocalFrame* frame, const WebPluginParams& params)
override |
| 104 { | 103 { |
| 105 if (params.mimeType == WebString::fromUTF8("application/x-webkit-test-we
bplugin")) | 104 if (params.mimeType == WebString::fromUTF8("application/x-webkit-test-we
bplugin")) |
| 106 return new TestPlugin(frame, params, this); | 105 return new TestPlugin(frame, params, this); |
| 107 if (params.mimeType == WebString::fromUTF8("application/pdf")) | 106 if (params.mimeType == WebString::fromUTF8("application/pdf")) |
| 108 return new TestPlugin(frame, params, this); | 107 return new TestPlugin(frame, params, this); |
| 109 return WebFrameClient::createPlugin(frame, params); | 108 return WebFrameClient::createPlugin(frame, params); |
| 110 } | 109 } |
| 111 | 110 |
| 112 public: | 111 public: |
| 113 void onPrintPage() { m_printedPage = true; } | 112 void onPrintPage() { m_printedPage = true; } |
| 114 bool printedAtLeastOnePage() { return m_printedPage; } | 113 bool printedAtLeastOnePage() { return m_printedPage; } |
| 115 | 114 |
| 116 private: | 115 private: |
| 117 bool m_printedPage = false; | 116 bool m_printedPage = false; |
| 118 }; | 117 }; |
| 119 | 118 |
| 120 bool TestPlugin::printPage(int pageNumber, WebCanvas* canvas) | 119 void TestPlugin::printPage(int pageNumber, WebCanvas* canvas, bool unused) |
| 121 { | 120 { |
| 122 ASSERT(m_testClient); | 121 ASSERT(m_testClient); |
| 123 m_testClient->onPrintPage(); | 122 m_testClient->onPrintPage(); |
| 124 return true; | |
| 125 } | 123 } |
| 126 | 124 |
| 127 | |
| 128 WebPluginContainer* getWebPluginContainer(WebView* webView, const WebString& id) | 125 WebPluginContainer* getWebPluginContainer(WebView* webView, const WebString& id) |
| 129 { | 126 { |
| 130 WebElement element = webView->mainFrame()->document().getElementById(id); | 127 WebElement element = webView->mainFrame()->document().getElementById(id); |
| 131 return element.pluginContainer(); | 128 return element.pluginContainer(); |
| 132 } | 129 } |
| 133 | 130 |
| 134 TEST_F(WebPluginContainerTest, WindowToLocalPointTest) | 131 TEST_F(WebPluginContainerTest, WindowToLocalPointTest) |
| 135 { | 132 { |
| 136 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("plugin_container.html")); | 133 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("plugin_container.html")); |
| 137 FrameTestHelpers::WebViewHelper webViewHelper; | 134 FrameTestHelpers::WebViewHelper webViewHelper; |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 WebRect rect = pluginContainerImpl->element().boundsInViewportSpace(); | 375 WebRect rect = pluginContainerImpl->element().boundsInViewportSpace(); |
| 379 EXPECT_TRUE(pluginContainerImpl->isRectTopmost(rect)); | 376 EXPECT_TRUE(pluginContainerImpl->isRectTopmost(rect)); |
| 380 | 377 |
| 381 // Cause the plugin's frame to be detached. | 378 // Cause the plugin's frame to be detached. |
| 382 webViewHelper.reset(); | 379 webViewHelper.reset(); |
| 383 | 380 |
| 384 EXPECT_FALSE(pluginContainerImpl->isRectTopmost(rect)); | 381 EXPECT_FALSE(pluginContainerImpl->isRectTopmost(rect)); |
| 385 } | 382 } |
| 386 | 383 |
| 387 } // namespace blink | 384 } // namespace blink |
| OLD | NEW |