Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(418)

Side by Side Diff: content/browser/web_contents/web_contents_view_aura_browsertest.cc

Issue 1372253002: gfx: Make conversions from gfx::Point to PointF explicit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: pointfconvert-gfx: . Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 ExecuteSyncJSFunction(main_frame, "navigate_next()"); 483 ExecuteSyncJSFunction(main_frame, "navigate_next()");
484 EXPECT_EQ(2, GetCurrentIndex()); 484 EXPECT_EQ(2, GetCurrentIndex());
485 web_contents->GetController().GoBack(); 485 web_contents->GetController().GoBack();
486 EXPECT_EQ(1, GetCurrentIndex()); 486 EXPECT_EQ(1, GetCurrentIndex());
487 487
488 aura::Window* content = web_contents->GetContentNativeView(); 488 aura::Window* content = web_contents->GetContentNativeView();
489 ui::EventProcessor* dispatcher = content->GetHost()->event_processor(); 489 ui::EventProcessor* dispatcher = content->GetHost()->event_processor();
490 gfx::Rect bounds = content->GetBoundsInRootWindow(); 490 gfx::Rect bounds = content->GetBoundsInRootWindow();
491 491
492 base::TimeDelta timestamp = ui::EventTimeForNow(); 492 base::TimeDelta timestamp = ui::EventTimeForNow();
493 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, 493 ui::TouchEvent press(
494 gfx::Point(bounds.x() + bounds.width() / 2, bounds.y() + 5), 494 ui::ET_TOUCH_PRESSED,
495 0, timestamp); 495 gfx::PointF(bounds.x() + bounds.width() / 2.f, bounds.y() + 5.f), 0,
496 timestamp);
496 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&press); 497 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&press);
497 ASSERT_FALSE(details.dispatcher_destroyed); 498 ASSERT_FALSE(details.dispatcher_destroyed);
498 EXPECT_EQ(1, GetCurrentIndex()); 499 EXPECT_EQ(1, GetCurrentIndex());
499 500
500 timestamp += base::TimeDelta::FromMilliseconds(10); 501 timestamp += base::TimeDelta::FromMilliseconds(10);
501 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, 502 ui::TouchEvent move1(ui::ET_TOUCH_MOVED,
502 gfx::Point(bounds.right() - 10, bounds.y() + 5), 503 gfx::PointF(bounds.right() - 10.f, bounds.y() + 5.f), 0,
503 0, timestamp); 504 timestamp);
504 details = dispatcher->OnEventFromSource(&move1); 505 details = dispatcher->OnEventFromSource(&move1);
505 ASSERT_FALSE(details.dispatcher_destroyed); 506 ASSERT_FALSE(details.dispatcher_destroyed);
506 EXPECT_EQ(1, GetCurrentIndex()); 507 EXPECT_EQ(1, GetCurrentIndex());
507 508
508 // Swipe back from the right edge, back to the left edge, back to the right 509 // Swipe back from the right edge, back to the left edge, back to the right
509 // edge. 510 // edge.
510 511
511 for (int x = bounds.right() - 10; x >= bounds.x() + 10; x-= 10) { 512 for (int x = bounds.right() - 10; x >= bounds.x() + 10; x-= 10) {
512 timestamp += base::TimeDelta::FromMilliseconds(10); 513 timestamp += base::TimeDelta::FromMilliseconds(10);
513 ui::TouchEvent inc(ui::ET_TOUCH_MOVED, 514 ui::TouchEvent inc(ui::ET_TOUCH_MOVED, gfx::PointF(x, bounds.y() + 5.f), 0,
514 gfx::Point(x, bounds.y() + 5), 515 timestamp);
515 0, timestamp);
516 details = dispatcher->OnEventFromSource(&inc); 516 details = dispatcher->OnEventFromSource(&inc);
517 ASSERT_FALSE(details.dispatcher_destroyed); 517 ASSERT_FALSE(details.dispatcher_destroyed);
518 EXPECT_EQ(1, GetCurrentIndex()); 518 EXPECT_EQ(1, GetCurrentIndex());
519 } 519 }
520 520
521 for (int x = bounds.x() + 10; x <= bounds.width() - 10; x+= 10) { 521 for (int x = bounds.x() + 10; x <= bounds.width() - 10; x+= 10) {
522 timestamp += base::TimeDelta::FromMilliseconds(10); 522 timestamp += base::TimeDelta::FromMilliseconds(10);
523 ui::TouchEvent inc(ui::ET_TOUCH_MOVED, 523 ui::TouchEvent inc(ui::ET_TOUCH_MOVED, gfx::PointF(x, bounds.y() + 5.f), 0,
524 gfx::Point(x, bounds.y() + 5), 524 timestamp);
525 0, timestamp);
526 details = dispatcher->OnEventFromSource(&inc); 525 details = dispatcher->OnEventFromSource(&inc);
527 ASSERT_FALSE(details.dispatcher_destroyed); 526 ASSERT_FALSE(details.dispatcher_destroyed);
528 EXPECT_EQ(1, GetCurrentIndex()); 527 EXPECT_EQ(1, GetCurrentIndex());
529 } 528 }
530 529
531 for (int x = bounds.width() - 10; x >= bounds.x() + 10; x-= 10) { 530 for (int x = bounds.width() - 10; x >= bounds.x() + 10; x-= 10) {
532 timestamp += base::TimeDelta::FromMilliseconds(10); 531 timestamp += base::TimeDelta::FromMilliseconds(10);
533 ui::TouchEvent inc(ui::ET_TOUCH_MOVED, 532 ui::TouchEvent inc(ui::ET_TOUCH_MOVED, gfx::PointF(x, bounds.y() + 5.f), 0,
534 gfx::Point(x, bounds.y() + 5), 533 timestamp);
535 0, timestamp);
536 details = dispatcher->OnEventFromSource(&inc); 534 details = dispatcher->OnEventFromSource(&inc);
537 ASSERT_FALSE(details.dispatcher_destroyed); 535 ASSERT_FALSE(details.dispatcher_destroyed);
538 EXPECT_EQ(1, GetCurrentIndex()); 536 EXPECT_EQ(1, GetCurrentIndex());
539 } 537 }
540 538
541 // Do not end the overscroll sequence. 539 // Do not end the overscroll sequence.
542 } 540 }
543 541
544 // Tests that the page has has a screenshot when navigation happens: 542 // Tests that the page has has a screenshot when navigation happens:
545 // - from within the page (from a JS function) 543 // - from within the page (from a JS function)
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
1028 1026
1029 aura::Window* content = web_contents->GetContentNativeView(); 1027 aura::Window* content = web_contents->GetContentNativeView();
1030 ui::EventProcessor* dispatcher = content->GetHost()->event_processor(); 1028 ui::EventProcessor* dispatcher = content->GetHost()->event_processor();
1031 gfx::Rect bounds = content->GetBoundsInRootWindow(); 1029 gfx::Rect bounds = content->GetBoundsInRootWindow();
1032 1030
1033 // Overscroll horizontally. 1031 // Overscroll horizontally.
1034 { 1032 {
1035 int kXStep = bounds.width() / 10; 1033 int kXStep = bounds.width() / 10;
1036 gfx::Point location(bounds.right() - kXStep, bounds.y() + 5); 1034 gfx::Point location(bounds.right() - kXStep, bounds.y() + 5);
1037 base::TimeDelta timestamp = ui::EventTimeForNow(); 1035 base::TimeDelta timestamp = ui::EventTimeForNow();
1038 ui::TouchEvent press( 1036 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::PointF(location), 0,
1039 ui::ET_TOUCH_PRESSED, 1037 timestamp);
1040 location,
1041 0,
1042 timestamp);
1043 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&press); 1038 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&press);
1044 ASSERT_FALSE(details.dispatcher_destroyed); 1039 ASSERT_FALSE(details.dispatcher_destroyed);
1045 WaitAFrame(); 1040 WaitAFrame();
1046 location -= gfx::Vector2d(kXStep, 0); 1041 location -= gfx::Vector2d(kXStep, 0);
1047 timestamp += base::TimeDelta::FromMilliseconds(10); 1042 timestamp += base::TimeDelta::FromMilliseconds(10);
1048 1043
1049 while (location.x() > bounds.x() + kXStep) { 1044 while (location.x() > bounds.x() + kXStep) {
1050 ui::TouchEvent inc(ui::ET_TOUCH_MOVED, location, 0, timestamp); 1045 ui::TouchEvent inc(ui::ET_TOUCH_MOVED, gfx::PointF(location), 0,
1046 timestamp);
1051 details = dispatcher->OnEventFromSource(&inc); 1047 details = dispatcher->OnEventFromSource(&inc);
1052 ASSERT_FALSE(details.dispatcher_destroyed); 1048 ASSERT_FALSE(details.dispatcher_destroyed);
1053 WaitAFrame(); 1049 WaitAFrame();
1054 location -= gfx::Vector2d(10, 0); 1050 location -= gfx::Vector2d(10, 0);
1055 timestamp += base::TimeDelta::FromMilliseconds(10); 1051 timestamp += base::TimeDelta::FromMilliseconds(10);
1056 } 1052 }
1057 1053
1058 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, location, 0, timestamp); 1054 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::PointF(location), 0,
1055 timestamp);
1059 details = dispatcher->OnEventFromSource(&release); 1056 details = dispatcher->OnEventFromSource(&release);
1060 ASSERT_FALSE(details.dispatcher_destroyed); 1057 ASSERT_FALSE(details.dispatcher_destroyed);
1061 WaitAFrame(); 1058 WaitAFrame();
1062 1059
1063 EXPECT_EQ(0, tracker.num_overscroll_updates()); 1060 EXPECT_EQ(0, tracker.num_overscroll_updates());
1064 EXPECT_FALSE(tracker.overscroll_completed()); 1061 EXPECT_FALSE(tracker.overscroll_completed());
1065 } 1062 }
1066 1063
1067 // Overscroll vertically. 1064 // Overscroll vertically.
1068 { 1065 {
1069 tracker.Reset(); 1066 tracker.Reset();
1070 1067
1071 int kYStep = bounds.height() / 10; 1068 int kYStep = bounds.height() / 10;
1072 gfx::Point location(bounds.x() + 10, bounds.y() + kYStep); 1069 gfx::Point location(bounds.x() + 10, bounds.y() + kYStep);
1073 base::TimeDelta timestamp = ui::EventTimeForNow(); 1070 base::TimeDelta timestamp = ui::EventTimeForNow();
1074 ui::TouchEvent press( 1071 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::PointF(location), 0,
1075 ui::ET_TOUCH_PRESSED, 1072 timestamp);
1076 location,
1077 0,
1078 timestamp);
1079 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&press); 1073 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&press);
1080 ASSERT_FALSE(details.dispatcher_destroyed); 1074 ASSERT_FALSE(details.dispatcher_destroyed);
1081 WaitAFrame(); 1075 WaitAFrame();
1082 location += gfx::Vector2d(0, kYStep); 1076 location += gfx::Vector2d(0, kYStep);
1083 timestamp += base::TimeDelta::FromMilliseconds(10); 1077 timestamp += base::TimeDelta::FromMilliseconds(10);
1084 1078
1085 while (location.y() < bounds.bottom() - kYStep) { 1079 while (location.y() < bounds.bottom() - kYStep) {
1086 ui::TouchEvent inc(ui::ET_TOUCH_MOVED, location, 0, timestamp); 1080 ui::TouchEvent inc(ui::ET_TOUCH_MOVED, gfx::PointF(location), 0,
1081 timestamp);
1087 details = dispatcher->OnEventFromSource(&inc); 1082 details = dispatcher->OnEventFromSource(&inc);
1088 ASSERT_FALSE(details.dispatcher_destroyed); 1083 ASSERT_FALSE(details.dispatcher_destroyed);
1089 WaitAFrame(); 1084 WaitAFrame();
1090 location += gfx::Vector2d(0, kYStep); 1085 location += gfx::Vector2d(0, kYStep);
1091 timestamp += base::TimeDelta::FromMilliseconds(10); 1086 timestamp += base::TimeDelta::FromMilliseconds(10);
1092 } 1087 }
1093 1088
1094 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, location, 0, timestamp); 1089 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::PointF(location), 0,
1090 timestamp);
1095 details = dispatcher->OnEventFromSource(&release); 1091 details = dispatcher->OnEventFromSource(&release);
1096 ASSERT_FALSE(details.dispatcher_destroyed); 1092 ASSERT_FALSE(details.dispatcher_destroyed);
1097 WaitAFrame(); 1093 WaitAFrame();
1098 1094
1099 EXPECT_LT(0, tracker.num_overscroll_updates()); 1095 EXPECT_LT(0, tracker.num_overscroll_updates());
1100 EXPECT_TRUE(tracker.overscroll_completed()); 1096 EXPECT_TRUE(tracker.overscroll_completed());
1101 } 1097 }
1102 1098
1103 // Start out overscrolling vertically, then switch directions and finish 1099 // Start out overscrolling vertically, then switch directions and finish
1104 // overscrolling horizontally. 1100 // overscrolling horizontally.
1105 { 1101 {
1106 tracker.Reset(); 1102 tracker.Reset();
1107 1103
1108 int kXStep = bounds.width() / 10; 1104 int kXStep = bounds.width() / 10;
1109 int kYStep = bounds.height() / 10; 1105 int kYStep = bounds.height() / 10;
1110 gfx::Point location = bounds.origin() + gfx::Vector2d(0, kYStep); 1106 gfx::Point location = bounds.origin() + gfx::Vector2d(0, kYStep);
1111 base::TimeDelta timestamp = ui::EventTimeForNow(); 1107 base::TimeDelta timestamp = ui::EventTimeForNow();
1112 ui::TouchEvent press( 1108 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::PointF(location), 0,
1113 ui::ET_TOUCH_PRESSED, 1109 timestamp);
1114 location,
1115 0,
1116 timestamp);
1117 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&press); 1110 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&press);
1118 ASSERT_FALSE(details.dispatcher_destroyed); 1111 ASSERT_FALSE(details.dispatcher_destroyed);
1119 WaitAFrame(); 1112 WaitAFrame();
1120 location += gfx::Vector2d(0, kYStep); 1113 location += gfx::Vector2d(0, kYStep);
1121 timestamp += base::TimeDelta::FromMilliseconds(10); 1114 timestamp += base::TimeDelta::FromMilliseconds(10);
1122 1115
1123 for (size_t i = 0; i < 3; ++i) { 1116 for (size_t i = 0; i < 3; ++i) {
1124 ui::TouchEvent inc(ui::ET_TOUCH_MOVED, location, 0, timestamp); 1117 ui::TouchEvent inc(ui::ET_TOUCH_MOVED, gfx::PointF(location), 0,
1118 timestamp);
1125 details = dispatcher->OnEventFromSource(&inc); 1119 details = dispatcher->OnEventFromSource(&inc);
1126 ASSERT_FALSE(details.dispatcher_destroyed); 1120 ASSERT_FALSE(details.dispatcher_destroyed);
1127 WaitAFrame(); 1121 WaitAFrame();
1128 location += gfx::Vector2d(0, kYStep); 1122 location += gfx::Vector2d(0, kYStep);
1129 timestamp += base::TimeDelta::FromMilliseconds(10); 1123 timestamp += base::TimeDelta::FromMilliseconds(10);
1130 } 1124 }
1131 1125
1132 while (location.x() < bounds.right() - kXStep) { 1126 while (location.x() < bounds.right() - kXStep) {
1133 ui::TouchEvent inc(ui::ET_TOUCH_MOVED, location, 0, timestamp); 1127 ui::TouchEvent inc(ui::ET_TOUCH_MOVED, gfx::PointF(location), 0,
1128 timestamp);
1134 details = dispatcher->OnEventFromSource(&inc); 1129 details = dispatcher->OnEventFromSource(&inc);
1135 ASSERT_FALSE(details.dispatcher_destroyed); 1130 ASSERT_FALSE(details.dispatcher_destroyed);
1136 WaitAFrame(); 1131 WaitAFrame();
1137 location += gfx::Vector2d(kXStep, 0); 1132 location += gfx::Vector2d(kXStep, 0);
1138 timestamp += base::TimeDelta::FromMilliseconds(10); 1133 timestamp += base::TimeDelta::FromMilliseconds(10);
1139 } 1134 }
1140 1135
1141 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, location, 0, timestamp); 1136 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::PointF(location), 0,
1137 timestamp);
1142 details = dispatcher->OnEventFromSource(&release); 1138 details = dispatcher->OnEventFromSource(&release);
1143 ASSERT_FALSE(details.dispatcher_destroyed); 1139 ASSERT_FALSE(details.dispatcher_destroyed);
1144 WaitAFrame(); 1140 WaitAFrame();
1145 1141
1146 EXPECT_LT(0, tracker.num_overscroll_updates()); 1142 EXPECT_LT(0, tracker.num_overscroll_updates());
1147 EXPECT_FALSE(tracker.overscroll_completed()); 1143 EXPECT_FALSE(tracker.overscroll_completed());
1148 } 1144 }
1149 } 1145 }
1150 1146
1151 } // namespace content 1147 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698