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

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: fix windows compile 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..813848c6f6cff1129939c9134a8586ebfe67c500 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);
}
@@ -78,6 +80,35 @@ class PluginInstanceThrottlerImplTest
base::MessageLoop loop_;
};
+TEST_F(PluginInstanceThrottlerImplTest, PosterImage) {
piman 2015/02/07 00:02:13 This could still go to chrome/renderer/chrome_cont
+ size_t size = 3;
+ blink::WebVector<blink::WebString> names(size);
+ blink::WebVector<blink::WebString> values(size);
+
+ blink::WebPluginParams params;
+ params.url = GURL("http://b.com/foo.swf");
+
+ params.attributeNames.swap(names);
+ params.attributeValues.swap(values);
+
+ params.attributeNames[0] = "poster";
+ params.attributeValues[0] = "poster.jpg";
+
+ EXPECT_EQ(GURL("http://a.com/poster.jpg"),
+ PluginInstanceThrottler::GetPluginInstancePosterImage(
+ params, GURL("http://a.com/page.html")));
+
+ params.attributeValues[0] = "http://b.com/poster.jpg";
+ EXPECT_EQ(GURL("http://b.com/poster.jpg"),
+ PluginInstanceThrottler::GetPluginInstancePosterImage(
+ params, GURL("http://a.com/page.html")));
+
+ // Ignore empty poster paramaters.
+ params.attributeValues[0] = "";
+ EXPECT_EQ(GURL(), PluginInstanceThrottler::GetPluginInstancePosterImage(
+ params, GURL("http://a.com/page.html")));
+}
+
TEST_F(PluginInstanceThrottlerImplTest, ThrottleAndUnthrottleByClick) {
EXPECT_FALSE(throttler()->IsThrottled());
EXPECT_EQ(0, change_callback_calls());
@@ -125,6 +156,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