| 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 | 9 |
| 9 #if defined(USE_AURA) | 10 #if defined(USE_AURA) |
| 10 #include "ui/aura/env.h" | 11 #include "ui/aura/env.h" |
| 11 #include "ui/aura/test/aura_test_helper.h" | 12 #include "ui/aura/test/aura_test_helper.h" |
| 12 #endif | 13 #endif |
| 13 | 14 |
| 14 namespace views { | 15 namespace views { |
| 15 | 16 |
| 16 ViewsTestBase::ViewsTestBase() | 17 ViewsTestBase::ViewsTestBase() |
| 17 : setup_called_(false), | 18 : setup_called_(false), |
| (...skipping 12 matching lines...) Expand all Loading... |
| 30 setup_called_ = true; | 31 setup_called_ = true; |
| 31 if (!views_delegate_.get()) | 32 if (!views_delegate_.get()) |
| 32 views_delegate_.reset(new TestViewsDelegate()); | 33 views_delegate_.reset(new TestViewsDelegate()); |
| 33 #if defined(USE_AURA) | 34 #if defined(USE_AURA) |
| 34 aura_test_helper_.reset(new aura::test::AuraTestHelper(&message_loop_)); | 35 aura_test_helper_.reset(new aura::test::AuraTestHelper(&message_loop_)); |
| 35 aura_test_helper_->SetUp(); | 36 aura_test_helper_->SetUp(); |
| 36 #endif // USE_AURA | 37 #endif // USE_AURA |
| 37 } | 38 } |
| 38 | 39 |
| 39 void ViewsTestBase::TearDown() { | 40 void ViewsTestBase::TearDown() { |
| 41 ui::Clipboard::DestroyClipboardForCurrentThread(); |
| 42 |
| 40 // Flush the message loop because we have pending release tasks | 43 // Flush the message loop because we have pending release tasks |
| 41 // and these tasks if un-executed would upset Valgrind. | 44 // and these tasks if un-executed would upset Valgrind. |
| 42 RunPendingMessages(); | 45 RunPendingMessages(); |
| 43 teardown_called_ = true; | 46 teardown_called_ = true; |
| 44 views_delegate_.reset(); | 47 views_delegate_.reset(); |
| 45 testing::Test::TearDown(); | 48 testing::Test::TearDown(); |
| 46 #if defined(USE_AURA) | 49 #if defined(USE_AURA) |
| 47 aura_test_helper_->TearDown(); | 50 aura_test_helper_->TearDown(); |
| 48 #endif | 51 #endif |
| 49 } | 52 } |
| 50 | 53 |
| 51 void ViewsTestBase::RunPendingMessages() { | 54 void ViewsTestBase::RunPendingMessages() { |
| 52 base::RunLoop run_loop; | 55 base::RunLoop run_loop; |
| 53 #if defined(USE_AURA) | 56 #if defined(USE_AURA) |
| 54 run_loop.set_dispatcher(aura::Env::GetInstance()->GetDispatcher()); | 57 run_loop.set_dispatcher(aura::Env::GetInstance()->GetDispatcher()); |
| 55 #endif | 58 #endif |
| 56 run_loop.RunUntilIdle(); | 59 run_loop.RunUntilIdle(); |
| 57 } | 60 } |
| 58 | 61 |
| 59 } // namespace views | 62 } // namespace views |
| OLD | NEW |