| 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 "ui/aura/test/aura_test_base.h" | 5 #include "ui/aura/test/aura_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 |
| 11 #include "ui/aura/desktop.h" | 11 #include "ui/aura/desktop.h" |
| 12 #include "ui/aura/test/test_desktop_delegate.h" | 12 #include "ui/aura/test/test_desktop_delegate.h" |
| 13 #include "ui/gfx/compositor/test_compositor.h" | |
| 14 | 13 |
| 15 namespace aura { | 14 namespace aura { |
| 16 namespace test { | 15 namespace test { |
| 17 | 16 |
| 18 static ui::Compositor* TestCreateCompositor() { | |
| 19 return new ui::TestCompositor(); | |
| 20 } | |
| 21 | |
| 22 AuraTestBase::AuraTestBase() | 17 AuraTestBase::AuraTestBase() |
| 23 : setup_called_(false), | 18 : setup_called_(false), |
| 24 teardown_called_(false) { | 19 teardown_called_(false) { |
| 25 #if defined(OS_WIN) | 20 #if defined(OS_WIN) |
| 26 OleInitialize(NULL); | 21 OleInitialize(NULL); |
| 27 #endif | 22 #endif |
| 28 | 23 |
| 29 aura::Desktop::set_compositor_factory_for_testing(&TestCreateCompositor); | |
| 30 // TestDesktopDelegate is owned by the desktop. | 24 // TestDesktopDelegate is owned by the desktop. |
| 31 new TestDesktopDelegate(); | 25 new TestDesktopDelegate(); |
| 32 Desktop::GetInstance()->Show(); | 26 Desktop::GetInstance()->Show(); |
| 33 Desktop::GetInstance()->SetHostSize(gfx::Size(600, 600)); | 27 Desktop::GetInstance()->SetHostSize(gfx::Size(600, 600)); |
| 34 } | 28 } |
| 35 | 29 |
| 36 AuraTestBase::~AuraTestBase() { | 30 AuraTestBase::~AuraTestBase() { |
| 37 #if defined(OS_WIN) | 31 #if defined(OS_WIN) |
| 38 OleUninitialize(); | 32 OleUninitialize(); |
| 39 #endif | 33 #endif |
| 40 CHECK(setup_called_) | 34 CHECK(setup_called_) |
| 41 << "You have overridden SetUp but never called super class's SetUp"; | 35 << "You have overridden SetUp but never called super class's SetUp"; |
| 42 CHECK(teardown_called_) | 36 CHECK(teardown_called_) |
| 43 << "You have overridden TearDown but never called super class's TearDown"; | 37 << "You have overridden TearDown but never called super class's TearDown"; |
| 44 | 38 |
| 45 // Flush the message loop because we have pending release tasks | 39 // Flush the message loop because we have pending release tasks |
| 46 // and these tasks if un-executed would upset Valgrind. | 40 // and these tasks if un-executed would upset Valgrind. |
| 47 message_loop_.RunAllPendingWithDispatcher( | 41 message_loop_.RunAllPendingWithDispatcher( |
| 48 Desktop::GetInstance()->GetDispatcher()); | 42 Desktop::GetInstance()->GetDispatcher()); |
| 49 | 43 |
| 50 // Ensure that we don't use the previously-allocated static Desktop object | 44 // Ensure that we don't use the previously-allocated static Desktop object |
| 51 // later -- on Linux, it holds a reference to our message loop's X connection. | 45 // later -- on Linux, it holds a reference to our message loop's X connection. |
| 52 aura::Desktop::DeleteInstanceForTesting(); | 46 aura::Desktop::DeleteInstanceForTesting(); |
| 53 aura::Desktop::set_compositor_factory_for_testing(NULL); | |
| 54 } | 47 } |
| 55 | 48 |
| 56 void AuraTestBase::SetUp() { | 49 void AuraTestBase::SetUp() { |
| 57 testing::Test::SetUp(); | 50 testing::Test::SetUp(); |
| 58 setup_called_ = true; | 51 setup_called_ = true; |
| 59 } | 52 } |
| 60 | 53 |
| 61 void AuraTestBase::TearDown() { | 54 void AuraTestBase::TearDown() { |
| 62 teardown_called_ = true; | 55 teardown_called_ = true; |
| 63 testing::Test::TearDown(); | 56 testing::Test::TearDown(); |
| 64 } | 57 } |
| 65 | 58 |
| 66 } // namespace test | 59 } // namespace test |
| 67 } // namespace aura | 60 } // namespace aura |
| OLD | NEW |