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

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

Issue 1862853002: Makes WindowTree::SetFocus(null) work (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: moar cleanup Created 4 years, 8 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/ws/default_access_policy.cc ('k') | components/mus/ws/window_server.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 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 740 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 FocusChangeObserver observer(window11); 751 FocusChangeObserver observer(window11);
752 observer.set_quit_on_change(false); 752 observer.set_quit_on_change(false);
753 GetFirstRoot(embedded)->SetFocus(); 753 GetFirstRoot(embedded)->SetFocus();
754 ASSERT_NE(nullptr, observer.last_gained_focus()); 754 ASSERT_NE(nullptr, observer.last_gained_focus());
755 ASSERT_NE(nullptr, observer.last_lost_focus()); 755 ASSERT_NE(nullptr, observer.last_lost_focus());
756 EXPECT_EQ(window11->id(), observer.last_lost_focus()->id()); 756 EXPECT_EQ(window11->id(), observer.last_lost_focus()->id());
757 EXPECT_EQ(GetFirstRoot(embedded)->id(), observer.last_gained_focus()->id()); 757 EXPECT_EQ(GetFirstRoot(embedded)->id(), observer.last_gained_focus()->id());
758 } 758 }
759 } 759 }
760 760
761 TEST_F(WindowServerTest, ClearFocus) {
762 Window* window1 = window_manager()->NewWindow();
763 window1->SetVisible(true);
764 GetFirstWMRoot()->AddChild(window1);
765
766 WindowTreeConnection* embedded = Embed(window1).connection;
767 ASSERT_NE(nullptr, embedded);
768 Window* window11 = embedded->NewWindow();
769 window11->SetVisible(true);
770 GetFirstRoot(embedded)->AddChild(window11);
771
772 // Focus the embed root in |embedded|.
773 Window* embedded_root = GetFirstRoot(embedded);
774 {
775 FocusChangeObserver observer(embedded_root);
776 observer.set_quit_on_change(false);
777 embedded_root->SetFocus();
778 ASSERT_TRUE(embedded_root->HasFocus());
779 ASSERT_NE(nullptr, observer.last_gained_focus());
780 EXPECT_EQ(embedded_root->id(), observer.last_gained_focus()->id());
781
782 // |embedded_root| is the same as |window1|, make sure |window1| got
783 // focus too.
784 ASSERT_TRUE(WaitForWindowToHaveFocus(window1));
785 }
786
787 {
788 FocusChangeObserver observer(window1);
789 embedded->ClearFocus();
790 ASSERT_FALSE(embedded_root->HasFocus());
791 EXPECT_FALSE(embedded->GetFocusedWindow());
792
793 ASSERT_TRUE(WindowServerTestBase::DoRunLoopWithTimeout());
794 EXPECT_FALSE(window1->HasFocus());
795 EXPECT_FALSE(window_manager()->GetFocusedWindow());
796 }
797 }
798
761 TEST_F(WindowServerTest, FocusNonFocusableWindow) { 799 TEST_F(WindowServerTest, FocusNonFocusableWindow) {
762 Window* window = window_manager()->NewWindow(); 800 Window* window = window_manager()->NewWindow();
763 window->SetVisible(true); 801 window->SetVisible(true);
764 GetFirstWMRoot()->AddChild(window); 802 GetFirstWMRoot()->AddChild(window);
765 803
766 WindowTreeConnection* connection = Embed(window).connection; 804 WindowTreeConnection* connection = Embed(window).connection;
767 ASSERT_NE(nullptr, connection); 805 ASSERT_NE(nullptr, connection);
768 ASSERT_FALSE(connection->GetRoots().empty()); 806 ASSERT_FALSE(connection->GetRoots().empty());
769 Window* client_window = *connection->GetRoots().begin(); 807 Window* client_window = *connection->GetRoots().begin();
770 client_window->SetCanFocus(false); 808 client_window->SetCanFocus(false);
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
1102 ASSERT_TRUE(window_in_wm); 1140 ASSERT_TRUE(window_in_wm);
1103 1141
1104 // Change the bounds in the wm, and make sure the child sees it. 1142 // Change the bounds in the wm, and make sure the child sees it.
1105 window_in_wm->SetBounds(gfx::Rect(1, 11, 12, 101)); 1143 window_in_wm->SetBounds(gfx::Rect(1, 11, 12, 101));
1106 ASSERT_TRUE(WaitForBoundsToChange(window_in_second_connection)); 1144 ASSERT_TRUE(WaitForBoundsToChange(window_in_second_connection));
1107 EXPECT_EQ(gfx::Rect(1, 11, 12, 101), window_in_second_connection->bounds()); 1145 EXPECT_EQ(gfx::Rect(1, 11, 12, 101), window_in_second_connection->bounds());
1108 } 1146 }
1109 1147
1110 } // namespace ws 1148 } // namespace ws
1111 } // namespace mus 1149 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/ws/default_access_policy.cc ('k') | components/mus/ws/window_server.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698