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

Side by Side Diff: ui/aura/test/aura_test_helper.cc

Issue 145293007: ui: No more TestCompositor. Use NullDraw contexts in unit tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: testsnulldraw: Created 6 years, 10 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
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/aura/test/aura_test_helper.h" 5 #include "ui/aura/test/aura_test_helper.h"
6 6
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "ui/aura/client/aura_constants.h" 9 #include "ui/aura/client/aura_constants.h"
10 #include "ui/aura/client/default_activation_client.h" 10 #include "ui/aura/client/default_activation_client.h"
11 #include "ui/aura/client/default_capture_client.h" 11 #include "ui/aura/client/default_capture_client.h"
12 #include "ui/aura/client/focus_client.h" 12 #include "ui/aura/client/focus_client.h"
13 #include "ui/aura/env.h" 13 #include "ui/aura/env.h"
14 #include "ui/aura/input_state_lookup.h" 14 #include "ui/aura/input_state_lookup.h"
15 #include "ui/aura/root_window.h" 15 #include "ui/aura/root_window.h"
16 #include "ui/aura/test/env_test_helper.h" 16 #include "ui/aura/test/env_test_helper.h"
17 #include "ui/aura/test/test_focus_client.h" 17 #include "ui/aura/test/test_focus_client.h"
18 #include "ui/aura/test/test_screen.h" 18 #include "ui/aura/test/test_screen.h"
19 #include "ui/aura/test/test_window_tree_client.h" 19 #include "ui/aura/test/test_window_tree_client.h"
20 #include "ui/base/ime/dummy_input_method.h" 20 #include "ui/base/ime/dummy_input_method.h"
21 #include "ui/base/ime/input_method_initializer.h" 21 #include "ui/base/ime/input_method_initializer.h"
22 #include "ui/compositor/compositor.h" 22 #include "ui/compositor/compositor.h"
23 #include "ui/compositor/layer_animator.h" 23 #include "ui/compositor/layer_animator.h"
24 #include "ui/compositor/scoped_animation_duration_scale_mode.h" 24 #include "ui/compositor/scoped_animation_duration_scale_mode.h"
25 #include "ui/compositor/test/context_factories_for_test.h"
26 #include "ui/gfx/screen.h" 25 #include "ui/gfx/screen.h"
27 26
28 #if defined(USE_X11) 27 #if defined(USE_X11)
29 #include "ui/aura/root_window_host_x11.h" 28 #include "ui/aura/root_window_host_x11.h"
30 #include "ui/base/x/x11_util.h" 29 #include "ui/base/x/x11_util.h"
31 #endif 30 #endif
32 31
33 namespace aura { 32 namespace aura {
34 namespace test { 33 namespace test {
35 34
(...skipping 11 matching lines...) Expand all
47 #endif 46 #endif
48 } 47 }
49 48
50 AuraTestHelper::~AuraTestHelper() { 49 AuraTestHelper::~AuraTestHelper() {
51 CHECK(setup_called_) 50 CHECK(setup_called_)
52 << "AuraTestHelper::SetUp() never called."; 51 << "AuraTestHelper::SetUp() never called.";
53 CHECK(teardown_called_) 52 CHECK(teardown_called_)
54 << "AuraTestHelper::TearDown() never called."; 53 << "AuraTestHelper::TearDown() never called.";
55 } 54 }
56 55
57 void AuraTestHelper::SetUp(bool allow_test_contexts) { 56 void AuraTestHelper::SetUp() {
58 setup_called_ = true; 57 setup_called_ = true;
59 58
60 // The ContextFactory must exist before any Compositors are created.
61 ui::InitializeContextFactoryForTests(allow_test_contexts);
62
63 Env::CreateInstance(); 59 Env::CreateInstance();
64 // Unit tests generally don't want to query the system, rather use the state 60 // Unit tests generally don't want to query the system, rather use the state
65 // from RootWindow. 61 // from RootWindow.
66 EnvTestHelper(Env::GetInstance()).SetInputStateLookup( 62 EnvTestHelper(Env::GetInstance()).SetInputStateLookup(
67 scoped_ptr<InputStateLookup>()); 63 scoped_ptr<InputStateLookup>());
68 64
69 ui::InitializeInputMethodForTesting(); 65 ui::InitializeInputMethodForTesting();
70 66
71 test_screen_.reset(TestScreen::Create()); 67 test_screen_.reset(TestScreen::Create());
72 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_.get()); 68 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_.get());
(...skipping 28 matching lines...) Expand all
101 test_screen_.reset(); 97 test_screen_.reset();
102 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, NULL); 98 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, NULL);
103 99
104 #if defined(USE_X11) 100 #if defined(USE_X11)
105 ui::ResetXCursorCache(); 101 ui::ResetXCursorCache();
106 #endif 102 #endif
107 103
108 ui::ShutdownInputMethodForTesting(); 104 ui::ShutdownInputMethodForTesting();
109 105
110 Env::DeleteInstance(); 106 Env::DeleteInstance();
111
112 ui::TerminateContextFactoryForTests();
113 } 107 }
114 108
115 void AuraTestHelper::RunAllPendingInMessageLoop() { 109 void AuraTestHelper::RunAllPendingInMessageLoop() {
116 // TODO(jbates) crbug.com/134753 Find quitters of this RunLoop and have them 110 // TODO(jbates) crbug.com/134753 Find quitters of this RunLoop and have them
117 // use run_loop.QuitClosure(). 111 // use run_loop.QuitClosure().
118 base::RunLoop run_loop(Env::GetInstance()->GetDispatcher()); 112 base::RunLoop run_loop(Env::GetInstance()->GetDispatcher());
119 run_loop.RunUntilIdle(); 113 run_loop.RunUntilIdle();
120 } 114 }
121 115
122 } // namespace test 116 } // namespace test
123 } // namespace aura 117 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698