| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "services/ui/ws/user_display_manager.h" | 5 #include "services/ui/ws/user_display_manager.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/atomicops.h" | |
| 12 #include "base/macros.h" | 11 #include "base/macros.h" |
| 13 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 14 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
| 15 #include "mojo/public/cpp/bindings/binding.h" | 14 #include "mojo/public/cpp/bindings/binding.h" |
| 16 #include "mojo/public/cpp/bindings/interface_request.h" | 15 #include "mojo/public/cpp/bindings/interface_request.h" |
| 17 #include "services/ui/common/task_runner_test_base.h" | 16 #include "services/ui/common/task_runner_test_base.h" |
| 18 #include "services/ui/common/types.h" | 17 #include "services/ui/common/types.h" |
| 19 #include "services/ui/common/util.h" | 18 #include "services/ui/common/util.h" |
| 20 #include "services/ui/display/screen_manager.h" | 19 #include "services/ui/display/screen_manager.h" |
| 21 #include "services/ui/ws/display_manager.h" | 20 #include "services/ui/ws/display_manager.h" |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 display_manager_observer1.GetAndClearObserverCalls()); | 202 display_manager_observer1.GetAndClearObserverCalls()); |
| 204 | 203 |
| 205 // Remove the display and verify observer is notified. | 204 // Remove the display and verify observer is notified. |
| 206 screen_manager().RemoveDisplay(second_display_id); | 205 screen_manager().RemoveDisplay(second_display_id); |
| 207 RunUntilIdle(); | 206 RunUntilIdle(); |
| 208 | 207 |
| 209 EXPECT_EQ("OnDisplayRemoved 2", | 208 EXPECT_EQ("OnDisplayRemoved 2", |
| 210 display_manager_observer1.GetAndClearObserverCalls()); | 209 display_manager_observer1.GetAndClearObserverCalls()); |
| 211 } | 210 } |
| 212 | 211 |
| 213 TEST_F(UserDisplayManagerTest, NegativeCoordinates) { | |
| 214 screen_manager().AddDisplay(); | |
| 215 | |
| 216 TestDisplayManagerObserver display_manager_observer1; | |
| 217 DisplayManager* display_manager = window_server()->display_manager(); | |
| 218 AddWindowManager(window_server(), kUserId1); | |
| 219 UserDisplayManager* user_display_manager1 = | |
| 220 display_manager->GetUserDisplayManager(kUserId1); | |
| 221 ASSERT_TRUE(user_display_manager1); | |
| 222 | |
| 223 user_display_manager1->OnMouseCursorLocationChanged(gfx::Point(-10, -11)); | |
| 224 | |
| 225 base::subtle::Atomic32* cursor_location_memory = nullptr; | |
| 226 mojo::ScopedSharedBufferHandle handle = | |
| 227 user_display_manager1->GetCursorLocationMemory(); | |
| 228 mojo::ScopedSharedBufferMapping cursor_location_mapping = | |
| 229 handle->Map(sizeof(base::subtle::Atomic32)); | |
| 230 ASSERT_TRUE(cursor_location_mapping); | |
| 231 cursor_location_memory = | |
| 232 reinterpret_cast<base::subtle::Atomic32*>(cursor_location_mapping.get()); | |
| 233 | |
| 234 base::subtle::Atomic32 location = | |
| 235 base::subtle::NoBarrier_Load(cursor_location_memory); | |
| 236 EXPECT_EQ(gfx::Point(static_cast<int16_t>(location >> 16), | |
| 237 static_cast<int16_t>(location & 0xFFFF)), | |
| 238 gfx::Point(-10, -11)); | |
| 239 } | |
| 240 | |
| 241 } // namespace test | 212 } // namespace test |
| 242 } // namespace ws | 213 } // namespace ws |
| 243 } // namespace ui | 214 } // namespace ui |
| OLD | NEW |