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

Unified Diff: ash/mus/window_manager_common_unittests.cc

Issue 2843193002: chromeos: fix focus for mushrome (Closed)
Patch Set: feedback Created 3 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 | « ash/mus/window_manager.cc ('k') | ash/root_window_controller.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/mus/window_manager_common_unittests.cc
diff --git a/ash/mus/window_manager_common_unittests.cc b/ash/mus/window_manager_common_unittests.cc
new file mode 100644
index 0000000000000000000000000000000000000000..ccec34cd8421047e67ee62b8b1186b2a27c8eaf2
--- /dev/null
+++ b/ash/mus/window_manager_common_unittests.cc
@@ -0,0 +1,49 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ash/public/cpp/config.h"
+#include "ash/shell.h"
+#include "ash/test/ash_test_base.h"
+#include "ash/test/ash_test_helper.h"
+#include "ui/aura/test/mus/test_window_manager_client.h"
+#include "ui/aura/test/mus/test_window_tree.h"
+#include "ui/aura/test/mus/test_window_tree_client_setup.h"
+#include "ui/aura/window.h"
+
+// The tests in this file are in all configs of ash, where as those in
+// window_manager_unittest.cc is only run in Config::MASH.
+
+namespace ash {
+namespace mus {
+
+using WindowManagerCommonTest = test::AshTestBase;
+
+TEST_F(WindowManagerCommonTest, Focus) {
+ if (Shell::GetAshConfig() == Config::CLASSIC)
+ return;
+
+ // Ensure that activation parents have been added, an ancestor of |window|
+ // must support activation for the focus attempt below to succeed.
+ aura::TestWindowManagerClient* test_window_manager_client =
+ ash_test_helper()
+ ->window_tree_client_setup()
+ ->test_window_manager_client();
+ EXPECT_LT(0u,
+ test_window_manager_client->GetChangeCountForType(
+ aura::WindowManagerClientChangeType::ADD_ACTIVATION_PARENT));
+
+ // Ensure a call to Window::Focus() makes it way to the WindowTree.
+ std::unique_ptr<aura::Window> window = CreateTestWindow();
+ aura::TestWindowTree* test_window_tree =
+ ash_test_helper()->window_tree_client_setup()->window_tree();
+ const size_t initial_focus_count = test_window_tree->GetChangeCountForType(
+ aura::WindowTreeChangeType::FOCUS);
+ window->Focus();
+ EXPECT_TRUE(window->HasFocus());
+ EXPECT_EQ(initial_focus_count + 1, test_window_tree->GetChangeCountForType(
+ aura::WindowTreeChangeType::FOCUS));
+}
+
+} // namespace mus
+} // namespace ash
« no previous file with comments | « ash/mus/window_manager.cc ('k') | ash/root_window_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698