| 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/atomicops.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 return ws_test_helper_.window_server_delegate(); | 121 return ws_test_helper_.window_server_delegate(); |
| 122 } | 122 } |
| 123 | 123 |
| 124 private: | 124 private: |
| 125 TestPlatformScreen platform_screen_; | 125 TestPlatformScreen platform_screen_; |
| 126 WindowServerTestHelper ws_test_helper_; | 126 WindowServerTestHelper ws_test_helper_; |
| 127 DISALLOW_COPY_AND_ASSIGN(UserDisplayManagerTest); | 127 DISALLOW_COPY_AND_ASSIGN(UserDisplayManagerTest); |
| 128 }; | 128 }; |
| 129 | 129 |
| 130 TEST_F(UserDisplayManagerTest, OnlyNotifyWhenFrameDecorationsSet) { | 130 TEST_F(UserDisplayManagerTest, OnlyNotifyWhenFrameDecorationsSet) { |
| 131 window_server_delegate()->set_num_displays_to_create(1); | 131 window_server_delegate()->CreateDisplays(1); |
| 132 | 132 |
| 133 const UserId kUserId1 = "2"; | 133 const UserId kUserId1 = "2"; |
| 134 TestDisplayManagerObserver display_manager_observer1; | 134 TestDisplayManagerObserver display_manager_observer1; |
| 135 DisplayManager* display_manager = window_server()->display_manager(); | 135 DisplayManager* display_manager = window_server()->display_manager(); |
| 136 WindowManagerWindowTreeFactorySetTestApi( | 136 WindowManagerWindowTreeFactorySetTestApi( |
| 137 window_server()->window_manager_window_tree_factory_set()) | 137 window_server()->window_manager_window_tree_factory_set()) |
| 138 .Add(kUserId1); | 138 .Add(kUserId1); |
| 139 UserDisplayManager* user_display_manager1 = | 139 UserDisplayManager* user_display_manager1 = |
| 140 display_manager->GetUserDisplayManager(kUserId1); | 140 display_manager->GetUserDisplayManager(kUserId1); |
| 141 ASSERT_TRUE(user_display_manager1); | 141 ASSERT_TRUE(user_display_manager1); |
| 142 UserDisplayManagerTestApi(user_display_manager1) | 142 UserDisplayManagerTestApi(user_display_manager1) |
| 143 .SetTestObserver(&display_manager_observer1); | 143 .SetTestObserver(&display_manager_observer1); |
| 144 // Observer should not have been notified yet. | 144 // Observer should not have been notified yet. |
| 145 EXPECT_EQ(std::string(), | 145 EXPECT_EQ(std::string(), |
| 146 display_manager_observer1.GetAndClearObserverCalls()); | 146 display_manager_observer1.GetAndClearObserverCalls()); |
| 147 | 147 |
| 148 // Set the frame decoration values, which should trigger sending immediately. | 148 // Set the frame decoration values, which should trigger sending immediately. |
| 149 ASSERT_EQ(1u, display_manager->displays().size()); | 149 ASSERT_EQ(1u, display_manager->displays().size()); |
| 150 window_server() | 150 window_server() |
| 151 ->window_manager_window_tree_factory_set() | 151 ->window_manager_window_tree_factory_set() |
| 152 ->GetWindowManagerStateForUser(kUserId1) | 152 ->GetWindowManagerStateForUser(kUserId1) |
| 153 ->SetFrameDecorationValues(CreateDefaultFrameDecorationValues()); | 153 ->SetFrameDecorationValues(CreateDefaultFrameDecorationValues()); |
| 154 EXPECT_EQ("OnDisplays 1", | 154 EXPECT_EQ("OnDisplays 1", |
| 155 display_manager_observer1.GetAndClearObserverCalls()); | 155 display_manager_observer1.GetAndClearObserverCalls()); |
| 156 | 156 |
| 157 UserDisplayManagerTestApi(user_display_manager1).SetTestObserver(nullptr); | 157 UserDisplayManagerTestApi(user_display_manager1).SetTestObserver(nullptr); |
| 158 } | 158 } |
| 159 | 159 |
| 160 TEST_F(UserDisplayManagerTest, AddObserverAfterFrameDecorationsSet) { | 160 TEST_F(UserDisplayManagerTest, AddObserverAfterFrameDecorationsSet) { |
| 161 window_server_delegate()->set_num_displays_to_create(1); | 161 window_server_delegate()->CreateDisplays(1); |
| 162 | 162 |
| 163 const UserId kUserId1 = "2"; | 163 const UserId kUserId1 = "2"; |
| 164 TestDisplayManagerObserver display_manager_observer1; | 164 TestDisplayManagerObserver display_manager_observer1; |
| 165 DisplayManager* display_manager = window_server()->display_manager(); | 165 DisplayManager* display_manager = window_server()->display_manager(); |
| 166 WindowManagerWindowTreeFactorySetTestApi( | 166 WindowManagerWindowTreeFactorySetTestApi( |
| 167 window_server()->window_manager_window_tree_factory_set()) | 167 window_server()->window_manager_window_tree_factory_set()) |
| 168 .Add(kUserId1); | 168 .Add(kUserId1); |
| 169 UserDisplayManager* user_display_manager1 = | 169 UserDisplayManager* user_display_manager1 = |
| 170 display_manager->GetUserDisplayManager(kUserId1); | 170 display_manager->GetUserDisplayManager(kUserId1); |
| 171 ASSERT_TRUE(user_display_manager1); | 171 ASSERT_TRUE(user_display_manager1); |
| 172 ASSERT_EQ(1u, display_manager->displays().size()); | 172 ASSERT_EQ(1u, display_manager->displays().size()); |
| 173 window_server() | 173 window_server() |
| 174 ->window_manager_window_tree_factory_set() | 174 ->window_manager_window_tree_factory_set() |
| 175 ->GetWindowManagerStateForUser(kUserId1) | 175 ->GetWindowManagerStateForUser(kUserId1) |
| 176 ->SetFrameDecorationValues(CreateDefaultFrameDecorationValues()); | 176 ->SetFrameDecorationValues(CreateDefaultFrameDecorationValues()); |
| 177 | 177 |
| 178 UserDisplayManagerTestApi(user_display_manager1) | 178 UserDisplayManagerTestApi(user_display_manager1) |
| 179 .SetTestObserver(&display_manager_observer1); | 179 .SetTestObserver(&display_manager_observer1); |
| 180 EXPECT_EQ("OnDisplays 1", | 180 EXPECT_EQ("OnDisplays 1", |
| 181 display_manager_observer1.GetAndClearObserverCalls()); | 181 display_manager_observer1.GetAndClearObserverCalls()); |
| 182 | 182 |
| 183 UserDisplayManagerTestApi(user_display_manager1).SetTestObserver(nullptr); | 183 UserDisplayManagerTestApi(user_display_manager1).SetTestObserver(nullptr); |
| 184 } | 184 } |
| 185 | 185 |
| 186 TEST_F(UserDisplayManagerTest, AddRemoveDisplay) { | 186 TEST_F(UserDisplayManagerTest, AddRemoveDisplay) { |
| 187 window_server_delegate()->set_num_displays_to_create(1); | 187 window_server_delegate()->CreateDisplays(1); |
| 188 | 188 |
| 189 const UserId kUserId1 = "2"; | 189 const UserId kUserId1 = "2"; |
| 190 TestDisplayManagerObserver display_manager_observer1; | 190 TestDisplayManagerObserver display_manager_observer1; |
| 191 DisplayManager* display_manager = window_server()->display_manager(); | 191 DisplayManager* display_manager = window_server()->display_manager(); |
| 192 WindowManagerWindowTreeFactorySetTestApi( | 192 WindowManagerWindowTreeFactorySetTestApi( |
| 193 window_server()->window_manager_window_tree_factory_set()) | 193 window_server()->window_manager_window_tree_factory_set()) |
| 194 .Add(kUserId1); | 194 .Add(kUserId1); |
| 195 UserDisplayManager* user_display_manager1 = | 195 UserDisplayManager* user_display_manager1 = |
| 196 display_manager->GetUserDisplayManager(kUserId1); | 196 display_manager->GetUserDisplayManager(kUserId1); |
| 197 ASSERT_TRUE(user_display_manager1); | 197 ASSERT_TRUE(user_display_manager1); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 216 // Remove the display and verify observer is notified. | 216 // Remove the display and verify observer is notified. |
| 217 display_manager->DestroyDisplay(display2); | 217 display_manager->DestroyDisplay(display2); |
| 218 display2 = nullptr; | 218 display2 = nullptr; |
| 219 EXPECT_EQ("OnDisplayRemoved 2", | 219 EXPECT_EQ("OnDisplayRemoved 2", |
| 220 display_manager_observer1.GetAndClearObserverCalls()); | 220 display_manager_observer1.GetAndClearObserverCalls()); |
| 221 | 221 |
| 222 UserDisplayManagerTestApi(user_display_manager1).SetTestObserver(nullptr); | 222 UserDisplayManagerTestApi(user_display_manager1).SetTestObserver(nullptr); |
| 223 } | 223 } |
| 224 | 224 |
| 225 TEST_F(UserDisplayManagerTest, NegativeCoordinates) { | 225 TEST_F(UserDisplayManagerTest, NegativeCoordinates) { |
| 226 window_server_delegate()->set_num_displays_to_create(1); | 226 window_server_delegate()->CreateDisplays(1); |
| 227 | 227 |
| 228 const UserId kUserId1 = "2"; | 228 const UserId kUserId1 = "2"; |
| 229 TestDisplayManagerObserver display_manager_observer1; | 229 TestDisplayManagerObserver display_manager_observer1; |
| 230 DisplayManager* display_manager = window_server()->display_manager(); | 230 DisplayManager* display_manager = window_server()->display_manager(); |
| 231 WindowManagerWindowTreeFactorySetTestApi( | 231 WindowManagerWindowTreeFactorySetTestApi( |
| 232 window_server()->window_manager_window_tree_factory_set()) | 232 window_server()->window_manager_window_tree_factory_set()) |
| 233 .Add(kUserId1); | 233 .Add(kUserId1); |
| 234 UserDisplayManager* user_display_manager1 = | 234 UserDisplayManager* user_display_manager1 = |
| 235 display_manager->GetUserDisplayManager(kUserId1); | 235 display_manager->GetUserDisplayManager(kUserId1); |
| 236 ASSERT_TRUE(user_display_manager1); | 236 ASSERT_TRUE(user_display_manager1); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 249 base::subtle::Atomic32 location = | 249 base::subtle::Atomic32 location = |
| 250 base::subtle::NoBarrier_Load(cursor_location_memory); | 250 base::subtle::NoBarrier_Load(cursor_location_memory); |
| 251 EXPECT_EQ(gfx::Point(static_cast<int16_t>(location >> 16), | 251 EXPECT_EQ(gfx::Point(static_cast<int16_t>(location >> 16), |
| 252 static_cast<int16_t>(location & 0xFFFF)), | 252 static_cast<int16_t>(location & 0xFFFF)), |
| 253 gfx::Point(-10, -11)); | 253 gfx::Point(-10, -11)); |
| 254 } | 254 } |
| 255 | 255 |
| 256 } // namespace test | 256 } // namespace test |
| 257 } // namespace ws | 257 } // namespace ws |
| 258 } // namespace ui | 258 } // namespace ui |
| OLD | NEW |