Chromium Code Reviews| 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 832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 843 EXPECT_EQ(blink::WebInputEvent::TouchMove, view_->touch_event_.type); | 843 EXPECT_EQ(blink::WebInputEvent::TouchMove, view_->touch_event_.type); |
| 844 EXPECT_TRUE(view_->touch_event_.cancelable); | 844 EXPECT_TRUE(view_->touch_event_.cancelable); |
| 845 EXPECT_EQ(1U, view_->touch_event_.touchesLength); | 845 EXPECT_EQ(1U, view_->touch_event_.touchesLength); |
| 846 EXPECT_EQ(blink::WebTouchPoint::StateMoved, | 846 EXPECT_EQ(blink::WebTouchPoint::StateMoved, |
| 847 view_->touch_event_.touches[0].state); | 847 view_->touch_event_.touches[0].state); |
| 848 | 848 |
| 849 view_->OnTouchEvent(&release); | 849 view_->OnTouchEvent(&release); |
| 850 EXPECT_FALSE(release.handled()); | 850 EXPECT_FALSE(release.handled()); |
| 851 EXPECT_EQ(blink::WebInputEvent::TouchEnd, view_->touch_event_.type); | 851 EXPECT_EQ(blink::WebInputEvent::TouchEnd, view_->touch_event_.type); |
| 852 EXPECT_TRUE(view_->touch_event_.cancelable); | 852 EXPECT_TRUE(view_->touch_event_.cancelable); |
| 853 EXPECT_EQ(0U, view_->touch_event_.touchesLength); | 853 EXPECT_EQ(1U, view_->touch_event_.touchesLength); |
|
tdresser
2014/08/28 14:36:33
These changes are only necessary because the true
| |
| 854 | 854 |
| 855 // Now install some touch-event handlers and do the same steps. The touch | 855 // Now install some touch-event handlers and do the same steps. The touch |
| 856 // events should now be consumed. However, the touch-event state should be | 856 // events should now be consumed. However, the touch-event state should be |
| 857 // updated as before. | 857 // updated as before. |
| 858 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); | 858 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); |
| 859 EXPECT_TRUE(widget_host_->ShouldForwardTouchEvent()); | 859 EXPECT_TRUE(widget_host_->ShouldForwardTouchEvent()); |
| 860 | 860 |
| 861 view_->OnTouchEvent(&press); | 861 view_->OnTouchEvent(&press); |
| 862 EXPECT_TRUE(press.stopped_propagation()); | 862 EXPECT_TRUE(press.stopped_propagation()); |
| 863 EXPECT_EQ(blink::WebInputEvent::TouchStart, view_->touch_event_.type); | 863 EXPECT_EQ(blink::WebInputEvent::TouchStart, view_->touch_event_.type); |
| 864 EXPECT_TRUE(view_->touch_event_.cancelable); | 864 EXPECT_TRUE(view_->touch_event_.cancelable); |
| 865 EXPECT_EQ(1U, view_->touch_event_.touchesLength); | 865 EXPECT_EQ(1U, view_->touch_event_.touchesLength); |
| 866 EXPECT_EQ(blink::WebTouchPoint::StatePressed, | 866 EXPECT_EQ(blink::WebTouchPoint::StatePressed, |
| 867 view_->touch_event_.touches[0].state); | 867 view_->touch_event_.touches[0].state); |
| 868 | 868 |
| 869 view_->OnTouchEvent(&move); | 869 view_->OnTouchEvent(&move); |
| 870 EXPECT_TRUE(move.stopped_propagation()); | 870 EXPECT_TRUE(move.stopped_propagation()); |
| 871 EXPECT_EQ(blink::WebInputEvent::TouchMove, view_->touch_event_.type); | 871 EXPECT_EQ(blink::WebInputEvent::TouchMove, view_->touch_event_.type); |
| 872 EXPECT_TRUE(view_->touch_event_.cancelable); | 872 EXPECT_TRUE(view_->touch_event_.cancelable); |
| 873 EXPECT_EQ(1U, view_->touch_event_.touchesLength); | 873 EXPECT_EQ(1U, view_->touch_event_.touchesLength); |
| 874 EXPECT_EQ(blink::WebTouchPoint::StateMoved, | 874 EXPECT_EQ(blink::WebTouchPoint::StateMoved, |
| 875 view_->touch_event_.touches[0].state); | 875 view_->touch_event_.touches[0].state); |
| 876 | 876 |
| 877 view_->OnTouchEvent(&release); | 877 view_->OnTouchEvent(&release); |
| 878 EXPECT_TRUE(release.stopped_propagation()); | 878 EXPECT_TRUE(release.stopped_propagation()); |
| 879 EXPECT_EQ(blink::WebInputEvent::TouchEnd, view_->touch_event_.type); | 879 EXPECT_EQ(blink::WebInputEvent::TouchEnd, view_->touch_event_.type); |
| 880 EXPECT_TRUE(view_->touch_event_.cancelable); | 880 EXPECT_TRUE(view_->touch_event_.cancelable); |
| 881 EXPECT_EQ(0U, view_->touch_event_.touchesLength); | 881 EXPECT_EQ(1U, view_->touch_event_.touchesLength); |
| 882 | 882 |
| 883 // Now start a touch event, and remove the event-handlers before the release. | 883 // Now start a touch event, and remove the event-handlers before the release. |
| 884 view_->OnTouchEvent(&press); | 884 view_->OnTouchEvent(&press); |
| 885 EXPECT_TRUE(press.stopped_propagation()); | 885 EXPECT_TRUE(press.stopped_propagation()); |
| 886 EXPECT_EQ(blink::WebInputEvent::TouchStart, view_->touch_event_.type); | 886 EXPECT_EQ(blink::WebInputEvent::TouchStart, view_->touch_event_.type); |
| 887 EXPECT_EQ(1U, view_->touch_event_.touchesLength); | 887 EXPECT_EQ(1U, view_->touch_event_.touchesLength); |
| 888 EXPECT_EQ(blink::WebTouchPoint::StatePressed, | 888 EXPECT_EQ(blink::WebTouchPoint::StatePressed, |
| 889 view_->touch_event_.touches[0].state); | 889 view_->touch_event_.touches[0].state); |
| 890 | 890 |
| 891 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, false)); | 891 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, false)); |
| 892 EXPECT_FALSE(widget_host_->ShouldForwardTouchEvent()); | 892 EXPECT_FALSE(widget_host_->ShouldForwardTouchEvent()); |
| 893 | 893 |
| 894 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(20, 20), 0, | 894 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(20, 20), 0, |
| 895 base::Time::NowFromSystemTime() - base::Time()); | 895 base::Time::NowFromSystemTime() - base::Time()); |
| 896 view_->OnTouchEvent(&move2); | 896 view_->OnTouchEvent(&move2); |
| 897 EXPECT_FALSE(move2.handled()); | 897 EXPECT_FALSE(move2.handled()); |
| 898 EXPECT_EQ(blink::WebInputEvent::TouchMove, view_->touch_event_.type); | 898 EXPECT_EQ(blink::WebInputEvent::TouchMove, view_->touch_event_.type); |
| 899 EXPECT_EQ(1U, view_->touch_event_.touchesLength); | 899 EXPECT_EQ(1U, view_->touch_event_.touchesLength); |
| 900 EXPECT_EQ(blink::WebTouchPoint::StateMoved, | 900 EXPECT_EQ(blink::WebTouchPoint::StateMoved, |
| 901 view_->touch_event_.touches[0].state); | 901 view_->touch_event_.touches[0].state); |
| 902 | 902 |
| 903 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(20, 20), 0, | 903 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(20, 20), 0, |
| 904 base::Time::NowFromSystemTime() - base::Time()); | 904 base::Time::NowFromSystemTime() - base::Time()); |
| 905 view_->OnTouchEvent(&release2); | 905 view_->OnTouchEvent(&release2); |
| 906 EXPECT_FALSE(release2.handled()); | 906 EXPECT_FALSE(release2.handled()); |
| 907 EXPECT_EQ(blink::WebInputEvent::TouchEnd, view_->touch_event_.type); | 907 EXPECT_EQ(blink::WebInputEvent::TouchEnd, view_->touch_event_.type); |
| 908 EXPECT_EQ(0U, view_->touch_event_.touchesLength); | 908 EXPECT_EQ(1U, view_->touch_event_.touchesLength); |
| 909 } | 909 } |
| 910 | 910 |
| 911 // Checks that touch-events are queued properly when there is a touch-event | 911 // Checks that touch-events are queued properly when there is a touch-event |
| 912 // handler on the page. | 912 // handler on the page. |
| 913 TEST_F(RenderWidgetHostViewAuraTest, TouchEventSyncAsync) { | 913 TEST_F(RenderWidgetHostViewAuraTest, TouchEventSyncAsync) { |
| 914 view_->InitAsChild(NULL); | 914 view_->InitAsChild(NULL); |
| 915 view_->Show(); | 915 view_->Show(); |
| 916 | 916 |
| 917 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); | 917 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); |
| 918 EXPECT_TRUE(widget_host_->ShouldForwardTouchEvent()); | 918 EXPECT_TRUE(widget_host_->ShouldForwardTouchEvent()); |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 949 view_->OnTouchEvent(&move); | 949 view_->OnTouchEvent(&move); |
| 950 EXPECT_TRUE(move.stopped_propagation()); | 950 EXPECT_TRUE(move.stopped_propagation()); |
| 951 EXPECT_EQ(blink::WebInputEvent::TouchMove, view_->touch_event_.type); | 951 EXPECT_EQ(blink::WebInputEvent::TouchMove, view_->touch_event_.type); |
| 952 EXPECT_EQ(1U, view_->touch_event_.touchesLength); | 952 EXPECT_EQ(1U, view_->touch_event_.touchesLength); |
| 953 EXPECT_EQ(blink::WebTouchPoint::StateMoved, | 953 EXPECT_EQ(blink::WebTouchPoint::StateMoved, |
| 954 view_->touch_event_.touches[0].state); | 954 view_->touch_event_.touches[0].state); |
| 955 | 955 |
| 956 view_->OnTouchEvent(&release); | 956 view_->OnTouchEvent(&release); |
| 957 EXPECT_TRUE(release.stopped_propagation()); | 957 EXPECT_TRUE(release.stopped_propagation()); |
| 958 EXPECT_EQ(blink::WebInputEvent::TouchEnd, view_->touch_event_.type); | 958 EXPECT_EQ(blink::WebInputEvent::TouchEnd, view_->touch_event_.type); |
| 959 EXPECT_EQ(0U, view_->touch_event_.touchesLength); | 959 EXPECT_EQ(1U, view_->touch_event_.touchesLength); |
| 960 } | 960 } |
| 961 | 961 |
| 962 TEST_F(RenderWidgetHostViewAuraTest, PhysicalBackingSizeWithScale) { | 962 TEST_F(RenderWidgetHostViewAuraTest, PhysicalBackingSizeWithScale) { |
| 963 view_->InitAsChild(NULL); | 963 view_->InitAsChild(NULL); |
| 964 aura::client::ParentWindowWithContext( | 964 aura::client::ParentWindowWithContext( |
| 965 view_->GetNativeView(), | 965 view_->GetNativeView(), |
| 966 parent_view_->GetNativeView()->GetRootWindow(), | 966 parent_view_->GetNativeView()->GetRootWindow(), |
| 967 gfx::Rect()); | 967 gfx::Rect()); |
| 968 sink_->ClearMessages(); | 968 sink_->ClearMessages(); |
| 969 view_->SetSize(gfx::Size(100, 100)); | 969 view_->SetSize(gfx::Size(100, 100)); |
| (...skipping 1777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2747 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->completed_mode()); | 2747 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->completed_mode()); |
| 2748 | 2748 |
| 2749 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, | 2749 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, |
| 2750 blink::WebGestureDeviceTouchscreen); | 2750 blink::WebGestureDeviceTouchscreen); |
| 2751 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); | 2751 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); |
| 2752 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->completed_mode()); | 2752 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->completed_mode()); |
| 2753 EXPECT_EQ(3U, sink_->message_count()); | 2753 EXPECT_EQ(3U, sink_->message_count()); |
| 2754 } | 2754 } |
| 2755 | 2755 |
| 2756 } // namespace content | 2756 } // namespace content |
| OLD | NEW |