Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1939)

Unified Diff: content/renderer/pepper/plugin_instance_throttler_impl_unittest.cc

Issue 904913003: Plugin Power Saver: Fix implicitly sized and below the fold plugins. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/renderer/pepper/plugin_instance_throttler_impl_unittest.cc
diff --git a/content/renderer/pepper/plugin_instance_throttler_impl_unittest.cc b/content/renderer/pepper/plugin_instance_throttler_impl_unittest.cc
index fc284b0ae74abf0292fc74decfecb04c24138fa4..0b3e398749d8674c6f06a83be90e1e3fba36a036 100644
--- a/content/renderer/pepper/plugin_instance_throttler_impl_unittest.cc
+++ b/content/renderer/pepper/plugin_instance_throttler_impl_unittest.cc
@@ -27,6 +27,9 @@ class PluginInstanceThrottlerImplTest
: public testing::Test,
public PluginInstanceThrottler::Observer {
protected:
+ const int kMaximumFramesToExamine =
+ PluginInstanceThrottlerImpl::kMaximumFramesToExamine;
+
PluginInstanceThrottlerImplTest() : change_callback_calls_(0) {}
~PluginInstanceThrottlerImplTest() override {
throttler_->RemoveObserver(this);
@@ -36,8 +39,10 @@ class PluginInstanceThrottlerImplTest
blink::WebRect rect;
rect.width = 100;
rect.height = 100;
- throttler_.reset(new PluginInstanceThrottlerImpl(
- nullptr, GURL("http://example.com"), true /* power_saver_enabled */));
+ throttler_.reset(
+ new PluginInstanceThrottlerImpl(true /* power_saver_enabled */));
+ throttler_->Initialize(nullptr, GURL("http://example.com"),
+ "Shockwave Flash", rect);
throttler_->AddObserver(this);
}
@@ -125,6 +130,19 @@ TEST_F(PluginInstanceThrottlerImplTest, ThrottleByKeyframe) {
EXPECT_EQ(1, change_callback_calls());
}
+TEST_F(PluginInstanceThrottlerImplTest, MaximumKeyframesAnalyzed) {
+ EXPECT_FALSE(throttler()->IsThrottled());
+ EXPECT_EQ(0, change_callback_calls());
+
+ SkBitmap boring_bitmap;
+
+ // Throttle after tons of boring bitmaps.
+ for (int i = 0; i < kMaximumFramesToExamine; ++i) {
+ throttler()->OnImageFlush(&boring_bitmap);
+ }
+ EXPECT_TRUE(throttler()->IsThrottled());
+ EXPECT_EQ(1, change_callback_calls());
+}
TEST_F(PluginInstanceThrottlerImplTest, IgnoreThrottlingAfterMouseUp) {
EXPECT_FALSE(throttler()->IsThrottled());
EXPECT_EQ(0, change_callback_calls());
« no previous file with comments | « content/renderer/pepper/plugin_instance_throttler_impl.cc ('k') | content/renderer/pepper/plugin_power_saver_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698