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

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

Issue 97013002: [Input View] Makes the input view window support window.resizeTo() and w3c visibility API its web c… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years 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"
11 #include "ui/aura/layout_manager.h"
11 #include "ui/aura/root_window.h" 12 #include "ui/aura/root_window.h"
12 #include "ui/aura/test/aura_test_helper.h" 13 #include "ui/aura/test/aura_test_helper.h"
13 #include "ui/aura/test/event_generator.h" 14 #include "ui/aura/test/event_generator.h"
14 #include "ui/aura/test/test_window_delegate.h" 15 #include "ui/aura/test/test_window_delegate.h"
15 #include "ui/aura/window.h" 16 #include "ui/aura/window.h"
16 #include "ui/base/ime/input_method.h" 17 #include "ui/base/ime/input_method.h"
17 #include "ui/base/ime/input_method_factory.h" 18 #include "ui/base/ime/input_method_factory.h"
18 #include "ui/base/ime/text_input_client.h" 19 #include "ui/base/ime/text_input_client.h"
19 #include "ui/compositor/layer_type.h" 20 #include "ui/compositor/layer_type.h"
20 #include "ui/gfx/rect.h" 21 #include "ui/gfx/rect.h"
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 // Schedule to hide keyboard. 328 // Schedule to hide keyboard.
328 input_method->SetFocusedTextInputClient(&no_input_client_1); 329 input_method->SetFocusedTextInputClient(&no_input_client_1);
329 EXPECT_TRUE(WillHideKeyboard()); 330 EXPECT_TRUE(WillHideKeyboard());
330 // Cancel keyboard hide. 331 // Cancel keyboard hide.
331 input_method->SetFocusedTextInputClient(&input_client_2); 332 input_method->SetFocusedTextInputClient(&input_client_2);
332 333
333 EXPECT_FALSE(WillHideKeyboard()); 334 EXPECT_FALSE(WillHideKeyboard());
334 EXPECT_TRUE(keyboard_container->IsVisible()); 335 EXPECT_TRUE(keyboard_container->IsVisible());
335 } 336 }
336 337
338 TEST_F(KeyboardControllerTest, KeyboardResizingFromContents) {
339 aura::Window* keyboard_container = controller()->GetContainerWindow();
340 aura::Window* keyboard_window = proxy()->GetKeyboardWindow();
341 keyboard_container->SetBounds(gfx::Rect(800, 600));
342 keyboard_container->AddChild(keyboard_window);
343
344 // Default keyboard size.
345 EXPECT_EQ(180, keyboard_window->bounds().height());
346
347 // Resizes from contents when flag is unset.
348 keyboard_window->SetBounds(gfx::Rect(100, 80));
349 EXPECT_EQ(180, keyboard_window->bounds().height());
350
351 // Resizes from contents when flag is set.
352 proxy()->set_resizing_from_contents(true);
353 keyboard_window->SetBounds(gfx::Rect(100, 80));
354 EXPECT_EQ(80, keyboard_window->bounds().height());
355
356 // Resizes from container when flag is set.
357 keyboard_container->SetBounds(gfx::Rect(400, 300));
358 EXPECT_EQ(80, keyboard_window->bounds().height());
359
360 // Resizes from container when flag is unset.
361 proxy()->set_resizing_from_contents(false);
362 keyboard_container->SetBounds(gfx::Rect(800, 600));
363 EXPECT_EQ(180, keyboard_window->bounds().height());
364 }
365
337 class KeyboardControllerUsabilityTest : public KeyboardControllerTest { 366 class KeyboardControllerUsabilityTest : public KeyboardControllerTest {
338 public: 367 public:
339 KeyboardControllerUsabilityTest() {} 368 KeyboardControllerUsabilityTest() {}
340 virtual ~KeyboardControllerUsabilityTest() {} 369 virtual ~KeyboardControllerUsabilityTest() {}
341 370
342 virtual void SetUp() OVERRIDE { 371 virtual void SetUp() OVERRIDE {
343 CommandLine::ForCurrentProcess()->AppendSwitch( 372 CommandLine::ForCurrentProcess()->AppendSwitch(
344 switches::kKeyboardUsabilityExperiment); 373 switches::kKeyboardUsabilityExperiment);
345 KeyboardControllerTest::SetUp(); 374 KeyboardControllerTest::SetUp();
346 } 375 }
(...skipping 16 matching lines...) Expand all
363 392
364 EXPECT_TRUE(keyboard_container->IsVisible()); 393 EXPECT_TRUE(keyboard_container->IsVisible());
365 394
366 input_method->SetFocusedTextInputClient(&no_input_client); 395 input_method->SetFocusedTextInputClient(&no_input_client);
367 // Keyboard should not hide itself after lost focus. 396 // Keyboard should not hide itself after lost focus.
368 EXPECT_TRUE(keyboard_container->IsVisible()); 397 EXPECT_TRUE(keyboard_container->IsVisible());
369 EXPECT_FALSE(WillHideKeyboard()); 398 EXPECT_FALSE(WillHideKeyboard());
370 } 399 }
371 400
372 } // namespace keyboard 401 } // 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