| 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 <utility> |
| 8 |
| 7 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 8 #include "ui/base/clipboard/clipboard.h" | 10 #include "ui/base/clipboard/clipboard.h" |
| 9 | 11 |
| 10 namespace views { | 12 namespace views { |
| 11 | 13 |
| 12 ViewsTestBase::ViewsTestBase() | 14 ViewsTestBase::ViewsTestBase() |
| 13 : setup_called_(false), | 15 : setup_called_(false), |
| 14 teardown_called_(false) { | 16 teardown_called_(false) { |
| 15 } | 17 } |
| 16 | 18 |
| 17 ViewsTestBase::~ViewsTestBase() { | 19 ViewsTestBase::~ViewsTestBase() { |
| 18 CHECK(setup_called_) | 20 CHECK(setup_called_) |
| 19 << "You have overridden SetUp but never called super class's SetUp"; | 21 << "You have overridden SetUp but never called super class's SetUp"; |
| 20 CHECK(teardown_called_) | 22 CHECK(teardown_called_) |
| 21 << "You have overridden TearDown but never called super class's TearDown"; | 23 << "You have overridden TearDown but never called super class's TearDown"; |
| 22 } | 24 } |
| 23 | 25 |
| 24 void ViewsTestBase::SetUp() { | 26 void ViewsTestBase::SetUp() { |
| 25 testing::Test::SetUp(); | 27 testing::Test::SetUp(); |
| 26 setup_called_ = true; | 28 setup_called_ = true; |
| 27 if (!views_delegate_for_setup_) | 29 if (!views_delegate_for_setup_) |
| 28 views_delegate_for_setup_.reset(new TestViewsDelegate()); | 30 views_delegate_for_setup_.reset(new TestViewsDelegate()); |
| 29 | 31 |
| 30 test_helper_.reset( | 32 test_helper_.reset( |
| 31 new ScopedViewsTestHelper(views_delegate_for_setup_.Pass())); | 33 new ScopedViewsTestHelper(std::move(views_delegate_for_setup_))); |
| 32 } | 34 } |
| 33 | 35 |
| 34 void ViewsTestBase::TearDown() { | 36 void ViewsTestBase::TearDown() { |
| 35 ui::Clipboard::DestroyClipboardForCurrentThread(); | 37 ui::Clipboard::DestroyClipboardForCurrentThread(); |
| 36 | 38 |
| 37 // Flush the message loop because we have pending release tasks | 39 // Flush the message loop because we have pending release tasks |
| 38 // and these tasks if un-executed would upset Valgrind. | 40 // and these tasks if un-executed would upset Valgrind. |
| 39 RunPendingMessages(); | 41 RunPendingMessages(); |
| 40 teardown_called_ = true; | 42 teardown_called_ = true; |
| 41 testing::Test::TearDown(); | 43 testing::Test::TearDown(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 52 Widget::InitParams params(type); | 54 Widget::InitParams params(type); |
| 53 params.context = GetContext(); | 55 params.context = GetContext(); |
| 54 return params; | 56 return params; |
| 55 } | 57 } |
| 56 | 58 |
| 57 gfx::NativeWindow ViewsTestBase::GetContext() { | 59 gfx::NativeWindow ViewsTestBase::GetContext() { |
| 58 return test_helper_->GetContext(); | 60 return test_helper_->GetContext(); |
| 59 } | 61 } |
| 60 | 62 |
| 61 } // namespace views | 63 } // namespace views |
| OLD | NEW |