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

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

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

Powered by Google App Engine
This is Rietveld 408576698