| 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 |
| 11 namespace views { | 11 namespace views { |
| 12 | 12 |
| 13 ViewsTestBase::ViewsTestBase() { | 13 ViewsTestBase::ViewsTestBase() |
| 14 : setup_called_(false), |
| 15 teardown_called_(false) { |
| 14 #if defined(OS_WIN) | 16 #if defined(OS_WIN) |
| 15 OleInitialize(NULL); | 17 OleInitialize(NULL); |
| 16 #endif | 18 #endif |
| 17 } | 19 } |
| 18 | 20 |
| 19 ViewsTestBase::~ViewsTestBase() { | 21 ViewsTestBase::~ViewsTestBase() { |
| 20 #if defined(OS_WIN) | 22 #if defined(OS_WIN) |
| 21 OleUninitialize(); | 23 OleUninitialize(); |
| 22 #endif | 24 #endif |
| 25 CHECK(setup_called_) |
| 26 << "You have overridden SetUp but never called super class's SetUp"; |
| 27 CHECK(teardown_called_) |
| 28 << "You have overrideen TearDown but never called super class's TearDown"; |
| 29 } |
| 30 |
| 31 void ViewsTestBase::SetUp() { |
| 32 testing::Test::SetUp(); |
| 33 setup_called_ = true; |
| 34 if (!views_delegate_.get()) |
| 35 views_delegate_.reset(new TestViewsDelegate()); |
| 23 } | 36 } |
| 24 | 37 |
| 25 void ViewsTestBase::TearDown() { | 38 void ViewsTestBase::TearDown() { |
| 26 // Flush the message loop because we have pending release tasks | 39 // Flush the message loop because we have pending release tasks |
| 27 // and these tasks if un-executed would upset Valgrind. | 40 // and these tasks if un-executed would upset Valgrind. |
| 28 RunPendingMessages(); | 41 RunPendingMessages(); |
| 42 teardown_called_ = true; |
| 43 views_delegate_.reset(); |
| 44 testing::Test::TearDown(); |
| 29 } | 45 } |
| 30 | 46 |
| 31 } // namespace views | 47 } // namespace views |
| OLD | NEW |