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

Side by Side Diff: ui/events/x/events_x_unittest.cc

Issue 1071193002: Change device IDs from unsigned to signed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more test fixes Created 5 years, 8 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 <cstring> 5 #include <cstring>
6 #include <set> 6 #include <set>
7 7
8 #include <X11/extensions/XInput2.h> 8 #include <X11/extensions/XInput2.h>
9 #include <X11/Xlib.h> 9 #include <X11/Xlib.h>
10 #include <X11/Xutil.h> 10 #include <X11/Xutil.h>
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 event.xbutton.time = time_stamp.InMilliseconds(); 223 event.xbutton.time = time_stamp.InMilliseconds();
224 MouseEvent mouseev(&event); 224 MouseEvent mouseev(&event);
225 EXPECT_EQ(ui::ET_MOUSE_RELEASED, mouseev.type()); 225 EXPECT_EQ(ui::ET_MOUSE_RELEASED, mouseev.type());
226 EXPECT_EQ(i, mouseev.GetClickCount()); 226 EXPECT_EQ(i, mouseev.GetClickCount());
227 } 227 }
228 time_stamp += base::TimeDelta::FromMilliseconds(1); 228 time_stamp += base::TimeDelta::FromMilliseconds(1);
229 } 229 }
230 } 230 }
231 231
232 TEST_F(EventsXTest, TouchEventBasic) { 232 TEST_F(EventsXTest, TouchEventBasic) {
233 std::vector<unsigned int> devices; 233 std::vector<int> devices;
234 devices.push_back(0); 234 devices.push_back(0);
235 ui::SetUpTouchDevicesForTest(devices); 235 ui::SetUpTouchDevicesForTest(devices);
236 std::vector<Valuator> valuators; 236 std::vector<Valuator> valuators;
237 237
238 // Init touch begin with tracking id 5, touch id 0. 238 // Init touch begin with tracking id 5, touch id 0.
239 valuators.push_back(Valuator(DeviceDataManagerX11::DT_TOUCH_MAJOR, 20)); 239 valuators.push_back(Valuator(DeviceDataManagerX11::DT_TOUCH_MAJOR, 20));
240 valuators.push_back( 240 valuators.push_back(
241 Valuator(DeviceDataManagerX11::DT_TOUCH_ORIENTATION, 0.3f)); 241 Valuator(DeviceDataManagerX11::DT_TOUCH_ORIENTATION, 0.3f));
242 valuators.push_back(Valuator(DeviceDataManagerX11::DT_TOUCH_PRESSURE, 100)); 242 valuators.push_back(Valuator(DeviceDataManagerX11::DT_TOUCH_PRESSURE, 100));
243 ui::ScopedXI2Event scoped_xevent; 243 ui::ScopedXI2Event scoped_xevent;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 int GetTouchIdForTrackingId(uint32 tracking_id) { 308 int GetTouchIdForTrackingId(uint32 tracking_id) {
309 int slot = 0; 309 int slot = 0;
310 bool success = 310 bool success =
311 TouchFactory::GetInstance()->QuerySlotForTrackingID(tracking_id, &slot); 311 TouchFactory::GetInstance()->QuerySlotForTrackingID(tracking_id, &slot);
312 if (success) 312 if (success)
313 return slot; 313 return slot;
314 return -1; 314 return -1;
315 } 315 }
316 316
317 TEST_F(EventsXTest, TouchEventNotRemovingFromNativeMapping) { 317 TEST_F(EventsXTest, TouchEventNotRemovingFromNativeMapping) {
318 std::vector<unsigned int> devices; 318 std::vector<int> devices;
319 devices.push_back(0); 319 devices.push_back(0);
320 ui::SetUpTouchDevicesForTest(devices); 320 ui::SetUpTouchDevicesForTest(devices);
321 std::vector<Valuator> valuators; 321 std::vector<Valuator> valuators;
322 322
323 const int kTrackingId = 5; 323 const int kTrackingId = 5;
324 324
325 // Two touch presses with the same tracking id. 325 // Two touch presses with the same tracking id.
326 ui::ScopedXI2Event xpress0; 326 ui::ScopedXI2Event xpress0;
327 xpress0.InitTouchEvent( 327 xpress0.InitTouchEvent(
328 0, XI_TouchBegin, kTrackingId, gfx::Point(10, 10), valuators); 328 0, XI_TouchBegin, kTrackingId, gfx::Point(10, 10), valuators);
(...skipping 25 matching lines...) Expand all
354 { 354 {
355 ui::TouchEvent urelease1(xrelease1); 355 ui::TouchEvent urelease1(xrelease1);
356 } 356 }
357 EXPECT_EQ(-1, GetTouchIdForTrackingId(kTrackingId)); 357 EXPECT_EQ(-1, GetTouchIdForTrackingId(kTrackingId));
358 } 358 }
359 359
360 // Copied events should not remove native touch id mappings, as this causes a 360 // Copied events should not remove native touch id mappings, as this causes a
361 // crash (crbug.com/467102). Copied events do not contain a proper 361 // crash (crbug.com/467102). Copied events do not contain a proper
362 // base::NativeEvent and should not attempt to access it. 362 // base::NativeEvent and should not attempt to access it.
363 TEST_F(EventsXTest, CopiedTouchEventNotRemovingFromNativeMapping) { 363 TEST_F(EventsXTest, CopiedTouchEventNotRemovingFromNativeMapping) {
364 std::vector<unsigned int> devices; 364 std::vector<int> devices;
365 devices.push_back(0); 365 devices.push_back(0);
366 ui::SetUpTouchDevicesForTest(devices); 366 ui::SetUpTouchDevicesForTest(devices);
367 std::vector<Valuator> valuators; 367 std::vector<Valuator> valuators;
368 368
369 // Create a release event which has a native touch id mapping. 369 // Create a release event which has a native touch id mapping.
370 ui::ScopedXI2Event xrelease0; 370 ui::ScopedXI2Event xrelease0;
371 xrelease0.InitTouchEvent(0, XI_TouchEnd, 0, gfx::Point(10, 10), valuators); 371 xrelease0.InitTouchEvent(0, XI_TouchEnd, 0, gfx::Point(10, 10), valuators);
372 ui::TouchEvent urelease0(xrelease0); 372 ui::TouchEvent urelease0(xrelease0);
373 { 373 {
374 // When the copy is destructed it should not attempt to remove the mapping. 374 // When the copy is destructed it should not attempt to remove the mapping.
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 // Max function key code plus 1. 532 // Max function key code plus 1.
533 EXPECT_FALSE(HasFunctionKeyFlagSetIfSupported(display, XK_F35 + 1)); 533 EXPECT_FALSE(HasFunctionKeyFlagSetIfSupported(display, XK_F35 + 1));
534 } 534 }
535 535
536 // Verifies that the type of events from a disabled keyboard is ET_UNKNOWN, but 536 // Verifies that the type of events from a disabled keyboard is ET_UNKNOWN, but
537 // that an exception list of keys can still be processed. 537 // that an exception list of keys can still be processed.
538 TEST_F(EventsXTest, DisableKeyboard) { 538 TEST_F(EventsXTest, DisableKeyboard) {
539 DeviceDataManagerX11* device_data_manager = 539 DeviceDataManagerX11* device_data_manager =
540 static_cast<DeviceDataManagerX11*>( 540 static_cast<DeviceDataManagerX11*>(
541 DeviceDataManager::GetInstance()); 541 DeviceDataManager::GetInstance());
542 unsigned int blocked_device_id = 1; 542 int blocked_device_id = 1;
543 unsigned int other_device_id = 2; 543 int other_device_id = 2;
544 unsigned int master_device_id = 3; 544 int master_device_id = 3;
545 device_data_manager->DisableDevice(blocked_device_id); 545 device_data_manager->DisableDevice(blocked_device_id);
546 546
547 scoped_ptr<std::set<KeyboardCode> > excepted_keys(new std::set<KeyboardCode>); 547 scoped_ptr<std::set<KeyboardCode> > excepted_keys(new std::set<KeyboardCode>);
548 excepted_keys->insert(VKEY_B); 548 excepted_keys->insert(VKEY_B);
549 device_data_manager->SetDisabledKeyboardAllowedKeys(excepted_keys.Pass()); 549 device_data_manager->SetDisabledKeyboardAllowedKeys(excepted_keys.Pass());
550 550
551 ScopedXI2Event xev; 551 ScopedXI2Event xev;
552 // A is not allowed on the blocked keyboard, and should return ET_UNKNOWN. 552 // A is not allowed on the blocked keyboard, and should return ET_UNKNOWN.
553 xev.InitGenericKeyEvent(master_device_id, 553 xev.InitGenericKeyEvent(master_device_id,
554 blocked_device_id, 554 blocked_device_id,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 ui::VKEY_A, 589 ui::VKEY_A,
590 0); 590 0);
591 EXPECT_EQ(ui::ET_KEY_PRESSED, ui::EventTypeFromNative(xev)); 591 EXPECT_EQ(ui::ET_KEY_PRESSED, ui::EventTypeFromNative(xev));
592 } 592 }
593 593
594 // Verifies that the type of events from a disabled mouse is ET_UNKNOWN. 594 // Verifies that the type of events from a disabled mouse is ET_UNKNOWN.
595 TEST_F(EventsXTest, DisableMouse) { 595 TEST_F(EventsXTest, DisableMouse) {
596 DeviceDataManagerX11* device_data_manager = 596 DeviceDataManagerX11* device_data_manager =
597 static_cast<DeviceDataManagerX11*>( 597 static_cast<DeviceDataManagerX11*>(
598 DeviceDataManager::GetInstance()); 598 DeviceDataManager::GetInstance());
599 unsigned int blocked_device_id = 1; 599 int blocked_device_id = 1;
600 unsigned int other_device_id = 2; 600 int other_device_id = 2;
601 std::vector<unsigned int> device_list; 601 std::vector<int> device_list;
602 device_list.push_back(blocked_device_id); 602 device_list.push_back(blocked_device_id);
603 device_list.push_back(other_device_id); 603 device_list.push_back(other_device_id);
604 TouchFactory::GetInstance()->SetPointerDeviceForTest(device_list); 604 TouchFactory::GetInstance()->SetPointerDeviceForTest(device_list);
605 605
606 device_data_manager->DisableDevice(blocked_device_id); 606 device_data_manager->DisableDevice(blocked_device_id);
607 607
608 ScopedXI2Event xev; 608 ScopedXI2Event xev;
609 xev.InitGenericButtonEvent(blocked_device_id, ET_MOUSE_PRESSED, gfx::Point(), 609 xev.InitGenericButtonEvent(blocked_device_id, ET_MOUSE_PRESSED, gfx::Point(),
610 EF_LEFT_MOUSE_BUTTON); 610 EF_LEFT_MOUSE_BUTTON);
611 EXPECT_EQ(ui::ET_UNKNOWN, ui::EventTypeFromNative(xev)); 611 EXPECT_EQ(ui::ET_UNKNOWN, ui::EventTypeFromNative(xev));
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 KeyEventTestApi test_event(&key_event); 655 KeyEventTestApi test_event(&key_event);
656 test_event.set_is_char(true); 656 test_event.set_is_char(true);
657 } 657 }
658 EXPECT_FALSE(key_event.flags() & ui::EF_IME_FABRICATED_KEY); 658 EXPECT_FALSE(key_event.flags() & ui::EF_IME_FABRICATED_KEY);
659 } 659 }
660 } 660 }
661 } 661 }
662 #endif 662 #endif
663 663
664 } // namespace ui 664 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698