| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ui/views/test/scoped_views_test_helper.h" |
| 6 |
| 7 #include "base/message_loop/message_loop.h" |
| 8 #include "ui/base/ime/input_method_initializer.h" |
| 9 #include "ui/compositor/test/context_factories_for_test.h" |
| 10 #include "ui/views/test/test_views_delegate.h" |
| 11 #include "ui/views/test/views_test_helper.h" |
| 12 |
| 13 namespace views { |
| 14 |
| 15 ScopedViewsTestHelper::ScopedViewsTestHelper() |
| 16 : ScopedViewsTestHelper(make_scoped_ptr(new TestViewsDelegate)) { |
| 17 } |
| 18 |
| 19 ScopedViewsTestHelper::ScopedViewsTestHelper( |
| 20 scoped_ptr<TestViewsDelegate> views_delegate) |
| 21 : views_delegate_(views_delegate.Pass()) { |
| 22 // The ContextFactory must exist before any Compositors are created. |
| 23 bool enable_pixel_output = false; |
| 24 ui::ContextFactory* context_factory = |
| 25 ui::InitializeContextFactoryForTests(enable_pixel_output); |
| 26 views_delegate_->set_context_factory(context_factory); |
| 27 |
| 28 test_helper_.reset(ViewsTestHelper::Create(base::MessageLoopForUI::current(), |
| 29 context_factory)); |
| 30 test_helper_->SetUp(); |
| 31 |
| 32 ui::InitializeInputMethodForTesting(); |
| 33 } |
| 34 |
| 35 ScopedViewsTestHelper::~ScopedViewsTestHelper() { |
| 36 ui::ShutdownInputMethodForTesting(); |
| 37 test_helper_->TearDown(); |
| 38 test_helper_.reset(); |
| 39 |
| 40 ui::TerminateContextFactoryForTests(); |
| 41 views_delegate_.reset(); |
| 42 } |
| 43 |
| 44 gfx::NativeWindow ScopedViewsTestHelper::GetContext() { |
| 45 return test_helper_->GetContext(); |
| 46 } |
| 47 |
| 48 } // namespace views |
| OLD | NEW |