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

Side by Side Diff: ash/root_window_controller_unittest.cc

Issue 25111002: Only show virtual keyboard on primary root window (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move KeyboardController to shell Created 7 years, 2 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 "ash/root_window_controller.h" 5 #include "ash/root_window_controller.h"
6 6
7 #include "ash/session_state_delegate.h" 7 #include "ash/session_state_delegate.h"
8 #include "ash/shelf/shelf_layout_manager.h" 8 #include "ash/shelf/shelf_layout_manager.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/shell_window_ids.h" 10 #include "ash/shell_window_ids.h"
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 virtual void SetUp() OVERRIDE { 555 virtual void SetUp() OVERRIDE {
556 CommandLine::ForCurrentProcess()->AppendSwitch( 556 CommandLine::ForCurrentProcess()->AppendSwitch(
557 keyboard::switches::kEnableVirtualKeyboard); 557 keyboard::switches::kEnableVirtualKeyboard);
558 test::AshTestBase::SetUp(); 558 test::AshTestBase::SetUp();
559 } 559 }
560 560
561 private: 561 private:
562 DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardRootWindowControllerTest); 562 DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardRootWindowControllerTest);
563 }; 563 };
564 564
565 TEST_F(VirtualKeyboardRootWindowControllerTest,
566 VirtualKeyboardOnPrimaryRootWindowOnly) {
567 if (!SupportsMultipleDisplays())
568 return;
569
570 UpdateDisplay("500x500,500x500");
571
572 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
573 aura::RootWindow* primary_root_window = Shell::GetPrimaryRootWindow();
574 aura::RootWindow* secondary_root_window =
575 root_windows[0] == primary_root_window ?
576 root_windows[1] : root_windows[0];
577
578 aura::Window* keyboard_container = Shell::GetContainer(primary_root_window,
579 internal::kShellWindowId_VirtualKeyboardContainer);
580 ASSERT_TRUE(keyboard_container);
581 keyboard_container = Shell::GetContainer(secondary_root_window,
582 internal::kShellWindowId_VirtualKeyboardContainer);
583 ASSERT_FALSE(keyboard_container);
584 }
585
565 // Test for http://crbug.com/263599. Virtual keyboard should be able to receive 586 // Test for http://crbug.com/263599. Virtual keyboard should be able to receive
566 // events at blocked user session. 587 // events at blocked user session.
567 TEST_F(VirtualKeyboardRootWindowControllerTest, 588 TEST_F(VirtualKeyboardRootWindowControllerTest,
568 ClickVirtualKeyboardInBlockedWindow) { 589 ClickVirtualKeyboardInBlockedWindow) {
569 aura::RootWindow* root_window = ash::Shell::GetPrimaryRootWindow(); 590 aura::RootWindow* root_window = Shell::GetPrimaryRootWindow();
570 aura::Window* keyboard_container = Shell::GetContainer(root_window, 591 aura::Window* keyboard_container = Shell::GetContainer(root_window,
571 internal::kShellWindowId_VirtualKeyboardContainer); 592 internal::kShellWindowId_VirtualKeyboardContainer);
572 ASSERT_TRUE(keyboard_container); 593 ASSERT_TRUE(keyboard_container);
573 keyboard_container->Show(); 594 keyboard_container->Show();
574 595
575 ClickTestWindow* main_delegate = new ClickTestWindow(); 596 ClickTestWindow* main_delegate = new ClickTestWindow();
576 scoped_ptr<aura::Window> keyboard_window( 597 scoped_ptr<aura::Window> keyboard_window(
577 main_delegate->CreateTestWindowWithParent(keyboard_container)); 598 main_delegate->CreateTestWindowWithParent(keyboard_container));
578 keyboard_container->layout_manager()->OnWindowResized(); 599 keyboard_container->layout_manager()->OnWindowResized();
579 keyboard_window->Show(); 600 keyboard_window->Show();
580 aura::test::EventGenerator event_generator(root_window, 601 aura::test::EventGenerator event_generator(root_window,
581 keyboard_window.get()); 602 keyboard_window.get());
582 event_generator.ClickLeftButton(); 603 event_generator.ClickLeftButton();
583 int expected_mouse_presses = 1; 604 int expected_mouse_presses = 1;
584 EXPECT_EQ(expected_mouse_presses, main_delegate->mouse_presses()); 605 EXPECT_EQ(expected_mouse_presses, main_delegate->mouse_presses());
585 606
586 for (int block_reason = FIRST_BLOCK_REASON; 607 for (int block_reason = FIRST_BLOCK_REASON;
587 block_reason < NUMBER_OF_BLOCK_REASONS; 608 block_reason < NUMBER_OF_BLOCK_REASONS;
588 ++block_reason) { 609 ++block_reason) {
589 BlockUserSession(static_cast<UserSessionBlockReason>(block_reason)); 610 BlockUserSession(static_cast<UserSessionBlockReason>(block_reason));
590 event_generator.ClickLeftButton(); 611 event_generator.ClickLeftButton();
591 expected_mouse_presses++; 612 expected_mouse_presses++;
592 EXPECT_EQ(expected_mouse_presses, main_delegate->mouse_presses()); 613 EXPECT_EQ(expected_mouse_presses, main_delegate->mouse_presses());
593 UnblockUserSession(); 614 UnblockUserSession();
594 } 615 }
595 } 616 }
596 617
597 } // namespace test 618 } // namespace test
598 } // namespace ash 619 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698