Chromium Code Reviews| 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" |
| 11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 13 #include "services/ui/common/types.h" | 13 #include "services/ui/common/types.h" |
| 14 #include "services/ui/common/util.h" | 14 #include "services/ui/common/util.h" |
| 15 #include "services/ui/display/platform_screen.h" | |
| 15 #include "services/ui/public/interfaces/window_tree.mojom.h" | 16 #include "services/ui/public/interfaces/window_tree.mojom.h" |
| 16 #include "services/ui/surfaces/display_compositor.h" | 17 #include "services/ui/surfaces/display_compositor.h" |
| 17 #include "services/ui/ws/display_manager.h" | 18 #include "services/ui/ws/display_manager.h" |
| 18 #include "services/ui/ws/ids.h" | 19 #include "services/ui/ws/ids.h" |
| 19 #include "services/ui/ws/platform_display.h" | 20 #include "services/ui/ws/platform_display.h" |
| 20 #include "services/ui/ws/platform_display_factory.h" | 21 #include "services/ui/ws/platform_display_factory.h" |
| 21 #include "services/ui/ws/platform_display_init_params.h" | 22 #include "services/ui/ws/platform_display_init_params.h" |
| 22 #include "services/ui/ws/server_window.h" | 23 #include "services/ui/ws/server_window.h" |
| 23 #include "services/ui/ws/test_utils.h" | 24 #include "services/ui/ws/test_utils.h" |
| 24 #include "services/ui/ws/window_manager_state.h" | 25 #include "services/ui/ws/window_manager_state.h" |
| 25 #include "services/ui/ws/window_manager_window_tree_factory_set.h" | 26 #include "services/ui/ws/window_manager_window_tree_factory_set.h" |
| 26 #include "services/ui/ws/window_server.h" | 27 #include "services/ui/ws/window_server.h" |
| 27 #include "services/ui/ws/window_server_delegate.h" | 28 #include "services/ui/ws/window_server_delegate.h" |
| 28 #include "services/ui/ws/window_tree.h" | 29 #include "services/ui/ws/window_tree.h" |
| 29 #include "services/ui/ws/window_tree_binding.h" | 30 #include "services/ui/ws/window_tree_binding.h" |
| 30 #include "testing/gtest/include/gtest/gtest.h" | 31 #include "testing/gtest/include/gtest/gtest.h" |
| 31 #include "ui/gfx/geometry/rect.h" | 32 #include "ui/gfx/geometry/rect.h" |
| 32 | 33 |
| 33 namespace ui { | 34 namespace ui { |
| 34 namespace ws { | 35 namespace ws { |
| 35 namespace test { | 36 namespace test { |
| 36 namespace { | 37 namespace { |
| 37 | 38 |
| 39 // Stub PlatformScreen implementation so PlatformScreen::GetInstance() doesn't | |
| 40 // fail. | |
| 41 class PlatformScreenTest : public display::PlatformScreen { | |
| 42 public: | |
| 43 PlatformScreenTest() {} | |
| 44 ~PlatformScreenTest() override {} | |
| 45 | |
| 46 // display::PlatformScreen: | |
| 47 void AddInterfaces(service_manager::InterfaceRegistry* registry) override {} | |
| 48 void Init(display::PlatformScreenDelegate* delegate) override {} | |
| 49 void RequestCloseDisplay(int64_t display_id) override {} | |
| 50 int64_t GetPrimaryDisplayId() const override { return 1; } | |
| 51 | |
| 52 private: | |
| 53 DISALLOW_COPY_AND_ASSIGN(PlatformScreenTest); | |
| 54 }; | |
| 55 PlatformScreenTest* platform_screen = new PlatformScreenTest(); | |
|
sky
2016/10/28 17:08:47
If you create PlatformScreenTest outside of the te
kylechar
2016/10/28 19:40:37
Done and done.
| |
| 56 | |
| 38 class TestDisplayManagerObserver : public mojom::DisplayManagerObserver { | 57 class TestDisplayManagerObserver : public mojom::DisplayManagerObserver { |
| 39 public: | 58 public: |
| 40 TestDisplayManagerObserver() {} | 59 TestDisplayManagerObserver() {} |
| 41 ~TestDisplayManagerObserver() override {} | 60 ~TestDisplayManagerObserver() override {} |
| 42 | 61 |
| 43 std::string GetAndClearObserverCalls() { | 62 std::string GetAndClearObserverCalls() { |
| 44 std::string result; | 63 std::string result; |
| 45 std::swap(observer_calls_, result); | 64 std::swap(observer_calls_, result); |
| 46 return result; | 65 return result; |
| 47 } | 66 } |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 58 std::string display_ids; | 77 std::string display_ids; |
| 59 for (const auto& wm_display : wm_displays) { | 78 for (const auto& wm_display : wm_displays) { |
| 60 if (!display_ids.empty()) | 79 if (!display_ids.empty()) |
| 61 display_ids += " "; | 80 display_ids += " "; |
| 62 display_ids += base::Int64ToString(wm_display->display.id()); | 81 display_ids += base::Int64ToString(wm_display->display.id()); |
| 63 } | 82 } |
| 64 return display_ids; | 83 return display_ids; |
| 65 } | 84 } |
| 66 | 85 |
| 67 // mojom::DisplayManagerObserver: | 86 // mojom::DisplayManagerObserver: |
| 68 void OnDisplays(mojo::Array<mojom::WsDisplayPtr> displays) override { | 87 void OnDisplays(mojo::Array<mojom::WsDisplayPtr> displays, |
| 88 int64_t primary_display_id, | |
| 89 int64_t internal_display_id) override { | |
| 69 AddCall("OnDisplays " + DisplayIdsToString(displays)); | 90 AddCall("OnDisplays " + DisplayIdsToString(displays)); |
| 70 } | 91 } |
| 71 void OnDisplaysChanged(mojo::Array<mojom::WsDisplayPtr> displays) override { | 92 void OnDisplaysChanged(mojo::Array<mojom::WsDisplayPtr> displays) override { |
| 72 AddCall("OnDisplaysChanged " + DisplayIdsToString(displays)); | 93 AddCall("OnDisplaysChanged " + DisplayIdsToString(displays)); |
| 73 } | 94 } |
| 74 void OnDisplayRemoved(int64_t id) override { | 95 void OnDisplayRemoved(int64_t id) override { |
| 75 AddCall("OnDisplayRemoved " + base::Int64ToString(id)); | 96 AddCall("OnDisplayRemoved " + base::Int64ToString(id)); |
| 76 } | 97 } |
| 98 void OnPrimaryDisplayChanged(int64_t id) override { | |
| 99 AddCall("OnPrimaryDisplayChanged " + base::Int64ToString(id)); | |
| 100 } | |
| 77 | 101 |
| 78 std::string observer_calls_; | 102 std::string observer_calls_; |
| 79 | 103 |
| 80 DISALLOW_COPY_AND_ASSIGN(TestDisplayManagerObserver); | 104 DISALLOW_COPY_AND_ASSIGN(TestDisplayManagerObserver); |
| 81 }; | 105 }; |
| 82 | 106 |
| 83 mojom::FrameDecorationValuesPtr CreateDefaultFrameDecorationValues() { | 107 mojom::FrameDecorationValuesPtr CreateDefaultFrameDecorationValues() { |
| 84 return mojom::FrameDecorationValues::New(); | 108 return mojom::FrameDecorationValues::New(); |
| 85 } | 109 } |
| 86 | 110 |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 225 base::subtle::Atomic32 location = | 249 base::subtle::Atomic32 location = |
| 226 base::subtle::NoBarrier_Load(cursor_location_memory); | 250 base::subtle::NoBarrier_Load(cursor_location_memory); |
| 227 EXPECT_EQ(gfx::Point(static_cast<int16_t>(location >> 16), | 251 EXPECT_EQ(gfx::Point(static_cast<int16_t>(location >> 16), |
| 228 static_cast<int16_t>(location & 0xFFFF)), | 252 static_cast<int16_t>(location & 0xFFFF)), |
| 229 gfx::Point(-10, -11)); | 253 gfx::Point(-10, -11)); |
| 230 } | 254 } |
| 231 | 255 |
| 232 } // namespace test | 256 } // namespace test |
| 233 } // namespace ws | 257 } // namespace ws |
| 234 } // namespace ui | 258 } // namespace ui |
| OLD | NEW |