Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(298)

Side by Side Diff: ui/views/test/views_test_base.cc

Issue 273073002: Changes code using Compositor to pass in ContextFactory (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix tooltip on chromeos Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/views/test/views_test_base.h ('k') | ui/views/test/views_test_helper.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "ui/views/test/views_test_helper.h" 11 #include "ui/views/test/views_test_helper.h"
12 12
13 namespace views { 13 namespace views {
14 14
15 ViewsTestBase::ViewsTestBase() 15 ViewsTestBase::ViewsTestBase()
16 : setup_called_(false), 16 : context_factory_(NULL),
17 setup_called_(false),
17 teardown_called_(false) { 18 teardown_called_(false) {
18 } 19 }
19 20
20 ViewsTestBase::~ViewsTestBase() { 21 ViewsTestBase::~ViewsTestBase() {
21 CHECK(setup_called_) 22 CHECK(setup_called_)
22 << "You have overridden SetUp but never called super class's SetUp"; 23 << "You have overridden SetUp but never called super class's SetUp";
23 CHECK(teardown_called_) 24 CHECK(teardown_called_)
24 << "You have overridden TearDown but never called super class's TearDown"; 25 << "You have overridden TearDown but never called super class's TearDown";
25 } 26 }
26 27
27 void ViewsTestBase::SetUp() { 28 void ViewsTestBase::SetUp() {
28 testing::Test::SetUp(); 29 testing::Test::SetUp();
29 setup_called_ = true; 30 setup_called_ = true;
30 if (!views_delegate_.get()) 31 TestViewsDelegate* test_views_delegate = NULL;
31 views_delegate_.reset(new TestViewsDelegate()); 32 if (!views_delegate_.get()) {
33 test_views_delegate = new TestViewsDelegate;
34 views_delegate_.reset(test_views_delegate);
35 }
32 // The ContextFactory must exist before any Compositors are created. 36 // The ContextFactory must exist before any Compositors are created.
33 bool enable_pixel_output = false; 37 bool enable_pixel_output = false;
34 ui::InitializeContextFactoryForTests(enable_pixel_output); 38 context_factory_ = ui::InitializeContextFactoryForTests(enable_pixel_output);
39 views_delegate_->set_context_factory(context_factory_);
35 40
36 test_helper_.reset(ViewsTestHelper::Create(&message_loop_)); 41 test_helper_.reset(ViewsTestHelper::Create(&message_loop_, context_factory_));
37 test_helper_->SetUp(); 42 test_helper_->SetUp();
38 ui::InitializeInputMethodForTesting(); 43 ui::InitializeInputMethodForTesting();
39 } 44 }
40 45
41 void ViewsTestBase::TearDown() { 46 void ViewsTestBase::TearDown() {
42 ui::Clipboard::DestroyClipboardForCurrentThread(); 47 ui::Clipboard::DestroyClipboardForCurrentThread();
43 48
44 // Flush the message loop because we have pending release tasks 49 // Flush the message loop because we have pending release tasks
45 // and these tasks if un-executed would upset Valgrind. 50 // and these tasks if un-executed would upset Valgrind.
46 RunPendingMessages(); 51 RunPendingMessages();
(...skipping 15 matching lines...) Expand all
62 Widget::InitParams params(type); 67 Widget::InitParams params(type);
63 params.context = GetContext(); 68 params.context = GetContext();
64 return params; 69 return params;
65 } 70 }
66 71
67 gfx::NativeView ViewsTestBase::GetContext() { 72 gfx::NativeView ViewsTestBase::GetContext() {
68 return test_helper_->GetContext(); 73 return test_helper_->GetContext();
69 } 74 }
70 75
71 } // namespace views 76 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/test/views_test_base.h ('k') | ui/views/test/views_test_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698