| 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 "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 web_contents->GetController().GoBack(); | 486 web_contents->GetController().GoBack(); |
| 487 EXPECT_EQ(1, GetCurrentIndex()); | 487 EXPECT_EQ(1, GetCurrentIndex()); |
| 488 | 488 |
| 489 aura::Window* content = web_contents->GetContentNativeView(); | 489 aura::Window* content = web_contents->GetContentNativeView(); |
| 490 ui::EventProcessor* dispatcher = content->GetHost()->event_processor(); | 490 ui::EventProcessor* dispatcher = content->GetHost()->event_processor(); |
| 491 gfx::Rect bounds = content->GetBoundsInRootWindow(); | 491 gfx::Rect bounds = content->GetBoundsInRootWindow(); |
| 492 | 492 |
| 493 base::TimeDelta timestamp = ui::EventTimeForNow(); | 493 base::TimeDelta timestamp = ui::EventTimeForNow(); |
| 494 ui::TouchEvent press( | 494 ui::TouchEvent press( |
| 495 ui::ET_TOUCH_PRESSED, | 495 ui::ET_TOUCH_PRESSED, |
| 496 gfx::PointF(bounds.x() + bounds.width() / 2.f, bounds.y() + 5.f), 0, | 496 gfx::Point(bounds.x() + bounds.width() / 2, bounds.y() + 5), 0, |
| 497 timestamp); | 497 timestamp); |
| 498 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&press); | 498 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&press); |
| 499 ASSERT_FALSE(details.dispatcher_destroyed); | 499 ASSERT_FALSE(details.dispatcher_destroyed); |
| 500 EXPECT_EQ(1, GetCurrentIndex()); | 500 EXPECT_EQ(1, GetCurrentIndex()); |
| 501 | 501 |
| 502 timestamp += base::TimeDelta::FromMilliseconds(10); | 502 timestamp += base::TimeDelta::FromMilliseconds(10); |
| 503 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, | 503 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, |
| 504 gfx::PointF(bounds.right() - 10.f, bounds.y() + 5.f), 0, | 504 gfx::Point(bounds.right() - 10, bounds.y() + 5), 0, |
| 505 timestamp); | 505 timestamp); |
| 506 details = dispatcher->OnEventFromSource(&move1); | 506 details = dispatcher->OnEventFromSource(&move1); |
| 507 ASSERT_FALSE(details.dispatcher_destroyed); | 507 ASSERT_FALSE(details.dispatcher_destroyed); |
| 508 EXPECT_EQ(1, GetCurrentIndex()); | 508 EXPECT_EQ(1, GetCurrentIndex()); |
| 509 | 509 |
| 510 // Swipe back from the right edge, back to the left edge, back to the right | 510 // Swipe back from the right edge, back to the left edge, back to the right |
| 511 // edge. | 511 // edge. |
| 512 | 512 |
| 513 for (int x = bounds.right() - 10; x >= bounds.x() + 10; x-= 10) { | 513 for (int x = bounds.right() - 10; x >= bounds.x() + 10; x-= 10) { |
| 514 timestamp += base::TimeDelta::FromMilliseconds(10); | 514 timestamp += base::TimeDelta::FromMilliseconds(10); |
| 515 ui::TouchEvent inc(ui::ET_TOUCH_MOVED, gfx::PointF(x, bounds.y() + 5.f), 0, | 515 ui::TouchEvent inc(ui::ET_TOUCH_MOVED, gfx::Point(x, bounds.y() + 5), 0, |
| 516 timestamp); | 516 timestamp); |
| 517 details = dispatcher->OnEventFromSource(&inc); | 517 details = dispatcher->OnEventFromSource(&inc); |
| 518 ASSERT_FALSE(details.dispatcher_destroyed); | 518 ASSERT_FALSE(details.dispatcher_destroyed); |
| 519 EXPECT_EQ(1, GetCurrentIndex()); | 519 EXPECT_EQ(1, GetCurrentIndex()); |
| 520 } | 520 } |
| 521 | 521 |
| 522 for (int x = bounds.x() + 10; x <= bounds.width() - 10; x+= 10) { | 522 for (int x = bounds.x() + 10; x <= bounds.width() - 10; x+= 10) { |
| 523 timestamp += base::TimeDelta::FromMilliseconds(10); | 523 timestamp += base::TimeDelta::FromMilliseconds(10); |
| 524 ui::TouchEvent inc(ui::ET_TOUCH_MOVED, gfx::PointF(x, bounds.y() + 5.f), 0, | 524 ui::TouchEvent inc(ui::ET_TOUCH_MOVED, gfx::Point(x, bounds.y() + 5), 0, |
| 525 timestamp); | 525 timestamp); |
| 526 details = dispatcher->OnEventFromSource(&inc); | 526 details = dispatcher->OnEventFromSource(&inc); |
| 527 ASSERT_FALSE(details.dispatcher_destroyed); | 527 ASSERT_FALSE(details.dispatcher_destroyed); |
| 528 EXPECT_EQ(1, GetCurrentIndex()); | 528 EXPECT_EQ(1, GetCurrentIndex()); |
| 529 } | 529 } |
| 530 | 530 |
| 531 for (int x = bounds.width() - 10; x >= bounds.x() + 10; x-= 10) { | 531 for (int x = bounds.width() - 10; x >= bounds.x() + 10; x-= 10) { |
| 532 timestamp += base::TimeDelta::FromMilliseconds(10); | 532 timestamp += base::TimeDelta::FromMilliseconds(10); |
| 533 ui::TouchEvent inc(ui::ET_TOUCH_MOVED, gfx::PointF(x, bounds.y() + 5.f), 0, | 533 ui::TouchEvent inc(ui::ET_TOUCH_MOVED, gfx::Point(x, bounds.y() + 5), 0, |
| 534 timestamp); | 534 timestamp); |
| 535 details = dispatcher->OnEventFromSource(&inc); | 535 details = dispatcher->OnEventFromSource(&inc); |
| 536 ASSERT_FALSE(details.dispatcher_destroyed); | 536 ASSERT_FALSE(details.dispatcher_destroyed); |
| 537 EXPECT_EQ(1, GetCurrentIndex()); | 537 EXPECT_EQ(1, GetCurrentIndex()); |
| 538 } | 538 } |
| 539 | 539 |
| 540 // Do not end the overscroll sequence. | 540 // Do not end the overscroll sequence. |
| 541 } | 541 } |
| 542 | 542 |
| 543 // Tests that the page has has a screenshot when navigation happens: | 543 // Tests that the page has has a screenshot when navigation happens: |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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::TimeDelta timestamp = ui::EventTimeForNow(); |
| 1037 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::PointF(location), 0, | 1037 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, location, 0, timestamp); |
| 1038 timestamp); | |
| 1039 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&press); | 1038 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&press); |
| 1040 ASSERT_FALSE(details.dispatcher_destroyed); | 1039 ASSERT_FALSE(details.dispatcher_destroyed); |
| 1041 WaitAFrame(); | 1040 WaitAFrame(); |
| 1042 location -= gfx::Vector2d(kXStep, 0); | 1041 location -= gfx::Vector2d(kXStep, 0); |
| 1043 timestamp += base::TimeDelta::FromMilliseconds(10); | 1042 timestamp += base::TimeDelta::FromMilliseconds(10); |
| 1044 | 1043 |
| 1045 while (location.x() > bounds.x() + kXStep) { | 1044 while (location.x() > bounds.x() + kXStep) { |
| 1046 ui::TouchEvent inc(ui::ET_TOUCH_MOVED, gfx::PointF(location), 0, | 1045 ui::TouchEvent inc(ui::ET_TOUCH_MOVED, location, 0, timestamp); |
| 1047 timestamp); | |
| 1048 details = dispatcher->OnEventFromSource(&inc); | 1046 details = dispatcher->OnEventFromSource(&inc); |
| 1049 ASSERT_FALSE(details.dispatcher_destroyed); | 1047 ASSERT_FALSE(details.dispatcher_destroyed); |
| 1050 WaitAFrame(); | 1048 WaitAFrame(); |
| 1051 location -= gfx::Vector2d(10, 0); | 1049 location -= gfx::Vector2d(10, 0); |
| 1052 timestamp += base::TimeDelta::FromMilliseconds(10); | 1050 timestamp += base::TimeDelta::FromMilliseconds(10); |
| 1053 } | 1051 } |
| 1054 | 1052 |
| 1055 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::PointF(location), 0, | 1053 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, location, 0, timestamp); |
| 1056 timestamp); | |
| 1057 details = dispatcher->OnEventFromSource(&release); | 1054 details = dispatcher->OnEventFromSource(&release); |
| 1058 ASSERT_FALSE(details.dispatcher_destroyed); | 1055 ASSERT_FALSE(details.dispatcher_destroyed); |
| 1059 WaitAFrame(); | 1056 WaitAFrame(); |
| 1060 | 1057 |
| 1061 EXPECT_EQ(0, tracker.num_overscroll_updates()); | 1058 EXPECT_EQ(0, tracker.num_overscroll_updates()); |
| 1062 EXPECT_FALSE(tracker.overscroll_completed()); | 1059 EXPECT_FALSE(tracker.overscroll_completed()); |
| 1063 } | 1060 } |
| 1064 | 1061 |
| 1065 // Overscroll vertically. | 1062 // Overscroll vertically. |
| 1066 { | 1063 { |
| 1067 tracker.Reset(); | 1064 tracker.Reset(); |
| 1068 | 1065 |
| 1069 int kYStep = bounds.height() / 10; | 1066 int kYStep = bounds.height() / 10; |
| 1070 gfx::Point location(bounds.x() + 10, bounds.y() + kYStep); | 1067 gfx::Point location(bounds.x() + 10, bounds.y() + kYStep); |
| 1071 base::TimeDelta timestamp = ui::EventTimeForNow(); | 1068 base::TimeDelta timestamp = ui::EventTimeForNow(); |
| 1072 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::PointF(location), 0, | 1069 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, location, 0, timestamp); |
| 1073 timestamp); | |
| 1074 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&press); | 1070 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&press); |
| 1075 ASSERT_FALSE(details.dispatcher_destroyed); | 1071 ASSERT_FALSE(details.dispatcher_destroyed); |
| 1076 WaitAFrame(); | 1072 WaitAFrame(); |
| 1077 location += gfx::Vector2d(0, kYStep); | 1073 location += gfx::Vector2d(0, kYStep); |
| 1078 timestamp += base::TimeDelta::FromMilliseconds(10); | 1074 timestamp += base::TimeDelta::FromMilliseconds(10); |
| 1079 | 1075 |
| 1080 while (location.y() < bounds.bottom() - kYStep) { | 1076 while (location.y() < bounds.bottom() - kYStep) { |
| 1081 ui::TouchEvent inc(ui::ET_TOUCH_MOVED, gfx::PointF(location), 0, | 1077 ui::TouchEvent inc(ui::ET_TOUCH_MOVED, location, 0, timestamp); |
| 1082 timestamp); | |
| 1083 details = dispatcher->OnEventFromSource(&inc); | 1078 details = dispatcher->OnEventFromSource(&inc); |
| 1084 ASSERT_FALSE(details.dispatcher_destroyed); | 1079 ASSERT_FALSE(details.dispatcher_destroyed); |
| 1085 WaitAFrame(); | 1080 WaitAFrame(); |
| 1086 location += gfx::Vector2d(0, kYStep); | 1081 location += gfx::Vector2d(0, kYStep); |
| 1087 timestamp += base::TimeDelta::FromMilliseconds(10); | 1082 timestamp += base::TimeDelta::FromMilliseconds(10); |
| 1088 } | 1083 } |
| 1089 | 1084 |
| 1090 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::PointF(location), 0, | 1085 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, location, 0, timestamp); |
| 1091 timestamp); | |
| 1092 details = dispatcher->OnEventFromSource(&release); | 1086 details = dispatcher->OnEventFromSource(&release); |
| 1093 ASSERT_FALSE(details.dispatcher_destroyed); | 1087 ASSERT_FALSE(details.dispatcher_destroyed); |
| 1094 WaitAFrame(); | 1088 WaitAFrame(); |
| 1095 | 1089 |
| 1096 EXPECT_LT(0, tracker.num_overscroll_updates()); | 1090 EXPECT_LT(0, tracker.num_overscroll_updates()); |
| 1097 EXPECT_TRUE(tracker.overscroll_completed()); | 1091 EXPECT_TRUE(tracker.overscroll_completed()); |
| 1098 } | 1092 } |
| 1099 | 1093 |
| 1100 // Start out overscrolling vertically, then switch directions and finish | 1094 // Start out overscrolling vertically, then switch directions and finish |
| 1101 // overscrolling horizontally. | 1095 // overscrolling horizontally. |
| 1102 { | 1096 { |
| 1103 tracker.Reset(); | 1097 tracker.Reset(); |
| 1104 | 1098 |
| 1105 int kXStep = bounds.width() / 10; | 1099 int kXStep = bounds.width() / 10; |
| 1106 int kYStep = bounds.height() / 10; | 1100 int kYStep = bounds.height() / 10; |
| 1107 gfx::Point location = bounds.origin() + gfx::Vector2d(0, kYStep); | 1101 gfx::Point location = bounds.origin() + gfx::Vector2d(0, kYStep); |
| 1108 base::TimeDelta timestamp = ui::EventTimeForNow(); | 1102 base::TimeDelta timestamp = ui::EventTimeForNow(); |
| 1109 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::PointF(location), 0, | 1103 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, location, 0, timestamp); |
| 1110 timestamp); | |
| 1111 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&press); | 1104 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&press); |
| 1112 ASSERT_FALSE(details.dispatcher_destroyed); | 1105 ASSERT_FALSE(details.dispatcher_destroyed); |
| 1113 WaitAFrame(); | 1106 WaitAFrame(); |
| 1114 location += gfx::Vector2d(0, kYStep); | 1107 location += gfx::Vector2d(0, kYStep); |
| 1115 timestamp += base::TimeDelta::FromMilliseconds(10); | 1108 timestamp += base::TimeDelta::FromMilliseconds(10); |
| 1116 | 1109 |
| 1117 for (size_t i = 0; i < 3; ++i) { | 1110 for (size_t i = 0; i < 3; ++i) { |
| 1118 ui::TouchEvent inc(ui::ET_TOUCH_MOVED, gfx::PointF(location), 0, | 1111 ui::TouchEvent inc(ui::ET_TOUCH_MOVED, location, 0, timestamp); |
| 1119 timestamp); | |
| 1120 details = dispatcher->OnEventFromSource(&inc); | 1112 details = dispatcher->OnEventFromSource(&inc); |
| 1121 ASSERT_FALSE(details.dispatcher_destroyed); | 1113 ASSERT_FALSE(details.dispatcher_destroyed); |
| 1122 WaitAFrame(); | 1114 WaitAFrame(); |
| 1123 location += gfx::Vector2d(0, kYStep); | 1115 location += gfx::Vector2d(0, kYStep); |
| 1124 timestamp += base::TimeDelta::FromMilliseconds(10); | 1116 timestamp += base::TimeDelta::FromMilliseconds(10); |
| 1125 } | 1117 } |
| 1126 | 1118 |
| 1127 while (location.x() < bounds.right() - kXStep) { | 1119 while (location.x() < bounds.right() - kXStep) { |
| 1128 ui::TouchEvent inc(ui::ET_TOUCH_MOVED, gfx::PointF(location), 0, | 1120 ui::TouchEvent inc(ui::ET_TOUCH_MOVED, location, 0, timestamp); |
| 1129 timestamp); | |
| 1130 details = dispatcher->OnEventFromSource(&inc); | 1121 details = dispatcher->OnEventFromSource(&inc); |
| 1131 ASSERT_FALSE(details.dispatcher_destroyed); | 1122 ASSERT_FALSE(details.dispatcher_destroyed); |
| 1132 WaitAFrame(); | 1123 WaitAFrame(); |
| 1133 location += gfx::Vector2d(kXStep, 0); | 1124 location += gfx::Vector2d(kXStep, 0); |
| 1134 timestamp += base::TimeDelta::FromMilliseconds(10); | 1125 timestamp += base::TimeDelta::FromMilliseconds(10); |
| 1135 } | 1126 } |
| 1136 | 1127 |
| 1137 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::PointF(location), 0, | 1128 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, location, 0, timestamp); |
| 1138 timestamp); | |
| 1139 details = dispatcher->OnEventFromSource(&release); | 1129 details = dispatcher->OnEventFromSource(&release); |
| 1140 ASSERT_FALSE(details.dispatcher_destroyed); | 1130 ASSERT_FALSE(details.dispatcher_destroyed); |
| 1141 WaitAFrame(); | 1131 WaitAFrame(); |
| 1142 | 1132 |
| 1143 EXPECT_LT(0, tracker.num_overscroll_updates()); | 1133 EXPECT_LT(0, tracker.num_overscroll_updates()); |
| 1144 EXPECT_FALSE(tracker.overscroll_completed()); | 1134 EXPECT_FALSE(tracker.overscroll_completed()); |
| 1145 } | 1135 } |
| 1146 } | 1136 } |
| 1147 | 1137 |
| 1148 } // namespace content | 1138 } // namespace content |
| OLD | NEW |