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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_mac_unittest.mm

Issue 2317253005: SourceEventType added to LatencyInfo (Closed)
Patch Set: Used a switch-case to set the SourceEventType in latencyInfo. Created 4 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/browser/renderer_host/render_widget_host_view_mac.h" 5 #include "content/browser/renderer_host/render_widget_host_view_mac.h"
6 6
7 #include <Cocoa/Cocoa.h> 7 #include <Cocoa/Cocoa.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <tuple> 10 #include <tuple>
(...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 NSEvent* wheelEvent2 = MockScrollWheelEventWithPhase(@selector(phaseEnded),0); 896 NSEvent* wheelEvent2 = MockScrollWheelEventWithPhase(@selector(phaseEnded),0);
897 [view->cocoa_view() scrollWheel:wheelEvent2]; 897 [view->cocoa_view() scrollWheel:wheelEvent2];
898 ui::LatencyInfo::LatencyComponent ui_component2; 898 ui::LatencyInfo::LatencyComponent ui_component2;
899 ASSERT_TRUE(host->lastWheelEventLatencyInfo.FindLatency( 899 ASSERT_TRUE(host->lastWheelEventLatencyInfo.FindLatency(
900 ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, &ui_component2) ); 900 ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, &ui_component2) );
901 901
902 // Clean up. 902 // Clean up.
903 host->ShutdownAndDestroyWidget(true); 903 host->ShutdownAndDestroyWidget(true);
904 } 904 }
905 905
906 TEST_F(RenderWidgetHostViewMacTest, SourceEventTypeExistsInLatencyInfo) {
907 // Initialize the view associated with a MockRenderWidgetHostImpl, rather than
908 // the MockRenderProcessHost that is set up by the test harness which mocks
909 // out |OnMessageReceived()|.
910 TestBrowserContext browser_context;
911 MockRenderProcessHost* process_host =
912 new MockRenderProcessHost(&browser_context);
913 process_host->Init();
914 MockRenderWidgetHostDelegate delegate;
915 int32_t routing_id = process_host->GetNextRoutingID();
916 MockRenderWidgetHostImpl* host =
917 new MockRenderWidgetHostImpl(&delegate, process_host, routing_id);
918 RenderWidgetHostViewMac* view = new RenderWidgetHostViewMac(host, false);
919 process_host->sink().ClearMessages();
920
921 // Send a wheel event for scrolling by 3 lines.
922 // Verifies that SourceEventType exists in forwarded LatencyInfo object.
923 NSEvent* wheelEvent = MockScrollWheelEventWithPhase(@selector(phaseBegan), 3);
924 [view->cocoa_view() scrollWheel:wheelEvent];
925 ASSERT_TRUE(host->lastWheelEventLatencyInfo.source_event_type() ==
926 ui::SourceEventType::WHEEL);
927
928 // Clean up.
929 host->ShutdownAndDestroyWidget(true);
930 }
931
906 TEST_F(RenderWidgetHostViewMacTest, ScrollWheelEndEventDelivery) { 932 TEST_F(RenderWidgetHostViewMacTest, ScrollWheelEndEventDelivery) {
907 // Initialize the view associated with a MockRenderWidgetHostImpl, rather than 933 // Initialize the view associated with a MockRenderWidgetHostImpl, rather than
908 // the MockRenderProcessHost that is set up by the test harness which mocks 934 // the MockRenderProcessHost that is set up by the test harness which mocks
909 // out |OnMessageReceived()|. 935 // out |OnMessageReceived()|.
910 TestBrowserContext browser_context; 936 TestBrowserContext browser_context;
911 MockRenderProcessHost* process_host = 937 MockRenderProcessHost* process_host =
912 new MockRenderProcessHost(&browser_context); 938 new MockRenderProcessHost(&browser_context);
913 process_host->Init(); 939 process_host->Init();
914 MockRenderWidgetHostDelegate delegate; 940 MockRenderWidgetHostDelegate delegate;
915 int32_t routing_id = process_host->GetNextRoutingID(); 941 int32_t routing_id = process_host->GetNextRoutingID();
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
1457 // Repeat for the tab's view. 1483 // Repeat for the tab's view.
1458 [rwhv_cocoa_ setMarkedText:text 1484 [rwhv_cocoa_ setMarkedText:text
1459 selectedRange:selectedRange 1485 selectedRange:selectedRange
1460 replacementRange:replacementRange]; 1486 replacementRange:replacementRange];
1461 EXPECT_TRUE([rwhv_cocoa_ hasMarkedText]); 1487 EXPECT_TRUE([rwhv_cocoa_ hasMarkedText]);
1462 rwhv_mac_->ImeCancelComposition(); 1488 rwhv_mac_->ImeCancelComposition();
1463 EXPECT_FALSE([rwhv_cocoa_ hasMarkedText]); 1489 EXPECT_FALSE([rwhv_cocoa_ hasMarkedText]);
1464 } 1490 }
1465 1491
1466 } // namespace content 1492 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698