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

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

Issue 2029743002: Check WindowTreeClient for empty inflight queue upon teardown (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More tests Created 4 years, 6 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
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"
11 #include "base/run_loop.h" 11 #include "base/run_loop.h"
12 #include "components/mus/common/util.h" 12 #include "components/mus/common/util.h"
13 #include "components/mus/public/cpp/lib/window_private.h" 13 #include "components/mus/public/cpp/lib/window_private.h"
14 #include "components/mus/public/cpp/tests/window_server_test_base.h" 14 #include "components/mus/public/cpp/tests/window_server_test_base.h"
15 #include "components/mus/public/cpp/tests/window_tree_client_private.h"
15 #include "components/mus/public/cpp/window_observer.h" 16 #include "components/mus/public/cpp/window_observer.h"
16 #include "components/mus/public/cpp/window_tree_client.h" 17 #include "components/mus/public/cpp/window_tree_client.h"
17 #include "components/mus/public/cpp/window_tree_client_delegate.h" 18 #include "components/mus/public/cpp/window_tree_client_delegate.h"
18 #include "components/mus/public/cpp/window_tree_client_observer.h" 19 #include "components/mus/public/cpp/window_tree_client_observer.h"
19 #include "ui/gfx/geometry/rect.h" 20 #include "ui/gfx/geometry/rect.h"
20 21
21 namespace mus { 22 namespace mus {
22 namespace ws { 23 namespace ws {
23 24
24 namespace { 25 namespace {
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 { 751 {
751 FocusChangeObserver observer(window11); 752 FocusChangeObserver observer(window11);
752 observer.set_quit_on_change(false); 753 observer.set_quit_on_change(false);
753 window11->SetFocus(); 754 window11->SetFocus();
754 ASSERT_TRUE(window11->HasFocus()); 755 ASSERT_TRUE(window11->HasFocus());
755 ASSERT_NE(nullptr, observer.last_gained_focus()); 756 ASSERT_NE(nullptr, observer.last_gained_focus());
756 ASSERT_NE(nullptr, observer.last_lost_focus()); 757 ASSERT_NE(nullptr, observer.last_lost_focus());
757 EXPECT_EQ(server_id(window11), server_id(observer.last_gained_focus())); 758 EXPECT_EQ(server_id(window11), server_id(observer.last_gained_focus()));
758 EXPECT_EQ(server_id(GetFirstRoot(embedded)), 759 EXPECT_EQ(server_id(GetFirstRoot(embedded)),
759 server_id(observer.last_lost_focus())); 760 server_id(observer.last_lost_focus()));
761 ASSERT_TRUE(WaitForWindowToHaveFocus(window11));
sadrul 2016/06/15 06:42:46 Why? window11 already has focus (asserted above in
760 } 762 }
761 763
762 { 764 {
763 // Add an observer on the Window that loses focus, and make sure the 765 // Add an observer on the Window that loses focus, and make sure the
764 // observer sees the right values. 766 // observer sees the right values.
765 FocusChangeObserver observer(window11); 767 FocusChangeObserver observer(window11);
766 observer.set_quit_on_change(false); 768 observer.set_quit_on_change(false);
767 GetFirstRoot(embedded)->SetFocus(); 769 GetFirstRoot(embedded)->SetFocus();
768 ASSERT_NE(nullptr, observer.last_gained_focus()); 770 ASSERT_NE(nullptr, observer.last_gained_focus());
769 ASSERT_NE(nullptr, observer.last_lost_focus()); 771 ASSERT_NE(nullptr, observer.last_lost_focus());
770 EXPECT_EQ(server_id(window11), server_id(observer.last_lost_focus())); 772 EXPECT_EQ(server_id(window11), server_id(observer.last_lost_focus()));
771 EXPECT_EQ(server_id(GetFirstRoot(embedded)), 773 EXPECT_EQ(server_id(GetFirstRoot(embedded)),
772 server_id(observer.last_gained_focus())); 774 server_id(observer.last_gained_focus()));
775 ASSERT_TRUE(WaitForWindowToHaveFocus(GetFirstRoot(embedded)));
773 } 776 }
777
778 WindowTreeClientPrivate(embedded).WaitForInFlightQueue();
774 } 779 }
775 780
776 TEST_F(WindowServerTest, ClearFocus) { 781 TEST_F(WindowServerTest, ClearFocus) {
777 Window* window1 = window_manager()->NewWindow(); 782 Window* window1 = window_manager()->NewWindow();
778 window1->SetVisible(true); 783 window1->SetVisible(true);
779 GetFirstWMRoot()->AddChild(window1); 784 GetFirstWMRoot()->AddChild(window1);
780 785
781 WindowTreeClient* embedded = Embed(window1).client; 786 WindowTreeClient* embedded = Embed(window1).client;
782 ASSERT_NE(nullptr, embedded); 787 ASSERT_NE(nullptr, embedded);
783 Window* window11 = embedded->NewWindow(); 788 Window* window11 = embedded->NewWindow();
(...skipping 19 matching lines...) Expand all
803 { 808 {
804 FocusChangeObserver observer(window1); 809 FocusChangeObserver observer(window1);
805 embedded->ClearFocus(); 810 embedded->ClearFocus();
806 ASSERT_FALSE(embedded_root->HasFocus()); 811 ASSERT_FALSE(embedded_root->HasFocus());
807 EXPECT_FALSE(embedded->GetFocusedWindow()); 812 EXPECT_FALSE(embedded->GetFocusedWindow());
808 813
809 ASSERT_TRUE(WindowServerTestBase::DoRunLoopWithTimeout()); 814 ASSERT_TRUE(WindowServerTestBase::DoRunLoopWithTimeout());
810 EXPECT_FALSE(window1->HasFocus()); 815 EXPECT_FALSE(window1->HasFocus());
811 EXPECT_FALSE(window_manager()->GetFocusedWindow()); 816 EXPECT_FALSE(window_manager()->GetFocusedWindow());
812 } 817 }
818
819 WindowTreeClientPrivate(embedded).WaitForInFlightQueue();
sadrul 2016/06/15 06:42:46 I don't think we should require individual tests t
jonross 2016/06/15 14:03:08 Yeah I dislike having certain tests with this. I c
813 } 820 }
814 821
815 TEST_F(WindowServerTest, FocusNonFocusableWindow) { 822 TEST_F(WindowServerTest, FocusNonFocusableWindow) {
816 Window* window = window_manager()->NewWindow(); 823 Window* window = window_manager()->NewWindow();
817 window->SetVisible(true); 824 window->SetVisible(true);
818 GetFirstWMRoot()->AddChild(window); 825 GetFirstWMRoot()->AddChild(window);
819 826
820 WindowTreeClient* client = Embed(window).client; 827 WindowTreeClient* client = Embed(window).client;
821 ASSERT_NE(nullptr, client); 828 ASSERT_NE(nullptr, client);
822 ASSERT_FALSE(client->GetRoots().empty()); 829 ASSERT_FALSE(client->GetRoots().empty());
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 GetChildWindowByServerId(window_manager(), server_id(child21)))); 891 GetChildWindowByServerId(window_manager(), server_id(child21))));
885 EXPECT_EQ(server_id(child21), 892 EXPECT_EQ(server_id(child21),
886 server_id(window_manager()->GetFocusedWindow())); 893 server_id(window_manager()->GetFocusedWindow()));
887 EXPECT_EQ(server_id(child21), server_id(embedded2->GetFocusedWindow())); 894 EXPECT_EQ(server_id(child21), server_id(embedded2->GetFocusedWindow()));
888 EXPECT_TRUE(WaitForNoWindowToHaveFocus(embedded1)); 895 EXPECT_TRUE(WaitForNoWindowToHaveFocus(embedded1));
889 EXPECT_EQ(nullptr, embedded1->GetFocusedWindow()); 896 EXPECT_EQ(nullptr, embedded1->GetFocusedWindow());
890 EXPECT_GT(ValidIndexOf(parent->children(), child2), 897 EXPECT_GT(ValidIndexOf(parent->children(), child2),
891 ValidIndexOf(parent->children(), child1)); 898 ValidIndexOf(parent->children(), child1));
892 EXPECT_GT(ValidIndexOf(parent->children(), child3), 899 EXPECT_GT(ValidIndexOf(parent->children(), child3),
893 ValidIndexOf(parent->children(), child1)); 900 ValidIndexOf(parent->children(), child1));
901
902 WindowTreeClientPrivate(embedded1).WaitForInFlightQueue();
903 WindowTreeClientPrivate(embedded2).WaitForInFlightQueue();
894 } 904 }
895 905
896 TEST_F(WindowServerTest, ActivationNext) { 906 TEST_F(WindowServerTest, ActivationNext) {
897 Window* parent = GetFirstWMRoot(); 907 Window* parent = GetFirstWMRoot();
898 Window* child1 = NewVisibleWindow(parent, window_manager()); 908 Window* child1 = NewVisibleWindow(parent, window_manager());
899 Window* child2 = NewVisibleWindow(parent, window_manager()); 909 Window* child2 = NewVisibleWindow(parent, window_manager());
900 Window* child3 = NewVisibleWindow(parent, window_manager()); 910 Window* child3 = NewVisibleWindow(parent, window_manager());
901 911
902 WindowTreeClient* embedded1 = Embed(child1).client; 912 WindowTreeClient* embedded1 = Embed(child1).client;
903 ASSERT_NE(nullptr, embedded1); 913 ASSERT_NE(nullptr, embedded1);
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
1160 ASSERT_TRUE(window_in_wm); 1170 ASSERT_TRUE(window_in_wm);
1161 1171
1162 // Change the bounds in the wm, and make sure the child sees it. 1172 // Change the bounds in the wm, and make sure the child sees it.
1163 window_in_wm->SetBounds(gfx::Rect(1, 11, 12, 101)); 1173 window_in_wm->SetBounds(gfx::Rect(1, 11, 12, 101));
1164 ASSERT_TRUE(WaitForBoundsToChange(window_in_second_client)); 1174 ASSERT_TRUE(WaitForBoundsToChange(window_in_second_client));
1165 EXPECT_EQ(gfx::Rect(1, 11, 12, 101), window_in_second_client->bounds()); 1175 EXPECT_EQ(gfx::Rect(1, 11, 12, 101), window_in_second_client->bounds());
1166 } 1176 }
1167 1177
1168 } // namespace ws 1178 } // namespace ws
1169 } // namespace mus 1179 } // namespace mus
OLDNEW
« components/mus/public/cpp/tests/window_tree_client_unittest.cc ('K') | « components/mus/ws/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698