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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/mus/ws/window_manager_client_unittest.cc
diff --git a/components/mus/ws/window_manager_client_unittest.cc b/components/mus/ws/window_manager_client_unittest.cc
index a064f076dd2df4843ba35f378b9cba4fc6369835..86e096e20c5f4e020c3490c1f40e74a9221ef3f2 100644
--- a/components/mus/ws/window_manager_client_unittest.cc
+++ b/components/mus/ws/window_manager_client_unittest.cc
@@ -758,6 +758,44 @@ TEST_F(WindowServerTest, Focus) {
}
}
+TEST_F(WindowServerTest, ClearFocus) {
+ Window* window1 = window_manager()->NewWindow();
+ window1->SetVisible(true);
+ GetFirstWMRoot()->AddChild(window1);
+
+ WindowTreeConnection* embedded = Embed(window1).connection;
+ ASSERT_NE(nullptr, embedded);
+ Window* window11 = embedded->NewWindow();
+ window11->SetVisible(true);
+ GetFirstRoot(embedded)->AddChild(window11);
+
+ // Focus the embed root in |embedded|.
+ Window* embedded_root = GetFirstRoot(embedded);
+ {
+ FocusChangeObserver observer(embedded_root);
+ observer.set_quit_on_change(false);
+ embedded_root->SetFocus();
+ ASSERT_TRUE(embedded_root->HasFocus());
+ ASSERT_NE(nullptr, observer.last_gained_focus());
+ EXPECT_EQ(embedded_root->id(), observer.last_gained_focus()->id());
+
+ // |embedded_root| is the same as |window1|, make sure |window1| got
+ // focus too.
+ ASSERT_TRUE(WaitForWindowToHaveFocus(window1));
+ }
+
+ {
+ FocusChangeObserver observer(window1);
+ embedded->ClearFocus();
+ ASSERT_FALSE(embedded_root->HasFocus());
+ EXPECT_FALSE(embedded->GetFocusedWindow());
+
+ ASSERT_TRUE(WindowServerTestBase::DoRunLoopWithTimeout());
+ EXPECT_FALSE(window1->HasFocus());
+ EXPECT_FALSE(window_manager()->GetFocusedWindow());
+ }
+}
+
TEST_F(WindowServerTest, FocusNonFocusableWindow) {
Window* window = window_manager()->NewWindow();
window->SetVisible(true);
« 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