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/gfx/native_widget_types.h" | 11 #include "ui/gfx/native_widget_types.h" |
11 #include "ui/gfx/point.h" | 12 #include "ui/gfx/point.h" |
12 #include "ui/views/bubble/bubble_delegate.h" | 13 #include "ui/views/bubble/bubble_delegate.h" |
13 #include "ui/views/controls/textfield/textfield.h" | 14 #include "ui/views/controls/textfield/textfield.h" |
14 #include "ui/views/test/test_views_delegate.h" | 15 #include "ui/views/test/test_views_delegate.h" |
15 #include "ui/views/test/views_test_base.h" | 16 #include "ui/views/test/views_test_base.h" |
16 #include "ui/views/views_delegate.h" | 17 #include "ui/views/views_delegate.h" |
17 #include "ui/views/widget/native_widget_delegate.h" | 18 #include "ui/views/widget/native_widget_delegate.h" |
18 | 19 |
19 #if defined(USE_AURA) | 20 #if defined(USE_AURA) |
(...skipping 1263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1283 Widget* widget = CreateTopLevelPlatformWidget(); | 1284 Widget* widget = CreateTopLevelPlatformWidget(); |
1284 widget->GetRootView()->AddChildView(focused_view); | 1285 widget->GetRootView()->AddChildView(focused_view); |
1285 widget->GetRootView()->AddChildView(cursor_view); | 1286 widget->GetRootView()->AddChildView(cursor_view); |
1286 | 1287 |
1287 focused_view->RequestFocus(); | 1288 focused_view->RequestFocus(); |
1288 EXPECT_TRUE(focused_view->HasFocus()); | 1289 EXPECT_TRUE(focused_view->HasFocus()); |
1289 | 1290 |
1290 // Generate a scroll event on the cursor view. The focused view will receive a | 1291 // Generate a scroll event on the cursor view. The focused view will receive a |
1291 // wheel event, but since it doesn't process the event, the view under the | 1292 // wheel event, but since it doesn't process the event, the view under the |
1292 // cursor will receive the wheel event. | 1293 // cursor will receive the wheel event. |
1293 ui::ScrollEvent scroll(ui::ET_SCROLL, gfx::Point(65, 5), 0, 0, 20); | 1294 ui::ScrollEvent scroll(ui::ET_SCROLL, |
| 1295 gfx::Point(65, 5), |
| 1296 ui::EventTimeForNow(), |
| 1297 0, |
| 1298 0, |
| 1299 20, |
| 1300 2); |
1294 widget->OnScrollEvent(&scroll); | 1301 widget->OnScrollEvent(&scroll); |
1295 | 1302 |
1296 EXPECT_EQ(0, focused_view->GetEventCount(ui::ET_SCROLL)); | 1303 EXPECT_EQ(0, focused_view->GetEventCount(ui::ET_SCROLL)); |
1297 EXPECT_EQ(1, focused_view->GetEventCount(ui::ET_MOUSEWHEEL)); | 1304 EXPECT_EQ(1, focused_view->GetEventCount(ui::ET_MOUSEWHEEL)); |
1298 | 1305 |
1299 EXPECT_EQ(1, cursor_view->GetEventCount(ui::ET_SCROLL)); | 1306 EXPECT_EQ(1, cursor_view->GetEventCount(ui::ET_SCROLL)); |
1300 EXPECT_EQ(1, cursor_view->GetEventCount(ui::ET_MOUSEWHEEL)); | 1307 EXPECT_EQ(1, cursor_view->GetEventCount(ui::ET_MOUSEWHEEL)); |
1301 | 1308 |
1302 focused_view->ResetCounts(); | 1309 focused_view->ResetCounts(); |
1303 cursor_view->ResetCounts(); | 1310 cursor_view->ResetCounts(); |
1304 | 1311 |
1305 ui::ScrollEvent scroll2(ui::ET_SCROLL, gfx::Point(5, 5), 0, 0, 20); | 1312 ui::ScrollEvent scroll2(ui::ET_SCROLL, |
| 1313 gfx::Point(5, 5), |
| 1314 ui::EventTimeForNow(), |
| 1315 0, |
| 1316 0, |
| 1317 20, |
| 1318 2); |
1306 widget->OnScrollEvent(&scroll2); | 1319 widget->OnScrollEvent(&scroll2); |
1307 EXPECT_EQ(1, focused_view->GetEventCount(ui::ET_SCROLL)); | 1320 EXPECT_EQ(1, focused_view->GetEventCount(ui::ET_SCROLL)); |
1308 EXPECT_EQ(1, focused_view->GetEventCount(ui::ET_MOUSEWHEEL)); | 1321 EXPECT_EQ(1, focused_view->GetEventCount(ui::ET_MOUSEWHEEL)); |
1309 | 1322 |
1310 EXPECT_EQ(0, cursor_view->GetEventCount(ui::ET_SCROLL)); | 1323 EXPECT_EQ(0, cursor_view->GetEventCount(ui::ET_SCROLL)); |
1311 EXPECT_EQ(0, cursor_view->GetEventCount(ui::ET_MOUSEWHEEL)); | 1324 EXPECT_EQ(0, cursor_view->GetEventCount(ui::ET_MOUSEWHEEL)); |
1312 | 1325 |
1313 widget->CloseNow(); | 1326 widget->CloseNow(); |
1314 } | 1327 } |
1315 | 1328 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1370 EXPECT_EQ(1, scroll_view->GetEventCount(ui::ET_GESTURE_SCROLL_BEGIN)); | 1383 EXPECT_EQ(1, scroll_view->GetEventCount(ui::ET_GESTURE_SCROLL_BEGIN)); |
1371 EXPECT_EQ(1, scroll_view->GetEventCount(ui::ET_GESTURE_SCROLL_UPDATE)); | 1384 EXPECT_EQ(1, scroll_view->GetEventCount(ui::ET_GESTURE_SCROLL_UPDATE)); |
1372 EXPECT_EQ(1, scroll_view->GetEventCount(ui::ET_GESTURE_SCROLL_END)); | 1385 EXPECT_EQ(1, scroll_view->GetEventCount(ui::ET_GESTURE_SCROLL_END)); |
1373 } | 1386 } |
1374 | 1387 |
1375 widget->CloseNow(); | 1388 widget->CloseNow(); |
1376 } | 1389 } |
1377 | 1390 |
1378 } // namespace | 1391 } // namespace |
1379 } // namespace views | 1392 } // namespace views |
OLD | NEW |