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

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: Move Get Poster call to anon namespace 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..9bbee4fb03284ab0e76c683808a40ac7c03ba2f4 100644
--- a/content/renderer/pepper/plugin_instance_throttler_impl_unittest.cc
+++ b/content/renderer/pepper/plugin_instance_throttler_impl_unittest.cc
@@ -36,8 +36,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 +127,20 @@ 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 < PluginInstanceThrottlerImpl::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());

Powered by Google App Engine
This is Rietveld 408576698