Chromium Code Reviews| 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" |
| 11 #include "ui/base/ime/input_method_initializer.h" | 11 #include "ui/base/ime/input_method_initializer.h" |
| 12 #include "ui/compositor/test/context_factories_for_test.h" | 12 #include "ui/compositor/test/context_factories_for_test.h" |
| 13 #include "ui/views/test/platform_test_helper.h" | 13 #include "ui/views/test/platform_test_helper.h" |
| 14 #include "ui/views/test/test_views_delegate.h" | 14 #include "ui/views/test/test_views_delegate.h" |
| 15 #include "ui/views/test/views_test_helper.h" | 15 #include "ui/views/test/views_test_helper.h" |
| 16 | 16 |
| 17 #if defined(USE_AURA) | 17 #if defined(USE_AURA) |
| 18 #include "ui/aura/env.h" | 18 #include "ui/aura/env.h" // nogncheck |
| 19 #endif | 19 #endif |
| 20 | 20 |
| 21 namespace views { | 21 namespace views { |
| 22 | 22 |
| 23 ScopedViewsTestHelper::ScopedViewsTestHelper() | 23 ScopedViewsTestHelper::ScopedViewsTestHelper() |
| 24 : ScopedViewsTestHelper(base::WrapUnique(new TestViewsDelegate)) {} | 24 : ScopedViewsTestHelper(base::WrapUnique(new TestViewsDelegate)) {} |
| 25 | 25 |
| 26 ScopedViewsTestHelper::ScopedViewsTestHelper( | 26 ScopedViewsTestHelper::ScopedViewsTestHelper( |
| 27 std::unique_ptr<TestViewsDelegate> views_delegate) | 27 std::unique_ptr<TestViewsDelegate> views_delegate) |
| 28 : views_delegate_(std::move(views_delegate)), | 28 : views_delegate_(std::move(views_delegate)), |
| 29 platform_test_helper_(PlatformTestHelper::Create()) { | 29 platform_test_helper_(PlatformTestHelper::Create()) { |
| 30 // The ContextFactory must exist before any Compositors are created. | 30 // The ContextFactory must exist before any Compositors are created. |
| 31 bool enable_pixel_output = false; | 31 bool enable_pixel_output = false; |
| 32 #if defined(USE_AURA) | 32 #if defined(USE_AURA) |
| 33 ui::ContextFactory* old_context_factory = nullptr; | 33 ui::ContextFactory* old_context_factory = nullptr; |
|
tapted
2016/09/19 03:23:36
This looks like it could easily be moved to ViewsT
| |
| 34 if (PlatformTestHelper::IsMus()) { | 34 if (PlatformTestHelper::IsMus()) { |
| 35 old_context_factory = aura::Env::GetInstance()->context_factory(); | 35 old_context_factory = aura::Env::GetInstance()->context_factory(); |
| 36 DCHECK(old_context_factory); | 36 DCHECK(old_context_factory); |
| 37 } | 37 } |
| 38 #endif | 38 #endif |
| 39 ui::ContextFactory* context_factory = | 39 ui::ContextFactory* context_factory = |
| 40 ui::InitializeContextFactoryForTests(enable_pixel_output); | 40 ui::InitializeContextFactoryForTests(enable_pixel_output); |
| 41 views_delegate_->set_context_factory(context_factory); | 41 views_delegate_->set_context_factory(context_factory); |
| 42 | 42 |
| 43 test_helper_.reset(ViewsTestHelper::Create(base::MessageLoopForUI::current(), | 43 test_helper_.reset(ViewsTestHelper::Create(base::MessageLoopForUI::current(), |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 71 platform_test_helper_.reset(); | 71 platform_test_helper_.reset(); |
| 72 | 72 |
| 73 ui::TerminateContextFactoryForTests(); | 73 ui::TerminateContextFactoryForTests(); |
| 74 } | 74 } |
| 75 | 75 |
| 76 gfx::NativeWindow ScopedViewsTestHelper::GetContext() { | 76 gfx::NativeWindow ScopedViewsTestHelper::GetContext() { |
| 77 return test_helper_->GetContext(); | 77 return test_helper_->GetContext(); |
| 78 } | 78 } |
| 79 | 79 |
| 80 } // namespace views | 80 } // namespace views |
| OLD | NEW |