| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 #include "public/web/WebView.h" | 51 #include "public/web/WebView.h" |
| 52 #include "third_party/skia/include/core/SkPictureRecorder.h" | 52 #include "third_party/skia/include/core/SkPictureRecorder.h" |
| 53 #include "web/WebLocalFrameImpl.h" | 53 #include "web/WebLocalFrameImpl.h" |
| 54 #include "web/WebPluginContainerImpl.h" | 54 #include "web/WebPluginContainerImpl.h" |
| 55 #include "web/WebViewImpl.h" | 55 #include "web/WebViewImpl.h" |
| 56 #include "web/tests/FakeWebPlugin.h" | 56 #include "web/tests/FakeWebPlugin.h" |
| 57 #include "web/tests/FrameTestHelpers.h" | 57 #include "web/tests/FrameTestHelpers.h" |
| 58 #include <gtest/gtest.h> | 58 #include <gtest/gtest.h> |
| 59 | 59 |
| 60 using blink::testing::runPendingTasks; | 60 using blink::testing::runPendingTasks; |
| 61 using namespace blink; | |
| 62 | 61 |
| 63 namespace { | 62 namespace blink { |
| 64 | 63 |
| 65 class WebPluginContainerTest : public ::testing::Test { | 64 class WebPluginContainerTest : public ::testing::Test { |
| 66 public: | 65 public: |
| 67 WebPluginContainerTest() | 66 WebPluginContainerTest() |
| 68 : m_baseURL("http://www.test.com/") | 67 : m_baseURL("http://www.test.com/") |
| 69 { | 68 { |
| 70 } | 69 } |
| 71 | 70 |
| 72 virtual void TearDown() | 71 void TearDown() override |
| 73 { | 72 { |
| 74 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); | 73 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); |
| 75 } | 74 } |
| 76 | 75 |
| 77 protected: | 76 protected: |
| 78 std::string m_baseURL; | 77 std::string m_baseURL; |
| 79 }; | 78 }; |
| 80 | 79 |
| 81 class TestPluginWebFrameClient; | 80 class TestPluginWebFrameClient; |
| 82 | 81 |
| 83 // Subclass of FakeWebPlugin that has a selection of 'x' as plain text and 'y' a
s markup text. | 82 // Subclass of FakeWebPlugin that has a selection of 'x' as plain text and 'y' a
s markup text. |
| 84 class TestPlugin : public FakeWebPlugin { | 83 class TestPlugin : public FakeWebPlugin { |
| 85 public: | 84 public: |
| 86 TestPlugin(WebFrame* frame, const WebPluginParams& params, TestPluginWebFram
eClient* testClient) | 85 TestPlugin(WebFrame* frame, const WebPluginParams& params, TestPluginWebFram
eClient* testClient) |
| 87 : FakeWebPlugin(frame, params) | 86 : FakeWebPlugin(frame, params) |
| 88 { | 87 { |
| 89 m_testClient = testClient; | 88 m_testClient = testClient; |
| 90 } | 89 } |
| 91 | 90 |
| 92 virtual bool hasSelection() const { return true; } | 91 bool hasSelection() const override { return true; } |
| 93 virtual WebString selectionAsText() const { return WebString("x"); } | 92 WebString selectionAsText() const override { return WebString("x"); } |
| 94 virtual WebString selectionAsMarkup() const { return WebString("y"); } | 93 WebString selectionAsMarkup() const override { return WebString("y"); } |
| 95 virtual bool supportsPaginatedPrint() { return true; } | 94 bool supportsPaginatedPrint() override { return true; } |
| 96 virtual int printBegin(const WebPrintParams& printParams) { return 1; } | 95 int printBegin(const WebPrintParams& printParams) override { return 1; } |
| 97 virtual bool printPage(int pageNumber, WebCanvas*); | 96 bool printPage(int pageNumber, WebCanvas*) override; |
| 97 |
| 98 private: | 98 private: |
| 99 TestPluginWebFrameClient* m_testClient; | 99 TestPluginWebFrameClient* m_testClient; |
| 100 }; | 100 }; |
| 101 | 101 |
| 102 class TestPluginWebFrameClient : public FrameTestHelpers::TestWebFrameClient { | 102 class TestPluginWebFrameClient : public FrameTestHelpers::TestWebFrameClient { |
| 103 virtual WebPlugin* createPlugin(WebLocalFrame* frame, const WebPluginParams&
params) override | 103 WebPlugin* createPlugin(WebLocalFrame* frame, const WebPluginParams& params)
override |
| 104 { | 104 { |
| 105 if (params.mimeType == WebString::fromUTF8("application/x-webkit-test-we
bplugin")) | 105 if (params.mimeType == WebString::fromUTF8("application/x-webkit-test-we
bplugin")) |
| 106 return new TestPlugin(frame, params, this); | 106 return new TestPlugin(frame, params, this); |
| 107 if (params.mimeType == WebString::fromUTF8("application/pdf")) | 107 if (params.mimeType == WebString::fromUTF8("application/pdf")) |
| 108 return new TestPlugin(frame, params, this); | 108 return new TestPlugin(frame, params, this); |
| 109 return WebFrameClient::createPlugin(frame, params); | 109 return WebFrameClient::createPlugin(frame, params); |
| 110 } | 110 } |
| 111 | 111 |
| 112 public: | 112 public: |
| 113 void onPrintPage() { m_printedPage = true; } | 113 void onPrintPage() { m_printedPage = true; } |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 pluginContainerImpl->setFrameRect(IntRect(0, 0, 300, 300)); | 376 pluginContainerImpl->setFrameRect(IntRect(0, 0, 300, 300)); |
| 377 | 377 |
| 378 WebRect rect = pluginContainerImpl->element().boundsInViewportSpace(); | 378 WebRect rect = pluginContainerImpl->element().boundsInViewportSpace(); |
| 379 EXPECT_TRUE(pluginContainerImpl->isRectTopmost(rect)); | 379 EXPECT_TRUE(pluginContainerImpl->isRectTopmost(rect)); |
| 380 | 380 |
| 381 // Cause the plugin's frame to be detached. | 381 // Cause the plugin's frame to be detached. |
| 382 webViewHelper.reset(); | 382 webViewHelper.reset(); |
| 383 | 383 |
| 384 EXPECT_FALSE(pluginContainerImpl->isRectTopmost(rect)); | 384 EXPECT_FALSE(pluginContainerImpl->isRectTopmost(rect)); |
| 385 } | 385 } |
| 386 } | 386 |
| 387 } // namespace blink |
| OLD | NEW |