Chromium Code Reviews| 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..c06f924ccd98a157a097880893df49b798d33130 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,12 @@ void ViewsTestHelperAura::TearDown() { |
| } |
| gfx::NativeWindow ViewsTestHelperAura::GetContext() { |
| + if (PlatformTestHelper::IsAuraMusClient()) { |
| + // GetContext() returns a root of a WindowTreeHost that doesn't make sense |
|
msw
2016/11/11 00:29:24
nit: "WindowTreeHost, which doesn't", maybe explai
sky
2016/11/11 01:09:14
Done.
|
| + // for aura-mus-client. |
| + return nullptr; |
| + } |
| + |
| return aura_test_helper_->root_window(); |
| } |