OLD | NEW |
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_aura.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/memory/shared_memory.h" | 9 #include "base/memory/shared_memory.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 924 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
935 EXPECT_EQ(InputMsg_ImeConfirmComposition::ID, | 935 EXPECT_EQ(InputMsg_ImeConfirmComposition::ID, |
936 sink_->GetMessageAt(0)->type()); | 936 sink_->GetMessageAt(0)->type()); |
937 EXPECT_EQ(InputMsg_HandleInputEvent::ID, | 937 EXPECT_EQ(InputMsg_HandleInputEvent::ID, |
938 sink_->GetMessageAt(1)->type()); | 938 sink_->GetMessageAt(1)->type()); |
939 } | 939 } |
940 } | 940 } |
941 | 941 |
942 // Checks that touch-event state is maintained correctly. | 942 // Checks that touch-event state is maintained correctly. |
943 TEST_F(RenderWidgetHostViewAuraTest, TouchEventState) { | 943 TEST_F(RenderWidgetHostViewAuraTest, TouchEventState) { |
944 view_->InitAsChild(NULL); | 944 view_->InitAsChild(NULL); |
| 945 aura_test_helper_->root_window()->AddChild(view_->window()); |
945 view_->Show(); | 946 view_->Show(); |
946 | 947 |
947 // Start with no touch-event handler in the renderer. | 948 // Start with no touch-event handler in the renderer. |
948 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, false)); | 949 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, false)); |
949 EXPECT_FALSE(widget_host_->ShouldForwardTouchEvent()); | 950 EXPECT_FALSE(widget_host_->ShouldForwardTouchEvent()); |
950 | 951 |
951 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, | 952 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, |
952 gfx::Point(30, 30), | 953 gfx::Point(30, 30), |
953 0, | 954 0, |
954 ui::EventTimeForNow()); | 955 ui::EventTimeForNow()); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1043 view_->OnTouchEvent(&release2); | 1044 view_->OnTouchEvent(&release2); |
1044 EXPECT_FALSE(release2.handled()); | 1045 EXPECT_FALSE(release2.handled()); |
1045 EXPECT_EQ(blink::WebInputEvent::TouchEnd, view_->touch_event_.type); | 1046 EXPECT_EQ(blink::WebInputEvent::TouchEnd, view_->touch_event_.type); |
1046 EXPECT_EQ(0U, view_->touch_event_.touchesLength); | 1047 EXPECT_EQ(0U, view_->touch_event_.touchesLength); |
1047 } | 1048 } |
1048 | 1049 |
1049 // Checks that touch-events are queued properly when there is a touch-event | 1050 // Checks that touch-events are queued properly when there is a touch-event |
1050 // handler on the page. | 1051 // handler on the page. |
1051 TEST_F(RenderWidgetHostViewAuraTest, TouchEventSyncAsync) { | 1052 TEST_F(RenderWidgetHostViewAuraTest, TouchEventSyncAsync) { |
1052 view_->InitAsChild(NULL); | 1053 view_->InitAsChild(NULL); |
| 1054 aura_test_helper_->root_window()->AddChild(view_->window()); |
1053 view_->Show(); | 1055 view_->Show(); |
1054 | 1056 |
1055 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); | 1057 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); |
1056 EXPECT_TRUE(widget_host_->ShouldForwardTouchEvent()); | 1058 EXPECT_TRUE(widget_host_->ShouldForwardTouchEvent()); |
1057 | 1059 |
1058 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, | 1060 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, |
1059 gfx::Point(30, 30), | 1061 gfx::Point(30, 30), |
1060 0, | 1062 0, |
1061 ui::EventTimeForNow()); | 1063 ui::EventTimeForNow()); |
1062 ui::TouchEvent move(ui::ET_TOUCH_MOVED, | 1064 ui::TouchEvent move(ui::ET_TOUCH_MOVED, |
(...skipping 922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1985 ViewMsg_Resize::Read(message, ¶ms); | 1987 ViewMsg_Resize::Read(message, ¶ms); |
1986 EXPECT_EQ(60, params.a.visible_viewport_size.height()); | 1988 EXPECT_EQ(60, params.a.visible_viewport_size.height()); |
1987 } | 1989 } |
1988 | 1990 |
1989 // Ensures that touch event positions are never truncated to integers. | 1991 // Ensures that touch event positions are never truncated to integers. |
1990 TEST_F(RenderWidgetHostViewAuraTest, TouchEventPositionsArentRounded) { | 1992 TEST_F(RenderWidgetHostViewAuraTest, TouchEventPositionsArentRounded) { |
1991 const float kX = 30.58f; | 1993 const float kX = 30.58f; |
1992 const float kY = 50.23f; | 1994 const float kY = 50.23f; |
1993 | 1995 |
1994 view_->InitAsChild(NULL); | 1996 view_->InitAsChild(NULL); |
| 1997 aura_test_helper_->root_window()->AddChild(view_->window()); |
1995 view_->Show(); | 1998 view_->Show(); |
1996 | 1999 |
1997 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, | 2000 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, |
1998 gfx::PointF(kX, kY), | 2001 gfx::PointF(kX, kY), |
1999 0, | 2002 0, |
2000 ui::EventTimeForNow()); | 2003 ui::EventTimeForNow()); |
2001 | 2004 |
2002 view_->OnTouchEvent(&press); | 2005 view_->OnTouchEvent(&press); |
2003 EXPECT_EQ(blink::WebInputEvent::TouchStart, view_->touch_event_.type); | 2006 EXPECT_EQ(blink::WebInputEvent::TouchStart, view_->touch_event_.type); |
2004 EXPECT_TRUE(view_->touch_event_.cancelable); | 2007 EXPECT_TRUE(view_->touch_event_.cancelable); |
(...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2907 } | 2910 } |
2908 | 2911 |
2909 // Tests that when view initiated shutdown happens (i.e. RWHView is deleted | 2912 // Tests that when view initiated shutdown happens (i.e. RWHView is deleted |
2910 // before RWH), we clean up properly and don't leak the RWHVGuest. | 2913 // before RWH), we clean up properly and don't leak the RWHVGuest. |
2911 TEST_F(RenderWidgetHostViewGuestAuraTest, GuestViewDoesNotLeak) { | 2914 TEST_F(RenderWidgetHostViewGuestAuraTest, GuestViewDoesNotLeak) { |
2912 TearDownEnvironment(); | 2915 TearDownEnvironment(); |
2913 ASSERT_FALSE(guest_view_weak_.get()); | 2916 ASSERT_FALSE(guest_view_weak_.get()); |
2914 } | 2917 } |
2915 | 2918 |
2916 } // namespace content | 2919 } // namespace content |
OLD | NEW |