| 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 964 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 975 EXPECT_EQ(blink::WebInputEvent::TouchMove, view_->touch_event_.type); | 975 EXPECT_EQ(blink::WebInputEvent::TouchMove, view_->touch_event_.type); |
| 976 EXPECT_TRUE(view_->touch_event_.cancelable); | 976 EXPECT_TRUE(view_->touch_event_.cancelable); |
| 977 EXPECT_EQ(1U, view_->touch_event_.touchesLength); | 977 EXPECT_EQ(1U, view_->touch_event_.touchesLength); |
| 978 EXPECT_EQ(blink::WebTouchPoint::StateMoved, | 978 EXPECT_EQ(blink::WebTouchPoint::StateMoved, |
| 979 view_->touch_event_.touches[0].state); | 979 view_->touch_event_.touches[0].state); |
| 980 | 980 |
| 981 view_->OnTouchEvent(&release); | 981 view_->OnTouchEvent(&release); |
| 982 EXPECT_FALSE(release.handled()); | 982 EXPECT_FALSE(release.handled()); |
| 983 EXPECT_EQ(blink::WebInputEvent::TouchEnd, view_->touch_event_.type); | 983 EXPECT_EQ(blink::WebInputEvent::TouchEnd, view_->touch_event_.type); |
| 984 EXPECT_TRUE(view_->touch_event_.cancelable); | 984 EXPECT_TRUE(view_->touch_event_.cancelable); |
| 985 EXPECT_EQ(0U, view_->touch_event_.touchesLength); | 985 EXPECT_EQ(1U, view_->touch_event_.touchesLength); |
| 986 | 986 |
| 987 // Now install some touch-event handlers and do the same steps. The touch | 987 // Now install some touch-event handlers and do the same steps. The touch |
| 988 // events should now be consumed. However, the touch-event state should be | 988 // events should now be consumed. However, the touch-event state should be |
| 989 // updated as before. | 989 // updated as before. |
| 990 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); | 990 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); |
| 991 EXPECT_TRUE(widget_host_->ShouldForwardTouchEvent()); | 991 EXPECT_TRUE(widget_host_->ShouldForwardTouchEvent()); |
| 992 | 992 |
| 993 view_->OnTouchEvent(&press); | 993 view_->OnTouchEvent(&press); |
| 994 EXPECT_TRUE(press.synchronous_handling_disabled()); | 994 EXPECT_TRUE(press.synchronous_handling_disabled()); |
| 995 EXPECT_EQ(blink::WebInputEvent::TouchStart, view_->touch_event_.type); | 995 EXPECT_EQ(blink::WebInputEvent::TouchStart, view_->touch_event_.type); |
| 996 EXPECT_TRUE(view_->touch_event_.cancelable); | 996 EXPECT_TRUE(view_->touch_event_.cancelable); |
| 997 EXPECT_EQ(1U, view_->touch_event_.touchesLength); | 997 EXPECT_EQ(1U, view_->touch_event_.touchesLength); |
| 998 EXPECT_EQ(blink::WebTouchPoint::StatePressed, | 998 EXPECT_EQ(blink::WebTouchPoint::StatePressed, |
| 999 view_->touch_event_.touches[0].state); | 999 view_->touch_event_.touches[0].state); |
| 1000 | 1000 |
| 1001 view_->OnTouchEvent(&move); | 1001 view_->OnTouchEvent(&move); |
| 1002 EXPECT_TRUE(move.synchronous_handling_disabled()); | 1002 EXPECT_TRUE(move.synchronous_handling_disabled()); |
| 1003 EXPECT_EQ(blink::WebInputEvent::TouchMove, view_->touch_event_.type); | 1003 EXPECT_EQ(blink::WebInputEvent::TouchMove, view_->touch_event_.type); |
| 1004 EXPECT_TRUE(view_->touch_event_.cancelable); | 1004 EXPECT_TRUE(view_->touch_event_.cancelable); |
| 1005 EXPECT_EQ(1U, view_->touch_event_.touchesLength); | 1005 EXPECT_EQ(1U, view_->touch_event_.touchesLength); |
| 1006 EXPECT_EQ(blink::WebTouchPoint::StateMoved, | 1006 EXPECT_EQ(blink::WebTouchPoint::StateMoved, |
| 1007 view_->touch_event_.touches[0].state); | 1007 view_->touch_event_.touches[0].state); |
| 1008 | 1008 |
| 1009 view_->OnTouchEvent(&release); | 1009 view_->OnTouchEvent(&release); |
| 1010 EXPECT_TRUE(release.synchronous_handling_disabled()); | 1010 EXPECT_TRUE(release.synchronous_handling_disabled()); |
| 1011 EXPECT_EQ(blink::WebInputEvent::TouchEnd, view_->touch_event_.type); | 1011 EXPECT_EQ(blink::WebInputEvent::TouchEnd, view_->touch_event_.type); |
| 1012 EXPECT_TRUE(view_->touch_event_.cancelable); | 1012 EXPECT_TRUE(view_->touch_event_.cancelable); |
| 1013 EXPECT_EQ(0U, view_->touch_event_.touchesLength); | 1013 EXPECT_EQ(1U, view_->touch_event_.touchesLength); |
| 1014 | 1014 |
| 1015 // Now start a touch event, and remove the event-handlers before the release. | 1015 // Now start a touch event, and remove the event-handlers before the release. |
| 1016 view_->OnTouchEvent(&press); | 1016 view_->OnTouchEvent(&press); |
| 1017 EXPECT_TRUE(press.synchronous_handling_disabled()); | 1017 EXPECT_TRUE(press.synchronous_handling_disabled()); |
| 1018 EXPECT_EQ(blink::WebInputEvent::TouchStart, view_->touch_event_.type); | 1018 EXPECT_EQ(blink::WebInputEvent::TouchStart, view_->touch_event_.type); |
| 1019 EXPECT_EQ(1U, view_->touch_event_.touchesLength); | 1019 EXPECT_EQ(1U, view_->touch_event_.touchesLength); |
| 1020 EXPECT_EQ(blink::WebTouchPoint::StatePressed, | 1020 EXPECT_EQ(blink::WebTouchPoint::StatePressed, |
| 1021 view_->touch_event_.touches[0].state); | 1021 view_->touch_event_.touches[0].state); |
| 1022 | 1022 |
| 1023 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, false)); | 1023 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, false)); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1037 EXPECT_EQ(blink::WebInputEvent::TouchMove, view_->touch_event_.type); | 1037 EXPECT_EQ(blink::WebInputEvent::TouchMove, view_->touch_event_.type); |
| 1038 EXPECT_EQ(1U, view_->touch_event_.touchesLength); | 1038 EXPECT_EQ(1U, view_->touch_event_.touchesLength); |
| 1039 EXPECT_EQ(blink::WebTouchPoint::StateMoved, | 1039 EXPECT_EQ(blink::WebTouchPoint::StateMoved, |
| 1040 view_->touch_event_.touches[0].state); | 1040 view_->touch_event_.touches[0].state); |
| 1041 | 1041 |
| 1042 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(20, 20), 0, | 1042 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(20, 20), 0, |
| 1043 base::Time::NowFromSystemTime() - base::Time()); | 1043 base::Time::NowFromSystemTime() - base::Time()); |
| 1044 view_->OnTouchEvent(&release2); | 1044 view_->OnTouchEvent(&release2); |
| 1045 EXPECT_FALSE(release2.handled()); | 1045 EXPECT_FALSE(release2.handled()); |
| 1046 EXPECT_EQ(blink::WebInputEvent::TouchEnd, view_->touch_event_.type); | 1046 EXPECT_EQ(blink::WebInputEvent::TouchEnd, view_->touch_event_.type); |
| 1047 EXPECT_EQ(0U, view_->touch_event_.touchesLength); | 1047 EXPECT_EQ(1U, view_->touch_event_.touchesLength); |
| 1048 } | 1048 } |
| 1049 | 1049 |
| 1050 // 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 |
| 1051 // handler on the page. | 1051 // handler on the page. |
| 1052 TEST_F(RenderWidgetHostViewAuraTest, TouchEventSyncAsync) { | 1052 TEST_F(RenderWidgetHostViewAuraTest, TouchEventSyncAsync) { |
| 1053 view_->InitAsChild(NULL); | 1053 view_->InitAsChild(NULL); |
| 1054 view_->Show(); | 1054 view_->Show(); |
| 1055 | 1055 |
| 1056 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); | 1056 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); |
| 1057 EXPECT_TRUE(widget_host_->ShouldForwardTouchEvent()); | 1057 EXPECT_TRUE(widget_host_->ShouldForwardTouchEvent()); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1088 view_->OnTouchEvent(&move); | 1088 view_->OnTouchEvent(&move); |
| 1089 EXPECT_TRUE(move.synchronous_handling_disabled()); | 1089 EXPECT_TRUE(move.synchronous_handling_disabled()); |
| 1090 EXPECT_EQ(blink::WebInputEvent::TouchMove, view_->touch_event_.type); | 1090 EXPECT_EQ(blink::WebInputEvent::TouchMove, view_->touch_event_.type); |
| 1091 EXPECT_EQ(1U, view_->touch_event_.touchesLength); | 1091 EXPECT_EQ(1U, view_->touch_event_.touchesLength); |
| 1092 EXPECT_EQ(blink::WebTouchPoint::StateMoved, | 1092 EXPECT_EQ(blink::WebTouchPoint::StateMoved, |
| 1093 view_->touch_event_.touches[0].state); | 1093 view_->touch_event_.touches[0].state); |
| 1094 | 1094 |
| 1095 view_->OnTouchEvent(&release); | 1095 view_->OnTouchEvent(&release); |
| 1096 EXPECT_TRUE(release.synchronous_handling_disabled()); | 1096 EXPECT_TRUE(release.synchronous_handling_disabled()); |
| 1097 EXPECT_EQ(blink::WebInputEvent::TouchEnd, view_->touch_event_.type); | 1097 EXPECT_EQ(blink::WebInputEvent::TouchEnd, view_->touch_event_.type); |
| 1098 EXPECT_EQ(0U, view_->touch_event_.touchesLength); | 1098 EXPECT_EQ(1U, view_->touch_event_.touchesLength); |
| 1099 } | 1099 } |
| 1100 | 1100 |
| 1101 TEST_F(RenderWidgetHostViewAuraTest, PhysicalBackingSizeWithScale) { | 1101 TEST_F(RenderWidgetHostViewAuraTest, PhysicalBackingSizeWithScale) { |
| 1102 view_->InitAsChild(NULL); | 1102 view_->InitAsChild(NULL); |
| 1103 aura::client::ParentWindowWithContext( | 1103 aura::client::ParentWindowWithContext( |
| 1104 view_->GetNativeView(), | 1104 view_->GetNativeView(), |
| 1105 parent_view_->GetNativeView()->GetRootWindow(), | 1105 parent_view_->GetNativeView()->GetRootWindow(), |
| 1106 gfx::Rect()); | 1106 gfx::Rect()); |
| 1107 sink_->ClearMessages(); | 1107 sink_->ClearMessages(); |
| 1108 view_->SetSize(gfx::Size(100, 100)); | 1108 view_->SetSize(gfx::Size(100, 100)); |
| (...skipping 1854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2963 view_->OnTouchEvent(&press); | 2963 view_->OnTouchEvent(&press); |
| 2964 view_->OnTouchEvent(&invalid_move); | 2964 view_->OnTouchEvent(&invalid_move); |
| 2965 // Valid press is handled asynchronously. | 2965 // Valid press is handled asynchronously. |
| 2966 EXPECT_TRUE(press.synchronous_handling_disabled()); | 2966 EXPECT_TRUE(press.synchronous_handling_disabled()); |
| 2967 // Invalid move is handled synchronously, but is consumed. | 2967 // Invalid move is handled synchronously, but is consumed. |
| 2968 EXPECT_FALSE(invalid_move.synchronous_handling_disabled()); | 2968 EXPECT_FALSE(invalid_move.synchronous_handling_disabled()); |
| 2969 EXPECT_TRUE(invalid_move.stopped_propagation()); | 2969 EXPECT_TRUE(invalid_move.stopped_propagation()); |
| 2970 } | 2970 } |
| 2971 | 2971 |
| 2972 } // namespace content | 2972 } // namespace content |
| OLD | NEW |