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

Side by Side Diff: services/ui/ws/cursor_location_manager_unittest.cc

Issue 2696963003: Split cursor location from UserDisplayManager. (Closed)
Patch Set: Fix nits. Created 3 years, 10 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 | « services/ui/ws/cursor_location_manager.cc ('k') | services/ui/ws/display_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "services/ui/ws/cursor_location_manager.h"
6
7 #include "base/atomicops.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "ui/gfx/geometry/point.h"
10
11 namespace ui {
12 namespace ws {
13 namespace test {
14 namespace {
15
16 gfx::Point Atomic32ToPoint(base::subtle::Atomic32 atomic) {
17 return gfx::Point(static_cast<int16_t>(atomic >> 16),
18 static_cast<int16_t>(atomic & 0xFFFF));
19 }
20
21 } // namespace
22
23 TEST(CursorLocationManagerTest, PositiveCoordinates) {
24 const gfx::Point point(100, 150);
25
26 CursorLocationManager cursor_location_manager;
27 cursor_location_manager.OnMouseCursorLocationChanged(point);
28
29 base::subtle::Atomic32* cursor_location_memory = nullptr;
30 mojo::ScopedSharedBufferHandle handle =
31 cursor_location_manager.GetCursorLocationMemory();
32 mojo::ScopedSharedBufferMapping cursor_location_mapping =
33 handle->Map(sizeof(base::subtle::Atomic32));
34 ASSERT_TRUE(cursor_location_mapping);
35 cursor_location_memory =
36 reinterpret_cast<base::subtle::Atomic32*>(cursor_location_mapping.get());
37
38 base::subtle::Atomic32 location =
39 base::subtle::NoBarrier_Load(cursor_location_memory);
40 EXPECT_EQ(point, Atomic32ToPoint(location));
41 }
42
43 TEST(CursorLocationManagerTest, NegativeCoordinates) {
44 const gfx::Point point(-10, -11);
45
46 CursorLocationManager cursor_location_manager;
47 cursor_location_manager.OnMouseCursorLocationChanged(point);
48
49 base::subtle::Atomic32* cursor_location_memory = nullptr;
50 mojo::ScopedSharedBufferHandle handle =
51 cursor_location_manager.GetCursorLocationMemory();
52 mojo::ScopedSharedBufferMapping cursor_location_mapping =
53 handle->Map(sizeof(base::subtle::Atomic32));
54 ASSERT_TRUE(cursor_location_mapping);
55 cursor_location_memory =
56 reinterpret_cast<base::subtle::Atomic32*>(cursor_location_mapping.get());
57
58 base::subtle::Atomic32 location =
59 base::subtle::NoBarrier_Load(cursor_location_memory);
60 EXPECT_EQ(point, Atomic32ToPoint(location));
61 }
62
63 } // namespace test
64 } // namespace ws
65 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/ws/cursor_location_manager.cc ('k') | services/ui/ws/display_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698