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

Unified Diff: ui/views/mus/desktop_window_tree_host_mus_unittest.cc

Issue 2690553004: Fixes bug in DesktopWindowTreeHostMus's activation handling (Closed)
Patch Set: Created 3 years, 10 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
Index: ui/views/mus/desktop_window_tree_host_mus_unittest.cc
diff --git a/ui/views/mus/desktop_window_tree_host_mus_unittest.cc b/ui/views/mus/desktop_window_tree_host_mus_unittest.cc
index 394abfa46cbafa9eed03b264f176aaf3d142e6ae..f4976aab0eb75b8ab04914db827eecae3da20508 100644
--- a/ui/views/mus/desktop_window_tree_host_mus_unittest.cc
+++ b/ui/views/mus/desktop_window_tree_host_mus_unittest.cc
@@ -8,7 +8,9 @@
#include "base/memory/ptr_util.h"
#include "ui/aura/client/cursor_client.h"
+#include "ui/aura/client/focus_client.h"
#include "ui/aura/client/transient_window_client.h"
+#include "ui/aura/env.h"
#include "ui/aura/mus/capture_synchronizer.h"
#include "ui/aura/mus/in_flight_change.h"
#include "ui/aura/mus/window_mus.h"
@@ -179,14 +181,35 @@ TEST_F(DesktopWindowTreeHostMusTest, Deactivate) {
widget2->Show();
widget1->Activate();
+ EXPECT_TRUE(widget1->GetNativeWindow()->HasFocus());
+
RunPendingMessages();
EXPECT_TRUE(widget1->IsActive());
+ EXPECT_TRUE(widget1->GetNativeWindow()->HasFocus());
EXPECT_EQ(widget_activated(), widget1.get());
DeactivateAndWait(widget1.get());
EXPECT_FALSE(widget1->IsActive());
}
+TEST_F(DesktopWindowTreeHostMusTest, ActivateBeforeShow) {
+ std::unique_ptr<Widget> widget1(CreateWidget());
+ // Activation can be attempted before visible.
+ widget1->Activate();
+ widget1->Show();
+ widget1->Activate();
+ EXPECT_TRUE(widget1->IsActive());
+ // The Widget's NativeWindow (|DesktopNativeWidgetAura::content_window_|)
+ // should be active.
+ EXPECT_TRUE(widget1->GetNativeWindow()->HasFocus());
+ // Env's active FocusClient should match the active window.
+ aura::client::FocusClient* widget_focus_client =
+ aura::client::GetFocusClient(widget1->GetNativeWindow());
+ ASSERT_TRUE(widget_focus_client);
+ EXPECT_EQ(widget_focus_client,
+ aura::Env::GetInstance()->active_focus_client());
+}
+
TEST_F(DesktopWindowTreeHostMusTest, CursorClientDuringTearDown) {
std::unique_ptr<Widget> widget(CreateWidget());
widget->Show();
« ui/views/mus/desktop_window_tree_host_mus.cc ('K') | « ui/views/mus/desktop_window_tree_host_mus.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698