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

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

Issue 1868363002: Replace scoped_ptr with std::unique_ptr in //ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scopedptrcc
Patch Set: scopedptrui: rebase-make_scoped_ptr Created 4 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
« no previous file with comments | « ui/events/test/test_event_target.cc ('k') | ui/gfx/animation/animation_container_unittest.cc » ('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 <stddef.h>
6 #include <stdint.h>
7 #include <X11/XKBlib.h> 5 #include <X11/XKBlib.h>
8 #include <X11/Xlib.h> 6 #include <X11/Xlib.h>
9 #include <X11/Xutil.h> 7 #include <X11/Xutil.h>
10 #include <X11/extensions/XInput2.h> 8 #include <X11/extensions/XInput2.h>
9 #include <stddef.h>
10 #include <stdint.h>
11 11
12 #include <cstring> 12 #include <cstring>
13 #include <memory>
13 #include <set> 14 #include <set>
14 #include <utility> 15 #include <utility>
15 16
16 // Generically-named #defines from Xlib that conflict with symbols in GTest. 17 // Generically-named #defines from Xlib that conflict with symbols in GTest.
17 #undef Bool 18 #undef Bool
18 #undef None 19 #undef None
19 20
20 #include "base/macros.h" 21 #include "base/macros.h"
21 #include "base/memory/scoped_ptr.h"
22 #include "build/build_config.h" 22 #include "build/build_config.h"
23 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
24 #include "ui/events/devices/x11/device_data_manager_x11.h" 24 #include "ui/events/devices/x11/device_data_manager_x11.h"
25 #include "ui/events/devices/x11/touch_factory_x11.h" 25 #include "ui/events/devices/x11/touch_factory_x11.h"
26 #include "ui/events/event.h" 26 #include "ui/events/event.h"
27 #include "ui/events/event_constants.h" 27 #include "ui/events/event_constants.h"
28 #include "ui/events/event_utils.h" 28 #include "ui/events/event_utils.h"
29 #include "ui/events/test/events_test_utils.h" 29 #include "ui/events/test/events_test_utils.h"
30 #include "ui/events/test/events_test_utils_x11.h" 30 #include "ui/events/test/events_test_utils_x11.h"
31 #include "ui/events/x/events_x_utils.h" 31 #include "ui/events/x/events_x_utils.h"
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 devices.push_back(0); 320 devices.push_back(0);
321 ui::SetUpTouchDevicesForTest(devices); 321 ui::SetUpTouchDevicesForTest(devices);
322 std::vector<Valuator> valuators; 322 std::vector<Valuator> valuators;
323 323
324 const int kTrackingId = 5; 324 const int kTrackingId = 5;
325 325
326 // Two touch presses with the same tracking id. 326 // Two touch presses with the same tracking id.
327 ui::ScopedXI2Event xpress0; 327 ui::ScopedXI2Event xpress0;
328 xpress0.InitTouchEvent( 328 xpress0.InitTouchEvent(
329 0, XI_TouchBegin, kTrackingId, gfx::Point(10, 10), valuators); 329 0, XI_TouchBegin, kTrackingId, gfx::Point(10, 10), valuators);
330 scoped_ptr<ui::TouchEvent> upress0(new ui::TouchEvent(xpress0)); 330 std::unique_ptr<ui::TouchEvent> upress0(new ui::TouchEvent(xpress0));
331 EXPECT_EQ(0, GetTouchIdForTrackingId(kTrackingId)); 331 EXPECT_EQ(0, GetTouchIdForTrackingId(kTrackingId));
332 332
333 ui::ScopedXI2Event xpress1; 333 ui::ScopedXI2Event xpress1;
334 xpress1.InitTouchEvent( 334 xpress1.InitTouchEvent(
335 0, XI_TouchBegin, kTrackingId, gfx::Point(20, 20), valuators); 335 0, XI_TouchBegin, kTrackingId, gfx::Point(20, 20), valuators);
336 ui::TouchEvent upress1(xpress1); 336 ui::TouchEvent upress1(xpress1);
337 EXPECT_EQ(0, GetTouchIdForTrackingId(kTrackingId)); 337 EXPECT_EQ(0, GetTouchIdForTrackingId(kTrackingId));
338 338
339 // The first touch release shouldn't clear the mapping from the 339 // The first touch release shouldn't clear the mapping from the
340 // tracking id. 340 // tracking id.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 // that an exception list of keys can still be processed. 382 // that an exception list of keys can still be processed.
383 TEST_F(EventsXTest, DisableKeyboard) { 383 TEST_F(EventsXTest, DisableKeyboard) {
384 DeviceDataManagerX11* device_data_manager = 384 DeviceDataManagerX11* device_data_manager =
385 static_cast<DeviceDataManagerX11*>( 385 static_cast<DeviceDataManagerX11*>(
386 DeviceDataManager::GetInstance()); 386 DeviceDataManager::GetInstance());
387 int blocked_device_id = 1; 387 int blocked_device_id = 1;
388 int other_device_id = 2; 388 int other_device_id = 2;
389 int master_device_id = 3; 389 int master_device_id = 3;
390 device_data_manager->DisableDevice(blocked_device_id); 390 device_data_manager->DisableDevice(blocked_device_id);
391 391
392 scoped_ptr<std::set<KeyboardCode> > excepted_keys(new std::set<KeyboardCode>); 392 std::unique_ptr<std::set<KeyboardCode>> excepted_keys(
393 new std::set<KeyboardCode>);
393 excepted_keys->insert(VKEY_B); 394 excepted_keys->insert(VKEY_B);
394 device_data_manager->SetDisabledKeyboardAllowedKeys(std::move(excepted_keys)); 395 device_data_manager->SetDisabledKeyboardAllowedKeys(std::move(excepted_keys));
395 396
396 ScopedXI2Event xev; 397 ScopedXI2Event xev;
397 // A is not allowed on the blocked keyboard, and should return ET_UNKNOWN. 398 // A is not allowed on the blocked keyboard, and should return ET_UNKNOWN.
398 xev.InitGenericKeyEvent(master_device_id, 399 xev.InitGenericKeyEvent(master_device_id,
399 blocked_device_id, 400 blocked_device_id,
400 ui::ET_KEY_PRESSED, 401 ui::ET_KEY_PRESSED,
401 ui::VKEY_A, 402 ui::VKEY_A,
402 0); 403 0);
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 ui::EventTimeFromNative(&event).ToInternalValue()); 543 ui::EventTimeFromNative(&event).ToInternalValue());
543 event.xbutton.time = 2; 544 event.xbutton.time = 2;
544 EXPECT_EQ(base::TimeDelta::FromMilliseconds(2).ToInternalValue(), 545 EXPECT_EQ(base::TimeDelta::FromMilliseconds(2).ToInternalValue(),
545 ui::EventTimeFromNative(&event).ToInternalValue()); 546 ui::EventTimeFromNative(&event).ToInternalValue());
546 event.xbutton.time = 0xFFFFFFFF; 547 event.xbutton.time = 0xFFFFFFFF;
547 EXPECT_EQ(base::TimeDelta::FromMilliseconds(0xFFFFFFFF).ToInternalValue(), 548 EXPECT_EQ(base::TimeDelta::FromMilliseconds(0xFFFFFFFF).ToInternalValue(),
548 ui::EventTimeFromNative(&event).ToInternalValue()); 549 ui::EventTimeFromNative(&event).ToInternalValue());
549 } 550 }
550 551
551 } // namespace ui 552 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/test/test_event_target.cc ('k') | ui/gfx/animation/animation_container_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698