| 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_initializer.h" | 9 #include "ui/base/ime/input_method_initializer.h" |
| 10 #include "ui/compositor/test/context_factories_for_test.h" | 10 #include "ui/compositor/test/context_factories_for_test.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 << "You have overridden TearDown but never called super class's TearDown"; | 24 << "You have overridden TearDown but never called super class's TearDown"; |
| 25 } | 25 } |
| 26 | 26 |
| 27 void ViewsTestBase::SetUp() { | 27 void ViewsTestBase::SetUp() { |
| 28 testing::Test::SetUp(); | 28 testing::Test::SetUp(); |
| 29 setup_called_ = true; | 29 setup_called_ = true; |
| 30 if (!views_delegate_.get()) | 30 if (!views_delegate_.get()) |
| 31 views_delegate_.reset(new TestViewsDelegate()); | 31 views_delegate_.reset(new TestViewsDelegate()); |
| 32 // The ContextFactory must exist before any Compositors are created. | 32 // The ContextFactory must exist before any Compositors are created. |
| 33 bool enable_pixel_output = false; | 33 bool enable_pixel_output = false; |
| 34 ui::InitializeContextFactoryForTests(enable_pixel_output); | 34 ui::ContextFactory* context_factory = |
| 35 ui::InitializeContextFactoryForTests(enable_pixel_output); |
| 35 | 36 |
| 36 test_helper_.reset(ViewsTestHelper::Create(&message_loop_)); | 37 test_helper_.reset(ViewsTestHelper::Create(&message_loop_, context_factory)); |
| 37 test_helper_->SetUp(); | 38 test_helper_->SetUp(); |
| 38 ui::InitializeInputMethodForTesting(); | 39 ui::InitializeInputMethodForTesting(); |
| 39 } | 40 } |
| 40 | 41 |
| 41 void ViewsTestBase::TearDown() { | 42 void ViewsTestBase::TearDown() { |
| 42 ui::Clipboard::DestroyClipboardForCurrentThread(); | 43 ui::Clipboard::DestroyClipboardForCurrentThread(); |
| 43 | 44 |
| 44 // Flush the message loop because we have pending release tasks | 45 // Flush the message loop because we have pending release tasks |
| 45 // and these tasks if un-executed would upset Valgrind. | 46 // and these tasks if un-executed would upset Valgrind. |
| 46 RunPendingMessages(); | 47 RunPendingMessages(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 62 Widget::InitParams params(type); | 63 Widget::InitParams params(type); |
| 63 params.context = GetContext(); | 64 params.context = GetContext(); |
| 64 return params; | 65 return params; |
| 65 } | 66 } |
| 66 | 67 |
| 67 gfx::NativeView ViewsTestBase::GetContext() { | 68 gfx::NativeView ViewsTestBase::GetContext() { |
| 68 return test_helper_->GetContext(); | 69 return test_helper_->GetContext(); |
| 69 } | 70 } |
| 70 | 71 |
| 71 } // namespace views | 72 } // namespace views |
| OLD | NEW |