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

Side by Side Diff: components/mus/ws/window_manager_client_apptest.cc

Issue 1755003002: Remove MOJO_DISALLOW_COPY_AND_ASSIGN and MOJO_ALLOW_UNUSED_LOCAL. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 9 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 | « components/mus/public/cpp/window.h ('k') | components/mus/ws/window_tree_apptest.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 // Overridden from WindowObserver: 67 // Overridden from WindowObserver:
68 void OnWindowBoundsChanged(Window* window, 68 void OnWindowBoundsChanged(Window* window,
69 const gfx::Rect& old_bounds, 69 const gfx::Rect& old_bounds,
70 const gfx::Rect& new_bounds) override { 70 const gfx::Rect& new_bounds) override {
71 DCHECK_EQ(window, window_); 71 DCHECK_EQ(window, window_);
72 EXPECT_TRUE(WindowServerTestBase::QuitRunLoop()); 72 EXPECT_TRUE(WindowServerTestBase::QuitRunLoop());
73 } 73 }
74 74
75 Window* window_; 75 Window* window_;
76 76
77 MOJO_DISALLOW_COPY_AND_ASSIGN(BoundsChangeObserver); 77 DISALLOW_COPY_AND_ASSIGN(BoundsChangeObserver);
78 }; 78 };
79 79
80 // Wait until the bounds of the supplied window change; returns false on 80 // Wait until the bounds of the supplied window change; returns false on
81 // timeout. 81 // timeout.
82 bool WaitForBoundsToChange(Window* window) { 82 bool WaitForBoundsToChange(Window* window) {
83 BoundsChangeObserver observer(window); 83 BoundsChangeObserver observer(window);
84 return WindowServerTestBase::DoRunLoopWithTimeout(); 84 return WindowServerTestBase::DoRunLoopWithTimeout();
85 } 85 }
86 86
87 class ClientAreaChangeObserver : public WindowObserver { 87 class ClientAreaChangeObserver : public WindowObserver {
88 public: 88 public:
89 explicit ClientAreaChangeObserver(Window* window) : window_(window) { 89 explicit ClientAreaChangeObserver(Window* window) : window_(window) {
90 window_->AddObserver(this); 90 window_->AddObserver(this);
91 } 91 }
92 ~ClientAreaChangeObserver() override { window_->RemoveObserver(this); } 92 ~ClientAreaChangeObserver() override { window_->RemoveObserver(this); }
93 93
94 private: 94 private:
95 // Overridden from WindowObserver: 95 // Overridden from WindowObserver:
96 void OnWindowClientAreaChanged( 96 void OnWindowClientAreaChanged(
97 Window* window, 97 Window* window,
98 const gfx::Insets& old_client_area, 98 const gfx::Insets& old_client_area,
99 const std::vector<gfx::Rect>& old_additional_client_areas) override { 99 const std::vector<gfx::Rect>& old_additional_client_areas) override {
100 DCHECK_EQ(window, window_); 100 DCHECK_EQ(window, window_);
101 EXPECT_TRUE(WindowServerTestBase::QuitRunLoop()); 101 EXPECT_TRUE(WindowServerTestBase::QuitRunLoop());
102 } 102 }
103 103
104 Window* window_; 104 Window* window_;
105 105
106 MOJO_DISALLOW_COPY_AND_ASSIGN(ClientAreaChangeObserver); 106 DISALLOW_COPY_AND_ASSIGN(ClientAreaChangeObserver);
107 }; 107 };
108 108
109 // Wait until the bounds of the supplied window change; returns false on 109 // Wait until the bounds of the supplied window change; returns false on
110 // timeout. 110 // timeout.
111 bool WaitForClientAreaToChange(Window* window) { 111 bool WaitForClientAreaToChange(Window* window) {
112 ClientAreaChangeObserver observer(window); 112 ClientAreaChangeObserver observer(window);
113 return WindowServerTestBase::DoRunLoopWithTimeout(); 113 return WindowServerTestBase::DoRunLoopWithTimeout();
114 } 114 }
115 115
116 // Spins a run loop until the tree beginning at |root| has |tree_size| windows 116 // Spins a run loop until the tree beginning at |root| has |tree_size| windows
(...skipping 19 matching lines...) Expand all
136 size_t count = 1; 136 size_t count = 1;
137 Window::Children::const_iterator it = window->children().begin(); 137 Window::Children::const_iterator it = window->children().begin();
138 for (; it != window->children().end(); ++it) 138 for (; it != window->children().end(); ++it)
139 count += CountWindows(*it); 139 count += CountWindows(*it);
140 return count; 140 return count;
141 } 141 }
142 142
143 Window* tree_; 143 Window* tree_;
144 size_t tree_size_; 144 size_t tree_size_;
145 145
146 MOJO_DISALLOW_COPY_AND_ASSIGN(TreeSizeMatchesObserver); 146 DISALLOW_COPY_AND_ASSIGN(TreeSizeMatchesObserver);
147 }; 147 };
148 148
149 // Wait until |window| has |tree_size| descendants; returns false on timeout. 149 // Wait until |window| has |tree_size| descendants; returns false on timeout.
150 // The count includes |window|. For example, if you want to wait for |window| to 150 // The count includes |window|. For example, if you want to wait for |window| to
151 // have a single child, use a |tree_size| of 2. 151 // have a single child, use a |tree_size| of 2.
152 bool WaitForTreeSizeToMatch(Window* window, size_t tree_size) { 152 bool WaitForTreeSizeToMatch(Window* window, size_t tree_size) {
153 TreeSizeMatchesObserver observer(window, tree_size); 153 TreeSizeMatchesObserver observer(window, tree_size);
154 return observer.IsTreeCorrectSize() || 154 return observer.IsTreeCorrectSize() ||
155 WindowServerTestBase::DoRunLoopWithTimeout(); 155 WindowServerTestBase::DoRunLoopWithTimeout();
156 } 156 }
157 157
158 class OrderChangeObserver : public WindowObserver { 158 class OrderChangeObserver : public WindowObserver {
159 public: 159 public:
160 OrderChangeObserver(Window* window) : window_(window) { 160 OrderChangeObserver(Window* window) : window_(window) {
161 window_->AddObserver(this); 161 window_->AddObserver(this);
162 } 162 }
163 ~OrderChangeObserver() override { window_->RemoveObserver(this); } 163 ~OrderChangeObserver() override { window_->RemoveObserver(this); }
164 164
165 private: 165 private:
166 // Overridden from WindowObserver: 166 // Overridden from WindowObserver:
167 void OnWindowReordered(Window* window, 167 void OnWindowReordered(Window* window,
168 Window* relative_window, 168 Window* relative_window,
169 mojom::OrderDirection direction) override { 169 mojom::OrderDirection direction) override {
170 DCHECK_EQ(window, window_); 170 DCHECK_EQ(window, window_);
171 EXPECT_TRUE(WindowServerTestBase::QuitRunLoop()); 171 EXPECT_TRUE(WindowServerTestBase::QuitRunLoop());
172 } 172 }
173 173
174 Window* window_; 174 Window* window_;
175 175
176 MOJO_DISALLOW_COPY_AND_ASSIGN(OrderChangeObserver); 176 DISALLOW_COPY_AND_ASSIGN(OrderChangeObserver);
177 }; 177 };
178 178
179 // Wait until |window|'s tree size matches |tree_size|; returns false on 179 // Wait until |window|'s tree size matches |tree_size|; returns false on
180 // timeout. 180 // timeout.
181 bool WaitForOrderChange(WindowTreeConnection* connection, Window* window) { 181 bool WaitForOrderChange(WindowTreeConnection* connection, Window* window) {
182 OrderChangeObserver observer(window); 182 OrderChangeObserver observer(window);
183 return WindowServerTestBase::DoRunLoopWithTimeout(); 183 return WindowServerTestBase::DoRunLoopWithTimeout();
184 } 184 }
185 185
186 // Tracks a window's destruction. Query is_valid() for current state. 186 // Tracks a window's destruction. Query is_valid() for current state.
(...skipping 11 matching lines...) Expand all
198 198
199 private: 199 private:
200 // Overridden from WindowObserver: 200 // Overridden from WindowObserver:
201 void OnWindowDestroyed(Window* window) override { 201 void OnWindowDestroyed(Window* window) override {
202 DCHECK_EQ(window, window_); 202 DCHECK_EQ(window, window_);
203 window_ = nullptr; 203 window_ = nullptr;
204 } 204 }
205 205
206 Window* window_; 206 Window* window_;
207 207
208 MOJO_DISALLOW_COPY_AND_ASSIGN(WindowTracker); 208 DISALLOW_COPY_AND_ASSIGN(WindowTracker);
209 }; 209 };
210 210
211 } // namespace 211 } // namespace
212 212
213 // WindowServer 213 // WindowServer
214 // ----------------------------------------------------------------- 214 // -----------------------------------------------------------------
215 215
216 struct EmbedResult { 216 struct EmbedResult {
217 EmbedResult(WindowTreeConnection* connection, ConnectionSpecificId id) 217 EmbedResult(WindowTreeConnection* connection, ConnectionSpecificId id)
218 : connection(connection), connection_id(id) {} 218 : connection(connection), connection_id(id) {}
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 void EmbedCallbackImpl(bool result, ConnectionSpecificId connection_id) { 321 void EmbedCallbackImpl(bool result, ConnectionSpecificId connection_id) {
322 embed_details_->callback_run = true; 322 embed_details_->callback_run = true;
323 embed_details_->result = result; 323 embed_details_->result = result;
324 embed_details_->connection_id = connection_id; 324 embed_details_->connection_id = connection_id;
325 if (embed_details_->waiting && (!result || embed_details_->connection)) 325 if (embed_details_->waiting && (!result || embed_details_->connection))
326 EXPECT_TRUE(WindowServerTestBase::QuitRunLoop()); 326 EXPECT_TRUE(WindowServerTestBase::QuitRunLoop());
327 } 327 }
328 328
329 scoped_ptr<EmbedDetails> embed_details_; 329 scoped_ptr<EmbedDetails> embed_details_;
330 330
331 MOJO_DISALLOW_COPY_AND_ASSIGN(WindowServerTest); 331 DISALLOW_COPY_AND_ASSIGN(WindowServerTest);
332 }; 332 };
333 333
334 TEST_F(WindowServerTest, RootWindow) { 334 TEST_F(WindowServerTest, RootWindow) {
335 ASSERT_NE(nullptr, window_manager()); 335 ASSERT_NE(nullptr, window_manager());
336 EXPECT_EQ(1u, window_manager()->GetRoots().size()); 336 EXPECT_EQ(1u, window_manager()->GetRoots().size());
337 } 337 }
338 338
339 TEST_F(WindowServerTest, Embed) { 339 TEST_F(WindowServerTest, Embed) {
340 Window* window = window_manager()->NewWindow(); 340 Window* window = window_manager()->NewWindow();
341 ASSERT_NE(nullptr, window); 341 ASSERT_NE(nullptr, window);
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 533
534 private: 534 private:
535 // Overridden from WindowObserver: 535 // Overridden from WindowObserver:
536 void OnWindowVisibilityChanged(Window* window) override { 536 void OnWindowVisibilityChanged(Window* window) override {
537 EXPECT_EQ(window, window_); 537 EXPECT_EQ(window, window_);
538 EXPECT_TRUE(WindowServerTestBase::QuitRunLoop()); 538 EXPECT_TRUE(WindowServerTestBase::QuitRunLoop());
539 } 539 }
540 540
541 Window* window_; 541 Window* window_;
542 542
543 MOJO_DISALLOW_COPY_AND_ASSIGN(VisibilityChangeObserver); 543 DISALLOW_COPY_AND_ASSIGN(VisibilityChangeObserver);
544 }; 544 };
545 545
546 } // namespace 546 } // namespace
547 547
548 TEST_F(WindowServerTest, Visible) { 548 TEST_F(WindowServerTest, Visible) {
549 Window* window1 = window_manager()->NewWindow(); 549 Window* window1 = window_manager()->NewWindow();
550 window1->SetVisible(true); 550 window1->SetVisible(true);
551 GetFirstWMRoot()->AddChild(window1); 551 GetFirstWMRoot()->AddChild(window1);
552 552
553 // Embed another app and verify initial state. 553 // Embed another app and verify initial state.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 597
598 private: 598 private:
599 // Overridden from WindowObserver: 599 // Overridden from WindowObserver:
600 void OnWindowDrawnChanged(Window* window) override { 600 void OnWindowDrawnChanged(Window* window) override {
601 EXPECT_EQ(window, window_); 601 EXPECT_EQ(window, window_);
602 EXPECT_TRUE(WindowServerTestBase::QuitRunLoop()); 602 EXPECT_TRUE(WindowServerTestBase::QuitRunLoop());
603 } 603 }
604 604
605 Window* window_; 605 Window* window_;
606 606
607 MOJO_DISALLOW_COPY_AND_ASSIGN(DrawnChangeObserver); 607 DISALLOW_COPY_AND_ASSIGN(DrawnChangeObserver);
608 }; 608 };
609 609
610 } // namespace 610 } // namespace
611 611
612 TEST_F(WindowServerTest, Drawn) { 612 TEST_F(WindowServerTest, Drawn) {
613 Window* window1 = window_manager()->NewWindow(); 613 Window* window1 = window_manager()->NewWindow();
614 window1->SetVisible(true); 614 window1->SetVisible(true);
615 GetFirstWMRoot()->AddChild(window1); 615 GetFirstWMRoot()->AddChild(window1);
616 616
617 // Embed another app and verify initial state. 617 // Embed another app and verify initial state.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 last_lost_focus_ = lost_focus; 668 last_lost_focus_ = lost_focus;
669 if (quit_on_change_) 669 if (quit_on_change_)
670 EXPECT_TRUE(WindowServerTestBase::QuitRunLoop()); 670 EXPECT_TRUE(WindowServerTestBase::QuitRunLoop());
671 } 671 }
672 672
673 Window* window_; 673 Window* window_;
674 Window* last_gained_focus_; 674 Window* last_gained_focus_;
675 Window* last_lost_focus_; 675 Window* last_lost_focus_;
676 bool quit_on_change_; 676 bool quit_on_change_;
677 677
678 MOJO_DISALLOW_COPY_AND_ASSIGN(FocusChangeObserver); 678 DISALLOW_COPY_AND_ASSIGN(FocusChangeObserver);
679 }; 679 };
680 680
681 class NullFocusChangeObserver : public WindowTreeConnectionObserver { 681 class NullFocusChangeObserver : public WindowTreeConnectionObserver {
682 public: 682 public:
683 explicit NullFocusChangeObserver(WindowTreeConnection* connection) 683 explicit NullFocusChangeObserver(WindowTreeConnection* connection)
684 : connection_(connection) { 684 : connection_(connection) {
685 connection_->AddObserver(this); 685 connection_->AddObserver(this);
686 } 686 }
687 ~NullFocusChangeObserver() override { connection_->RemoveObserver(this); } 687 ~NullFocusChangeObserver() override { connection_->RemoveObserver(this); }
688 688
689 private: 689 private:
690 // Overridden from WindowTreeConnectionObserver. 690 // Overridden from WindowTreeConnectionObserver.
691 void OnWindowTreeFocusChanged(Window* gained_focus, 691 void OnWindowTreeFocusChanged(Window* gained_focus,
692 Window* lost_focus) override { 692 Window* lost_focus) override {
693 if (!gained_focus) 693 if (!gained_focus)
694 EXPECT_TRUE(WindowServerTestBase::QuitRunLoop()); 694 EXPECT_TRUE(WindowServerTestBase::QuitRunLoop());
695 } 695 }
696 696
697 WindowTreeConnection* connection_; 697 WindowTreeConnection* connection_;
698 698
699 MOJO_DISALLOW_COPY_AND_ASSIGN(NullFocusChangeObserver); 699 DISALLOW_COPY_AND_ASSIGN(NullFocusChangeObserver);
700 }; 700 };
701 701
702 bool WaitForWindowToHaveFocus(Window* window) { 702 bool WaitForWindowToHaveFocus(Window* window) {
703 if (window->HasFocus()) 703 if (window->HasFocus())
704 return true; 704 return true;
705 FocusChangeObserver observer(window); 705 FocusChangeObserver observer(window);
706 return WindowServerTestBase::DoRunLoopWithTimeout(); 706 return WindowServerTestBase::DoRunLoopWithTimeout();
707 } 707 }
708 708
709 bool WaitForNoWindowToHaveFocus(WindowTreeConnection* connection) { 709 bool WaitForNoWindowToHaveFocus(WindowTreeConnection* connection) {
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 window_ = nullptr; 897 window_ = nullptr;
898 898
899 // We should always get OnWindowDestroyed() before OnConnectionLost(). 899 // We should always get OnWindowDestroyed() before OnConnectionLost().
900 EXPECT_FALSE(test_->window_tree_connection_destroyed()); 900 EXPECT_FALSE(test_->window_tree_connection_destroyed());
901 } 901 }
902 902
903 WindowServerTestBase* test_; 903 WindowServerTestBase* test_;
904 Window* window_; 904 Window* window_;
905 bool* got_destroy_; 905 bool* got_destroy_;
906 906
907 MOJO_DISALLOW_COPY_AND_ASSIGN(DestroyedChangedObserver); 907 DISALLOW_COPY_AND_ASSIGN(DestroyedChangedObserver);
908 }; 908 };
909 909
910 } // namespace 910 } // namespace
911 911
912 // Verifies deleting a WindowServer sends the right notifications. 912 // Verifies deleting a WindowServer sends the right notifications.
913 TEST_F(WindowServerTest, DeleteWindowServer) { 913 TEST_F(WindowServerTest, DeleteWindowServer) {
914 Window* window = window_manager()->NewWindow(); 914 Window* window = window_manager()->NewWindow();
915 ASSERT_NE(nullptr, window); 915 ASSERT_NE(nullptr, window);
916 window->SetVisible(true); 916 window->SetVisible(true);
917 GetFirstWMRoot()->AddChild(window); 917 GetFirstWMRoot()->AddChild(window);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
956 private: 956 private:
957 // Overridden from WindowObserver: 957 // Overridden from WindowObserver:
958 void OnTreeChanged(const TreeChangeParams& params) override { 958 void OnTreeChanged(const TreeChangeParams& params) override {
959 if (params.target == window_ && !params.new_parent) 959 if (params.target == window_ && !params.new_parent)
960 was_removed_ = true; 960 was_removed_ = true;
961 } 961 }
962 962
963 Window* window_; 963 Window* window_;
964 bool was_removed_; 964 bool was_removed_;
965 965
966 MOJO_DISALLOW_COPY_AND_ASSIGN(WindowRemovedFromParentObserver); 966 DISALLOW_COPY_AND_ASSIGN(WindowRemovedFromParentObserver);
967 }; 967 };
968 968
969 TEST_F(WindowServerTest, EmbedRemovesChildren) { 969 TEST_F(WindowServerTest, EmbedRemovesChildren) {
970 Window* window1 = window_manager()->NewWindow(); 970 Window* window1 = window_manager()->NewWindow();
971 Window* window2 = window_manager()->NewWindow(); 971 Window* window2 = window_manager()->NewWindow();
972 GetFirstWMRoot()->AddChild(window1); 972 GetFirstWMRoot()->AddChild(window1);
973 window1->AddChild(window2); 973 window1->AddChild(window2);
974 974
975 WindowRemovedFromParentObserver observer(window2); 975 WindowRemovedFromParentObserver observer(window2);
976 window1->Embed(ConnectAndGetWindowServerClient()); 976 window1->Embed(ConnectAndGetWindowServerClient());
(...skipping 28 matching lines...) Expand all
1005 // We should always get OnWindowDestroyed() before 1005 // We should always get OnWindowDestroyed() before
1006 // OnWindowManagerDestroyed(). 1006 // OnWindowManagerDestroyed().
1007 EXPECT_FALSE(test_->window_tree_connection_destroyed()); 1007 EXPECT_FALSE(test_->window_tree_connection_destroyed());
1008 1008
1009 EXPECT_TRUE(WindowServerTestBase::QuitRunLoop()); 1009 EXPECT_TRUE(WindowServerTestBase::QuitRunLoop());
1010 } 1010 }
1011 1011
1012 WindowServerTestBase* test_; 1012 WindowServerTestBase* test_;
1013 bool* got_destroy_; 1013 bool* got_destroy_;
1014 1014
1015 MOJO_DISALLOW_COPY_AND_ASSIGN(DestroyObserver); 1015 DISALLOW_COPY_AND_ASSIGN(DestroyObserver);
1016 }; 1016 };
1017 1017
1018 } // namespace 1018 } // namespace
1019 1019
1020 // Verifies deleting a Window that is the root of another connection notifies 1020 // Verifies deleting a Window that is the root of another connection notifies
1021 // observers in the right order (OnWindowDestroyed() before 1021 // observers in the right order (OnWindowDestroyed() before
1022 // OnWindowManagerDestroyed()). 1022 // OnWindowManagerDestroyed()).
1023 TEST_F(WindowServerTest, WindowServerDestroyedAfterRootObserver) { 1023 TEST_F(WindowServerTest, WindowServerDestroyedAfterRootObserver) {
1024 Window* embed_window = window_manager()->NewWindow(); 1024 Window* embed_window = window_manager()->NewWindow();
1025 GetFirstWMRoot()->AddChild(embed_window); 1025 GetFirstWMRoot()->AddChild(embed_window);
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1172 ASSERT_TRUE(window_in_wm); 1172 ASSERT_TRUE(window_in_wm);
1173 1173
1174 // Change the bounds in the wm, and make sure the child sees it. 1174 // Change the bounds in the wm, and make sure the child sees it.
1175 window_in_wm->SetBounds(gfx::Rect(1, 11, 12, 101)); 1175 window_in_wm->SetBounds(gfx::Rect(1, 11, 12, 101));
1176 ASSERT_TRUE(WaitForBoundsToChange(window_in_second_connection)); 1176 ASSERT_TRUE(WaitForBoundsToChange(window_in_second_connection));
1177 EXPECT_EQ(gfx::Rect(1, 11, 12, 101), window_in_second_connection->bounds()); 1177 EXPECT_EQ(gfx::Rect(1, 11, 12, 101), window_in_second_connection->bounds());
1178 } 1178 }
1179 1179
1180 } // namespace ws 1180 } // namespace ws
1181 } // namespace mus 1181 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/public/cpp/window.h ('k') | components/mus/ws/window_tree_apptest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698