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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "ui/base/events/event_utils.h" | 10 #include "ui/base/events/event_utils.h" |
(...skipping 1299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1310 focused_view->RequestFocus(); | 1310 focused_view->RequestFocus(); |
1311 EXPECT_TRUE(focused_view->HasFocus()); | 1311 EXPECT_TRUE(focused_view->HasFocus()); |
1312 | 1312 |
1313 // Generate a scroll event on the cursor view. The focused view will receive a | 1313 // Generate a scroll event on the cursor view. The focused view will receive a |
1314 // wheel event, but since it doesn't process the event, the view under the | 1314 // wheel event, but since it doesn't process the event, the view under the |
1315 // cursor will receive the wheel event. | 1315 // cursor will receive the wheel event. |
1316 ui::ScrollEvent scroll(ui::ET_SCROLL, | 1316 ui::ScrollEvent scroll(ui::ET_SCROLL, |
1317 gfx::Point(65, 5), | 1317 gfx::Point(65, 5), |
1318 ui::EventTimeForNow(), | 1318 ui::EventTimeForNow(), |
1319 0, | 1319 0, |
1320 0, | 1320 0, 20, |
1321 20, | 1321 0, 20, |
1322 2); | 1322 2); |
1323 widget->OnScrollEvent(&scroll); | 1323 widget->OnScrollEvent(&scroll); |
1324 | 1324 |
1325 EXPECT_EQ(0, focused_view->GetEventCount(ui::ET_SCROLL)); | 1325 EXPECT_EQ(0, focused_view->GetEventCount(ui::ET_SCROLL)); |
1326 EXPECT_EQ(1, focused_view->GetEventCount(ui::ET_MOUSEWHEEL)); | 1326 EXPECT_EQ(1, focused_view->GetEventCount(ui::ET_MOUSEWHEEL)); |
1327 | 1327 |
1328 EXPECT_EQ(1, cursor_view->GetEventCount(ui::ET_SCROLL)); | 1328 EXPECT_EQ(1, cursor_view->GetEventCount(ui::ET_SCROLL)); |
1329 EXPECT_EQ(1, cursor_view->GetEventCount(ui::ET_MOUSEWHEEL)); | 1329 EXPECT_EQ(1, cursor_view->GetEventCount(ui::ET_MOUSEWHEEL)); |
1330 | 1330 |
1331 focused_view->ResetCounts(); | 1331 focused_view->ResetCounts(); |
1332 cursor_view->ResetCounts(); | 1332 cursor_view->ResetCounts(); |
1333 | 1333 |
1334 ui::ScrollEvent scroll2(ui::ET_SCROLL, | 1334 ui::ScrollEvent scroll2(ui::ET_SCROLL, |
1335 gfx::Point(5, 5), | 1335 gfx::Point(5, 5), |
1336 ui::EventTimeForNow(), | 1336 ui::EventTimeForNow(), |
1337 0, | 1337 0, |
1338 0, | 1338 0, 20, |
1339 20, | 1339 0, 20, |
1340 2); | 1340 2); |
1341 widget->OnScrollEvent(&scroll2); | 1341 widget->OnScrollEvent(&scroll2); |
1342 EXPECT_EQ(1, focused_view->GetEventCount(ui::ET_SCROLL)); | 1342 EXPECT_EQ(1, focused_view->GetEventCount(ui::ET_SCROLL)); |
1343 EXPECT_EQ(1, focused_view->GetEventCount(ui::ET_MOUSEWHEEL)); | 1343 EXPECT_EQ(1, focused_view->GetEventCount(ui::ET_MOUSEWHEEL)); |
1344 | 1344 |
1345 EXPECT_EQ(0, cursor_view->GetEventCount(ui::ET_SCROLL)); | 1345 EXPECT_EQ(0, cursor_view->GetEventCount(ui::ET_SCROLL)); |
1346 EXPECT_EQ(0, cursor_view->GetEventCount(ui::ET_MOUSEWHEEL)); | 1346 EXPECT_EQ(0, cursor_view->GetEventCount(ui::ET_MOUSEWHEEL)); |
1347 | 1347 |
1348 widget->CloseNow(); | 1348 widget->CloseNow(); |
1349 } | 1349 } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1405 EXPECT_EQ(1, scroll_view->GetEventCount(ui::ET_GESTURE_SCROLL_BEGIN)); | 1405 EXPECT_EQ(1, scroll_view->GetEventCount(ui::ET_GESTURE_SCROLL_BEGIN)); |
1406 EXPECT_EQ(1, scroll_view->GetEventCount(ui::ET_GESTURE_SCROLL_UPDATE)); | 1406 EXPECT_EQ(1, scroll_view->GetEventCount(ui::ET_GESTURE_SCROLL_UPDATE)); |
1407 EXPECT_EQ(1, scroll_view->GetEventCount(ui::ET_GESTURE_SCROLL_END)); | 1407 EXPECT_EQ(1, scroll_view->GetEventCount(ui::ET_GESTURE_SCROLL_END)); |
1408 } | 1408 } |
1409 | 1409 |
1410 widget->CloseNow(); | 1410 widget->CloseNow(); |
1411 } | 1411 } |
1412 | 1412 |
1413 } // namespace | 1413 } // namespace |
1414 } // namespace views | 1414 } // namespace views |
OLD | NEW |