OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ui/aura/aura_test_base.h" |
| 6 |
| 7 #if defined(OS_WIN) |
| 8 #include <ole2.h> |
| 9 #endif |
| 10 |
| 11 #include "ui/aura/desktop.h" |
| 12 #include "ui/gfx/compositor/test_compositor.h" |
| 13 |
| 14 namespace aura { |
| 15 |
| 16 static ui::Compositor* TestCreateCompositor() { |
| 17 return new ui::TestCompositor(); |
| 18 } |
| 19 |
| 20 AuraTestBase::AuraTestBase() |
| 21 : setup_called_(false), |
| 22 teardown_called_(false) { |
| 23 #if defined(OS_WIN) |
| 24 OleInitialize(NULL); |
| 25 #endif |
| 26 } |
| 27 |
| 28 AuraTestBase::~AuraTestBase() { |
| 29 #if defined(OS_WIN) |
| 30 OleUninitialize(); |
| 31 #endif |
| 32 CHECK(setup_called_) |
| 33 << "You have overridden SetUp but never called super class's SetUp"; |
| 34 CHECK(teardown_called_) |
| 35 << "You have overrideen TearDown but never called super class's TearDown"; |
| 36 } |
| 37 |
| 38 void AuraTestBase::SetUp() { |
| 39 testing::Test::SetUp(); |
| 40 setup_called_ = true; |
| 41 aura::Desktop::set_compositor_factory_for_testing(&TestCreateCompositor); |
| 42 if (!aura::Desktop::GetInstance()->default_parent()) |
| 43 aura::Desktop::GetInstance()->CreateDefaultParentForTesting(); |
| 44 Desktop::GetInstance()->Show(); |
| 45 Desktop::GetInstance()->SetSize(gfx::Size(500, 500)); |
| 46 } |
| 47 |
| 48 void AuraTestBase::TearDown() { |
| 49 // Flush the message loop because we have pending release tasks |
| 50 // and these tasks if un-executed would upset Valgrind. |
| 51 RunPendingMessages(); |
| 52 teardown_called_ = true; |
| 53 testing::Test::TearDown(); |
| 54 aura::Desktop::set_compositor_factory_for_testing(NULL); |
| 55 } |
| 56 |
| 57 } // namespace aura |
OLD | NEW |