forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
window_manager_common_unittests.cc
49 lines (41 loc) · 1.84 KB
/
window_manager_common_unittests.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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 = 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