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