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

Side by Side Diff: ash/extended_desktop_unittest.cc

Issue 322893005: MacViews: Add WidgetEventGenerator to abstract platform-specific event generation for tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move to events/test. ui:: stripping deferred. fix new win64 warnings (enabled in events) Created 6 years, 5 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 | « no previous file | ash/test/ash_test_base.cc » ('j') | ui/aura/test/event_generator.cc » ('J')
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/display_manager.h" 6 #include "ash/display/display_manager.h"
7 #include "ash/root_window_controller.h" 7 #include "ash/root_window_controller.h"
8 #include "ash/screen_util.h" 8 #include "ash/screen_util.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 850 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 lock_widget->Show(); 861 lock_widget->Show();
862 textfield->RequestFocus(); 862 textfield->RequestFocus();
863 863
864 aura::client::FocusClient* focus_client = 864 aura::client::FocusClient* focus_client =
865 aura::client::GetFocusClient(root_windows[0]); 865 aura::client::GetFocusClient(root_windows[0]);
866 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow()); 866 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow());
867 867
868 // The lock window should get events on both root windows. 868 // The lock window should get events on both root windows.
869 aura::test::EventGenerator& event_generator(GetEventGenerator()); 869 aura::test::EventGenerator& event_generator(GetEventGenerator());
870 870
871 event_generator.set_current_host(root_windows[0]->GetHost()); 871 event_generator.set_current_target(root_windows[0]);
872 event_generator.PressKey(ui::VKEY_A, 0); 872 event_generator.PressKey(ui::VKEY_A, 0);
873 event_generator.ReleaseKey(ui::VKEY_A, 0); 873 event_generator.ReleaseKey(ui::VKEY_A, 0);
874 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow()); 874 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow());
875 EXPECT_EQ("a", base::UTF16ToASCII(textfield->text())); 875 EXPECT_EQ("a", base::UTF16ToASCII(textfield->text()));
876 876
877 event_generator.set_current_host(root_windows[1]->GetHost()); 877 event_generator.set_current_target(root_windows[1]);
878 event_generator.PressKey(ui::VKEY_B, 0); 878 event_generator.PressKey(ui::VKEY_B, 0);
879 event_generator.ReleaseKey(ui::VKEY_B, 0); 879 event_generator.ReleaseKey(ui::VKEY_B, 0);
880 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow()); 880 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow());
881 EXPECT_EQ("ab", base::UTF16ToASCII(textfield->text())); 881 EXPECT_EQ("ab", base::UTF16ToASCII(textfield->text()));
882 882
883 // Deleting 2nd display. The lock window still should get the events. 883 // Deleting 2nd display. The lock window still should get the events.
884 UpdateDisplay("100x100"); 884 UpdateDisplay("100x100");
885 event_generator.PressKey(ui::VKEY_C, 0); 885 event_generator.PressKey(ui::VKEY_C, 0);
886 event_generator.ReleaseKey(ui::VKEY_C, 0); 886 event_generator.ReleaseKey(ui::VKEY_C, 0);
887 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow()); 887 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow());
888 EXPECT_EQ("abc", base::UTF16ToASCII(textfield->text())); 888 EXPECT_EQ("abc", base::UTF16ToASCII(textfield->text()));
889 889
890 // Creating 2nd display again, and lock window still should get events 890 // Creating 2nd display again, and lock window still should get events
891 // on both root windows. 891 // on both root windows.
892 UpdateDisplay("100x100,200x200"); 892 UpdateDisplay("100x100,200x200");
893 root_windows = Shell::GetAllRootWindows(); 893 root_windows = Shell::GetAllRootWindows();
894 event_generator.set_current_host(root_windows[0]->GetHost()); 894 event_generator.set_current_target(root_windows[0]);
895 event_generator.PressKey(ui::VKEY_D, 0); 895 event_generator.PressKey(ui::VKEY_D, 0);
896 event_generator.ReleaseKey(ui::VKEY_D, 0); 896 event_generator.ReleaseKey(ui::VKEY_D, 0);
897 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow()); 897 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow());
898 EXPECT_EQ("abcd", base::UTF16ToASCII(textfield->text())); 898 EXPECT_EQ("abcd", base::UTF16ToASCII(textfield->text()));
899 899
900 event_generator.set_current_host(root_windows[1]->GetHost()); 900 event_generator.set_current_target(root_windows[1]);
901 event_generator.PressKey(ui::VKEY_E, 0); 901 event_generator.PressKey(ui::VKEY_E, 0);
902 event_generator.ReleaseKey(ui::VKEY_E, 0); 902 event_generator.ReleaseKey(ui::VKEY_E, 0);
903 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow()); 903 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow());
904 EXPECT_EQ("abcde", base::UTF16ToASCII(textfield->text())); 904 EXPECT_EQ("abcde", base::UTF16ToASCII(textfield->text()));
905 } 905 }
906 906
907 TEST_F(ExtendedDesktopTest, PassiveGrab) { 907 TEST_F(ExtendedDesktopTest, PassiveGrab) {
908 if (!SupportsMultipleDisplays()) 908 if (!SupportsMultipleDisplays())
909 return; 909 return;
910 910
(...skipping 18 matching lines...) Expand all
929 generator.ReleaseLeftButton(); 929 generator.ReleaseLeftButton();
930 EXPECT_EQ("-999,-999 -999,-999", event_handler.GetLocationsAndReset()); 930 EXPECT_EQ("-999,-999 -999,-999", event_handler.GetLocationsAndReset());
931 931
932 generator.MoveMouseTo(400, 150); 932 generator.MoveMouseTo(400, 150);
933 EXPECT_EQ("100,150 100,150", event_handler.GetLocationsAndReset()); 933 EXPECT_EQ("100,150 100,150", event_handler.GetLocationsAndReset());
934 934
935 ash::Shell::GetInstance()->RemovePreTargetHandler(&event_handler); 935 ash::Shell::GetInstance()->RemovePreTargetHandler(&event_handler);
936 } 936 }
937 937
938 } // namespace ash 938 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/test/ash_test_base.cc » ('j') | ui/aura/test/event_generator.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698