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

Side by Side Diff: ui/keyboard/keyboard_controller_unittest.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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "ui/aura/client/focus_client.h" 10 #include "ui/aura/client/focus_client.h"
11 #include "ui/aura/layout_manager.h" 11 #include "ui/aura/layout_manager.h"
12 #include "ui/aura/root_window.h" 12 #include "ui/aura/root_window.h"
13 #include "ui/aura/test/aura_test_helper.h" 13 #include "ui/aura/test/aura_test_helper.h"
14 #include "ui/aura/test/event_generator.h" 14 #include "ui/aura/test/event_generator.h"
15 #include "ui/aura/test/test_window_delegate.h" 15 #include "ui/aura/test/test_window_delegate.h"
16 #include "ui/aura/window.h" 16 #include "ui/aura/window.h"
17 #include "ui/base/ime/input_method.h" 17 #include "ui/base/ime/input_method.h"
18 #include "ui/base/ime/input_method_factory.h" 18 #include "ui/base/ime/input_method_factory.h"
19 #include "ui/base/ime/text_input_client.h" 19 #include "ui/base/ime/text_input_client.h"
20 #include "ui/compositor/layer_type.h" 20 #include "ui/compositor/layer_type.h"
21 #include "ui/compositor/test/context_factories_for_test.h"
21 #include "ui/gfx/rect.h" 22 #include "ui/gfx/rect.h"
22 #include "ui/keyboard/keyboard_controller.h" 23 #include "ui/keyboard/keyboard_controller.h"
23 #include "ui/keyboard/keyboard_controller_proxy.h" 24 #include "ui/keyboard/keyboard_controller_proxy.h"
24 #include "ui/keyboard/keyboard_switches.h" 25 #include "ui/keyboard/keyboard_switches.h"
25 26
26 namespace keyboard { 27 namespace keyboard {
27 namespace { 28 namespace {
28 29
29 // An event handler that focuses a window when it is clicked/touched on. This is 30 // An event handler that focuses a window when it is clicked/touched on. This is
30 // used to match the focus manger behaviour in ash and views. 31 // used to match the focus manger behaviour in ash and views.
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 }; 191 };
191 192
192 } // namespace 193 } // namespace
193 194
194 class KeyboardControllerTest : public testing::Test { 195 class KeyboardControllerTest : public testing::Test {
195 public: 196 public:
196 KeyboardControllerTest() {} 197 KeyboardControllerTest() {}
197 virtual ~KeyboardControllerTest() {} 198 virtual ~KeyboardControllerTest() {}
198 199
199 virtual void SetUp() OVERRIDE { 200 virtual void SetUp() OVERRIDE {
201 // The ContextFactory must exist before any Compositors are created.
202 bool enable_pixel_output = false;
203 ui::InitializeContextFactoryForTests(enable_pixel_output);
204
200 aura_test_helper_.reset(new aura::test::AuraTestHelper(&message_loop_)); 205 aura_test_helper_.reset(new aura::test::AuraTestHelper(&message_loop_));
201 bool allow_test_contexts = true; 206 aura_test_helper_->SetUp();
202 aura_test_helper_->SetUp(allow_test_contexts);
203 ui::SetUpInputMethodFactoryForTesting(); 207 ui::SetUpInputMethodFactoryForTesting();
204 focus_controller_.reset(new TestFocusController(root_window())); 208 focus_controller_.reset(new TestFocusController(root_window()));
205 proxy_ = new TestKeyboardControllerProxy(); 209 proxy_ = new TestKeyboardControllerProxy();
206 controller_.reset(new KeyboardController(proxy_)); 210 controller_.reset(new KeyboardController(proxy_));
207 } 211 }
208 212
209 virtual void TearDown() OVERRIDE { 213 virtual void TearDown() OVERRIDE {
210 controller_.reset(); 214 controller_.reset();
211 focus_controller_.reset(); 215 focus_controller_.reset();
212 aura_test_helper_->TearDown(); 216 aura_test_helper_->TearDown();
217 ui::TerminateContextFactoryForTests();
213 } 218 }
214 219
215 aura::Window* root_window() { return aura_test_helper_->root_window(); } 220 aura::Window* root_window() { return aura_test_helper_->root_window(); }
216 KeyboardControllerProxy* proxy() { return proxy_; } 221 KeyboardControllerProxy* proxy() { return proxy_; }
217 KeyboardController* controller() { return controller_.get(); } 222 KeyboardController* controller() { return controller_.get(); }
218 223
219 void ShowKeyboard() { 224 void ShowKeyboard() {
220 TestTextInputClient test_text_input_client(ui::TEXT_INPUT_TYPE_TEXT); 225 TestTextInputClient test_text_input_client(ui::TEXT_INPUT_TYPE_TEXT);
221 SetFocus(&test_text_input_client); 226 SetFocus(&test_text_input_client);
222 } 227 }
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 SetFocus(&input_client); 486 SetFocus(&input_client);
482 EXPECT_TRUE(keyboard_container->IsVisible()); 487 EXPECT_TRUE(keyboard_container->IsVisible());
483 488
484 SetFocus(&no_input_client); 489 SetFocus(&no_input_client);
485 // Keyboard should not hide itself after lost focus. 490 // Keyboard should not hide itself after lost focus.
486 EXPECT_TRUE(keyboard_container->IsVisible()); 491 EXPECT_TRUE(keyboard_container->IsVisible());
487 EXPECT_FALSE(WillHideKeyboard()); 492 EXPECT_FALSE(WillHideKeyboard());
488 } 493 }
489 494
490 } // namespace keyboard 495 } // namespace keyboard
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698