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