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

Side by Side Diff: ui/keyboard/keyboard_controller_unittest.cc

Issue 276483002: Fix calculation of usable area of screen when VK is shown. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix unittests 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/keyboard/keyboard_controller_proxy.cc ('k') | no next file » | 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) 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"
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 focus_controller_.reset(); 181 focus_controller_.reset();
182 aura_test_helper_->TearDown(); 182 aura_test_helper_->TearDown();
183 ui::TerminateContextFactoryForTests(); 183 ui::TerminateContextFactoryForTests();
184 } 184 }
185 185
186 aura::Window* root_window() { return aura_test_helper_->root_window(); } 186 aura::Window* root_window() { return aura_test_helper_->root_window(); }
187 KeyboardControllerProxy* proxy() { return proxy_; } 187 KeyboardControllerProxy* proxy() { return proxy_; }
188 KeyboardController* controller() { return controller_.get(); } 188 KeyboardController* controller() { return controller_.get(); }
189 189
190 void ShowKeyboard() { 190 void ShowKeyboard() {
191 ui::DummyTextInputClient test_text_input_client(ui::TEXT_INPUT_TYPE_TEXT); 191 test_text_input_client_.reset(
192 SetFocus(&test_text_input_client); 192 new ui::DummyTextInputClient(ui::TEXT_INPUT_TYPE_TEXT));
193 SetFocus(test_text_input_client_.get());
193 } 194 }
194 195
195 protected: 196 protected:
196 void SetFocus(ui::TextInputClient* client) { 197 void SetFocus(ui::TextInputClient* client) {
197 ui::InputMethod* input_method = proxy()->GetInputMethod(); 198 ui::InputMethod* input_method = proxy()->GetInputMethod();
198 input_method->SetFocusedTextInputClient(client); 199 input_method->SetFocusedTextInputClient(client);
199 if (client && client->GetTextInputType() != ui::TEXT_INPUT_TYPE_NONE) { 200 if (client && client->GetTextInputType() != ui::TEXT_INPUT_TYPE_NONE) {
200 input_method->ShowImeIfNeeded(); 201 input_method->ShowImeIfNeeded();
201 if (proxy_->GetKeyboardWindow()->bounds().height() == 0) { 202 if (proxy_->GetKeyboardWindow()->bounds().height() == 0) {
202 // Set initial bounds for test keyboard window. 203 // Set initial bounds for test keyboard window.
203 proxy_->GetKeyboardWindow()->SetBounds( 204 proxy_->GetKeyboardWindow()->SetBounds(
204 KeyboardBoundsFromWindowBounds( 205 KeyboardBoundsFromWindowBounds(
205 controller()->GetContainerWindow()->bounds(), 100)); 206 controller()->GetContainerWindow()->bounds(), 100));
206 } 207 }
207 } 208 }
208 } 209 }
209 210
210 bool WillHideKeyboard() { 211 bool WillHideKeyboard() {
211 return controller_->WillHideKeyboard(); 212 return controller_->WillHideKeyboard();
212 } 213 }
213 214
214 base::MessageLoopForUI message_loop_; 215 base::MessageLoopForUI message_loop_;
215 scoped_ptr<aura::test::AuraTestHelper> aura_test_helper_; 216 scoped_ptr<aura::test::AuraTestHelper> aura_test_helper_;
216 scoped_ptr<TestFocusController> focus_controller_; 217 scoped_ptr<TestFocusController> focus_controller_;
217 218
218 private: 219 private:
219 KeyboardControllerProxy* proxy_; 220 KeyboardControllerProxy* proxy_;
220 scoped_ptr<KeyboardController> controller_; 221 scoped_ptr<KeyboardController> controller_;
221 222 scoped_ptr<ui::TextInputClient> test_text_input_client_;
222 DISALLOW_COPY_AND_ASSIGN(KeyboardControllerTest); 223 DISALLOW_COPY_AND_ASSIGN(KeyboardControllerTest);
223 }; 224 };
224 225
225 TEST_F(KeyboardControllerTest, KeyboardSize) { 226 TEST_F(KeyboardControllerTest, KeyboardSize) {
226 aura::Window* container(controller()->GetContainerWindow()); 227 aura::Window* container(controller()->GetContainerWindow());
227 aura::Window* keyboard(proxy()->GetKeyboardWindow()); 228 aura::Window* keyboard(proxy()->GetKeyboardWindow());
228 container->SetBounds(gfx::Rect(0, 0, 200, 100)); 229 container->SetBounds(gfx::Rect(0, 0, 200, 100));
229 230
230 container->AddChild(keyboard); 231 container->AddChild(keyboard);
231 const gfx::Rect& before_bounds = keyboard->bounds(); 232 const gfx::Rect& before_bounds = keyboard->bounds();
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 SetFocus(&input_client); 551 SetFocus(&input_client);
551 EXPECT_TRUE(keyboard_container->IsVisible()); 552 EXPECT_TRUE(keyboard_container->IsVisible());
552 553
553 SetFocus(&no_input_client); 554 SetFocus(&no_input_client);
554 // Keyboard should not hide itself after lost focus. 555 // Keyboard should not hide itself after lost focus.
555 EXPECT_TRUE(keyboard_container->IsVisible()); 556 EXPECT_TRUE(keyboard_container->IsVisible());
556 EXPECT_FALSE(WillHideKeyboard()); 557 EXPECT_FALSE(WillHideKeyboard());
557 } 558 }
558 559
559 } // namespace keyboard 560 } // namespace keyboard
OLDNEW
« no previous file with comments | « ui/keyboard/keyboard_controller_proxy.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698