| Index: ui/views/test/views_test_helper_aura.cc
|
| diff --git a/ui/views/test/views_test_helper_aura.cc b/ui/views/test/views_test_helper_aura.cc
|
| index f10f3942df5ed04737eecd60fe8158c27f047403..1c8c99a821f090450c56423679ab8a8c74447651 100644
|
| --- a/ui/views/test/views_test_helper_aura.cc
|
| +++ b/ui/views/test/views_test_helper_aura.cc
|
| @@ -6,6 +6,7 @@
|
|
|
| #include "ui/aura/client/screen_position_client.h"
|
| #include "ui/aura/test/aura_test_helper.h"
|
| +#include "ui/views/test/platform_test_helper.h"
|
| #include "ui/wm/core/capture_controller.h"
|
| #include "ui/wm/core/default_activation_client.h"
|
| #include "ui/wm/core/default_screen_position_client.h"
|
| @@ -34,7 +35,12 @@ void ViewsTestHelperAura::EnableMusWithWindowTreeClient(
|
|
|
| void ViewsTestHelperAura::SetUp() {
|
| aura_test_helper_->SetUp(context_factory_);
|
| +
|
| + // GetContext() may return null. See comment in GetContext().
|
| gfx::NativeWindow root_window = GetContext();
|
| + if (!root_window)
|
| + return;
|
| +
|
| new wm::DefaultActivationClient(root_window);
|
|
|
| if (!aura::client::GetScreenPositionClient(root_window)) {
|
| @@ -45,18 +51,21 @@ void ViewsTestHelperAura::SetUp() {
|
| }
|
|
|
| void ViewsTestHelperAura::TearDown() {
|
| - // Ensure all Widgets (and windows) are closed in unit tests. This is done
|
| - // automatically when the RootWindow is torn down, but is an error on
|
| - // platforms that must ensure no Compositors are alive when the ContextFactory
|
| - // is torn down.
|
| - // So, although it's optional, check the root window to detect failures before
|
| - // they hit the CQ on other platforms.
|
| - DCHECK(aura_test_helper_->root_window()->children().empty())
|
| - << "Not all windows were closed.";
|
| -
|
| - if (screen_position_client_.get() ==
|
| - aura::client::GetScreenPositionClient(GetContext()))
|
| - aura::client::SetScreenPositionClient(GetContext(), nullptr);
|
| + // GetContext() may return null. See comment in GetContext().
|
| + if (GetContext()) {
|
| + // Ensure all Widgets (and windows) are closed in unit tests. This is done
|
| + // automatically when the RootWindow is torn down, but is an error on
|
| + // platforms that must ensure no Compositors are alive when the
|
| + // ContextFactory is torn down.
|
| + // So, although it's optional, check the root window to detect failures
|
| + // before they hit the CQ on other platforms.
|
| + DCHECK(aura_test_helper_->root_window()->children().empty())
|
| + << "Not all windows were closed.";
|
| +
|
| + if (screen_position_client_.get() ==
|
| + aura::client::GetScreenPositionClient(GetContext()))
|
| + aura::client::SetScreenPositionClient(GetContext(), nullptr);
|
| + }
|
|
|
| aura_test_helper_->TearDown();
|
| CHECK(!wm::CaptureController::Get() ||
|
| @@ -64,6 +73,14 @@ void ViewsTestHelperAura::TearDown() {
|
| }
|
|
|
| gfx::NativeWindow ViewsTestHelperAura::GetContext() {
|
| + if (PlatformTestHelper::IsAuraMusClient()) {
|
| + // GetContext() returns the root of a WindowTreeHost associated with a
|
| + // single display that is intended for an ash like environment. Such a
|
| + // configuration doesn't make sense for aura-mus-client, where it's testing
|
| + // DesktopNativeWidgetAura.
|
| + return nullptr;
|
| + }
|
| +
|
| return aura_test_helper_->root_window();
|
| }
|
|
|
|
|