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

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

Issue 2904993003: chromeos: changes how DisplayManagerObservers are notified (Closed)
Patch Set: cleanup Created 3 years, 7 months 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.cc ('k') | services/ui/ws/window_manager_state.cc » ('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 "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
(...skipping 18 matching lines...) Expand all
29 #include "testing/gtest/include/gtest/gtest.h" 29 #include "testing/gtest/include/gtest/gtest.h"
30 #include "ui/gfx/geometry/rect.h" 30 #include "ui/gfx/geometry/rect.h"
31 31
32 namespace ui { 32 namespace ui {
33 namespace ws { 33 namespace ws {
34 namespace test { 34 namespace test {
35 namespace { 35 namespace {
36 36
37 const char kUserId1[] = "123"; 37 const char kUserId1[] = "123";
38 38
39 class TestDisplayManagerObserver : public mojom::DisplayManagerObserver {
40 public:
41 TestDisplayManagerObserver() : binding_(this) {}
42 ~TestDisplayManagerObserver() override {}
43
44 mojom::DisplayManagerObserverPtr GetPtr() {
45 return binding_.CreateInterfacePtrAndBind();
46 }
47
48 std::string GetAndClearObserverCalls() {
49 std::string result;
50 std::swap(observer_calls_, result);
51 return result;
52 }
53
54 private:
55 void AddCall(const std::string& call) {
56 if (!observer_calls_.empty())
57 observer_calls_ += "\n";
58 observer_calls_ += call;
59 }
60
61 std::string DisplayIdsToString(
62 const std::vector<mojom::WsDisplayPtr>& wm_displays) {
63 std::string display_ids;
64 for (const auto& wm_display : wm_displays) {
65 if (!display_ids.empty())
66 display_ids += " ";
67 display_ids += base::Int64ToString(wm_display->display.id());
68 }
69 return display_ids;
70 }
71
72 // mojom::DisplayManagerObserver:
73 void OnDisplaysChanged(std::vector<mojom::WsDisplayPtr> displays,
74 int64_t primary_display_id,
75 int64_t internal_display_id) override {
76 AddCall("OnDisplaysChanged " + DisplayIdsToString(displays));
77 }
78
79 mojo::Binding<mojom::DisplayManagerObserver> binding_;
80 std::string observer_calls_;
81
82 DISALLOW_COPY_AND_ASSIGN(TestDisplayManagerObserver);
83 };
84
85 mojom::FrameDecorationValuesPtr CreateDefaultFrameDecorationValues() { 39 mojom::FrameDecorationValuesPtr CreateDefaultFrameDecorationValues() {
86 return mojom::FrameDecorationValues::New(); 40 return mojom::FrameDecorationValues::New();
87 } 41 }
88 42
89 } // namespace 43 } // namespace
90 44
91 // ----------------------------------------------------------------------------- 45 // -----------------------------------------------------------------------------
92 46
93 class UserDisplayManagerTest : public TaskRunnerTestBase { 47 class UserDisplayManagerTest : public TaskRunnerTestBase {
94 public: 48 public:
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 screen_manager().RemoveDisplay(second_display_id); 150 screen_manager().RemoveDisplay(second_display_id);
197 RunUntilIdle(); 151 RunUntilIdle();
198 152
199 EXPECT_EQ("OnDisplaysChanged 1", 153 EXPECT_EQ("OnDisplaysChanged 1",
200 display_manager_observer1.GetAndClearObserverCalls()); 154 display_manager_observer1.GetAndClearObserverCalls());
201 } 155 }
202 156
203 } // namespace test 157 } // namespace test
204 } // namespace ws 158 } // namespace ws
205 } // namespace ui 159 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/ws/user_display_manager.cc ('k') | services/ui/ws/window_manager_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698