| Index: content/renderer/pepper/plugin_instance_throttler_impl_unittest.cc
|
| diff --git a/content/renderer/pepper/pepper_plugin_instance_throttler_unittest.cc b/content/renderer/pepper/plugin_instance_throttler_impl_unittest.cc
|
| similarity index 82%
|
| rename from content/renderer/pepper/pepper_plugin_instance_throttler_unittest.cc
|
| rename to content/renderer/pepper/plugin_instance_throttler_impl_unittest.cc
|
| index 1ada9add6985b6dd3426f201a064ccf6154cef73..3f77d5cbf717097a5b06372aa7d8ee8425763cfe 100644
|
| --- a/content/renderer/pepper/pepper_plugin_instance_throttler_unittest.cc
|
| +++ b/content/renderer/pepper/plugin_instance_throttler_impl_unittest.cc
|
| @@ -9,7 +9,7 @@
|
| #include "base/message_loop/message_loop.h"
|
| #include "content/public/common/content_switches.h"
|
| #include "content/public/renderer/render_frame.h"
|
| -#include "content/renderer/pepper/pepper_plugin_instance_throttler.h"
|
| +#include "content/renderer/pepper/plugin_instance_throttler_impl.h"
|
| #include "testing/gmock/include/gmock/gmock.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| #include "third_party/WebKit/public/web/WebInputEvent.h"
|
| @@ -23,36 +23,38 @@ class GURL;
|
|
|
| namespace content {
|
|
|
| -class PepperPluginInstanceThrottlerTest : public testing::Test {
|
| +class PluginInstanceThrottlerImplTest
|
| + : public testing::Test,
|
| + public PluginInstanceThrottler::Observer {
|
| protected:
|
| - PepperPluginInstanceThrottlerTest() : change_callback_calls_(0) {}
|
| + PluginInstanceThrottlerImplTest() : change_callback_calls_(0) {}
|
| + ~PluginInstanceThrottlerImplTest() override {
|
| + throttler_->RemoveObserver(this);
|
| + }
|
|
|
| void SetUp() override {
|
| blink::WebRect rect;
|
| rect.width = 100;
|
| rect.height = 100;
|
| - throttler_.reset(new PepperPluginInstanceThrottler(
|
| - nullptr, rect, true /* is_flash_plugin */, GURL("http://example.com"),
|
| - content::RenderFrame::POWER_SAVER_MODE_PERIPHERAL_THROTTLED,
|
| - base::Bind(&PepperPluginInstanceThrottlerTest::ChangeCallback,
|
| - base::Unretained(this))));
|
| + throttler_.reset(new PluginInstanceThrottlerImpl(
|
| + nullptr, GURL("http://example.com"),
|
| + PluginInstanceThrottlerImpl::POWER_SAVER_MODE_PERIPHERAL_THROTTLED));
|
| + throttler_->AddObserver(this);
|
| }
|
|
|
| - PepperPluginInstanceThrottler* throttler() {
|
| + PluginInstanceThrottlerImpl* throttler() {
|
| DCHECK(throttler_.get());
|
| return throttler_.get();
|
| }
|
|
|
| void DisablePowerSaverByRetroactiveWhitelist() {
|
| throttler()->DisablePowerSaver(
|
| - PepperPluginInstanceThrottler::UNTHROTTLE_METHOD_BY_WHITELIST);
|
| + PluginInstanceThrottlerImpl::UNTHROTTLE_METHOD_BY_WHITELIST);
|
| }
|
|
|
| int change_callback_calls() { return change_callback_calls_; }
|
|
|
| - void EngageThrottle() {
|
| - throttler_->SetPluginThrottled(true);
|
| - }
|
| + void EngageThrottle() { throttler_->SetPluginThrottled(true); }
|
|
|
| void SendEventAndTest(blink::WebInputEvent::Type event_type,
|
| bool expect_consumed,
|
| @@ -67,16 +69,17 @@ class PepperPluginInstanceThrottlerTest : public testing::Test {
|
| }
|
|
|
| private:
|
| - void ChangeCallback() { ++change_callback_calls_; }
|
| + // PluginInstanceThrottlerImpl::Observer
|
| + void OnThrottleStateChange() override { ++change_callback_calls_; }
|
|
|
| - scoped_ptr<PepperPluginInstanceThrottler> throttler_;
|
| + scoped_ptr<PluginInstanceThrottlerImpl> throttler_;
|
|
|
| int change_callback_calls_;
|
|
|
| base::MessageLoop loop_;
|
| };
|
|
|
| -TEST_F(PepperPluginInstanceThrottlerTest, ThrottleAndUnthrottleByClick) {
|
| +TEST_F(PluginInstanceThrottlerImplTest, ThrottleAndUnthrottleByClick) {
|
| EXPECT_FALSE(throttler()->is_throttled());
|
| EXPECT_EQ(0, change_callback_calls());
|
|
|
| @@ -88,7 +91,7 @@ TEST_F(PepperPluginInstanceThrottlerTest, ThrottleAndUnthrottleByClick) {
|
| SendEventAndTest(blink::WebInputEvent::Type::MouseUp, true, false, 2);
|
| }
|
|
|
| -TEST_F(PepperPluginInstanceThrottlerTest, ThrottleByKeyframe) {
|
| +TEST_F(PluginInstanceThrottlerImplTest, ThrottleByKeyframe) {
|
| EXPECT_FALSE(throttler()->is_throttled());
|
| EXPECT_EQ(0, change_callback_calls());
|
|
|
| @@ -123,7 +126,7 @@ TEST_F(PepperPluginInstanceThrottlerTest, ThrottleByKeyframe) {
|
| EXPECT_EQ(1, change_callback_calls());
|
| }
|
|
|
| -TEST_F(PepperPluginInstanceThrottlerTest, IgnoreThrottlingAfterMouseUp) {
|
| +TEST_F(PluginInstanceThrottlerImplTest, IgnoreThrottlingAfterMouseUp) {
|
| EXPECT_FALSE(throttler()->is_throttled());
|
| EXPECT_EQ(0, change_callback_calls());
|
|
|
| @@ -136,7 +139,7 @@ TEST_F(PepperPluginInstanceThrottlerTest, IgnoreThrottlingAfterMouseUp) {
|
| EXPECT_EQ(0, change_callback_calls());
|
| }
|
|
|
| -TEST_F(PepperPluginInstanceThrottlerTest, FastWhitelisting) {
|
| +TEST_F(PluginInstanceThrottlerImplTest, FastWhitelisting) {
|
| EXPECT_FALSE(throttler()->is_throttled());
|
| EXPECT_EQ(0, change_callback_calls());
|
|
|
| @@ -147,7 +150,7 @@ TEST_F(PepperPluginInstanceThrottlerTest, FastWhitelisting) {
|
| EXPECT_EQ(1, change_callback_calls());
|
| }
|
|
|
| -TEST_F(PepperPluginInstanceThrottlerTest, SlowWhitelisting) {
|
| +TEST_F(PluginInstanceThrottlerImplTest, SlowWhitelisting) {
|
| EXPECT_FALSE(throttler()->is_throttled());
|
| EXPECT_EQ(0, change_callback_calls());
|
|
|
| @@ -160,7 +163,7 @@ TEST_F(PepperPluginInstanceThrottlerTest, SlowWhitelisting) {
|
| EXPECT_EQ(2, change_callback_calls());
|
| }
|
|
|
| -TEST_F(PepperPluginInstanceThrottlerTest, EventConsumption) {
|
| +TEST_F(PluginInstanceThrottlerImplTest, EventConsumption) {
|
| EXPECT_FALSE(throttler()->is_throttled());
|
| EXPECT_EQ(0, change_callback_calls());
|
|
|
| @@ -189,7 +192,7 @@ TEST_F(PepperPluginInstanceThrottlerTest, EventConsumption) {
|
| SendEventAndTest(blink::WebInputEvent::Type::MouseUp, false, false, 2);
|
| }
|
|
|
| -TEST_F(PepperPluginInstanceThrottlerTest, ThrottleOnLeftClickOnly) {
|
| +TEST_F(PluginInstanceThrottlerImplTest, ThrottleOnLeftClickOnly) {
|
| EXPECT_FALSE(throttler()->is_throttled());
|
| EXPECT_EQ(0, change_callback_calls());
|
|
|
|
|