| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "content/public/common/content_switches.h" | 10 #include "content/public/common/content_switches.h" |
| 11 #include "content/public/renderer/render_frame.h" | 11 #include "content/public/renderer/render_frame.h" |
| 12 #include "content/renderer/pepper/plugin_instance_throttler_impl.h" | 12 #include "content/renderer/pepper/plugin_instance_throttler_impl.h" |
| 13 #include "testing/gmock/include/gmock/gmock.h" | 13 #include "testing/gmock/include/gmock/gmock.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 #include "third_party/WebKit/public/web/WebInputEvent.h" | 15 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 16 #include "third_party/WebKit/public/web/WebPluginParams.h" | 16 #include "third_party/WebKit/public/web/WebPluginParams.h" |
| 17 #include "ui/gfx/canvas.h" | 17 #include "ui/gfx/canvas.h" |
| 18 #include "url/gurl.h" |
| 19 #include "url/origin.h" |
| 18 | 20 |
| 19 using testing::_; | 21 using testing::_; |
| 20 using testing::Return; | 22 using testing::Return; |
| 21 | 23 |
| 22 class GURL; | |
| 23 | |
| 24 namespace content { | 24 namespace content { |
| 25 | 25 |
| 26 class PluginInstanceThrottlerImplTest | 26 class PluginInstanceThrottlerImplTest |
| 27 : public testing::Test, | 27 : public testing::Test, |
| 28 public PluginInstanceThrottler::Observer { | 28 public PluginInstanceThrottler::Observer { |
| 29 protected: | 29 protected: |
| 30 const int kMaximumFramesToExamine = | 30 const int kMaximumFramesToExamine = |
| 31 PluginInstanceThrottlerImpl::kMaximumFramesToExamine; | 31 PluginInstanceThrottlerImpl::kMaximumFramesToExamine; |
| 32 | 32 |
| 33 PluginInstanceThrottlerImplTest() : change_callback_calls_(0) {} | 33 PluginInstanceThrottlerImplTest() : change_callback_calls_(0) {} |
| 34 ~PluginInstanceThrottlerImplTest() override { | 34 ~PluginInstanceThrottlerImplTest() override { |
| 35 throttler_->RemoveObserver(this); | 35 throttler_->RemoveObserver(this); |
| 36 } | 36 } |
| 37 | 37 |
| 38 void SetUp() override { | 38 void SetUp() override { |
| 39 throttler_.reset(new PluginInstanceThrottlerImpl); | 39 throttler_.reset(new PluginInstanceThrottlerImpl); |
| 40 throttler_->Initialize(nullptr, GURL("http://example.com"), | 40 throttler_->Initialize(nullptr, url::Origin(GURL("http://example.com")), |
| 41 "Shockwave Flash", gfx::Size(100, 100)); | 41 "Shockwave Flash", gfx::Size(100, 100)); |
| 42 throttler_->AddObserver(this); | 42 throttler_->AddObserver(this); |
| 43 } | 43 } |
| 44 | 44 |
| 45 PluginInstanceThrottlerImpl* throttler() { | 45 PluginInstanceThrottlerImpl* throttler() { |
| 46 DCHECK(throttler_.get()); | 46 DCHECK(throttler_.get()); |
| 47 return throttler_.get(); | 47 return throttler_.get(); |
| 48 } | 48 } |
| 49 | 49 |
| 50 void DisablePowerSaverByRetroactiveWhitelist() { | 50 void DisablePowerSaverByRetroactiveWhitelist() { |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 event.modifiers = blink::WebInputEvent::Modifiers::MiddleButtonDown; | 210 event.modifiers = blink::WebInputEvent::Modifiers::MiddleButtonDown; |
| 211 EXPECT_TRUE(throttler()->ConsumeInputEvent(event)); | 211 EXPECT_TRUE(throttler()->ConsumeInputEvent(event)); |
| 212 EXPECT_TRUE(throttler()->IsThrottled()); | 212 EXPECT_TRUE(throttler()->IsThrottled()); |
| 213 | 213 |
| 214 event.modifiers = blink::WebInputEvent::Modifiers::LeftButtonDown; | 214 event.modifiers = blink::WebInputEvent::Modifiers::LeftButtonDown; |
| 215 EXPECT_TRUE(throttler()->ConsumeInputEvent(event)); | 215 EXPECT_TRUE(throttler()->ConsumeInputEvent(event)); |
| 216 EXPECT_FALSE(throttler()->IsThrottled()); | 216 EXPECT_FALSE(throttler()->IsThrottled()); |
| 217 } | 217 } |
| 218 | 218 |
| 219 } // namespace content | 219 } // namespace content |
| OLD | NEW |