| 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
|
|
|