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 <algorithm> | 5 #include <algorithm> |
6 #include <memory> | 6 #include <memory> |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 1470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1481 | 1481 |
1482 noscroll_view->SetBounds(0, 0, 50, 40); | 1482 noscroll_view->SetBounds(0, 0, 50, 40); |
1483 scroll_view->SetBounds(60, 0, 40, 40); | 1483 scroll_view->SetBounds(60, 0, 40, 40); |
1484 | 1484 |
1485 WidgetAutoclosePtr widget(CreateTopLevelPlatformWidget()); | 1485 WidgetAutoclosePtr widget(CreateTopLevelPlatformWidget()); |
1486 widget->GetRootView()->AddChildView(noscroll_view); | 1486 widget->GetRootView()->AddChildView(noscroll_view); |
1487 widget->GetRootView()->AddChildView(scroll_view); | 1487 widget->GetRootView()->AddChildView(scroll_view); |
1488 | 1488 |
1489 { | 1489 { |
1490 ui::GestureEvent begin( | 1490 ui::GestureEvent begin( |
1491 5, | 1491 5, 5, 0, base::TimeTicks(), |
1492 5, | |
1493 0, | |
1494 base::TimeDelta(), | |
1495 ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_BEGIN)); | 1492 ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_BEGIN)); |
1496 widget->OnGestureEvent(&begin); | 1493 widget->OnGestureEvent(&begin); |
1497 ui::GestureEvent update( | 1494 ui::GestureEvent update( |
1498 25, | 1495 25, 15, 0, base::TimeTicks(), |
1499 15, | |
1500 0, | |
1501 base::TimeDelta(), | |
1502 ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_UPDATE, 20, 10)); | 1496 ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_UPDATE, 20, 10)); |
1503 widget->OnGestureEvent(&update); | 1497 widget->OnGestureEvent(&update); |
1504 ui::GestureEvent end(25, | 1498 ui::GestureEvent end(25, 15, 0, base::TimeTicks(), |
1505 15, | |
1506 0, | |
1507 base::TimeDelta(), | |
1508 ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_END)); | 1499 ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_END)); |
1509 widget->OnGestureEvent(&end); | 1500 widget->OnGestureEvent(&end); |
1510 | 1501 |
1511 EXPECT_EQ(1, noscroll_view->GetEventCount(ui::ET_GESTURE_SCROLL_BEGIN)); | 1502 EXPECT_EQ(1, noscroll_view->GetEventCount(ui::ET_GESTURE_SCROLL_BEGIN)); |
1512 EXPECT_EQ(0, noscroll_view->GetEventCount(ui::ET_GESTURE_SCROLL_UPDATE)); | 1503 EXPECT_EQ(0, noscroll_view->GetEventCount(ui::ET_GESTURE_SCROLL_UPDATE)); |
1513 EXPECT_EQ(0, noscroll_view->GetEventCount(ui::ET_GESTURE_SCROLL_END)); | 1504 EXPECT_EQ(0, noscroll_view->GetEventCount(ui::ET_GESTURE_SCROLL_END)); |
1514 } | 1505 } |
1515 | 1506 |
1516 { | 1507 { |
1517 ui::GestureEvent begin( | 1508 ui::GestureEvent begin( |
1518 65, | 1509 65, 5, 0, base::TimeTicks(), |
1519 5, | |
1520 0, | |
1521 base::TimeDelta(), | |
1522 ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_BEGIN)); | 1510 ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_BEGIN)); |
1523 widget->OnGestureEvent(&begin); | 1511 widget->OnGestureEvent(&begin); |
1524 ui::GestureEvent update( | 1512 ui::GestureEvent update( |
1525 85, | 1513 85, 15, 0, base::TimeTicks(), |
1526 15, | |
1527 0, | |
1528 base::TimeDelta(), | |
1529 ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_UPDATE, 20, 10)); | 1514 ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_UPDATE, 20, 10)); |
1530 widget->OnGestureEvent(&update); | 1515 widget->OnGestureEvent(&update); |
1531 ui::GestureEvent end(85, | 1516 ui::GestureEvent end(85, 15, 0, base::TimeTicks(), |
1532 15, | |
1533 0, | |
1534 base::TimeDelta(), | |
1535 ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_END)); | 1517 ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_END)); |
1536 widget->OnGestureEvent(&end); | 1518 widget->OnGestureEvent(&end); |
1537 | 1519 |
1538 EXPECT_EQ(1, scroll_view->GetEventCount(ui::ET_GESTURE_SCROLL_BEGIN)); | 1520 EXPECT_EQ(1, scroll_view->GetEventCount(ui::ET_GESTURE_SCROLL_BEGIN)); |
1539 EXPECT_EQ(1, scroll_view->GetEventCount(ui::ET_GESTURE_SCROLL_UPDATE)); | 1521 EXPECT_EQ(1, scroll_view->GetEventCount(ui::ET_GESTURE_SCROLL_UPDATE)); |
1540 EXPECT_EQ(1, scroll_view->GetEventCount(ui::ET_GESTURE_SCROLL_END)); | 1522 EXPECT_EQ(1, scroll_view->GetEventCount(ui::ET_GESTURE_SCROLL_END)); |
1541 } | 1523 } |
1542 } | 1524 } |
1543 | 1525 |
1544 // Tests that event-handlers installed on the RootView get triggered correctly. | 1526 // Tests that event-handlers installed on the RootView get triggered correctly. |
(...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2253 ui::MouseEvent move(ui::ET_MOUSE_MOVED, move_location, move_location, | 2235 ui::MouseEvent move(ui::ET_MOUSE_MOVED, move_location, move_location, |
2254 ui::EventTimeForNow(), 0, 0); | 2236 ui::EventTimeForNow(), 0, 0); |
2255 widget->OnMouseEvent(&move); | 2237 widget->OnMouseEvent(&move); |
2256 EXPECT_EQ(view, GetMouseMoveHandler(root_view)); | 2238 EXPECT_EQ(view, GetMouseMoveHandler(root_view)); |
2257 widget->Hide(); | 2239 widget->Hide(); |
2258 EXPECT_EQ(NULL, GetMouseMoveHandler(root_view)); | 2240 EXPECT_EQ(NULL, GetMouseMoveHandler(root_view)); |
2259 | 2241 |
2260 // Check RootView::gesture_handler_. | 2242 // Check RootView::gesture_handler_. |
2261 widget->Show(); | 2243 widget->Show(); |
2262 EXPECT_EQ(NULL, GetGestureHandler(root_view)); | 2244 EXPECT_EQ(NULL, GetGestureHandler(root_view)); |
2263 ui::GestureEvent tap_down(15, | 2245 ui::GestureEvent tap_down(15, 15, 0, base::TimeTicks(), |
2264 15, | |
2265 0, | |
2266 base::TimeDelta(), | |
2267 ui::GestureEventDetails(ui::ET_GESTURE_TAP_DOWN)); | 2246 ui::GestureEventDetails(ui::ET_GESTURE_TAP_DOWN)); |
2268 widget->OnGestureEvent(&tap_down); | 2247 widget->OnGestureEvent(&tap_down); |
2269 EXPECT_EQ(view, GetGestureHandler(root_view)); | 2248 EXPECT_EQ(view, GetGestureHandler(root_view)); |
2270 widget->Hide(); | 2249 widget->Hide(); |
2271 EXPECT_EQ(NULL, GetGestureHandler(root_view)); | 2250 EXPECT_EQ(NULL, GetGestureHandler(root_view)); |
2272 | 2251 |
2273 widget->Close(); | 2252 widget->Close(); |
2274 } | 2253 } |
2275 | 2254 |
2276 // Convenience to make constructing a GestureEvent simpler. | 2255 // Convenience to make constructing a GestureEvent simpler. |
2277 class GestureEventForTest : public ui::GestureEvent { | 2256 class GestureEventForTest : public ui::GestureEvent { |
2278 public: | 2257 public: |
2279 GestureEventForTest(ui::EventType type, int x, int y) | 2258 GestureEventForTest(ui::EventType type, int x, int y) |
2280 : GestureEvent(x, | 2259 : GestureEvent(x, |
2281 y, | 2260 y, |
2282 0, | 2261 0, |
2283 base::TimeDelta(), | 2262 base::TimeTicks(), |
2284 ui::GestureEventDetails(type)) {} | 2263 ui::GestureEventDetails(type)) {} |
2285 | 2264 |
2286 GestureEventForTest(ui::GestureEventDetails details, int x, int y) | 2265 GestureEventForTest(ui::GestureEventDetails details, int x, int y) |
2287 : GestureEvent(x, y, 0, base::TimeDelta(), details) {} | 2266 : GestureEvent(x, y, 0, base::TimeTicks(), details) {} |
2288 }; | 2267 }; |
2289 | 2268 |
2290 // Tests that the |gesture_handler_| member in RootView is always NULL | 2269 // Tests that the |gesture_handler_| member in RootView is always NULL |
2291 // after the dispatch of a ui::ET_GESTURE_END event corresponding to | 2270 // after the dispatch of a ui::ET_GESTURE_END event corresponding to |
2292 // the release of the final touch point on the screen, but that | 2271 // the release of the final touch point on the screen, but that |
2293 // ui::ET_GESTURE_END events corresponding to the removal of any other touch | 2272 // ui::ET_GESTURE_END events corresponding to the removal of any other touch |
2294 // point do not modify |gesture_handler_|. | 2273 // point do not modify |gesture_handler_|. |
2295 TEST_F(WidgetTest, GestureEndEvents) { | 2274 TEST_F(WidgetTest, GestureEndEvents) { |
2296 Widget* widget = CreateTopLevelNativeWidget(); | 2275 Widget* widget = CreateTopLevelNativeWidget(); |
2297 widget->SetBounds(gfx::Rect(0, 0, 300, 300)); | 2276 widget->SetBounds(gfx::Rect(0, 0, 300, 300)); |
(...skipping 1413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3711 EXPECT_FALSE(!!IsWindow(owned_hwnd)); | 3690 EXPECT_FALSE(!!IsWindow(owned_hwnd)); |
3712 EXPECT_TRUE(!!IsWindowEnabled(top_hwnd)); | 3691 EXPECT_TRUE(!!IsWindowEnabled(top_hwnd)); |
3713 | 3692 |
3714 top_level_widget.CloseNow(); | 3693 top_level_widget.CloseNow(); |
3715 } | 3694 } |
3716 | 3695 |
3717 #endif // defined(OS_WIN) | 3696 #endif // defined(OS_WIN) |
3718 | 3697 |
3719 } // namespace test | 3698 } // namespace test |
3720 } // namespace views | 3699 } // namespace views |
OLD | NEW |