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

Side by Side Diff: ash/extended_desktop_unittest.cc

Issue 11047030: Decouple EventClientImpl and root window. Check containers on the same root window as focused windo… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix type in event_filter_unittest Created 8 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
« no previous file with comments | « ash/accelerators/accelerator_table.cc ('k') | ash/root_window_controller.h » ('j') | 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) 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/display/display_controller.h" 5 #include "ash/display/display_controller.h"
6 #include "ash/display/multi_display_manager.h" 6 #include "ash/display/multi_display_manager.h"
7 #include "ash/screen_ash.h"
7 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/shell_window_ids.h"
8 #include "ash/system/tray/system_tray.h" 10 #include "ash/system/tray/system_tray.h"
9 #include "ash/test/ash_test_base.h" 11 #include "ash/test/ash_test_base.h"
10 #include "ash/wm/coordinate_conversion.h" 12 #include "ash/wm/coordinate_conversion.h"
11 #include "ash/wm/property_util.h" 13 #include "ash/wm/property_util.h"
12 #include "ash/wm/window_cycle_controller.h" 14 #include "ash/wm/window_cycle_controller.h"
13 #include "ash/wm/window_properties.h" 15 #include "ash/wm/window_properties.h"
14 #include "ash/wm/window_util.h" 16 #include "ash/wm/window_util.h"
17 #include "base/string_util.h"
15 #include "ui/aura/client/activation_client.h" 18 #include "ui/aura/client/activation_client.h"
16 #include "ui/aura/client/capture_client.h" 19 #include "ui/aura/client/capture_client.h"
17 #include "ui/aura/env.h" 20 #include "ui/aura/env.h"
18 #include "ui/aura/focus_manager.h" 21 #include "ui/aura/focus_manager.h"
19 #include "ui/aura/root_window.h" 22 #include "ui/aura/root_window.h"
20 #include "ui/aura/test/event_generator.h" 23 #include "ui/aura/test/event_generator.h"
21 #include "ui/aura/test/test_windows.h" 24 #include "ui/aura/test/test_windows.h"
22 #include "ui/aura/window.h" 25 #include "ui/aura/window.h"
23 #include "ui/base/cursor/cursor.h" 26 #include "ui/base/cursor/cursor.h"
24 #include "ui/gfx/display.h" 27 #include "ui/gfx/display.h"
25 #include "ui/gfx/screen.h" 28 #include "ui/gfx/screen.h"
29 #include "ui/views/controls/textfield/textfield.h"
26 #include "ui/views/widget/widget.h" 30 #include "ui/views/widget/widget.h"
27 #include "ui/views/widget/widget_delegate.h" 31 #include "ui/views/widget/widget_delegate.h"
28 32
29 namespace ash { 33 namespace ash {
30 namespace { 34 namespace {
31 35
32 views::Widget* CreateTestWidgetWithParent(views::Widget* parent, 36 views::Widget* CreateTestWidgetWithParent(views::Widget* parent,
33 const gfx::Rect& bounds, 37 const gfx::Rect& bounds,
34 bool child) { 38 bool child) {
35 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); 39 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 w1->GetNativeView()->SetProperty(internal::kStayInSameRootWindowKey, true); 596 w1->GetNativeView()->SetProperty(internal::kStayInSameRootWindowKey, true);
593 w1->SetBounds(gfx::Rect(10, 10, 50, 50)); 597 w1->SetBounds(gfx::Rect(10, 10, 50, 50));
594 EXPECT_EQ(root_windows[1], w1->GetNativeView()->GetRootWindow()); 598 EXPECT_EQ(root_windows[1], w1->GetNativeView()->GetRootWindow());
595 599
596 // The widget should now move to the 1st root window without the property. 600 // The widget should now move to the 1st root window without the property.
597 w1->GetNativeView()->ClearProperty(internal::kStayInSameRootWindowKey); 601 w1->GetNativeView()->ClearProperty(internal::kStayInSameRootWindowKey);
598 w1->SetBounds(gfx::Rect(10, 10, 50, 50)); 602 w1->SetBounds(gfx::Rect(10, 10, 50, 50));
599 EXPECT_EQ(root_windows[0], w1->GetNativeView()->GetRootWindow()); 603 EXPECT_EQ(root_windows[0], w1->GetNativeView()->GetRootWindow());
600 } 604 }
601 605
606 TEST_F(ExtendedDesktopTest, KeyEventsOnLockScreen) {
607 UpdateDisplay("100x100,200x200");
608 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
609
610 // Create normal windows on both displays.
611 views::Widget* widget1 = CreateTestWidget(
612 gfx::Screen::GetPrimaryDisplay().bounds());
613 widget1->Show();
614 EXPECT_EQ(root_windows[0], widget1->GetNativeView()->GetRootWindow());
615 views::Widget* widget2 = CreateTestWidget(
616 ScreenAsh::GetSecondaryDisplay().bounds());
617 widget2->Show();
618 EXPECT_EQ(root_windows[1], widget2->GetNativeView()->GetRootWindow());
619
620 // Create a LockScreen window.
621 views::Widget* lock_widget = CreateTestWidget(
622 gfx::Screen::GetPrimaryDisplay().bounds());
623 views::Textfield* textfield = new views::Textfield;
624 lock_widget->SetContentsView(textfield);
625
626 ash::Shell::GetContainer(
627 Shell::GetPrimaryRootWindow(),
628 ash::internal::kShellWindowId_LockScreenContainer)->
629 AddChild(lock_widget->GetNativeView());
630 lock_widget->Show();
631 textfield->RequestFocus();
632
633 aura::FocusManager* focus_manager = root_windows[0]->GetFocusManager();
634 EXPECT_EQ(lock_widget->GetNativeView(), focus_manager->GetFocusedWindow());
635
636 // The lock window should get events on both root windows.
637 aura::test::EventGenerator generator1(root_windows[0]);
638 generator1.PressKey(ui::VKEY_A, 0);
639 generator1.ReleaseKey(ui::VKEY_A, 0);
640 EXPECT_EQ(lock_widget->GetNativeView(), focus_manager->GetFocusedWindow());
641 EXPECT_EQ("a", UTF16ToASCII(textfield->text()));
642
643 aura::test::EventGenerator generator2(root_windows[1]);
644 generator2.PressKey(ui::VKEY_B, 0);
645 generator2.ReleaseKey(ui::VKEY_B, 0);
646 EXPECT_EQ(lock_widget->GetNativeView(), focus_manager->GetFocusedWindow());
647 EXPECT_EQ("ab", UTF16ToASCII(textfield->text()));
648
649 // Deleting 2nd display. The lock window still should get the events.
650 UpdateDisplay("100x100");
651 generator2.PressKey(ui::VKEY_C, 0);
652 generator2.ReleaseKey(ui::VKEY_C, 0);
653 EXPECT_EQ(lock_widget->GetNativeView(), focus_manager->GetFocusedWindow());
654 EXPECT_EQ("abc", UTF16ToASCII(textfield->text()));
655
656 // Creating 2nd display again, and lock window still should get events
657 // on both root windows.
658 UpdateDisplay("100x100,200x200");
659 root_windows = Shell::GetAllRootWindows();
660 generator1.PressKey(ui::VKEY_D, 0);
661 generator1.ReleaseKey(ui::VKEY_D, 0);
662 EXPECT_EQ(lock_widget->GetNativeView(), focus_manager->GetFocusedWindow());
663 EXPECT_EQ("abcd", UTF16ToASCII(textfield->text()));
664
665 aura::test::EventGenerator generator22(root_windows[1]);
666 generator22.PressKey(ui::VKEY_E, 0);
667 generator22.ReleaseKey(ui::VKEY_E, 0);
668 EXPECT_EQ(lock_widget->GetNativeView(), focus_manager->GetFocusedWindow());
669 EXPECT_EQ("abcde", UTF16ToASCII(textfield->text()));
670 }
671
602 } // namespace internal 672 } // namespace internal
603 } // namespace ash 673 } // namespace ash
OLDNEW
« no previous file with comments | « ash/accelerators/accelerator_table.cc ('k') | ash/root_window_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698