| 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 12 matching lines...) Expand all Loading... |
| 23 CHECK(teardown_called_) | 23 CHECK(teardown_called_) |
| 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 ui::ContextFactory* context_factory = NULL; |
| 34 #if !defined(OS_MACOSX) |
| 33 bool enable_pixel_output = false; | 35 bool enable_pixel_output = false; |
| 34 ui::ContextFactory* context_factory = | 36 context_factory = ui::InitializeContextFactoryForTests(enable_pixel_output); |
| 35 ui::InitializeContextFactoryForTests(enable_pixel_output); | 37 #endif |
| 36 | 38 |
| 37 test_helper_.reset(ViewsTestHelper::Create(&message_loop_, context_factory)); | 39 test_helper_.reset(ViewsTestHelper::Create(&message_loop_, context_factory)); |
| 38 test_helper_->SetUp(); | 40 test_helper_->SetUp(); |
| 39 ui::InitializeInputMethodForTesting(); | 41 ui::InitializeInputMethodForTesting(); |
| 40 } | 42 } |
| 41 | 43 |
| 42 void ViewsTestBase::TearDown() { | 44 void ViewsTestBase::TearDown() { |
| 43 ui::Clipboard::DestroyClipboardForCurrentThread(); | 45 ui::Clipboard::DestroyClipboardForCurrentThread(); |
| 44 | 46 |
| 45 // Flush the message loop because we have pending release tasks | 47 // Flush the message loop because we have pending release tasks |
| (...skipping 17 matching lines...) Expand all Loading... |
| 63 Widget::InitParams params(type); | 65 Widget::InitParams params(type); |
| 64 params.context = GetContext(); | 66 params.context = GetContext(); |
| 65 return params; | 67 return params; |
| 66 } | 68 } |
| 67 | 69 |
| 68 gfx::NativeWindow ViewsTestBase::GetContext() { | 70 gfx::NativeWindow ViewsTestBase::GetContext() { |
| 69 return test_helper_->GetContext(); | 71 return test_helper_->GetContext(); |
| 70 } | 72 } |
| 71 | 73 |
| 72 } // namespace views | 74 } // namespace views |
| OLD | NEW |