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

Side by Side Diff: content/renderer/pepper/pepper_plugin_instance_throttler_unittest.cc

Issue 802453004: Plugin Power Saver: Improve right-click and middle-click behavior. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@0208-plugin-power-saver-fix-black-video-on-resume-problem
Patch Set: Created 6 years 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 unified diff | Download patch
« no previous file with comments | « content/renderer/pepper/pepper_plugin_instance_throttler.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_constants.h" 10 #include "content/public/common/content_constants.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 void EngageThrottle() { 54 void EngageThrottle() {
55 throttler_->SetPluginThrottled(true); 55 throttler_->SetPluginThrottled(true);
56 } 56 }
57 57
58 void SendEventAndTest(blink::WebInputEvent::Type event_type, 58 void SendEventAndTest(blink::WebInputEvent::Type event_type,
59 bool expect_consumed, 59 bool expect_consumed,
60 bool expect_throttled, 60 bool expect_throttled,
61 int expect_change_callback_count) { 61 int expect_change_callback_count) {
62 blink::WebMouseEvent event; 62 blink::WebMouseEvent event;
63 event.type = event_type; 63 event.type = event_type;
64 event.modifiers = blink::WebInputEvent::Modifiers::LeftButtonDown;
64 EXPECT_EQ(expect_consumed, throttler()->ConsumeInputEvent(event)); 65 EXPECT_EQ(expect_consumed, throttler()->ConsumeInputEvent(event));
65 EXPECT_EQ(expect_throttled, throttler()->is_throttled()); 66 EXPECT_EQ(expect_throttled, throttler()->is_throttled());
66 EXPECT_EQ(expect_change_callback_count, change_callback_calls()); 67 EXPECT_EQ(expect_change_callback_count, change_callback_calls());
67 } 68 }
68 69
69 private: 70 private:
70 void ChangeCallback() { ++change_callback_calls_; } 71 void ChangeCallback() { ++change_callback_calls_; }
71 72
72 scoped_ptr<PepperPluginInstanceThrottler> throttler_; 73 scoped_ptr<PepperPluginInstanceThrottler> throttler_;
73 74
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 SendEventAndTest(blink::WebInputEvent::Type::MouseDown, false, false, 2); 183 SendEventAndTest(blink::WebInputEvent::Type::MouseDown, false, false, 2);
183 SendEventAndTest(blink::WebInputEvent::Type::MouseWheel, false, false, 2); 184 SendEventAndTest(blink::WebInputEvent::Type::MouseWheel, false, false, 2);
184 SendEventAndTest(blink::WebInputEvent::Type::MouseMove, false, false, 2); 185 SendEventAndTest(blink::WebInputEvent::Type::MouseMove, false, false, 2);
185 SendEventAndTest(blink::WebInputEvent::Type::KeyDown, false, false, 2); 186 SendEventAndTest(blink::WebInputEvent::Type::KeyDown, false, false, 2);
186 SendEventAndTest(blink::WebInputEvent::Type::KeyUp, false, false, 2); 187 SendEventAndTest(blink::WebInputEvent::Type::KeyUp, false, false, 2);
187 188
188 // Subsequent MouseUps should also not be consumed. 189 // Subsequent MouseUps should also not be consumed.
189 SendEventAndTest(blink::WebInputEvent::Type::MouseUp, false, false, 2); 190 SendEventAndTest(blink::WebInputEvent::Type::MouseUp, false, false, 2);
190 } 191 }
191 192
193 TEST_F(PepperPluginInstanceThrottlerTest, ThrottleOnLeftClickOnly) {
194 EXPECT_FALSE(throttler()->is_throttled());
195 EXPECT_EQ(0, change_callback_calls());
196
197 EngageThrottle();
198 EXPECT_TRUE(throttler()->is_throttled());
199 EXPECT_EQ(1, change_callback_calls());
200
201 blink::WebMouseEvent event;
202 event.type = blink::WebInputEvent::Type::MouseUp;
203
204 event.modifiers = blink::WebInputEvent::Modifiers::RightButtonDown;
205 EXPECT_FALSE(throttler()->ConsumeInputEvent(event));
206 EXPECT_TRUE(throttler()->is_throttled());
207
208 event.modifiers = blink::WebInputEvent::Modifiers::MiddleButtonDown;
209 EXPECT_TRUE(throttler()->ConsumeInputEvent(event));
210 EXPECT_TRUE(throttler()->is_throttled());
211
212 event.modifiers = blink::WebInputEvent::Modifiers::LeftButtonDown;
213 EXPECT_TRUE(throttler()->ConsumeInputEvent(event));
214 EXPECT_FALSE(throttler()->is_throttled());
215 }
216
192 } // namespace content 217 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/pepper/pepper_plugin_instance_throttler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698