| 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 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <ole2.h> | 8 #include <ole2.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 CHECK(teardown_called_) | 80 CHECK(teardown_called_) |
| 81 << "You have overrideen TearDown but never called super class's TearDown"; | 81 << "You have overrideen TearDown but never called super class's TearDown"; |
| 82 } | 82 } |
| 83 | 83 |
| 84 void ViewsTestBase::SetUp() { | 84 void ViewsTestBase::SetUp() { |
| 85 testing::Test::SetUp(); | 85 testing::Test::SetUp(); |
| 86 setup_called_ = true; | 86 setup_called_ = true; |
| 87 if (!views_delegate_.get()) | 87 if (!views_delegate_.get()) |
| 88 views_delegate_.reset(new TestViewsDelegate()); | 88 views_delegate_.reset(new TestViewsDelegate()); |
| 89 #if defined(USE_AURA) | 89 #if defined(USE_AURA) |
| 90 root_window_ = aura::RootWindow::GetInstance(); | 90 root_window_.reset(new aura::RootWindow); |
| 91 root_window_->SetProperty( | 91 root_window_->SetProperty( |
| 92 aura::client::kRootWindowInputMethodKey, | 92 aura::client::kRootWindowInputMethodKey, |
| 93 test_input_method_.get()); | 93 test_input_method_.get()); |
| 94 test_activation_client_.reset( | 94 test_activation_client_.reset( |
| 95 new aura::test::TestActivationClient(root_window_)); | 95 new aura::test::TestActivationClient(root_window_.get())); |
| 96 test_stacking_client_.reset( | 96 test_stacking_client_.reset( |
| 97 new aura::test::TestStackingClient(root_window_)); | 97 new aura::test::TestStackingClient(root_window_.get())); |
| 98 #endif | 98 #endif |
| 99 } | 99 } |
| 100 | 100 |
| 101 void ViewsTestBase::TearDown() { | 101 void ViewsTestBase::TearDown() { |
| 102 // Flush the message loop because we have pending release tasks | 102 // Flush the message loop because we have pending release tasks |
| 103 // and these tasks if un-executed would upset Valgrind. | 103 // and these tasks if un-executed would upset Valgrind. |
| 104 RunPendingMessages(); | 104 RunPendingMessages(); |
| 105 teardown_called_ = true; | 105 teardown_called_ = true; |
| 106 views_delegate_.reset(); | 106 views_delegate_.reset(); |
| 107 testing::Test::TearDown(); | 107 testing::Test::TearDown(); |
| 108 #if defined(USE_AURA) | 108 #if defined(USE_AURA) |
| 109 test_stacking_client_.reset(); | 109 test_stacking_client_.reset(); |
| 110 test_activation_client_.reset(); | 110 test_activation_client_.reset(); |
| 111 aura::RootWindow::DeleteInstance(); | 111 root_window_.reset(); |
| 112 #endif | 112 #endif |
| 113 } | 113 } |
| 114 | 114 |
| 115 void ViewsTestBase::RunPendingMessages() { | 115 void ViewsTestBase::RunPendingMessages() { |
| 116 #if defined(USE_AURA) | 116 #if defined(USE_AURA) |
| 117 message_loop_.RunAllPendingWithDispatcher( | 117 message_loop_.RunAllPendingWithDispatcher( |
| 118 aura::Env::GetInstance()->GetDispatcher()); | 118 aura::Env::GetInstance()->GetDispatcher()); |
| 119 #else | 119 #else |
| 120 message_loop_.RunAllPending(); | 120 message_loop_.RunAllPending(); |
| 121 #endif | 121 #endif |
| 122 } | 122 } |
| 123 | 123 |
| 124 } // namespace views | 124 } // namespace views |
| OLD | NEW |