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

Side by Side Diff: ui/views/widget/widget_unittest.cc

Issue 572593002: Revert of Clean up GestureEventDetails constructors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 <algorithm> 5 #include <algorithm>
6 #include <set> 6 #include <set>
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 1321 matching lines...) Expand 10 before | Expand all | Expand 10 after
1332 Widget* widget = CreateTopLevelPlatformWidget(); 1332 Widget* widget = CreateTopLevelPlatformWidget();
1333 widget->GetRootView()->AddChildView(noscroll_view); 1333 widget->GetRootView()->AddChildView(noscroll_view);
1334 widget->GetRootView()->AddChildView(scroll_view); 1334 widget->GetRootView()->AddChildView(scroll_view);
1335 1335
1336 { 1336 {
1337 ui::GestureEvent begin( 1337 ui::GestureEvent begin(
1338 5, 1338 5,
1339 5, 1339 5,
1340 0, 1340 0,
1341 base::TimeDelta(), 1341 base::TimeDelta(),
1342 ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_BEGIN)); 1342 ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_BEGIN, 0, 0));
1343 widget->OnGestureEvent(&begin); 1343 widget->OnGestureEvent(&begin);
1344 ui::GestureEvent update( 1344 ui::GestureEvent update(
1345 25, 1345 25,
1346 15, 1346 15,
1347 0, 1347 0,
1348 base::TimeDelta(), 1348 base::TimeDelta(),
1349 ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_UPDATE, 20, 10)); 1349 ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_UPDATE, 20, 10));
1350 widget->OnGestureEvent(&update); 1350 widget->OnGestureEvent(&update);
1351 ui::GestureEvent end(25, 1351 ui::GestureEvent end(
1352 15, 1352 25,
1353 0, 1353 15,
1354 base::TimeDelta(), 1354 0,
1355 ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_END)); 1355 base::TimeDelta(),
1356 ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_END, 0, 0));
1356 widget->OnGestureEvent(&end); 1357 widget->OnGestureEvent(&end);
1357 1358
1358 EXPECT_EQ(1, noscroll_view->GetEventCount(ui::ET_GESTURE_SCROLL_BEGIN)); 1359 EXPECT_EQ(1, noscroll_view->GetEventCount(ui::ET_GESTURE_SCROLL_BEGIN));
1359 EXPECT_EQ(0, noscroll_view->GetEventCount(ui::ET_GESTURE_SCROLL_UPDATE)); 1360 EXPECT_EQ(0, noscroll_view->GetEventCount(ui::ET_GESTURE_SCROLL_UPDATE));
1360 EXPECT_EQ(0, noscroll_view->GetEventCount(ui::ET_GESTURE_SCROLL_END)); 1361 EXPECT_EQ(0, noscroll_view->GetEventCount(ui::ET_GESTURE_SCROLL_END));
1361 } 1362 }
1362 1363
1363 { 1364 {
1364 ui::GestureEvent begin( 1365 ui::GestureEvent begin(
1365 65, 1366 65,
1366 5, 1367 5,
1367 0, 1368 0,
1368 base::TimeDelta(), 1369 base::TimeDelta(),
1369 ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_BEGIN)); 1370 ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_BEGIN, 0, 0));
1370 widget->OnGestureEvent(&begin); 1371 widget->OnGestureEvent(&begin);
1371 ui::GestureEvent update( 1372 ui::GestureEvent update(
1372 85, 1373 85,
1373 15, 1374 15,
1374 0, 1375 0,
1375 base::TimeDelta(), 1376 base::TimeDelta(),
1376 ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_UPDATE, 20, 10)); 1377 ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_UPDATE, 20, 10));
1377 widget->OnGestureEvent(&update); 1378 widget->OnGestureEvent(&update);
1378 ui::GestureEvent end(85, 1379 ui::GestureEvent end(
1379 15, 1380 85,
1380 0, 1381 15,
1381 base::TimeDelta(), 1382 0,
1382 ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_END)); 1383 base::TimeDelta(),
1384 ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_END, 0, 0));
1383 widget->OnGestureEvent(&end); 1385 widget->OnGestureEvent(&end);
1384 1386
1385 EXPECT_EQ(1, scroll_view->GetEventCount(ui::ET_GESTURE_SCROLL_BEGIN)); 1387 EXPECT_EQ(1, scroll_view->GetEventCount(ui::ET_GESTURE_SCROLL_BEGIN));
1386 EXPECT_EQ(1, scroll_view->GetEventCount(ui::ET_GESTURE_SCROLL_UPDATE)); 1388 EXPECT_EQ(1, scroll_view->GetEventCount(ui::ET_GESTURE_SCROLL_UPDATE));
1387 EXPECT_EQ(1, scroll_view->GetEventCount(ui::ET_GESTURE_SCROLL_END)); 1389 EXPECT_EQ(1, scroll_view->GetEventCount(ui::ET_GESTURE_SCROLL_END));
1388 } 1390 }
1389 1391
1390 widget->CloseNow(); 1392 widget->CloseNow();
1391 } 1393 }
1392 1394
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1461 // the target phase. 1463 // the target phase.
1462 view->set_handle_mode(EventCountView::CONSUME_EVENTS); 1464 view->set_handle_mode(EventCountView::CONSUME_EVENTS);
1463 1465
1464 // Dispatch a ui::ET_GESTURE_TAP_DOWN and a ui::ET_GESTURE_TAP_CANCEL event. 1466 // Dispatch a ui::ET_GESTURE_TAP_DOWN and a ui::ET_GESTURE_TAP_CANCEL event.
1465 // The events are handled at the target phase and should not reach the 1467 // The events are handled at the target phase and should not reach the
1466 // post-target handler. 1468 // post-target handler.
1467 ui::GestureEvent tap_down(5, 1469 ui::GestureEvent tap_down(5,
1468 5, 1470 5,
1469 0, 1471 0,
1470 ui::EventTimeForNow(), 1472 ui::EventTimeForNow(),
1471 ui::GestureEventDetails(ui::ET_GESTURE_TAP_DOWN)); 1473 ui::GestureEventDetails(ui::ET_GESTURE_TAP_DOWN,
1474 0,
1475 0));
1472 widget->OnGestureEvent(&tap_down); 1476 widget->OnGestureEvent(&tap_down);
1473 EXPECT_EQ(1, h1.GetEventCount(ui::ET_GESTURE_TAP_DOWN)); 1477 EXPECT_EQ(1, h1.GetEventCount(ui::ET_GESTURE_TAP_DOWN));
1474 EXPECT_EQ(1, view->GetEventCount(ui::ET_GESTURE_TAP_DOWN)); 1478 EXPECT_EQ(1, view->GetEventCount(ui::ET_GESTURE_TAP_DOWN));
1475 EXPECT_EQ(0, h2.GetEventCount(ui::ET_GESTURE_TAP_DOWN)); 1479 EXPECT_EQ(0, h2.GetEventCount(ui::ET_GESTURE_TAP_DOWN));
1476 1480
1477 ui::GestureEvent tap_cancel( 1481 ui::GestureEvent tap_cancel(5,
1478 5, 1482 5,
1479 5, 1483 0,
1480 0, 1484 ui::EventTimeForNow(),
1481 ui::EventTimeForNow(), 1485 ui::GestureEventDetails(ui::ET_GESTURE_TAP_CANCEL,
1482 ui::GestureEventDetails(ui::ET_GESTURE_TAP_CANCEL)); 1486 0,
1487 0));
1483 widget->OnGestureEvent(&tap_cancel); 1488 widget->OnGestureEvent(&tap_cancel);
1484 EXPECT_EQ(1, h1.GetEventCount(ui::ET_GESTURE_TAP_CANCEL)); 1489 EXPECT_EQ(1, h1.GetEventCount(ui::ET_GESTURE_TAP_CANCEL));
1485 EXPECT_EQ(1, view->GetEventCount(ui::ET_GESTURE_TAP_CANCEL)); 1490 EXPECT_EQ(1, view->GetEventCount(ui::ET_GESTURE_TAP_CANCEL));
1486 EXPECT_EQ(0, h2.GetEventCount(ui::ET_GESTURE_TAP_CANCEL)); 1491 EXPECT_EQ(0, h2.GetEventCount(ui::ET_GESTURE_TAP_CANCEL));
1487 1492
1488 h1.ResetCounts(); 1493 h1.ResetCounts();
1489 view->ResetCounts(); 1494 view->ResetCounts();
1490 h2.ResetCounts(); 1495 h2.ResetCounts();
1491 1496
1492 // Dispatch a ui::ET_SCROLL event. The event is handled at the target phase 1497 // Dispatch a ui::ET_SCROLL event. The event is handled at the target phase
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
1942 gfx::Point move_location(45, 15); 1947 gfx::Point move_location(45, 15);
1943 ui::MouseEvent move(ui::ET_MOUSE_MOVED, move_location, move_location, 0, 0); 1948 ui::MouseEvent move(ui::ET_MOUSE_MOVED, move_location, move_location, 0, 0);
1944 widget->OnMouseEvent(&move); 1949 widget->OnMouseEvent(&move);
1945 EXPECT_EQ(view, GetMouseMoveHandler(root_view)); 1950 EXPECT_EQ(view, GetMouseMoveHandler(root_view));
1946 widget->Hide(); 1951 widget->Hide();
1947 EXPECT_EQ(NULL, GetMouseMoveHandler(root_view)); 1952 EXPECT_EQ(NULL, GetMouseMoveHandler(root_view));
1948 1953
1949 // Check RootView::gesture_handler_. 1954 // Check RootView::gesture_handler_.
1950 widget->Show(); 1955 widget->Show();
1951 EXPECT_EQ(NULL, GetGestureHandler(root_view)); 1956 EXPECT_EQ(NULL, GetGestureHandler(root_view));
1952 ui::GestureEvent tap_down(15, 1957 ui::GestureEvent tap_down(
1953 15, 1958 15,
1954 0, 1959 15,
1955 base::TimeDelta(), 1960 0,
1956 ui::GestureEventDetails(ui::ET_GESTURE_TAP_DOWN)); 1961 base::TimeDelta(),
1962 ui::GestureEventDetails(ui::ET_GESTURE_TAP_DOWN, 0, 0));
1957 widget->OnGestureEvent(&tap_down); 1963 widget->OnGestureEvent(&tap_down);
1958 EXPECT_EQ(view, GetGestureHandler(root_view)); 1964 EXPECT_EQ(view, GetGestureHandler(root_view));
1959 widget->Hide(); 1965 widget->Hide();
1960 EXPECT_EQ(NULL, GetGestureHandler(root_view)); 1966 EXPECT_EQ(NULL, GetGestureHandler(root_view));
1961 1967
1962 widget->Close(); 1968 widget->Close();
1963 } 1969 }
1964 1970
1965 // Convenience to make constructing a GestureEvent simpler. 1971 // Convenience to make constructing a GestureEvent simpler.
1966 class GestureEventForTest : public ui::GestureEvent { 1972 class GestureEventForTest : public ui::GestureEvent {
1967 public: 1973 public:
1968 GestureEventForTest(ui::EventType type, int x, int y) 1974 GestureEventForTest(ui::EventType type, int x, int y)
1969 : GestureEvent(x, 1975 : GestureEvent(x,
1970 y, 1976 y,
1971 0, 1977 0,
1972 base::TimeDelta(), 1978 base::TimeDelta(),
1973 ui::GestureEventDetails(type)) {} 1979 ui::GestureEventDetails(type, 0.0f, 0.0f)) {}
1974 1980
1975 GestureEventForTest(ui::GestureEventDetails details, int x, int y) 1981 GestureEventForTest(ui::GestureEventDetails details, int x, int y)
1976 : GestureEvent(x, y, 0, base::TimeDelta(), details) {} 1982 : GestureEvent(x, y, 0, base::TimeDelta(), details) {}
1977 }; 1983 };
1978 1984
1979 // Tests that the |gesture_handler_| member in RootView is always NULL 1985 // Tests that the |gesture_handler_| member in RootView is always NULL
1980 // after the dispatch of a ui::ET_GESTURE_END event corresponding to 1986 // after the dispatch of a ui::ET_GESTURE_END event corresponding to
1981 // the release of the final touch point on the screen and that 1987 // the release of the final touch point on the screen and that
1982 // ui::ET_GESTURE_END events corresponding to the removal of any other touch 1988 // ui::ET_GESTURE_END events corresponding to the removal of any other touch
1983 // point are never dispatched to a view. Also verifies that 1989 // point are never dispatched to a view. Also verifies that
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2016 // should not set the gesture handler and should not be marked as handled 2022 // should not set the gesture handler and should not be marked as handled
2017 // because it is never dispatched. 2023 // because it is never dispatched.
2018 begin = GestureEventForTest(ui::ET_GESTURE_BEGIN, 15, 15); 2024 begin = GestureEventForTest(ui::ET_GESTURE_BEGIN, 15, 15);
2019 widget->OnGestureEvent(&begin); 2025 widget->OnGestureEvent(&begin);
2020 EXPECT_FALSE(begin.handled()); 2026 EXPECT_FALSE(begin.handled());
2021 EXPECT_EQ(NULL, GetGestureHandler(root_view)); 2027 EXPECT_EQ(NULL, GetGestureHandler(root_view));
2022 2028
2023 // If no gesture handler is set, dispatching only a ui::ET_GESTURE_BEGIN 2029 // If no gesture handler is set, dispatching only a ui::ET_GESTURE_BEGIN
2024 // corresponding to a second touch point should not set the gesture handler 2030 // corresponding to a second touch point should not set the gesture handler
2025 // and should not be marked as handled because it is never dispatched. 2031 // and should not be marked as handled because it is never dispatched.
2026 ui::GestureEventDetails details(ui::ET_GESTURE_END); 2032 ui::GestureEventDetails details(ui::ET_GESTURE_END, 15, 15);
2027 details.set_touch_points(2); 2033 details.set_touch_points(2);
2028 GestureEventForTest end_second_touch_point(details, 15, 15); 2034 GestureEventForTest end_second_touch_point(details, 15, 15);
2029 widget->OnGestureEvent(&end_second_touch_point); 2035 widget->OnGestureEvent(&end_second_touch_point);
2030 EXPECT_FALSE(end_second_touch_point.handled()); 2036 EXPECT_FALSE(end_second_touch_point.handled());
2031 EXPECT_EQ(NULL, GetGestureHandler(root_view)); 2037 EXPECT_EQ(NULL, GetGestureHandler(root_view));
2032 2038
2033 // If no gesture handler is set, dispatching only a ui::ET_GESTURE_END 2039 // If no gesture handler is set, dispatching only a ui::ET_GESTURE_END
2034 // event corresponding to the final touch point should not set the gesture 2040 // event corresponding to the final touch point should not set the gesture
2035 // handler. Furthermore, it should not be marked as handled because it was 2041 // handler. Furthermore, it should not be marked as handled because it was
2036 // not dispatched (GESTURE_END events are only dispatched in cases where 2042 // not dispatched (GESTURE_END events are only dispatched in cases where
(...skipping 1172 matching lines...) Expand 10 before | Expand all | Expand 10 after
3209 3215
3210 EXPECT_EQ(test_rect, root_view->bounds()); 3216 EXPECT_EQ(test_rect, root_view->bounds());
3211 widget->ReorderNativeViews(); 3217 widget->ReorderNativeViews();
3212 EXPECT_EQ(test_rect, root_view->bounds()); 3218 EXPECT_EQ(test_rect, root_view->bounds());
3213 3219
3214 widget->CloseNow(); 3220 widget->CloseNow();
3215 } 3221 }
3216 3222
3217 } // namespace test 3223 } // namespace test
3218 } // namespace views 3224 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/widget_interactive_uitest.cc ('k') | ui/wm/core/user_activity_detector_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698