| 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 <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/atomicops.h" |
| 9 #include "base/macros.h" | 10 #include "base/macros.h" |
| 10 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 11 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 12 #include "components/mus/common/types.h" | 13 #include "components/mus/common/types.h" |
| 13 #include "components/mus/common/util.h" | 14 #include "components/mus/common/util.h" |
| 14 #include "components/mus/public/interfaces/window_tree.mojom.h" | 15 #include "components/mus/public/interfaces/window_tree.mojom.h" |
| 15 #include "components/mus/surfaces/surfaces_state.h" | 16 #include "components/mus/surfaces/surfaces_state.h" |
| 16 #include "components/mus/ws/display_binding.h" | 17 #include "components/mus/ws/display_binding.h" |
| 17 #include "components/mus/ws/display_manager.h" | 18 #include "components/mus/ws/display_manager.h" |
| 18 #include "components/mus/ws/ids.h" | 19 #include "components/mus/ws/ids.h" |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 | 221 |
| 221 // Remove the display and verify observer is notified. | 222 // Remove the display and verify observer is notified. |
| 222 display_manager->DestroyDisplay(display2); | 223 display_manager->DestroyDisplay(display2); |
| 223 display2 = nullptr; | 224 display2 = nullptr; |
| 224 EXPECT_EQ("OnDisplayRemoved 2", | 225 EXPECT_EQ("OnDisplayRemoved 2", |
| 225 display_manager_observer1.GetAndClearObserverCalls()); | 226 display_manager_observer1.GetAndClearObserverCalls()); |
| 226 | 227 |
| 227 UserDisplayManagerTestApi(user_display_manager1).SetTestObserver(nullptr); | 228 UserDisplayManagerTestApi(user_display_manager1).SetTestObserver(nullptr); |
| 228 } | 229 } |
| 229 | 230 |
| 231 TEST_F(UserDisplayManagerTest, NegativeCoordinates) { |
| 232 window_server_delegate_.set_num_displays_to_create(1); |
| 233 |
| 234 const UserId kUserId1 = "2"; |
| 235 TestDisplayManagerObserver display_manager_observer1; |
| 236 DisplayManager* display_manager = window_server_->display_manager(); |
| 237 WindowManagerFactoryRegistryTestApi( |
| 238 window_server_->window_manager_factory_registry()) |
| 239 .AddService(kUserId1, &test_window_manager_factory_); |
| 240 UserDisplayManager* user_display_manager1 = |
| 241 display_manager->GetUserDisplayManager(kUserId1); |
| 242 ASSERT_TRUE(user_display_manager1); |
| 243 |
| 244 user_display_manager1->OnMouseCursorLocationChanged(gfx::Point(-10, -11)); |
| 245 |
| 246 base::subtle::Atomic32* cursor_location_memory = nullptr; |
| 247 mojo::ScopedSharedBufferHandle handle = |
| 248 user_display_manager1->GetCursorLocationMemory(); |
| 249 MojoResult result = mojo::MapBuffer( |
| 250 handle.get(), 0, |
| 251 sizeof(base::subtle::Atomic32), |
| 252 reinterpret_cast<void**>(&cursor_location_memory), |
| 253 MOJO_MAP_BUFFER_FLAG_NONE); |
| 254 ASSERT_EQ(MOJO_RESULT_OK, result); |
| 255 |
| 256 base::subtle::Atomic32 location = |
| 257 base::subtle::NoBarrier_Load(cursor_location_memory); |
| 258 EXPECT_EQ(gfx::Point(static_cast<int16_t>(location >> 16), |
| 259 static_cast<int16_t>(location & 0xFFFF)), |
| 260 gfx::Point(-10, -11)); |
| 261 } |
| 262 |
| 230 } // namespace test | 263 } // namespace test |
| 231 } // namespace ws | 264 } // namespace ws |
| 232 } // namespace mus | 265 } // namespace mus |
| OLD | NEW |