| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/views/test/scoped_views_test_helper.h" | 5 #include "ui/views/test/scoped_views_test_helper.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 context_factory)); | 37 context_factory)); |
| 38 test_helper_->SetUp(); | 38 test_helper_->SetUp(); |
| 39 | 39 |
| 40 #if defined(USE_AURA) | 40 #if defined(USE_AURA) |
| 41 // When running inside mus, the context-factory from | 41 // When running inside mus, the context-factory from |
| 42 // ui::InitializeContextFactoryForTests() is only needed for the default | 42 // ui::InitializeContextFactoryForTests() is only needed for the default |
| 43 // WindowTreeHost instance created by TestScreen. After that, the | 43 // WindowTreeHost instance created by TestScreen. After that, the |
| 44 // context-factory is used when creating Widgets (to set-up the compositor for | 44 // context-factory is used when creating Widgets (to set-up the compositor for |
| 45 // the corresponding mus::Windows). So unset the context-factory, so that | 45 // the corresponding mus::Windows). So unset the context-factory, so that |
| 46 // NativeWidgetMus installs the correct context-factory that can talk to mus. | 46 // NativeWidgetMus installs the correct context-factory that can talk to mus. |
| 47 if (PlatformTestHelper::IsMus()) | 47 if (platform_test_helper_->IsMus()) |
| 48 aura::Env::GetInstance()->set_context_factory(nullptr); | 48 aura::Env::GetInstance()->set_context_factory(nullptr); |
| 49 #endif | 49 #endif |
| 50 | 50 |
| 51 ui::InitializeInputMethodForTesting(); | 51 ui::InitializeInputMethodForTesting(); |
| 52 } | 52 } |
| 53 | 53 |
| 54 ScopedViewsTestHelper::~ScopedViewsTestHelper() { | 54 ScopedViewsTestHelper::~ScopedViewsTestHelper() { |
| 55 ui::ShutdownInputMethodForTesting(); | 55 ui::ShutdownInputMethodForTesting(); |
| 56 test_helper_->TearDown(); | 56 test_helper_->TearDown(); |
| 57 test_helper_.reset(); | 57 test_helper_.reset(); |
| 58 | 58 |
| 59 views_delegate_.reset(); | 59 views_delegate_.reset(); |
| 60 | 60 |
| 61 // The Mus PlatformTestHelper has state that is deleted by | 61 // The Mus PlatformTestHelper has state that is deleted by |
| 62 // ui::TerminateContextFactoryForTests(). | 62 // ui::TerminateContextFactoryForTests(). |
| 63 platform_test_helper_.reset(); | 63 platform_test_helper_.reset(); |
| 64 | 64 |
| 65 ui::TerminateContextFactoryForTests(); | 65 ui::TerminateContextFactoryForTests(); |
| 66 } | 66 } |
| 67 | 67 |
| 68 gfx::NativeWindow ScopedViewsTestHelper::GetContext() { | 68 gfx::NativeWindow ScopedViewsTestHelper::GetContext() { |
| 69 return test_helper_->GetContext(); | 69 return test_helper_->GetContext(); |
| 70 } | 70 } |
| 71 | 71 |
| 72 bool ScopedViewsTestHelper::IsMus() const { |
| 73 return platform_test_helper_->IsMus(); |
| 74 } |
| 75 |
| 72 } // namespace views | 76 } // namespace views |
| OLD | NEW |