Chromium Code Reviews| 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()); |