blob: 89c5cbbea822ba6f3f4f8ec9ba95e1b56b44b1b6 [file] [log] [blame]
sky68612712017-04-27 04:45:041// 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
sky68612712017-04-27 04:45:0414namespace ash {
sky68612712017-04-27 04:45:0415
James Cook317781a2017-07-18 02:08:0616using WindowManagerCommonTest = AshTestBase;
sky68612712017-04-27 04:45:0417
James Cookd7ea4d32017-12-08 00:53:3918// TODO(jamescook): Move into one of the existing WindowManager test suites.
sky68612712017-04-27 04:45:0419TEST_F(WindowManagerCommonTest, Focus) {
20 if (Shell::GetAshConfig() == Config::CLASSIC)
21 return;
22
23 // Ensure that activation parents have been added, an ancestor of |window|
24 // must support activation for the focus attempt below to succeed.
25 aura::TestWindowManagerClient* test_window_manager_client =
26 ash_test_helper()
27 ->window_tree_client_setup()
28 ->test_window_manager_client();
29 EXPECT_LT(0u,
30 test_window_manager_client->GetChangeCountForType(
31 aura::WindowManagerClientChangeType::ADD_ACTIVATION_PARENT));
32
33 // Ensure a call to Window::Focus() makes it way to the WindowTree.
34 std::unique_ptr<aura::Window> window = CreateTestWindow();
35 aura::TestWindowTree* test_window_tree =
36 ash_test_helper()->window_tree_client_setup()->window_tree();
37 const size_t initial_focus_count = test_window_tree->GetChangeCountForType(
38 aura::WindowTreeChangeType::FOCUS);
39 window->Focus();
40 EXPECT_TRUE(window->HasFocus());
41 EXPECT_EQ(initial_focus_count + 1, test_window_tree->GetChangeCountForType(
42 aura::WindowTreeChangeType::FOCUS));
43}
44
sky68612712017-04-27 04:45:0445} // namespace ash