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/web_contents/web_contents_view_aura.h" | 5 #include "content/browser/web_contents/web_contents_view_aura.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <tuple> | 8 #include <tuple> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 EXPECT_EQ(1, GetCurrentIndex()); | 493 EXPECT_EQ(1, GetCurrentIndex()); |
494 ExecuteSyncJSFunction(main_frame, "navigate_next()"); | 494 ExecuteSyncJSFunction(main_frame, "navigate_next()"); |
495 EXPECT_EQ(2, GetCurrentIndex()); | 495 EXPECT_EQ(2, GetCurrentIndex()); |
496 web_contents->GetController().GoBack(); | 496 web_contents->GetController().GoBack(); |
497 EXPECT_EQ(1, GetCurrentIndex()); | 497 EXPECT_EQ(1, GetCurrentIndex()); |
498 | 498 |
499 aura::Window* content = web_contents->GetContentNativeView(); | 499 aura::Window* content = web_contents->GetContentNativeView(); |
500 ui::EventProcessor* dispatcher = content->GetHost()->event_processor(); | 500 ui::EventProcessor* dispatcher = content->GetHost()->event_processor(); |
501 gfx::Rect bounds = content->GetBoundsInRootWindow(); | 501 gfx::Rect bounds = content->GetBoundsInRootWindow(); |
502 | 502 |
503 base::TimeDelta timestamp = ui::EventTimeForNow(); | 503 base::TimeTicks timestamp = ui::EventTimeForNow(); |
504 ui::TouchEvent press( | 504 ui::TouchEvent press( |
505 ui::ET_TOUCH_PRESSED, | 505 ui::ET_TOUCH_PRESSED, |
506 gfx::Point(bounds.x() + bounds.width() / 2, bounds.y() + 5), 0, | 506 gfx::Point(bounds.x() + bounds.width() / 2, bounds.y() + 5), 0, |
507 timestamp); | 507 timestamp); |
508 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&press); | 508 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&press); |
509 ASSERT_FALSE(details.dispatcher_destroyed); | 509 ASSERT_FALSE(details.dispatcher_destroyed); |
510 EXPECT_EQ(1, GetCurrentIndex()); | 510 EXPECT_EQ(1, GetCurrentIndex()); |
511 | 511 |
512 timestamp += base::TimeDelta::FromMilliseconds(10); | 512 timestamp += base::TimeDelta::FromMilliseconds(10); |
513 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, | 513 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, |
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1026 ui::ScopedAnimationDurationScaleMode::FAST_DURATION); | 1026 ui::ScopedAnimationDurationScaleMode::FAST_DURATION); |
1027 | 1027 |
1028 aura::Window* content = web_contents->GetContentNativeView(); | 1028 aura::Window* content = web_contents->GetContentNativeView(); |
1029 ui::EventProcessor* dispatcher = content->GetHost()->event_processor(); | 1029 ui::EventProcessor* dispatcher = content->GetHost()->event_processor(); |
1030 gfx::Rect bounds = content->GetBoundsInRootWindow(); | 1030 gfx::Rect bounds = content->GetBoundsInRootWindow(); |
1031 | 1031 |
1032 // Overscroll horizontally. | 1032 // Overscroll horizontally. |
1033 { | 1033 { |
1034 int kXStep = bounds.width() / 10; | 1034 int kXStep = bounds.width() / 10; |
1035 gfx::Point location(bounds.right() - kXStep, bounds.y() + 5); | 1035 gfx::Point location(bounds.right() - kXStep, bounds.y() + 5); |
1036 base::TimeDelta timestamp = ui::EventTimeForNow(); | 1036 base::TimeTicks timestamp = ui::EventTimeForNow(); |
1037 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, location, 0, timestamp); | 1037 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, location, 0, timestamp); |
1038 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&press); | 1038 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&press); |
1039 ASSERT_FALSE(details.dispatcher_destroyed); | 1039 ASSERT_FALSE(details.dispatcher_destroyed); |
1040 WaitAFrame(); | 1040 WaitAFrame(); |
1041 location -= gfx::Vector2d(kXStep, 0); | 1041 location -= gfx::Vector2d(kXStep, 0); |
1042 timestamp += base::TimeDelta::FromMilliseconds(10); | 1042 timestamp += base::TimeDelta::FromMilliseconds(10); |
1043 | 1043 |
1044 while (location.x() > bounds.x() + kXStep) { | 1044 while (location.x() > bounds.x() + kXStep) { |
1045 ui::TouchEvent inc(ui::ET_TOUCH_MOVED, location, 0, timestamp); | 1045 ui::TouchEvent inc(ui::ET_TOUCH_MOVED, location, 0, timestamp); |
1046 details = dispatcher->OnEventFromSource(&inc); | 1046 details = dispatcher->OnEventFromSource(&inc); |
(...skipping 11 matching lines...) Expand all Loading... |
1058 EXPECT_EQ(0, tracker.num_overscroll_updates()); | 1058 EXPECT_EQ(0, tracker.num_overscroll_updates()); |
1059 EXPECT_FALSE(tracker.overscroll_completed()); | 1059 EXPECT_FALSE(tracker.overscroll_completed()); |
1060 } | 1060 } |
1061 | 1061 |
1062 // Overscroll vertically. | 1062 // Overscroll vertically. |
1063 { | 1063 { |
1064 tracker.Reset(); | 1064 tracker.Reset(); |
1065 | 1065 |
1066 int kYStep = bounds.height() / 10; | 1066 int kYStep = bounds.height() / 10; |
1067 gfx::Point location(bounds.x() + 10, bounds.y() + kYStep); | 1067 gfx::Point location(bounds.x() + 10, bounds.y() + kYStep); |
1068 base::TimeDelta timestamp = ui::EventTimeForNow(); | 1068 base::TimeTicks timestamp = ui::EventTimeForNow(); |
1069 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, location, 0, timestamp); | 1069 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, location, 0, timestamp); |
1070 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&press); | 1070 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&press); |
1071 ASSERT_FALSE(details.dispatcher_destroyed); | 1071 ASSERT_FALSE(details.dispatcher_destroyed); |
1072 WaitAFrame(); | 1072 WaitAFrame(); |
1073 location += gfx::Vector2d(0, kYStep); | 1073 location += gfx::Vector2d(0, kYStep); |
1074 timestamp += base::TimeDelta::FromMilliseconds(10); | 1074 timestamp += base::TimeDelta::FromMilliseconds(10); |
1075 | 1075 |
1076 while (location.y() < bounds.bottom() - kYStep) { | 1076 while (location.y() < bounds.bottom() - kYStep) { |
1077 ui::TouchEvent inc(ui::ET_TOUCH_MOVED, location, 0, timestamp); | 1077 ui::TouchEvent inc(ui::ET_TOUCH_MOVED, location, 0, timestamp); |
1078 details = dispatcher->OnEventFromSource(&inc); | 1078 details = dispatcher->OnEventFromSource(&inc); |
(...skipping 13 matching lines...) Expand all Loading... |
1092 } | 1092 } |
1093 | 1093 |
1094 // Start out overscrolling vertically, then switch directions and finish | 1094 // Start out overscrolling vertically, then switch directions and finish |
1095 // overscrolling horizontally. | 1095 // overscrolling horizontally. |
1096 { | 1096 { |
1097 tracker.Reset(); | 1097 tracker.Reset(); |
1098 | 1098 |
1099 int kXStep = bounds.width() / 10; | 1099 int kXStep = bounds.width() / 10; |
1100 int kYStep = bounds.height() / 10; | 1100 int kYStep = bounds.height() / 10; |
1101 gfx::Point location = bounds.origin() + gfx::Vector2d(0, kYStep); | 1101 gfx::Point location = bounds.origin() + gfx::Vector2d(0, kYStep); |
1102 base::TimeDelta timestamp = ui::EventTimeForNow(); | 1102 base::TimeTicks timestamp = ui::EventTimeForNow(); |
1103 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, location, 0, timestamp); | 1103 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, location, 0, timestamp); |
1104 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&press); | 1104 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&press); |
1105 ASSERT_FALSE(details.dispatcher_destroyed); | 1105 ASSERT_FALSE(details.dispatcher_destroyed); |
1106 WaitAFrame(); | 1106 WaitAFrame(); |
1107 location += gfx::Vector2d(0, kYStep); | 1107 location += gfx::Vector2d(0, kYStep); |
1108 timestamp += base::TimeDelta::FromMilliseconds(10); | 1108 timestamp += base::TimeDelta::FromMilliseconds(10); |
1109 | 1109 |
1110 for (size_t i = 0; i < 3; ++i) { | 1110 for (size_t i = 0; i < 3; ++i) { |
1111 ui::TouchEvent inc(ui::ET_TOUCH_MOVED, location, 0, timestamp); | 1111 ui::TouchEvent inc(ui::ET_TOUCH_MOVED, location, 0, timestamp); |
1112 details = dispatcher->OnEventFromSource(&inc); | 1112 details = dispatcher->OnEventFromSource(&inc); |
(...skipping 16 matching lines...) Expand all Loading... |
1129 details = dispatcher->OnEventFromSource(&release); | 1129 details = dispatcher->OnEventFromSource(&release); |
1130 ASSERT_FALSE(details.dispatcher_destroyed); | 1130 ASSERT_FALSE(details.dispatcher_destroyed); |
1131 WaitAFrame(); | 1131 WaitAFrame(); |
1132 | 1132 |
1133 EXPECT_LT(0, tracker.num_overscroll_updates()); | 1133 EXPECT_LT(0, tracker.num_overscroll_updates()); |
1134 EXPECT_FALSE(tracker.overscroll_completed()); | 1134 EXPECT_FALSE(tracker.overscroll_completed()); |
1135 } | 1135 } |
1136 } | 1136 } |
1137 | 1137 |
1138 } // namespace content | 1138 } // namespace content |
OLD | NEW |