OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/platform_test_helper.h" | 5 #include "ui/views/test/platform_test_helper.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "ui/compositor/test/context_factories_for_test.h" |
10 #include "ui/views/widget/widget.h" | 11 #include "ui/views/widget/widget.h" |
11 | 12 |
12 #if defined(USE_AURA) | 13 #if defined(USE_AURA) |
13 #include "ui/aura/window.h" | 14 #include "ui/aura/window.h" |
14 #endif | 15 #endif |
15 | 16 |
16 namespace views { | 17 namespace views { |
17 namespace { | 18 namespace { |
18 | 19 |
19 PlatformTestHelper::Factory test_helper_factory; | 20 PlatformTestHelper::Factory test_helper_factory; |
20 bool is_mus = false; | 21 bool is_mus = false; |
21 | 22 |
22 } // namespace | 23 } // namespace |
23 | 24 |
| 25 PlatformTestHelper::~PlatformTestHelper() { |
| 26 ui::TerminateContextFactoryForTests(); |
| 27 } |
| 28 |
24 void PlatformTestHelper::set_factory(const Factory& factory) { | 29 void PlatformTestHelper::set_factory(const Factory& factory) { |
25 DCHECK(test_helper_factory.is_null()); | 30 DCHECK(test_helper_factory.is_null()); |
26 test_helper_factory = factory; | 31 test_helper_factory = factory; |
27 } | 32 } |
28 | 33 |
29 // static | 34 // static |
30 std::unique_ptr<PlatformTestHelper> PlatformTestHelper::Create() { | 35 std::unique_ptr<PlatformTestHelper> PlatformTestHelper::Create() { |
31 return !test_helper_factory.is_null() | 36 return !test_helper_factory.is_null() |
32 ? test_helper_factory.Run() | 37 ? test_helper_factory.Run() |
33 : base::WrapUnique(new PlatformTestHelper); | 38 : base::WrapUnique(new PlatformTestHelper); |
34 } | 39 } |
35 | 40 |
36 // static | 41 // static |
37 void PlatformTestHelper::SetIsMus() { | 42 void PlatformTestHelper::SetIsMus() { |
38 is_mus = true; | 43 is_mus = true; |
39 } | 44 } |
40 | 45 |
41 // static | 46 // static |
42 bool PlatformTestHelper::IsMus() { | 47 bool PlatformTestHelper::IsMus() { |
43 return is_mus; | 48 return is_mus; |
44 } | 49 } |
45 | 50 |
46 #if defined(USE_AURA) | 51 #if defined(USE_AURA) |
47 void PlatformTestHelper::SimulateNativeDestroy(Widget* widget) { | 52 void PlatformTestHelper::SimulateNativeDestroy(Widget* widget) { |
48 delete widget->GetNativeView(); | 53 delete widget->GetNativeView(); |
49 } | 54 } |
50 #endif | 55 #endif |
51 | 56 |
| 57 void PlatformTestHelper::InitializeContextFactory( |
| 58 ui::ContextFactory** context_factory, |
| 59 ui::ContextFactoryPrivate** context_factory_private) { |
| 60 bool enable_pixel_output = false; |
| 61 ui::InitializeContextFactoryForTests(enable_pixel_output, context_factory, |
| 62 context_factory_private); |
| 63 } |
| 64 |
52 } // namespace views | 65 } // namespace views |
OLD | NEW |