| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "views/test/views_test_base.h" | 5 #include "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 26 matching lines...) Expand all Loading... |
| 37 << "You have overridden SetUp but never called super class's SetUp"; | 37 << "You have overridden SetUp but never called super class's SetUp"; |
| 38 CHECK(teardown_called_) | 38 CHECK(teardown_called_) |
| 39 << "You have overrideen TearDown but never called super class's TearDown"; | 39 << "You have overrideen TearDown but never called super class's TearDown"; |
| 40 } | 40 } |
| 41 | 41 |
| 42 void ViewsTestBase::SetUp() { | 42 void ViewsTestBase::SetUp() { |
| 43 testing::Test::SetUp(); | 43 testing::Test::SetUp(); |
| 44 setup_called_ = true; | 44 setup_called_ = true; |
| 45 #if defined(USE_AURA) | 45 #if defined(USE_AURA) |
| 46 aura::Desktop::set_compositor_factory_for_testing(&TestCreateCompositor); | 46 aura::Desktop::set_compositor_factory_for_testing(&TestCreateCompositor); |
| 47 if (!aura::Desktop::GetInstance()->default_parent()) | |
| 48 aura::Desktop::GetInstance()->CreateDefaultParentForTesting(); | |
| 49 #else | 47 #else |
| 50 Widget::set_compositor_factory_for_testing(&TestCreateCompositor); | 48 Widget::set_compositor_factory_for_testing(&TestCreateCompositor); |
| 51 #endif | 49 #endif |
| 52 if (!views_delegate_.get()) | 50 if (!views_delegate_.get()) |
| 53 views_delegate_.reset(new TestViewsDelegate()); | 51 views_delegate_.reset(new TestViewsDelegate()); |
| 54 } | 52 } |
| 55 | 53 |
| 56 void ViewsTestBase::TearDown() { | 54 void ViewsTestBase::TearDown() { |
| 57 // Flush the message loop because we have pending release tasks | 55 // Flush the message loop because we have pending release tasks |
| 58 // and these tasks if un-executed would upset Valgrind. | 56 // and these tasks if un-executed would upset Valgrind. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 70 void ViewsTestBase::RunPendingMessages() { | 68 void ViewsTestBase::RunPendingMessages() { |
| 71 #if defined(USE_AURA) | 69 #if defined(USE_AURA) |
| 72 message_loop_.RunAllPendingWithDispatcher( | 70 message_loop_.RunAllPendingWithDispatcher( |
| 73 aura::Desktop::GetInstance()->GetDispatcher()); | 71 aura::Desktop::GetInstance()->GetDispatcher()); |
| 74 #else | 72 #else |
| 75 message_loop_.RunAllPending(); | 73 message_loop_.RunAllPending(); |
| 76 #endif | 74 #endif |
| 77 } | 75 } |
| 78 | 76 |
| 79 } // namespace views | 77 } // namespace views |
| OLD | NEW |