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

Side by Side Diff: content/renderer/render_widget_unittest.cc

Issue 2273703002: Force events to be non blocking if main thread is unresponsive. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix build. Created 4 years, 1 month 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "content/renderer/render_widget.h" 5 #include "content/renderer/render_widget.h"
6 6
7 #include <tuple> 7 #include <tuple>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 14 matching lines...) Expand all
25 #include "ui/gfx/geometry/rect.h" 25 #include "ui/gfx/geometry/rect.h"
26 26
27 using testing::_; 27 using testing::_;
28 28
29 namespace content { 29 namespace content {
30 30
31 namespace { 31 namespace {
32 32
33 const char* EVENT_LISTENER_RESULT_HISTOGRAM = "Event.PassiveListeners"; 33 const char* EVENT_LISTENER_RESULT_HISTOGRAM = "Event.PassiveListeners";
34 34
35 // Keep in sync with enum defined in
36 // RenderWidgetInputHandler::LogPassiveEventListenersUma.
35 enum { 37 enum {
36 PASSIVE_LISTENER_UMA_ENUM_PASSIVE, 38 PASSIVE_LISTENER_UMA_ENUM_PASSIVE,
37 PASSIVE_LISTENER_UMA_ENUM_UNCANCELABLE, 39 PASSIVE_LISTENER_UMA_ENUM_UNCANCELABLE,
38 PASSIVE_LISTENER_UMA_ENUM_SUPPRESSED, 40 PASSIVE_LISTENER_UMA_ENUM_SUPPRESSED,
39 PASSIVE_LISTENER_UMA_ENUM_CANCELABLE, 41 PASSIVE_LISTENER_UMA_ENUM_CANCELABLE,
40 PASSIVE_LISTENER_UMA_ENUM_CANCELABLE_AND_CANCELED, 42 PASSIVE_LISTENER_UMA_ENUM_CANCELABLE_AND_CANCELED,
41 PASSIVE_LISTENER_UMA_ENUM_FORCED_NON_BLOCKING_DUE_TO_FLING, 43 PASSIVE_LISTENER_UMA_ENUM_FORCED_NON_BLOCKING_DUE_TO_FLING,
44 PASSIVE_LISTENER_UMA_ENUM_FORCED_NON_BLOCKING_DUE_TO_MAIN_THREAD_RESPONSIVENES S,
42 PASSIVE_LISTENER_UMA_ENUM_COUNT 45 PASSIVE_LISTENER_UMA_ENUM_COUNT
43 }; 46 };
44 47
45 class MockWebWidget : public blink::WebWidget { 48 class MockWebWidget : public blink::WebWidget {
46 public: 49 public:
47 MOCK_METHOD1(handleInputEvent, 50 MOCK_METHOD1(handleInputEvent,
48 blink::WebInputEventResult(const blink::WebInputEvent&)); 51 blink::WebInputEventResult(const blink::WebInputEvent&));
49 }; 52 };
50 53
51 } // namespace 54 } // namespace
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 EXPECT_EQ(gfx::Vector2dF(10, 5), overscroll.current_fling_velocity); 283 EXPECT_EQ(gfx::Vector2dF(10, 5), overscroll.current_fling_velocity);
281 widget()->sink()->ClearMessages(); 284 widget()->sink()->ClearMessages();
282 } 285 }
283 286
284 TEST_F(RenderWidgetUnittest, RenderWidgetInputEventUmaMetrics) { 287 TEST_F(RenderWidgetUnittest, RenderWidgetInputEventUmaMetrics) {
285 SyntheticWebTouchEvent touch; 288 SyntheticWebTouchEvent touch;
286 touch.PressPoint(10, 10); 289 touch.PressPoint(10, 10);
287 touch.touchStartOrFirstTouchMove = true; 290 touch.touchStartOrFirstTouchMove = true;
288 291
289 EXPECT_CALL(*widget()->mock_webwidget(), handleInputEvent(_)) 292 EXPECT_CALL(*widget()->mock_webwidget(), handleInputEvent(_))
290 .Times(5) 293 .Times(7)
291 .WillRepeatedly( 294 .WillRepeatedly(
292 ::testing::Return(blink::WebInputEventResult::NotHandled)); 295 ::testing::Return(blink::WebInputEventResult::NotHandled));
293 296
294 widget()->SendInputEvent(touch); 297 widget()->SendInputEvent(touch);
295 histogram_tester().ExpectBucketCount(EVENT_LISTENER_RESULT_HISTOGRAM, 298 histogram_tester().ExpectBucketCount(EVENT_LISTENER_RESULT_HISTOGRAM,
296 PASSIVE_LISTENER_UMA_ENUM_CANCELABLE, 1); 299 PASSIVE_LISTENER_UMA_ENUM_CANCELABLE, 1);
297 300
298 touch.dispatchType = blink::WebInputEvent::DispatchType::EventNonBlocking; 301 touch.dispatchType = blink::WebInputEvent::DispatchType::EventNonBlocking;
299 widget()->SendInputEvent(touch); 302 widget()->SendInputEvent(touch);
300 histogram_tester().ExpectBucketCount(EVENT_LISTENER_RESULT_HISTOGRAM, 303 histogram_tester().ExpectBucketCount(EVENT_LISTENER_RESULT_HISTOGRAM,
(...skipping 15 matching lines...) Expand all
316 319
317 touch.MovePoint(0, 10, 10); 320 touch.MovePoint(0, 10, 10);
318 touch.touchStartOrFirstTouchMove = true; 321 touch.touchStartOrFirstTouchMove = true;
319 touch.dispatchType = 322 touch.dispatchType =
320 blink::WebInputEvent::DispatchType::ListenersForcedNonBlockingDueToFling; 323 blink::WebInputEvent::DispatchType::ListenersForcedNonBlockingDueToFling;
321 widget()->SendInputEvent(touch); 324 widget()->SendInputEvent(touch);
322 histogram_tester().ExpectBucketCount( 325 histogram_tester().ExpectBucketCount(
323 EVENT_LISTENER_RESULT_HISTOGRAM, 326 EVENT_LISTENER_RESULT_HISTOGRAM,
324 PASSIVE_LISTENER_UMA_ENUM_FORCED_NON_BLOCKING_DUE_TO_FLING, 2); 327 PASSIVE_LISTENER_UMA_ENUM_FORCED_NON_BLOCKING_DUE_TO_FLING, 2);
325 328
329 touch.dispatchType = blink::WebInputEvent::DispatchType::
330 ListenersForcedNonBlockingDueToMainThreadResponsiveness;
331 widget()->SendInputEvent(touch);
332 histogram_tester().ExpectBucketCount(
333 EVENT_LISTENER_RESULT_HISTOGRAM,
334 PASSIVE_LISTENER_UMA_ENUM_FORCED_NON_BLOCKING_DUE_TO_MAIN_THREAD_RESPONSIV ENESS,
335 1);
336
337 touch.MovePoint(0, 10, 10);
338 touch.touchStartOrFirstTouchMove = true;
339 touch.dispatchType = blink::WebInputEvent::DispatchType::
340 ListenersForcedNonBlockingDueToMainThreadResponsiveness;
341 widget()->SendInputEvent(touch);
342 histogram_tester().ExpectBucketCount(
343 EVENT_LISTENER_RESULT_HISTOGRAM,
344 PASSIVE_LISTENER_UMA_ENUM_FORCED_NON_BLOCKING_DUE_TO_MAIN_THREAD_RESPONSIV ENESS,
345 2);
346
326 EXPECT_CALL(*widget()->mock_webwidget(), handleInputEvent(_)) 347 EXPECT_CALL(*widget()->mock_webwidget(), handleInputEvent(_))
327 .WillOnce( 348 .WillOnce(
328 ::testing::Return(blink::WebInputEventResult::HandledSuppressed)); 349 ::testing::Return(blink::WebInputEventResult::HandledSuppressed));
329 touch.dispatchType = blink::WebInputEvent::DispatchType::Blocking; 350 touch.dispatchType = blink::WebInputEvent::DispatchType::Blocking;
330 widget()->SendInputEvent(touch); 351 widget()->SendInputEvent(touch);
331 histogram_tester().ExpectBucketCount(EVENT_LISTENER_RESULT_HISTOGRAM, 352 histogram_tester().ExpectBucketCount(EVENT_LISTENER_RESULT_HISTOGRAM,
332 PASSIVE_LISTENER_UMA_ENUM_SUPPRESSED, 1); 353 PASSIVE_LISTENER_UMA_ENUM_SUPPRESSED, 1);
333 354
334 EXPECT_CALL(*widget()->mock_webwidget(), handleInputEvent(_)) 355 EXPECT_CALL(*widget()->mock_webwidget(), handleInputEvent(_))
335 .WillOnce( 356 .WillOnce(
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 blink::WebRect popup_emulated_rect(130, 170, 100, 400); 509 blink::WebRect popup_emulated_rect(130, 170, 100, 400);
489 widget()->setWindowRect(popup_emulated_rect); 510 widget()->setWindowRect(popup_emulated_rect);
490 511
491 EXPECT_EQ(popup_emulated_rect.x, widget()->windowRect().x); 512 EXPECT_EQ(popup_emulated_rect.x, widget()->windowRect().x);
492 EXPECT_EQ(popup_emulated_rect.y, widget()->windowRect().y); 513 EXPECT_EQ(popup_emulated_rect.y, widget()->windowRect().y);
493 EXPECT_EQ(popup_emulated_rect.x, widget()->viewRect().x); 514 EXPECT_EQ(popup_emulated_rect.x, widget()->viewRect().x);
494 EXPECT_EQ(popup_emulated_rect.y, widget()->viewRect().y); 515 EXPECT_EQ(popup_emulated_rect.y, widget()->viewRect().y);
495 } 516 }
496 517
497 } // namespace content 518 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698