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

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

Issue 1975533002: Change ui::Event::time_stamp from TimeDelta to TimeTicks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 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
« no previous file with comments | « ui/views/widget/widget_interactive_uitest.cc ('k') | ui/views/win/hwnd_message_handler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <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 1477 matching lines...) Expand 10 before | Expand all | Expand 10 after
1488 1488
1489 noscroll_view->SetBounds(0, 0, 50, 40); 1489 noscroll_view->SetBounds(0, 0, 50, 40);
1490 scroll_view->SetBounds(60, 0, 40, 40); 1490 scroll_view->SetBounds(60, 0, 40, 40);
1491 1491
1492 WidgetAutoclosePtr widget(CreateTopLevelPlatformWidget()); 1492 WidgetAutoclosePtr widget(CreateTopLevelPlatformWidget());
1493 widget->GetRootView()->AddChildView(noscroll_view); 1493 widget->GetRootView()->AddChildView(noscroll_view);
1494 widget->GetRootView()->AddChildView(scroll_view); 1494 widget->GetRootView()->AddChildView(scroll_view);
1495 1495
1496 { 1496 {
1497 ui::GestureEvent begin( 1497 ui::GestureEvent begin(
1498 5, 1498 5, 5, 0, base::TimeTicks(),
1499 5,
1500 0,
1501 base::TimeDelta(),
1502 ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_BEGIN)); 1499 ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_BEGIN));
1503 widget->OnGestureEvent(&begin); 1500 widget->OnGestureEvent(&begin);
1504 ui::GestureEvent update( 1501 ui::GestureEvent update(
1505 25, 1502 25, 15, 0, base::TimeTicks(),
1506 15,
1507 0,
1508 base::TimeDelta(),
1509 ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_UPDATE, 20, 10)); 1503 ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_UPDATE, 20, 10));
1510 widget->OnGestureEvent(&update); 1504 widget->OnGestureEvent(&update);
1511 ui::GestureEvent end(25, 1505 ui::GestureEvent end(25, 15, 0, base::TimeTicks(),
1512 15,
1513 0,
1514 base::TimeDelta(),
1515 ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_END)); 1506 ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_END));
1516 widget->OnGestureEvent(&end); 1507 widget->OnGestureEvent(&end);
1517 1508
1518 EXPECT_EQ(1, noscroll_view->GetEventCount(ui::ET_GESTURE_SCROLL_BEGIN)); 1509 EXPECT_EQ(1, noscroll_view->GetEventCount(ui::ET_GESTURE_SCROLL_BEGIN));
1519 EXPECT_EQ(0, noscroll_view->GetEventCount(ui::ET_GESTURE_SCROLL_UPDATE)); 1510 EXPECT_EQ(0, noscroll_view->GetEventCount(ui::ET_GESTURE_SCROLL_UPDATE));
1520 EXPECT_EQ(0, noscroll_view->GetEventCount(ui::ET_GESTURE_SCROLL_END)); 1511 EXPECT_EQ(0, noscroll_view->GetEventCount(ui::ET_GESTURE_SCROLL_END));
1521 } 1512 }
1522 1513
1523 { 1514 {
1524 ui::GestureEvent begin( 1515 ui::GestureEvent begin(
1525 65, 1516 65, 5, 0, base::TimeTicks(),
1526 5,
1527 0,
1528 base::TimeDelta(),
1529 ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_BEGIN)); 1517 ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_BEGIN));
1530 widget->OnGestureEvent(&begin); 1518 widget->OnGestureEvent(&begin);
1531 ui::GestureEvent update( 1519 ui::GestureEvent update(
1532 85, 1520 85, 15, 0, base::TimeTicks(),
1533 15,
1534 0,
1535 base::TimeDelta(),
1536 ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_UPDATE, 20, 10)); 1521 ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_UPDATE, 20, 10));
1537 widget->OnGestureEvent(&update); 1522 widget->OnGestureEvent(&update);
1538 ui::GestureEvent end(85, 1523 ui::GestureEvent end(85, 15, 0, base::TimeTicks(),
1539 15,
1540 0,
1541 base::TimeDelta(),
1542 ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_END)); 1524 ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_END));
1543 widget->OnGestureEvent(&end); 1525 widget->OnGestureEvent(&end);
1544 1526
1545 EXPECT_EQ(1, scroll_view->GetEventCount(ui::ET_GESTURE_SCROLL_BEGIN)); 1527 EXPECT_EQ(1, scroll_view->GetEventCount(ui::ET_GESTURE_SCROLL_BEGIN));
1546 EXPECT_EQ(1, scroll_view->GetEventCount(ui::ET_GESTURE_SCROLL_UPDATE)); 1528 EXPECT_EQ(1, scroll_view->GetEventCount(ui::ET_GESTURE_SCROLL_UPDATE));
1547 EXPECT_EQ(1, scroll_view->GetEventCount(ui::ET_GESTURE_SCROLL_END)); 1529 EXPECT_EQ(1, scroll_view->GetEventCount(ui::ET_GESTURE_SCROLL_END));
1548 } 1530 }
1549 } 1531 }
1550 1532
1551 // Tests that event-handlers installed on the RootView get triggered correctly. 1533 // Tests that event-handlers installed on the RootView get triggered correctly.
(...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after
2260 ui::MouseEvent move(ui::ET_MOUSE_MOVED, move_location, move_location, 2242 ui::MouseEvent move(ui::ET_MOUSE_MOVED, move_location, move_location,
2261 ui::EventTimeForNow(), 0, 0); 2243 ui::EventTimeForNow(), 0, 0);
2262 widget->OnMouseEvent(&move); 2244 widget->OnMouseEvent(&move);
2263 EXPECT_EQ(view, GetMouseMoveHandler(root_view)); 2245 EXPECT_EQ(view, GetMouseMoveHandler(root_view));
2264 widget->Hide(); 2246 widget->Hide();
2265 EXPECT_EQ(NULL, GetMouseMoveHandler(root_view)); 2247 EXPECT_EQ(NULL, GetMouseMoveHandler(root_view));
2266 2248
2267 // Check RootView::gesture_handler_. 2249 // Check RootView::gesture_handler_.
2268 widget->Show(); 2250 widget->Show();
2269 EXPECT_EQ(NULL, GetGestureHandler(root_view)); 2251 EXPECT_EQ(NULL, GetGestureHandler(root_view));
2270 ui::GestureEvent tap_down(15, 2252 ui::GestureEvent tap_down(15, 15, 0, base::TimeTicks(),
2271 15,
2272 0,
2273 base::TimeDelta(),
2274 ui::GestureEventDetails(ui::ET_GESTURE_TAP_DOWN)); 2253 ui::GestureEventDetails(ui::ET_GESTURE_TAP_DOWN));
2275 widget->OnGestureEvent(&tap_down); 2254 widget->OnGestureEvent(&tap_down);
2276 EXPECT_EQ(view, GetGestureHandler(root_view)); 2255 EXPECT_EQ(view, GetGestureHandler(root_view));
2277 widget->Hide(); 2256 widget->Hide();
2278 EXPECT_EQ(NULL, GetGestureHandler(root_view)); 2257 EXPECT_EQ(NULL, GetGestureHandler(root_view));
2279 2258
2280 widget->Close(); 2259 widget->Close();
2281 } 2260 }
2282 2261
2283 // Convenience to make constructing a GestureEvent simpler. 2262 // Convenience to make constructing a GestureEvent simpler.
2284 class GestureEventForTest : public ui::GestureEvent { 2263 class GestureEventForTest : public ui::GestureEvent {
2285 public: 2264 public:
2286 GestureEventForTest(ui::EventType type, int x, int y) 2265 GestureEventForTest(ui::EventType type, int x, int y)
2287 : GestureEvent(x, 2266 : GestureEvent(x,
2288 y, 2267 y,
2289 0, 2268 0,
2290 base::TimeDelta(), 2269 base::TimeTicks(),
2291 ui::GestureEventDetails(type)) {} 2270 ui::GestureEventDetails(type)) {}
2292 2271
2293 GestureEventForTest(ui::GestureEventDetails details, int x, int y) 2272 GestureEventForTest(ui::GestureEventDetails details, int x, int y)
2294 : GestureEvent(x, y, 0, base::TimeDelta(), details) {} 2273 : GestureEvent(x, y, 0, base::TimeTicks(), details) {}
2295 }; 2274 };
2296 2275
2297 // Tests that the |gesture_handler_| member in RootView is always NULL 2276 // Tests that the |gesture_handler_| member in RootView is always NULL
2298 // after the dispatch of a ui::ET_GESTURE_END event corresponding to 2277 // after the dispatch of a ui::ET_GESTURE_END event corresponding to
2299 // the release of the final touch point on the screen, but that 2278 // the release of the final touch point on the screen, but that
2300 // ui::ET_GESTURE_END events corresponding to the removal of any other touch 2279 // ui::ET_GESTURE_END events corresponding to the removal of any other touch
2301 // point do not modify |gesture_handler_|. 2280 // point do not modify |gesture_handler_|.
2302 TEST_F(WidgetTest, GestureEndEvents) { 2281 TEST_F(WidgetTest, GestureEndEvents) {
2303 Widget* widget = CreateTopLevelNativeWidget(); 2282 Widget* widget = CreateTopLevelNativeWidget();
2304 widget->SetBounds(gfx::Rect(0, 0, 300, 300)); 2283 widget->SetBounds(gfx::Rect(0, 0, 300, 300));
(...skipping 1416 matching lines...) Expand 10 before | Expand all | Expand 10 after
3721 EXPECT_FALSE(!!IsWindow(owned_hwnd)); 3700 EXPECT_FALSE(!!IsWindow(owned_hwnd));
3722 EXPECT_TRUE(!!IsWindowEnabled(top_hwnd)); 3701 EXPECT_TRUE(!!IsWindowEnabled(top_hwnd));
3723 3702
3724 top_level_widget.CloseNow(); 3703 top_level_widget.CloseNow();
3725 } 3704 }
3726 3705
3727 #endif // defined(OS_WIN) 3706 #endif // defined(OS_WIN)
3728 3707
3729 } // namespace test 3708 } // namespace test
3730 } // namespace views 3709 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/widget_interactive_uitest.cc ('k') | ui/views/win/hwnd_message_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698