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..a30254468c2eaa9d4c03121536010d30bce96de9 |
--- /dev/null |
+++ b/ash/mus/window_manager_common_unittests.cc |
@@ -0,0 +1,47 @@ |
+// 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/mus/window_tree_client.h" |
msw
2017/04/26 23:01:08
nit: remove if not needed
sky
2017/04/26 23:30:28
Done.
|
+#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" |
+ |
+namespace ash { |
+namespace mus { |
+ |
+using WindowManagerCommonTest = test::AshTestBase; |
msw
2017/04/26 23:01:08
What prompts the 'common' part of this name and th
sky
2017/04/26 23:30:28
Added comment.
|
+ |
+TEST_F(WindowManagerCommonTest, Focus) { |
+ if (Shell::GetAshConfig() == Config::CLASSIC) |
+ return; |
+ |
+ // Mus will deny focus requests if there is no ancestors marked as |
msw
2017/04/26 23:01:08
nit: "there are", maybe rephrase like "Ensure that
sky
2017/04/26 23:30:28
Done.
|
+ // activation parents. |
+ aura::TestWindowManagerClient* test_window_manager_client = |
+ ash_test_helper() |
+ ->window_tree_client_setup() |
+ ->test_window_manager_client(); |
+ EXPECT_NE(0u, |
msw
2017/04/26 23:01:08
optional nit: ASSERT_LT
sky
2017/04/26 23:30:27
Done.
|
+ 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 |