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

Side by Side Diff: ash/display/display_controller_unittest.cc

Issue 14293028: [CleanUp] Add MoveMouseToInHost to aura::test::EventGenerator (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup Created 7 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 | « ash/ash_root_window_transformer_unittest.cc ('k') | ash/display/display_manager_unittest.cc » ('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 6
7 #include "ash/display/display_info.h" 7 #include "ash/display/display_info.h"
8 #include "ash/display/display_manager.h" 8 #include "ash/display/display_manager.h"
9 #include "ash/launcher/launcher.h" 9 #include "ash/launcher/launcher.h"
10 #include "ash/screen_ash.h" 10 #include "ash/screen_ash.h"
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 }; 174 };
175 175
176 gfx::Display::Rotation GetStoredRotation(int64 id) { 176 gfx::Display::Rotation GetStoredRotation(int64 id) {
177 return Shell::GetInstance()->display_manager()->GetDisplayInfo(id).rotation(); 177 return Shell::GetInstance()->display_manager()->GetDisplayInfo(id).rotation();
178 } 178 }
179 179
180 float GetStoredUIScale(int64 id) { 180 float GetStoredUIScale(int64 id) {
181 return Shell::GetInstance()->display_manager()->GetDisplayInfo(id).ui_scale(); 181 return Shell::GetInstance()->display_manager()->GetDisplayInfo(id).ui_scale();
182 } 182 }
183 183
184 void MoveMouseToInHostCoord(aura::RootWindow* root_window,
185 int host_x,
186 int host_y) {
187 gfx::Point move_point(host_x, host_y);
188 ui::MouseEvent mouseev(ui::ET_MOUSE_MOVED, move_point, move_point, 0);
189 root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouseev);
190 }
191
192 } // namespace 184 } // namespace
193 185
194 typedef test::AshTestBase DisplayControllerTest; 186 typedef test::AshTestBase DisplayControllerTest;
195 187
196 TEST_F(DisplayControllerShutdownTest, Shutdown) { 188 TEST_F(DisplayControllerShutdownTest, Shutdown) {
197 UpdateDisplay("444x333, 200x200"); 189 UpdateDisplay("444x333, 200x200");
198 } 190 }
199 191
200 TEST_F(DisplayControllerTest, SecondaryDisplayLayout) { 192 TEST_F(DisplayControllerTest, SecondaryDisplayLayout) {
201 TestObserver observer; 193 TestObserver observer;
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); 700 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
709 701
710 display_controller->SetOverscanInsets(display1.id(), 702 display_controller->SetOverscanInsets(display1.id(),
711 gfx::Insets(10, 15, 20, 25)); 703 gfx::Insets(10, 15, 20, 25));
712 EXPECT_EQ("0,0 80x170", root_windows[0]->bounds().ToString()); 704 EXPECT_EQ("0,0 80x170", root_windows[0]->bounds().ToString());
713 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString()); 705 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString());
714 EXPECT_EQ("80,0 150x200", 706 EXPECT_EQ("80,0 150x200",
715 ScreenAsh::GetSecondaryDisplay().bounds().ToString()); 707 ScreenAsh::GetSecondaryDisplay().bounds().ToString());
716 708
717 aura::test::EventGenerator generator(root_windows[0]); 709 aura::test::EventGenerator generator(root_windows[0]);
718 generator.MoveMouseTo(20, 25); 710 generator.MoveMouseToInHost(20, 25);
719 EXPECT_EQ("5,15", event_handler.GetLocationAndReset()); 711 EXPECT_EQ("5,15", event_handler.GetLocationAndReset());
720 712
721 display_controller->ClearCustomOverscanInsets(display1.id()); 713 display_controller->ClearCustomOverscanInsets(display1.id());
722 EXPECT_EQ("0,0 120x200", root_windows[0]->bounds().ToString()); 714 EXPECT_EQ("0,0 120x200", root_windows[0]->bounds().ToString());
723 EXPECT_EQ("120,0 150x200", 715 EXPECT_EQ("120,0 150x200",
724 ScreenAsh::GetSecondaryDisplay().bounds().ToString()); 716 ScreenAsh::GetSecondaryDisplay().bounds().ToString());
725 717
726 generator.MoveMouseTo(30, 20); 718 generator.MoveMouseToInHost(30, 20);
727 EXPECT_EQ("30,20", event_handler.GetLocationAndReset()); 719 EXPECT_EQ("30,20", event_handler.GetLocationAndReset());
728 720
729 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); 721 Shell::GetInstance()->RemovePreTargetHandler(&event_handler);
730 } 722 }
731 723
732 #if defined(OS_WIN) 724 #if defined(OS_WIN)
733 // On Win8 bots, the host window can't be resized and 725 // On Win8 bots, the host window can't be resized and
734 // SetTransform updates the window using the orignal host window 726 // SetTransform updates the window using the orignal host window
735 // size. 727 // size.
736 #define MAYBE_Rotate DISABLED_Rotate 728 #define MAYBE_Rotate DISABLED_Rotate
(...skipping 18 matching lines...) Expand all
755 UpdateDisplay("120x200,300x400*2"); 747 UpdateDisplay("120x200,300x400*2");
756 gfx::Display display1 = Shell::GetScreen()->GetPrimaryDisplay(); 748 gfx::Display display1 = Shell::GetScreen()->GetPrimaryDisplay();
757 int64 display2_id = ScreenAsh::GetSecondaryDisplay().id(); 749 int64 display2_id = ScreenAsh::GetSecondaryDisplay().id();
758 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); 750 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
759 aura::test::EventGenerator generator1(root_windows[0]); 751 aura::test::EventGenerator generator1(root_windows[0]);
760 752
761 EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString()); 753 EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString());
762 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString()); 754 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString());
763 EXPECT_EQ("120,0 150x200", 755 EXPECT_EQ("120,0 150x200",
764 ScreenAsh::GetSecondaryDisplay().bounds().ToString()); 756 ScreenAsh::GetSecondaryDisplay().bounds().ToString());
765 generator1.MoveMouseTo(50, 40); 757 generator1.MoveMouseToInHost(50, 40);
766 EXPECT_EQ("50,40", event_handler.GetLocationAndReset()); 758 EXPECT_EQ("50,40", event_handler.GetLocationAndReset());
767 EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display1.id())); 759 EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display1.id()));
768 EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display2_id)); 760 EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display2_id));
769 761
770 display_manager->SetDisplayRotation(display1.id(), 762 display_manager->SetDisplayRotation(display1.id(),
771 gfx::Display::ROTATE_90); 763 gfx::Display::ROTATE_90);
772 EXPECT_EQ("200x120", root_windows[0]->bounds().size().ToString()); 764 EXPECT_EQ("200x120", root_windows[0]->bounds().size().ToString());
773 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString()); 765 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString());
774 EXPECT_EQ("200,0 150x200", 766 EXPECT_EQ("200,0 150x200",
775 ScreenAsh::GetSecondaryDisplay().bounds().ToString()); 767 ScreenAsh::GetSecondaryDisplay().bounds().ToString());
776 generator1.MoveMouseTo(50, 40); 768 generator1.MoveMouseToInHost(50, 40);
777 EXPECT_EQ("40,69", event_handler.GetLocationAndReset()); 769 EXPECT_EQ("40,69", event_handler.GetLocationAndReset());
778 EXPECT_EQ(gfx::Display::ROTATE_90, GetStoredRotation(display1.id())); 770 EXPECT_EQ(gfx::Display::ROTATE_90, GetStoredRotation(display1.id()));
779 EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display2_id)); 771 EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display2_id));
780 772
781 DisplayLayout display_layout(DisplayLayout::BOTTOM, 50); 773 DisplayLayout display_layout(DisplayLayout::BOTTOM, 50);
782 display_controller->SetLayoutForCurrentDisplays(display_layout); 774 display_controller->SetLayoutForCurrentDisplays(display_layout);
783 EXPECT_EQ("50,120 150x200", 775 EXPECT_EQ("50,120 150x200",
784 ScreenAsh::GetSecondaryDisplay().bounds().ToString()); 776 ScreenAsh::GetSecondaryDisplay().bounds().ToString());
785 777
786 display_manager->SetDisplayRotation(display2_id, 778 display_manager->SetDisplayRotation(display2_id,
787 gfx::Display::ROTATE_270); 779 gfx::Display::ROTATE_270);
788 EXPECT_EQ("200x120", root_windows[0]->bounds().size().ToString()); 780 EXPECT_EQ("200x120", root_windows[0]->bounds().size().ToString());
789 EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString()); 781 EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString());
790 EXPECT_EQ("50,120 200x150", 782 EXPECT_EQ("50,120 200x150",
791 ScreenAsh::GetSecondaryDisplay().bounds().ToString()); 783 ScreenAsh::GetSecondaryDisplay().bounds().ToString());
792 EXPECT_EQ(gfx::Display::ROTATE_90, GetStoredRotation(display1.id())); 784 EXPECT_EQ(gfx::Display::ROTATE_90, GetStoredRotation(display1.id()));
793 EXPECT_EQ(gfx::Display::ROTATE_270, GetStoredRotation(display2_id)); 785 EXPECT_EQ(gfx::Display::ROTATE_270, GetStoredRotation(display2_id));
794 786
795 aura::test::EventGenerator generator2(root_windows[1]); 787 aura::test::EventGenerator generator2(root_windows[1]);
796 generator2.MoveMouseTo(50, 40); 788 generator2.MoveMouseToInHost(50, 40);
797 EXPECT_EQ("179,25", event_handler.GetLocationAndReset()); 789 EXPECT_EQ("179,25", event_handler.GetLocationAndReset());
798 display_manager->SetDisplayRotation(display1.id(), 790 display_manager->SetDisplayRotation(display1.id(),
799 gfx::Display::ROTATE_180); 791 gfx::Display::ROTATE_180);
800 792
801 EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString()); 793 EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString());
802 EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString()); 794 EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString());
803 // Dislay must share at least 100, so the x's offset becomes 20. 795 // Dislay must share at least 100, so the x's offset becomes 20.
804 EXPECT_EQ("20,200 200x150", 796 EXPECT_EQ("20,200 200x150",
805 ScreenAsh::GetSecondaryDisplay().bounds().ToString()); 797 ScreenAsh::GetSecondaryDisplay().bounds().ToString());
806 EXPECT_EQ(gfx::Display::ROTATE_180, GetStoredRotation(display1.id())); 798 EXPECT_EQ(gfx::Display::ROTATE_180, GetStoredRotation(display1.id()));
807 EXPECT_EQ(gfx::Display::ROTATE_270, GetStoredRotation(display2_id)); 799 EXPECT_EQ(gfx::Display::ROTATE_270, GetStoredRotation(display2_id));
808 800
809 generator1.MoveMouseTo(50, 40); 801 generator1.MoveMouseToInHost(50, 40);
810 EXPECT_EQ("69,159", event_handler.GetLocationAndReset()); 802 EXPECT_EQ("69,159", event_handler.GetLocationAndReset());
811 803
812 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); 804 Shell::GetInstance()->RemovePreTargetHandler(&event_handler);
813 } 805 }
814 806
815 TEST_F(DisplayControllerTest, MAYBE_ScaleRootWindow) { 807 TEST_F(DisplayControllerTest, MAYBE_ScaleRootWindow) {
816 TestEventHandler event_handler; 808 TestEventHandler event_handler;
817 Shell::GetInstance()->AddPreTargetHandler(&event_handler); 809 Shell::GetInstance()->AddPreTargetHandler(&event_handler);
818 810
819 UpdateDisplay("600x400*2@1.5,500x300"); 811 UpdateDisplay("600x400*2@1.5,500x300");
820 812
821 gfx::Display display1 = Shell::GetScreen()->GetPrimaryDisplay(); 813 gfx::Display display1 = Shell::GetScreen()->GetPrimaryDisplay();
822 gfx::Display::SetInternalDisplayId(display1.id()); 814 gfx::Display::SetInternalDisplayId(display1.id());
823 815
824 gfx::Display display2 = ScreenAsh::GetSecondaryDisplay(); 816 gfx::Display display2 = ScreenAsh::GetSecondaryDisplay();
825 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); 817 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
826 EXPECT_EQ("0,0 450x300", display1.bounds().ToString()); 818 EXPECT_EQ("0,0 450x300", display1.bounds().ToString());
827 EXPECT_EQ("0,0 450x300", root_windows[0]->bounds().ToString()); 819 EXPECT_EQ("0,0 450x300", root_windows[0]->bounds().ToString());
828 EXPECT_EQ("450,0 500x300", display2.bounds().ToString()); 820 EXPECT_EQ("450,0 500x300", display2.bounds().ToString());
829 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id())); 821 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id()));
830 EXPECT_EQ(1.0f, GetStoredUIScale(display2.id())); 822 EXPECT_EQ(1.0f, GetStoredUIScale(display2.id()));
831 823
832 aura::test::EventGenerator generator(root_windows[0]); 824 aura::test::EventGenerator generator(root_windows[0]);
833 generator.MoveMouseTo(599, 200); 825 generator.MoveMouseToInHost(599, 200);
834 EXPECT_EQ("449,150", event_handler.GetLocationAndReset()); 826 EXPECT_EQ("449,150", event_handler.GetLocationAndReset());
835 827
836 internal::DisplayManager* display_manager = 828 internal::DisplayManager* display_manager =
837 Shell::GetInstance()->display_manager(); 829 Shell::GetInstance()->display_manager();
838 display_manager->SetDisplayUIScale(display1.id(), 1.25f); 830 display_manager->SetDisplayUIScale(display1.id(), 1.25f);
839 display1 = Shell::GetScreen()->GetPrimaryDisplay(); 831 display1 = Shell::GetScreen()->GetPrimaryDisplay();
840 display2 = ScreenAsh::GetSecondaryDisplay(); 832 display2 = ScreenAsh::GetSecondaryDisplay();
841 EXPECT_EQ("0,0 375x250", display1.bounds().ToString()); 833 EXPECT_EQ("0,0 375x250", display1.bounds().ToString());
842 EXPECT_EQ("0,0 375x250", root_windows[0]->bounds().ToString()); 834 EXPECT_EQ("0,0 375x250", root_windows[0]->bounds().ToString());
843 EXPECT_EQ("375,0 500x300", display2.bounds().ToString()); 835 EXPECT_EQ("375,0 500x300", display2.bounds().ToString());
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 Shell::GetInstance()->AddPreTargetHandler(&event_handler); 873 Shell::GetInstance()->AddPreTargetHandler(&event_handler);
882 874
883 UpdateDisplay("600x400*2/r@1.5"); 875 UpdateDisplay("600x400*2/r@1.5");
884 876
885 gfx::Display display1 = Shell::GetScreen()->GetPrimaryDisplay(); 877 gfx::Display display1 = Shell::GetScreen()->GetPrimaryDisplay();
886 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); 878 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
887 EXPECT_EQ("0,0 300x450", display1.bounds().ToString()); 879 EXPECT_EQ("0,0 300x450", display1.bounds().ToString());
888 EXPECT_EQ("0,0 300x450", root_windows[0]->bounds().ToString()); 880 EXPECT_EQ("0,0 300x450", root_windows[0]->bounds().ToString());
889 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id())); 881 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id()));
890 882
891 MoveMouseToInHostCoord(root_windows[0], 0, 0); 883 aura::test::EventGenerator generator(root_windows[0]);
884 generator.MoveMouseToInHost(0, 0);
892 EXPECT_EQ("0,449", event_handler.GetLocationAndReset()); 885 EXPECT_EQ("0,449", event_handler.GetLocationAndReset());
893 MoveMouseToInHostCoord(root_windows[0], 599, 0); 886 generator.MoveMouseToInHost(599, 0);
894 EXPECT_EQ("0,0", event_handler.GetLocationAndReset()); 887 EXPECT_EQ("0,0", event_handler.GetLocationAndReset());
895 MoveMouseToInHostCoord(root_windows[0], 599, 399); 888 generator.MoveMouseToInHost(599, 399);
896 EXPECT_EQ("299,0", event_handler.GetLocationAndReset()); 889 EXPECT_EQ("299,0", event_handler.GetLocationAndReset());
897 MoveMouseToInHostCoord(root_windows[0], 0, 399); 890 generator.MoveMouseToInHost(0, 399);
898 EXPECT_EQ("299,449", event_handler.GetLocationAndReset()); 891 EXPECT_EQ("299,449", event_handler.GetLocationAndReset());
899 892
900 UpdateDisplay("600x400*2/u@1.5"); 893 UpdateDisplay("600x400*2/u@1.5");
901 display1 = Shell::GetScreen()->GetPrimaryDisplay(); 894 display1 = Shell::GetScreen()->GetPrimaryDisplay();
902 root_windows = Shell::GetAllRootWindows(); 895 root_windows = Shell::GetAllRootWindows();
903 EXPECT_EQ("0,0 450x300", display1.bounds().ToString()); 896 EXPECT_EQ("0,0 450x300", display1.bounds().ToString());
904 EXPECT_EQ("0,0 450x300", root_windows[0]->bounds().ToString()); 897 EXPECT_EQ("0,0 450x300", root_windows[0]->bounds().ToString());
905 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id())); 898 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id()));
906 899
907 MoveMouseToInHostCoord(root_windows[0], 0, 0); 900 generator.MoveMouseToInHost(0, 0);
908 EXPECT_EQ("449,299", event_handler.GetLocationAndReset()); 901 EXPECT_EQ("449,299", event_handler.GetLocationAndReset());
909 MoveMouseToInHostCoord(root_windows[0], 599, 0); 902 generator.MoveMouseToInHost(599, 0);
910 EXPECT_EQ("0,299", event_handler.GetLocationAndReset()); 903 EXPECT_EQ("0,299", event_handler.GetLocationAndReset());
911 MoveMouseToInHostCoord(root_windows[0], 599, 399); 904 generator.MoveMouseToInHost(599, 399);
912 EXPECT_EQ("0,0", event_handler.GetLocationAndReset()); 905 EXPECT_EQ("0,0", event_handler.GetLocationAndReset());
913 MoveMouseToInHostCoord(root_windows[0], 0, 399); 906 generator.MoveMouseToInHost(0, 399);
914 EXPECT_EQ("449,0", event_handler.GetLocationAndReset()); 907 EXPECT_EQ("449,0", event_handler.GetLocationAndReset());
915 908
916 UpdateDisplay("600x400*2/l@1.5"); 909 UpdateDisplay("600x400*2/l@1.5");
917 display1 = Shell::GetScreen()->GetPrimaryDisplay(); 910 display1 = Shell::GetScreen()->GetPrimaryDisplay();
918 root_windows = Shell::GetAllRootWindows(); 911 root_windows = Shell::GetAllRootWindows();
919 EXPECT_EQ("0,0 300x450", display1.bounds().ToString()); 912 EXPECT_EQ("0,0 300x450", display1.bounds().ToString());
920 EXPECT_EQ("0,0 300x450", root_windows[0]->bounds().ToString()); 913 EXPECT_EQ("0,0 300x450", root_windows[0]->bounds().ToString());
921 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id())); 914 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id()));
922 915
923 MoveMouseToInHostCoord(root_windows[0], 0, 0); 916 generator.MoveMouseToInHost(0, 0);
924 EXPECT_EQ("299,0", event_handler.GetLocationAndReset()); 917 EXPECT_EQ("299,0", event_handler.GetLocationAndReset());
925 MoveMouseToInHostCoord(root_windows[0], 599, 0); 918 generator.MoveMouseToInHost(599, 0);
926 EXPECT_EQ("299,449", event_handler.GetLocationAndReset()); 919 EXPECT_EQ("299,449", event_handler.GetLocationAndReset());
927 MoveMouseToInHostCoord(root_windows[0], 599, 399); 920 generator.MoveMouseToInHost(599, 399);
928 EXPECT_EQ("0,449", event_handler.GetLocationAndReset()); 921 EXPECT_EQ("0,449", event_handler.GetLocationAndReset());
929 MoveMouseToInHostCoord(root_windows[0], 0, 399); 922 generator.MoveMouseToInHost(0, 399);
930 EXPECT_EQ("0,0", event_handler.GetLocationAndReset()); 923 EXPECT_EQ("0,0", event_handler.GetLocationAndReset());
931 924
932 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); 925 Shell::GetInstance()->RemovePreTargetHandler(&event_handler);
933 } 926 }
934 927
935 } // namespace test 928 } // namespace test
936 } // namespace ash 929 } // namespace ash
OLDNEW
« no previous file with comments | « ash/ash_root_window_transformer_unittest.cc ('k') | ash/display/display_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698