OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ash/public/cpp/config.h" |
| 6 #include "ash/shell.h" |
| 7 #include "ash/test/ash_test_base.h" |
| 8 #include "ash/test/ash_test_helper.h" |
| 9 #include "ui/aura/test/mus/test_window_manager_client.h" |
| 10 #include "ui/aura/test/mus/test_window_tree.h" |
| 11 #include "ui/aura/test/mus/test_window_tree_client_setup.h" |
| 12 #include "ui/aura/window.h" |
| 13 |
| 14 // The tests in this file are in all configs of ash, where as those in |
| 15 // window_manager_unittest.cc is only run in Config::MASH. |
| 16 |
| 17 namespace ash { |
| 18 namespace mus { |
| 19 |
| 20 using WindowManagerCommonTest = test::AshTestBase; |
| 21 |
| 22 TEST_F(WindowManagerCommonTest, Focus) { |
| 23 if (Shell::GetAshConfig() == Config::CLASSIC) |
| 24 return; |
| 25 |
| 26 // Ensure that activation parents have been added, an ancestor of |window| |
| 27 // must support activation for the focus attempt below to succeed. |
| 28 aura::TestWindowManagerClient* test_window_manager_client = |
| 29 ash_test_helper() |
| 30 ->window_tree_client_setup() |
| 31 ->test_window_manager_client(); |
| 32 EXPECT_LT(0u, |
| 33 test_window_manager_client->GetChangeCountForType( |
| 34 aura::WindowManagerClientChangeType::ADD_ACTIVATION_PARENT)); |
| 35 |
| 36 // Ensure a call to Window::Focus() makes it way to the WindowTree. |
| 37 std::unique_ptr<aura::Window> window = CreateTestWindow(); |
| 38 aura::TestWindowTree* test_window_tree = |
| 39 ash_test_helper()->window_tree_client_setup()->window_tree(); |
| 40 const size_t initial_focus_count = test_window_tree->GetChangeCountForType( |
| 41 aura::WindowTreeChangeType::FOCUS); |
| 42 window->Focus(); |
| 43 EXPECT_TRUE(window->HasFocus()); |
| 44 EXPECT_EQ(initial_focus_count + 1, test_window_tree->GetChangeCountForType( |
| 45 aura::WindowTreeChangeType::FOCUS)); |
| 46 } |
| 47 |
| 48 } // namespace mus |
| 49 } // namespace ash |
OLD | NEW |