| Index: content/renderer/browser_plugin/browser_plugin_browsertest.cc
|
| diff --git a/content/renderer/browser_plugin/browser_plugin_browsertest.cc b/content/renderer/browser_plugin/browser_plugin_browsertest.cc
|
| index 5cdb34432b168a18b660baf677864064ae06f0b9..748f5756c17f8efe5425e182c20a6ecb25f71d88 100644
|
| --- a/content/renderer/browser_plugin/browser_plugin_browsertest.cc
|
| +++ b/content/renderer/browser_plugin/browser_plugin_browsertest.cc
|
| @@ -12,6 +12,7 @@
|
| #include "content/renderer/browser_plugin/browser_plugin.h"
|
| #include "content/renderer/browser_plugin/mock_browser_plugin.h"
|
| #include "content/renderer/browser_plugin/mock_browser_plugin_manager.h"
|
| +#include "content/renderer/browser_plugin/mock_browser_plugin_texture_provider.h"
|
| #include "content/renderer/render_thread_impl.h"
|
| #include "content/renderer/renderer_webkitplatformsupport_impl.h"
|
| #include "content/shell/shell_main_delegate.h"
|
| @@ -114,19 +115,21 @@ TEST_F(BrowserPluginTest, SrcAttribute) {
|
| {
|
| const IPC::Message* msg =
|
| browser_plugin_manager()->sink().GetUniqueMessageMatching(
|
| - BrowserPluginHostMsg_NavigateOrCreateGuest::ID);
|
| + BrowserPluginHostMsg_NavigateGuest::ID);
|
| ASSERT_TRUE(msg);
|
|
|
| int instance_id;
|
| long long frame_id;
|
| std::string src;
|
| gfx::Size size;
|
| - BrowserPluginHostMsg_NavigateOrCreateGuest::Read(
|
| + BrowserPluginHostMsg_Surface_Params params;
|
| + BrowserPluginHostMsg_NavigateGuest::Read(
|
| msg,
|
| &instance_id,
|
| &frame_id,
|
| &src,
|
| - &size);
|
| + &size,
|
| + ¶ms);
|
| EXPECT_EQ("foo", src);
|
| }
|
|
|
| @@ -138,19 +141,21 @@ TEST_F(BrowserPluginTest, SrcAttribute) {
|
| {
|
| const IPC::Message* msg =
|
| browser_plugin_manager()->sink().GetUniqueMessageMatching(
|
| - BrowserPluginHostMsg_NavigateOrCreateGuest::ID);
|
| + BrowserPluginHostMsg_NavigateGuest::ID);
|
| ASSERT_TRUE(msg);
|
|
|
| int instance_id;
|
| long long frame_id;
|
| std::string src;
|
| gfx::Size size;
|
| - BrowserPluginHostMsg_NavigateOrCreateGuest::Read(
|
| + BrowserPluginHostMsg_Surface_Params params;
|
| + BrowserPluginHostMsg_NavigateGuest::Read(
|
| msg,
|
| &instance_id,
|
| &frame_id,
|
| &src,
|
| - &size);
|
| + &size,
|
| + ¶ms);
|
| EXPECT_EQ("bar", src);
|
| std::string src_value =
|
| ExecuteScriptAndReturnString(
|
| @@ -323,4 +328,166 @@ TEST_F(BrowserPluginTest, CustomEvents) {
|
| EXPECT_EQ(kGoogleURL, ExecuteScriptAndReturnString("url"));
|
| }
|
|
|
| +TEST_F(BrowserPluginTest, CompositingSwitch) {
|
| + LoadHTML(GetHTMLForBrowserPluginObject().c_str());
|
| +
|
| + const IPC::Message* msg =
|
| + browser_plugin_manager()->sink().GetFirstMessageMatching(
|
| + BrowserPluginHostMsg_ResizeGuest::ID);
|
| + ASSERT_TRUE(msg);
|
| + PickleIterator iter = IPC::SyncMessage::GetDataIterator(msg);
|
| + BrowserPluginHostMsg_ResizeGuest::SendParam resize_params;
|
| + ASSERT_TRUE(IPC::ReadParam(msg, &iter, &resize_params));
|
| + int instance_id = resize_params.a;
|
| +
|
| + MockBrowserPlugin* browser_plugin =
|
| + static_cast<MockBrowserPlugin*>(
|
| + browser_plugin_manager()->GetBrowserPlugin(instance_id));
|
| + ASSERT_TRUE(browser_plugin);
|
| +
|
| + EXPECT_FALSE(browser_plugin->ignoringInput());
|
| + EXPECT_FALSE(browser_plugin->hasTextureProvider());
|
| +
|
| + MockBrowserPluginTextureProvider* provider =
|
| + new MockBrowserPluginTextureProvider(
|
| + browser_plugin->instance_id(),
|
| + browser_plugin->render_view()->GetRoutingID(),
|
| + 0);
|
| +
|
| + using ::testing::Mock;
|
| +
|
| + // Check initial resize
|
| + {
|
| + using ::testing::_;
|
| + using ::testing::Return;
|
| +
|
| + // Arbitrary constants
|
| + gfx::Size size(50, 20);
|
| +
|
| + // The plugin should use its own instance ID, but the routing ID is really
|
| + // an internal detail
|
| + EXPECT_CALL(*browser_plugin,
|
| + CreateTextureProvider(browser_plugin->instance_id(), _))
|
| + .WillOnce(Return(provider));
|
| + EXPECT_CALL(
|
| + *provider,
|
| + Resize(gfx::Size(browser_plugin->width(), browser_plugin->height())));
|
| + EXPECT_CALL(*provider, SurfaceResize(size));
|
| +
|
| + browser_plugin->SurfaceResize(size);
|
| +
|
| + EXPECT_FALSE(browser_plugin->ignoringInput());
|
| + ASSERT_TRUE(browser_plugin->hasTextureProvider());
|
| +
|
| + Mock::VerifyAndClear(provider);
|
| + }
|
| +
|
| + // Check subsequent resize
|
| + {
|
| + // Arbitrary constants
|
| + gfx::Size size(5223, 25626);
|
| +
|
| + EXPECT_CALL(*provider, SurfaceResize(size));
|
| +
|
| + browser_plugin->SurfaceResize(size);
|
| +
|
| + EXPECT_FALSE(browser_plugin->ignoringInput());
|
| +
|
| + Mock::VerifyAndClear(provider);
|
| + }
|
| +
|
| + // Check buffer swap
|
| + {
|
| + using ::testing::_;
|
| +
|
| + // Arbitrary constant
|
| + int surface_id = 453;
|
| +
|
| + EXPECT_CALL(*provider, SetDelayedSwap(surface_id, _));
|
| +
|
| + // TODO: Verify that the Info arg is correct
|
| + browser_plugin->BuffersSwapped(surface_id, BrowserPlugin_SwapInfo());
|
| +
|
| + EXPECT_TRUE(browser_plugin->ignoringInput());
|
| +
|
| + // Check to make sure it is actually ignoring input
|
| + WebKit::WebCursorInfo cursor_info;
|
| + bool handled = browser_plugin->handleInputEvent(WebKit::WebMouseEvent(),
|
| + cursor_info);
|
| + EXPECT_TRUE(handled);
|
| + ASSERT_FALSE(browser_plugin_manager()->sink().GetUniqueMessageMatching(
|
| + BrowserPluginHostMsg_HandleInputEvent::ID));
|
| +
|
| + Mock::VerifyAndClear(provider);
|
| + }
|
| +
|
| + // Check completion
|
| + {
|
| + browser_plugin->TextureProviderIsReady();
|
| +
|
| + EXPECT_FALSE(browser_plugin->ignoringInput());
|
| +
|
| + WebKit::WebCursorInfo cursor_info;
|
| + browser_plugin->handleInputEvent(WebKit::WebMouseEvent(),
|
| + cursor_info);
|
| + EXPECT_TRUE(browser_plugin_manager()->sink().GetUniqueMessageMatching(
|
| + BrowserPluginHostMsg_HandleInputEvent::ID));
|
| + }
|
| +
|
| + // Check subsequent resize
|
| + {
|
| + // Arbitrary constants
|
| + gfx::Size size(1, 1);
|
| +
|
| + EXPECT_CALL(*provider, SurfaceResize(size));
|
| +
|
| + browser_plugin->SurfaceResize(size);
|
| +
|
| + EXPECT_FALSE(browser_plugin->ignoringInput());
|
| +
|
| + Mock::VerifyAndClear(provider);
|
| + }
|
| +}
|
| +
|
| +/*
|
| +namespace {
|
| +
|
| +class MockTextureProviderClient
|
| + : WebKit::WebExternalTextureProvider::Client {
|
| + public:
|
| + MOCK_METHOD0(stopUsingProvider, void());
|
| + MOCK_METHOD0(didReceiveFrame, void());
|
| + MOCK_METHOD0(insertSyncPoint, unsigned());
|
| +};
|
| +
|
| +}
|
| +*/
|
| +
|
| +TEST_F(BrowserPluginTest, TextureProviderSingleThreaded) {
|
| + // Arbitrary constants
|
| + int instance_id = 4;
|
| + int routing_id = 4523;
|
| +
|
| + BrowserPluginTextureProvider* provider = new BrowserPluginTextureProvider(
|
| + instance_id,
|
| + routing_id,
|
| + 0);
|
| +
|
| + // TODO: Provide a ChannelProxy equivalent to IPC::TestSink and use to get
|
| + // messages. In the meanwhile, test the only thing we can.
|
| + {
|
| + EXPECT_TRUE(provider->flipped());
|
| + EXPECT_TRUE(provider->premultipliedAlpha());
|
| +
|
| + provider->Resize(gfx::Size(4, 4));
|
| + provider->SurfaceResize(gfx::Size(8, 8));
|
| +
|
| + // TODO: Not do floating point comparisons here. It works in this case
|
| + // because it's powers of 2.
|
| + EXPECT_EQ(provider->uvRect(), WebKit::WebFloatRect(0, 0, 0.5, 0.5));
|
| + }
|
| +
|
| + provider->Destroy();
|
| +}
|
| +
|
| } // namespace content
|
|
|