OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/aura/test/aura_test_base.h" | 5 #include "ui/aura/test/aura_test_base.h" |
6 | 6 |
7 #include "ui/aura/client/window_tree_client.h" | 7 #include "ui/aura/client/window_tree_client.h" |
8 #include "ui/aura/root_window.h" | 8 #include "ui/aura/root_window.h" |
9 #include "ui/aura/test/aura_test_helper.h" | 9 #include "ui/aura/test/aura_test_helper.h" |
10 #include "ui/aura/test/test_window_delegate.h" | 10 #include "ui/aura/test/test_window_delegate.h" |
11 #include "ui/aura/window.h" | 11 #include "ui/aura/window.h" |
12 #include "ui/base/ime/input_method_initializer.h" | 12 #include "ui/base/ime/input_method_initializer.h" |
| 13 #include "ui/compositor/test/context_factories_for_test.h" |
13 #include "ui/events/gestures/gesture_configuration.h" | 14 #include "ui/events/gestures/gesture_configuration.h" |
14 | 15 |
15 namespace aura { | 16 namespace aura { |
16 namespace test { | 17 namespace test { |
17 | 18 |
18 AuraTestBase::AuraTestBase() | 19 AuraTestBase::AuraTestBase() |
19 : setup_called_(false), | 20 : setup_called_(false), |
20 teardown_called_(false) { | 21 teardown_called_(false) { |
21 } | 22 } |
22 | 23 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 ui::GestureConfiguration::set_fling_acceleration_curve_coefficients( | 62 ui::GestureConfiguration::set_fling_acceleration_curve_coefficients( |
62 0, 0.0166667f); | 63 0, 0.0166667f); |
63 ui::GestureConfiguration::set_fling_acceleration_curve_coefficients( | 64 ui::GestureConfiguration::set_fling_acceleration_curve_coefficients( |
64 1, -0.0238095f); | 65 1, -0.0238095f); |
65 ui::GestureConfiguration::set_fling_acceleration_curve_coefficients( | 66 ui::GestureConfiguration::set_fling_acceleration_curve_coefficients( |
66 2, 0.0452381f); | 67 2, 0.0452381f); |
67 ui::GestureConfiguration::set_fling_acceleration_curve_coefficients( | 68 ui::GestureConfiguration::set_fling_acceleration_curve_coefficients( |
68 3, 0.8f); | 69 3, 0.8f); |
69 ui::GestureConfiguration::set_fling_velocity_cap(15000.0f); | 70 ui::GestureConfiguration::set_fling_velocity_cap(15000.0f); |
70 | 71 |
| 72 // The ContextFactory must exist before any Compositors are created. |
| 73 bool enable_pixel_output = false; |
| 74 ui::InitializeContextFactoryForTests(enable_pixel_output); |
| 75 |
71 helper_.reset(new AuraTestHelper(&message_loop_)); | 76 helper_.reset(new AuraTestHelper(&message_loop_)); |
72 bool allow_test_contexts = true; | 77 helper_->SetUp(); |
73 helper_->SetUp(allow_test_contexts); | |
74 } | 78 } |
75 | 79 |
76 void AuraTestBase::TearDown() { | 80 void AuraTestBase::TearDown() { |
77 teardown_called_ = true; | 81 teardown_called_ = true; |
78 | 82 |
79 // Flush the message loop because we have pending release tasks | 83 // Flush the message loop because we have pending release tasks |
80 // and these tasks if un-executed would upset Valgrind. | 84 // and these tasks if un-executed would upset Valgrind. |
81 RunAllPendingInMessageLoop(); | 85 RunAllPendingInMessageLoop(); |
82 | 86 |
83 helper_->TearDown(); | 87 helper_->TearDown(); |
| 88 ui::TerminateContextFactoryForTests(); |
84 ui::ShutdownInputMethodForTesting(); | 89 ui::ShutdownInputMethodForTesting(); |
85 testing::Test::TearDown(); | 90 testing::Test::TearDown(); |
86 } | 91 } |
87 | 92 |
88 Window* AuraTestBase::CreateNormalWindow(int id, Window* parent, | 93 Window* AuraTestBase::CreateNormalWindow(int id, Window* parent, |
89 WindowDelegate* delegate) { | 94 WindowDelegate* delegate) { |
90 Window* window = new Window( | 95 Window* window = new Window( |
91 delegate ? delegate : | 96 delegate ? delegate : |
92 test::TestWindowDelegate::CreateSelfDestroyingDelegate()); | 97 test::TestWindowDelegate::CreateSelfDestroyingDelegate()); |
93 window->set_id(id); | 98 window->set_id(id); |
94 window->Init(aura::WINDOW_LAYER_TEXTURED); | 99 window->Init(aura::WINDOW_LAYER_TEXTURED); |
95 parent->AddChild(window); | 100 parent->AddChild(window); |
96 window->SetBounds(gfx::Rect(0, 0, 100, 100)); | 101 window->SetBounds(gfx::Rect(0, 0, 100, 100)); |
97 window->Show(); | 102 window->Show(); |
98 return window; | 103 return window; |
99 } | 104 } |
100 | 105 |
101 void AuraTestBase::RunAllPendingInMessageLoop() { | 106 void AuraTestBase::RunAllPendingInMessageLoop() { |
102 helper_->RunAllPendingInMessageLoop(); | 107 helper_->RunAllPendingInMessageLoop(); |
103 } | 108 } |
104 | 109 |
105 void AuraTestBase::ParentWindow(Window* window) { | 110 void AuraTestBase::ParentWindow(Window* window) { |
106 client::ParentWindowWithContext(window, root_window(), gfx::Rect()); | 111 client::ParentWindowWithContext(window, root_window(), gfx::Rect()); |
107 } | 112 } |
108 | 113 |
109 } // namespace test | 114 } // namespace test |
110 } // namespace aura | 115 } // namespace aura |
OLD | NEW |