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

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

Issue 2461513002: Primary display change notifications. (Closed)
Patch Set: More fixes. Created 4 years, 1 month 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/user_display_manager_delegate.h ('k') | services/ui/ws/window_manager_state.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 TestPlatformScreen : public display::PlatformScreen {
42 public:
43 TestPlatformScreen() {}
44 ~TestPlatformScreen() 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(TestPlatformScreen);
54 };
55
38 class TestDisplayManagerObserver : public mojom::DisplayManagerObserver { 56 class TestDisplayManagerObserver : public mojom::DisplayManagerObserver {
39 public: 57 public:
40 TestDisplayManagerObserver() {} 58 TestDisplayManagerObserver() {}
41 ~TestDisplayManagerObserver() override {} 59 ~TestDisplayManagerObserver() override {}
42 60
43 std::string GetAndClearObserverCalls() { 61 std::string GetAndClearObserverCalls() {
44 std::string result; 62 std::string result;
45 std::swap(observer_calls_, result); 63 std::swap(observer_calls_, result);
46 return result; 64 return result;
47 } 65 }
(...skipping 10 matching lines...) Expand all
58 std::string display_ids; 76 std::string display_ids;
59 for (const auto& wm_display : wm_displays) { 77 for (const auto& wm_display : wm_displays) {
60 if (!display_ids.empty()) 78 if (!display_ids.empty())
61 display_ids += " "; 79 display_ids += " ";
62 display_ids += base::Int64ToString(wm_display->display.id()); 80 display_ids += base::Int64ToString(wm_display->display.id());
63 } 81 }
64 return display_ids; 82 return display_ids;
65 } 83 }
66 84
67 // mojom::DisplayManagerObserver: 85 // mojom::DisplayManagerObserver:
68 void OnDisplays(mojo::Array<mojom::WsDisplayPtr> displays) override { 86 void OnDisplays(mojo::Array<mojom::WsDisplayPtr> displays,
87 int64_t primary_display_id,
88 int64_t internal_display_id) override {
69 AddCall("OnDisplays " + DisplayIdsToString(displays)); 89 AddCall("OnDisplays " + DisplayIdsToString(displays));
70 } 90 }
71 void OnDisplaysChanged(mojo::Array<mojom::WsDisplayPtr> displays) override { 91 void OnDisplaysChanged(mojo::Array<mojom::WsDisplayPtr> displays) override {
72 AddCall("OnDisplaysChanged " + DisplayIdsToString(displays)); 92 AddCall("OnDisplaysChanged " + DisplayIdsToString(displays));
73 } 93 }
74 void OnDisplayRemoved(int64_t id) override { 94 void OnDisplayRemoved(int64_t id) override {
75 AddCall("OnDisplayRemoved " + base::Int64ToString(id)); 95 AddCall("OnDisplayRemoved " + base::Int64ToString(id));
76 } 96 }
97 void OnPrimaryDisplayChanged(int64_t id) override {
98 AddCall("OnPrimaryDisplayChanged " + base::Int64ToString(id));
99 }
77 100
78 std::string observer_calls_; 101 std::string observer_calls_;
79 102
80 DISALLOW_COPY_AND_ASSIGN(TestDisplayManagerObserver); 103 DISALLOW_COPY_AND_ASSIGN(TestDisplayManagerObserver);
81 }; 104 };
82 105
83 mojom::FrameDecorationValuesPtr CreateDefaultFrameDecorationValues() { 106 mojom::FrameDecorationValuesPtr CreateDefaultFrameDecorationValues() {
84 return mojom::FrameDecorationValues::New(); 107 return mojom::FrameDecorationValues::New();
85 } 108 }
86 109
87 } // namespace 110 } // namespace
88 111
89 // ----------------------------------------------------------------------------- 112 // -----------------------------------------------------------------------------
90 113
91 class UserDisplayManagerTest : public testing::Test { 114 class UserDisplayManagerTest : public testing::Test {
92 public: 115 public:
93 UserDisplayManagerTest() {} 116 UserDisplayManagerTest() {}
94 ~UserDisplayManagerTest() override {} 117 ~UserDisplayManagerTest() override {}
95 118
96 WindowServer* window_server() { return ws_test_helper_.window_server(); } 119 WindowServer* window_server() { return ws_test_helper_.window_server(); }
97 TestWindowServerDelegate* window_server_delegate() { 120 TestWindowServerDelegate* window_server_delegate() {
98 return ws_test_helper_.window_server_delegate(); 121 return ws_test_helper_.window_server_delegate();
99 } 122 }
100 123
101 private: 124 private:
125 TestPlatformScreen platform_screen_;
102 WindowServerTestHelper ws_test_helper_; 126 WindowServerTestHelper ws_test_helper_;
103 DISALLOW_COPY_AND_ASSIGN(UserDisplayManagerTest); 127 DISALLOW_COPY_AND_ASSIGN(UserDisplayManagerTest);
104 }; 128 };
105 129
106 TEST_F(UserDisplayManagerTest, OnlyNotifyWhenFrameDecorationsSet) { 130 TEST_F(UserDisplayManagerTest, OnlyNotifyWhenFrameDecorationsSet) {
107 window_server_delegate()->set_num_displays_to_create(1); 131 window_server_delegate()->set_num_displays_to_create(1);
108 132
109 const UserId kUserId1 = "2"; 133 const UserId kUserId1 = "2";
110 TestDisplayManagerObserver display_manager_observer1; 134 TestDisplayManagerObserver display_manager_observer1;
111 DisplayManager* display_manager = window_server()->display_manager(); 135 DisplayManager* display_manager = window_server()->display_manager();
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« no previous file with comments | « services/ui/ws/user_display_manager_delegate.h ('k') | services/ui/ws/window_manager_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698