| 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 f228eda3314dfb09b1fda232c1894a1e36dd544d..d66ce664e5258e7bc84f44de860daa2c6535340b 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 "skia/ext/platform_canvas.h"
|
| @@ -19,6 +20,8 @@
|
| #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
|
| #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptSource.h"
|
|
|
| +using ::testing::_;
|
| +
|
| namespace {
|
| const char kHTMLForBrowserPluginObject[] =
|
| "<object id='browserplugin' width='640px' height='480px'"
|
| @@ -640,4 +643,103 @@ TEST_F(BrowserPluginTest, RemoveBrowserPluginOnExit) {
|
| EXPECT_EQ(NULL, browser_plugin_manager()->GetBrowserPlugin(instance_id));
|
| }
|
|
|
| +TEST_F(BrowserPluginTest, TextureProviderInitDestroyNoClient) {
|
| + MockBrowserPluginTextureProvider *provider =
|
| + new MockBrowserPluginTextureProvider(
|
| + 1,
|
| + 2,
|
| + NULL,
|
| + scoped_refptr<base::MessageLoopProxy>());
|
| +
|
| + // Make sure we setup and destroy the filter.
|
| + EXPECT_CALL(*provider, RemoveFilter());
|
| + EXPECT_CALL(*provider, SetUpFilter());
|
| +
|
| + provider->Initialize();
|
| + provider->Destroy();
|
| +}
|
| +
|
| +namespace {
|
| +
|
| +class MockTextureProviderClient
|
| + : WebKit::WebExternalTextureProvider::Client {
|
| + public:
|
| + void setProvider(WebKit::WebExternalTextureProvider* provider) {
|
| + provider->setTextureProviderClient(this);
|
| + }
|
| +
|
| + MOCK_METHOD0(stopUsingProvider, void());
|
| + MOCK_METHOD1(didReceiveFrame, void(unsigned));
|
| + MOCK_METHOD3(didUpdateTextureParams, void(bool,
|
| + bool,
|
| + const WebKit::WebFloatRect&));
|
| + MOCK_METHOD0(insertSyncPoint, unsigned());
|
| +};
|
| +
|
| +}
|
| +
|
| +TEST_F(BrowserPluginTest, TextureProviderClient) {
|
| +
|
| + MockBrowserPluginTextureProvider *provider =
|
| + new MockBrowserPluginTextureProvider(
|
| + 100,
|
| + 200,
|
| + NULL,
|
| + scoped_refptr<base::MessageLoopProxy>());
|
| +
|
| + // We expect OnBuffersSwapped to send an ack.
|
| + EXPECT_CALL(*provider, Send(_));
|
| + EXPECT_CALL(*provider, RemoveFilter());
|
| + EXPECT_CALL(*provider, SetUpFilter());
|
| +
|
| + provider->Initialize();
|
| +
|
| + MockTextureProviderClient client;
|
| + // Make sure client is notified when the provider goes away.
|
| + EXPECT_CALL(client, stopUsingProvider());
|
| + // Make sure OnBuffersSwapped informs the client of new texture
|
| + // and inserts a sync point.
|
| + EXPECT_CALL(client, didReceiveFrame(_));
|
| + EXPECT_CALL(client, insertSyncPoint());
|
| + // Make sure OnSurfaceResize informs the client of new params.
|
| + EXPECT_CALL(client, didUpdateTextureParams(_, _, _));
|
| + client.setProvider(provider);
|
| +
|
| + provider->OnBuffersSwapped(100, 300, 200, 400);
|
| + gfx::Size size(640, 480);
|
| + provider->OnSurfaceResize(100, size);
|
| +
|
| + provider->Destroy();
|
| +}
|
| +
|
| +TEST_F(BrowserPluginTest, TextureProviderClientPendingSwap) {
|
| +
|
| + MockBrowserPluginTextureProvider *provider =
|
| + new MockBrowserPluginTextureProvider(
|
| + 100,
|
| + 200,
|
| + NULL,
|
| + scoped_refptr<base::MessageLoopProxy>());
|
| + // We expect OnBuffersSwapped to send an ack.
|
| + EXPECT_CALL(*provider, Send(_));
|
| + EXPECT_CALL(*provider, RemoveFilter());
|
| + EXPECT_CALL(*provider, SetUpFilter());
|
| + provider->Initialize();
|
| +
|
| + MockTextureProviderClient client;
|
| + // Make sure client is notified when the provider goes away.
|
| + EXPECT_CALL(client, stopUsingProvider());
|
| + // Make sure OnBuffersSwapped informs the client of new texture
|
| + // and inserts a sync point.
|
| + EXPECT_CALL(client, didReceiveFrame(_));
|
| + EXPECT_CALL(client, insertSyncPoint());
|
| +
|
| + // If we receive swap buffers before we have a client,
|
| + // we need to inform the client once it's set.
|
| + provider->OnBuffersSwapped(100, 300, 200, 400);
|
| + client.setProvider(provider);
|
| +
|
| + provider->Destroy();
|
| +}
|
| +
|
| } // namespace content
|
|
|