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/views/test/views_test_base.h" | 5 #include "ui/views/test/views_test_base.h" |
6 | 6 |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "ui/base/clipboard/clipboard.h" | 8 #include "ui/base/clipboard/clipboard.h" |
9 #include "ui/base/ime/input_method_initializer.h" | 9 #include "ui/base/ime/input_method_initializer.h" |
10 #include "ui/aura/env.h" | 10 #include "ui/aura/env.h" |
11 #include "ui/aura/test/aura_test_helper.h" | 11 #include "ui/aura/test/aura_test_helper.h" |
12 #include "ui/aura/window_event_dispatcher.h" | 12 #include "ui/aura/window_event_dispatcher.h" |
13 #include "ui/compositor/test/context_factories_for_test.h" | 13 #include "ui/compositor/test/context_factories_for_test.h" |
14 #include "ui/wm/core/capture_controller.h" | 14 #include "ui/wm/core/capture_controller.h" |
| 15 #include "ui/wm/core/default_activation_client.h" |
15 #include "ui/wm/core/wm_state.h" | 16 #include "ui/wm/core/wm_state.h" |
16 | 17 |
17 namespace views { | 18 namespace views { |
18 | 19 |
19 ViewsTestBase::ViewsTestBase() | 20 ViewsTestBase::ViewsTestBase() |
20 : setup_called_(false), | 21 : setup_called_(false), |
21 teardown_called_(false) { | 22 teardown_called_(false) { |
22 } | 23 } |
23 | 24 |
24 ViewsTestBase::~ViewsTestBase() { | 25 ViewsTestBase::~ViewsTestBase() { |
25 CHECK(setup_called_) | 26 CHECK(setup_called_) |
26 << "You have overridden SetUp but never called super class's SetUp"; | 27 << "You have overridden SetUp but never called super class's SetUp"; |
27 CHECK(teardown_called_) | 28 CHECK(teardown_called_) |
28 << "You have overridden TearDown but never called super class's TearDown"; | 29 << "You have overridden TearDown but never called super class's TearDown"; |
29 } | 30 } |
30 | 31 |
31 void ViewsTestBase::SetUp() { | 32 void ViewsTestBase::SetUp() { |
32 testing::Test::SetUp(); | 33 testing::Test::SetUp(); |
33 setup_called_ = true; | 34 setup_called_ = true; |
34 if (!views_delegate_.get()) | 35 if (!views_delegate_.get()) |
35 views_delegate_.reset(new TestViewsDelegate()); | 36 views_delegate_.reset(new TestViewsDelegate()); |
36 // The ContextFactory must exist before any Compositors are created. | 37 // The ContextFactory must exist before any Compositors are created. |
37 bool enable_pixel_output = false; | 38 bool enable_pixel_output = false; |
38 ui::InitializeContextFactoryForTests(enable_pixel_output); | 39 ui::InitializeContextFactoryForTests(enable_pixel_output); |
39 | 40 |
40 aura_test_helper_.reset(new aura::test::AuraTestHelper(&message_loop_)); | 41 aura_test_helper_.reset(new aura::test::AuraTestHelper(&message_loop_)); |
41 aura_test_helper_->SetUp(); | 42 aura_test_helper_->SetUp(); |
| 43 new wm::DefaultActivationClient(aura_test_helper_->root_window()); |
42 wm_state_.reset(new ::wm::WMState); | 44 wm_state_.reset(new ::wm::WMState); |
43 ui::InitializeInputMethodForTesting(); | 45 ui::InitializeInputMethodForTesting(); |
44 } | 46 } |
45 | 47 |
46 void ViewsTestBase::TearDown() { | 48 void ViewsTestBase::TearDown() { |
47 ui::Clipboard::DestroyClipboardForCurrentThread(); | 49 ui::Clipboard::DestroyClipboardForCurrentThread(); |
48 | 50 |
49 // Flush the message loop because we have pending release tasks | 51 // Flush the message loop because we have pending release tasks |
50 // and these tasks if un-executed would upset Valgrind. | 52 // and these tasks if un-executed would upset Valgrind. |
51 RunPendingMessages(); | 53 RunPendingMessages(); |
(...skipping 25 matching lines...) Expand all Loading... |
77 | 79 |
78 aura::WindowTreeHost* ViewsTestBase::host() { | 80 aura::WindowTreeHost* ViewsTestBase::host() { |
79 return aura_test_helper_->host(); | 81 return aura_test_helper_->host(); |
80 } | 82 } |
81 | 83 |
82 gfx::NativeView ViewsTestBase::GetContext() { | 84 gfx::NativeView ViewsTestBase::GetContext() { |
83 return aura_test_helper_->root_window(); | 85 return aura_test_helper_->root_window(); |
84 } | 86 } |
85 | 87 |
86 } // namespace views | 88 } // namespace views |
OLD | NEW |