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

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

Issue 213033002: Revert 259580 "Move wm/public into wm target" (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 9 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 | « trunk/src/ui/views/test/views_test_base.h ('k') | trunk/src/ui/views/views.gyp » ('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/aura/env.h" 10 #include "ui/aura/env.h"
11 #include "ui/aura/test/aura_test_helper.h" 11 #include "ui/aura/test/aura_test_helper.h"
12 #include "ui/aura/window_event_dispatcher.h" 12 #include "ui/aura/window_event_dispatcher.h"
13 #include "ui/compositor/test/context_factories_for_test.h" 13 #include "ui/compositor/test/context_factories_for_test.h"
14 #include "ui/wm/core/capture_controller.h" 14 #include "ui/wm/core/capture_controller.h"
15 #include "ui/wm/core/wm_state.h" 15 #include "ui/wm/core/wm_state.h"
16 #include "ui/wm/test/wm_test_helper.h"
17 16
18 namespace views { 17 namespace views {
19 18
20 ViewsTestBase::ViewsTestBase() 19 ViewsTestBase::ViewsTestBase()
21 : setup_called_(false), 20 : setup_called_(false),
22 teardown_called_(false) { 21 teardown_called_(false) {
23 } 22 }
24 23
25 ViewsTestBase::~ViewsTestBase() { 24 ViewsTestBase::~ViewsTestBase() {
26 CHECK(setup_called_) 25 CHECK(setup_called_)
27 << "You have overridden SetUp but never called super class's SetUp"; 26 << "You have overridden SetUp but never called super class's SetUp";
28 CHECK(teardown_called_) 27 CHECK(teardown_called_)
29 << "You have overridden TearDown but never called super class's TearDown"; 28 << "You have overridden TearDown but never called super class's TearDown";
30 } 29 }
31 30
32 void ViewsTestBase::SetUp() { 31 void ViewsTestBase::SetUp() {
33 testing::Test::SetUp(); 32 testing::Test::SetUp();
34 setup_called_ = true; 33 setup_called_ = true;
35 if (!views_delegate_.get()) 34 if (!views_delegate_.get())
36 views_delegate_.reset(new TestViewsDelegate()); 35 views_delegate_.reset(new TestViewsDelegate());
37 // The ContextFactory must exist before any Compositors are created. 36 // The ContextFactory must exist before any Compositors are created.
38 bool enable_pixel_output = false; 37 bool enable_pixel_output = false;
39 ui::InitializeContextFactoryForTests(enable_pixel_output); 38 ui::InitializeContextFactoryForTests(enable_pixel_output);
40 39
41 wm_test_helper_.reset(new wm::WMTestHelper); 40 aura_test_helper_.reset(new aura::test::AuraTestHelper(&message_loop_));
42 wm_test_helper_->SetUp(); 41 aura_test_helper_->SetUp();
43 wm_state_.reset(new ::wm::WMState); 42 wm_state_.reset(new ::wm::WMState);
44 ui::InitializeInputMethodForTesting(); 43 ui::InitializeInputMethodForTesting();
45 } 44 }
46 45
47 void ViewsTestBase::TearDown() { 46 void ViewsTestBase::TearDown() {
48 ui::Clipboard::DestroyClipboardForCurrentThread(); 47 ui::Clipboard::DestroyClipboardForCurrentThread();
49 48
50 // Flush the message loop because we have pending release tasks 49 // Flush the message loop because we have pending release tasks
51 // and these tasks if un-executed would upset Valgrind. 50 // and these tasks if un-executed would upset Valgrind.
52 RunPendingMessages(); 51 RunPendingMessages();
53 teardown_called_ = true; 52 teardown_called_ = true;
54 views_delegate_.reset(); 53 views_delegate_.reset();
55 testing::Test::TearDown(); 54 testing::Test::TearDown();
56 ui::ShutdownInputMethodForTesting(); 55 ui::ShutdownInputMethodForTesting();
57 wm_test_helper_->TearDown(); 56 aura_test_helper_->TearDown();
58 ui::TerminateContextFactoryForTests(); 57 ui::TerminateContextFactoryForTests();
59 wm_state_.reset(); 58 wm_state_.reset();
60 CHECK(!wm::ScopedCaptureClient::IsActive()); 59 CHECK(!wm::ScopedCaptureClient::IsActive());
61 } 60 }
62 61
63 void ViewsTestBase::RunPendingMessages() { 62 void ViewsTestBase::RunPendingMessages() {
64 base::RunLoop run_loop; 63 base::RunLoop run_loop;
65 run_loop.RunUntilIdle(); 64 run_loop.RunUntilIdle();
66 } 65 }
67 66
68 Widget::InitParams ViewsTestBase::CreateParams( 67 Widget::InitParams ViewsTestBase::CreateParams(
69 Widget::InitParams::Type type) { 68 Widget::InitParams::Type type) {
70 Widget::InitParams params(type); 69 Widget::InitParams params(type);
71 params.context = host()->window(); 70 params.context = aura_test_helper_->root_window();
72 return params; 71 return params;
73 } 72 }
74 73
75 ui::EventProcessor* ViewsTestBase::event_processor() { 74 ui::EventProcessor* ViewsTestBase::event_processor() {
76 return wm_test_helper_->host()->event_processor(); 75 return aura_test_helper_->event_processor();
77 } 76 }
78 77
79 aura::WindowTreeHost* ViewsTestBase::host() { 78 aura::WindowTreeHost* ViewsTestBase::host() {
80 return wm_test_helper_->host(); 79 return aura_test_helper_->host();
81 } 80 }
82 81
83 gfx::NativeView ViewsTestBase::GetContext() { 82 gfx::NativeView ViewsTestBase::GetContext() {
84 return wm_test_helper_->host()->window(); 83 return aura_test_helper_->root_window();
85 } 84 }
86 85
87 } // namespace views 86 } // namespace views
OLDNEW
« no previous file with comments | « trunk/src/ui/views/test/views_test_base.h ('k') | trunk/src/ui/views/views.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698