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

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

Issue 37733003: Make GetRootWindow() return a Window instead of a RootWindow. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: First cut for review/trybots 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/display/display_controller.h" 5 #include "ash/display/display_controller.h"
6 6
7 #include "ash/ash_switches.h" 7 #include "ash/ash_switches.h"
8 #include "ash/display/display_info.h" 8 #include "ash/display/display_info.h"
9 #include "ash/display/display_layout_store.h" 9 #include "ash/display/display_layout_store.h"
10 #include "ash/display/display_manager.h" 10 #include "ash/display/display_manager.h"
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 251
252 float touch_radius_x() { return touch_radius_x_; } 252 float touch_radius_x() { return touch_radius_x_; }
253 float touch_radius_y() { return touch_radius_y_; } 253 float touch_radius_y() { return touch_radius_y_; }
254 float scroll_x_offset() { return scroll_x_offset_; } 254 float scroll_x_offset() { return scroll_x_offset_; }
255 float scroll_y_offset() { return scroll_y_offset_; } 255 float scroll_y_offset() { return scroll_y_offset_; }
256 float scroll_x_offset_ordinal() { return scroll_x_offset_ordinal_; } 256 float scroll_x_offset_ordinal() { return scroll_x_offset_ordinal_; }
257 float scroll_y_offset_ordinal() { return scroll_y_offset_ordinal_; } 257 float scroll_y_offset_ordinal() { return scroll_y_offset_ordinal_; }
258 258
259 private: 259 private:
260 gfx::Point mouse_location_; 260 gfx::Point mouse_location_;
261 aura::RootWindow* target_root_; 261 aura::Window* target_root_;
262 262
263 float touch_radius_x_; 263 float touch_radius_x_;
264 float touch_radius_y_; 264 float touch_radius_y_;
265 float scroll_x_offset_; 265 float scroll_x_offset_;
266 float scroll_y_offset_; 266 float scroll_y_offset_;
267 float scroll_x_offset_ordinal_; 267 float scroll_x_offset_ordinal_;
268 float scroll_y_offset_ordinal_; 268 float scroll_y_offset_ordinal_;
269 269
270 DISALLOW_COPY_AND_ASSIGN(TestEventHandler); 270 DISALLOW_COPY_AND_ASSIGN(TestEventHandler);
271 }; 271 };
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 Shell::GetInstance()->display_manager(); 540 Shell::GetInstance()->display_manager();
541 541
542 UpdateDisplay("200x200,300x300"); 542 UpdateDisplay("200x200,300x300");
543 gfx::Display primary_display = Shell::GetScreen()->GetPrimaryDisplay(); 543 gfx::Display primary_display = Shell::GetScreen()->GetPrimaryDisplay();
544 gfx::Display secondary_display = ScreenAsh::GetSecondaryDisplay(); 544 gfx::Display secondary_display = ScreenAsh::GetSecondaryDisplay();
545 545
546 DisplayLayout display_layout(DisplayLayout::RIGHT, 50); 546 DisplayLayout display_layout(DisplayLayout::RIGHT, 50);
547 display_manager->SetLayoutForCurrentDisplays(display_layout); 547 display_manager->SetLayoutForCurrentDisplays(display_layout);
548 548
549 EXPECT_NE(primary_display.id(), secondary_display.id()); 549 EXPECT_NE(primary_display.id(), secondary_display.id());
550 aura::RootWindow* primary_root = 550 aura::Window* primary_root =
551 display_controller->GetRootWindowForDisplayId(primary_display.id()); 551 display_controller->GetRootWindowForDisplayId(primary_display.id());
552 aura::RootWindow* secondary_root = 552 aura::Window* secondary_root =
553 display_controller->GetRootWindowForDisplayId(secondary_display.id()); 553 display_controller->GetRootWindowForDisplayId(secondary_display.id());
554 EXPECT_NE(primary_root, secondary_root); 554 EXPECT_NE(primary_root, secondary_root);
555 aura::Window* launcher_window = 555 aura::Window* launcher_window =
556 Launcher::ForPrimaryDisplay()->shelf_widget()->GetNativeView(); 556 Launcher::ForPrimaryDisplay()->shelf_widget()->GetNativeView();
557 EXPECT_TRUE(primary_root->Contains(launcher_window)); 557 EXPECT_TRUE(primary_root->Contains(launcher_window));
558 EXPECT_FALSE(secondary_root->Contains(launcher_window)); 558 EXPECT_FALSE(secondary_root->Contains(launcher_window));
559 EXPECT_EQ(primary_display.id(), 559 EXPECT_EQ(primary_display.id(),
560 Shell::GetScreen()->GetDisplayNearestPoint( 560 Shell::GetScreen()->GetDisplayNearestPoint(
561 gfx::Point(-100, -100)).id()); 561 gfx::Point(-100, -100)).id());
562 EXPECT_EQ(primary_display.id(), 562 EXPECT_EQ(primary_display.id(),
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 Shell::GetInstance()->display_manager(); 634 Shell::GetInstance()->display_manager();
635 635
636 UpdateDisplay("200x200,300x300"); 636 UpdateDisplay("200x200,300x300");
637 gfx::Display primary_display = Shell::GetScreen()->GetPrimaryDisplay(); 637 gfx::Display primary_display = Shell::GetScreen()->GetPrimaryDisplay();
638 gfx::Display secondary_display = ScreenAsh::GetSecondaryDisplay(); 638 gfx::Display secondary_display = ScreenAsh::GetSecondaryDisplay();
639 639
640 DisplayLayout display_layout(DisplayLayout::RIGHT, 50); 640 DisplayLayout display_layout(DisplayLayout::RIGHT, 50);
641 display_manager->SetLayoutForCurrentDisplays(display_layout); 641 display_manager->SetLayoutForCurrentDisplays(display_layout);
642 642
643 EXPECT_NE(primary_display.id(), secondary_display.id()); 643 EXPECT_NE(primary_display.id(), secondary_display.id());
644 aura::RootWindow* primary_root = 644 aura::Window* primary_root =
645 display_controller->GetRootWindowForDisplayId(primary_display.id()); 645 display_controller->GetRootWindowForDisplayId(primary_display.id());
646 aura::RootWindow* secondary_root = 646 aura::Window* secondary_root =
647 display_controller->GetRootWindowForDisplayId(secondary_display.id()); 647 display_controller->GetRootWindowForDisplayId(secondary_display.id());
648 EXPECT_NE(primary_root, secondary_root); 648 EXPECT_NE(primary_root, secondary_root);
649 aura::Window* launcher_window = 649 aura::Window* launcher_window =
650 Launcher::ForPrimaryDisplay()->shelf_widget()->GetNativeView(); 650 Launcher::ForPrimaryDisplay()->shelf_widget()->GetNativeView();
651 EXPECT_TRUE(primary_root->Contains(launcher_window)); 651 EXPECT_TRUE(primary_root->Contains(launcher_window));
652 EXPECT_FALSE(secondary_root->Contains(launcher_window)); 652 EXPECT_FALSE(secondary_root->Contains(launcher_window));
653 EXPECT_EQ(primary_display.id(), 653 EXPECT_EQ(primary_display.id(),
654 Shell::GetScreen()->GetDisplayNearestPoint( 654 Shell::GetScreen()->GetDisplayNearestPoint(
655 gfx::Point(-100, -100)).id()); 655 gfx::Point(-100, -100)).id());
656 EXPECT_EQ(primary_display.id(), 656 EXPECT_EQ(primary_display.id(),
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 Shell::GetInstance()->display_manager(); 725 Shell::GetInstance()->display_manager();
726 726
727 UpdateDisplay("200x200,300x300"); 727 UpdateDisplay("200x200,300x300");
728 gfx::Display primary_display = Shell::GetScreen()->GetPrimaryDisplay(); 728 gfx::Display primary_display = Shell::GetScreen()->GetPrimaryDisplay();
729 gfx::Display secondary_display = ScreenAsh::GetSecondaryDisplay(); 729 gfx::Display secondary_display = ScreenAsh::GetSecondaryDisplay();
730 730
731 DisplayLayout display_layout(DisplayLayout::RIGHT, 50); 731 DisplayLayout display_layout(DisplayLayout::RIGHT, 50);
732 display_manager->SetLayoutForCurrentDisplays(display_layout); 732 display_manager->SetLayoutForCurrentDisplays(display_layout);
733 733
734 EXPECT_NE(primary_display.id(), secondary_display.id()); 734 EXPECT_NE(primary_display.id(), secondary_display.id());
735 aura::RootWindow* primary_root = 735 aura::Window* primary_root =
736 display_controller->GetRootWindowForDisplayId(primary_display.id()); 736 display_controller->GetRootWindowForDisplayId(primary_display.id());
737 aura::RootWindow* secondary_root = 737 aura::Window* secondary_root =
738 display_controller->GetRootWindowForDisplayId(secondary_display.id()); 738 display_controller->GetRootWindowForDisplayId(secondary_display.id());
739 aura::Window* launcher_window = 739 aura::Window* launcher_window =
740 Launcher::ForPrimaryDisplay()->shelf_widget()->GetNativeView(); 740 Launcher::ForPrimaryDisplay()->shelf_widget()->GetNativeView();
741 EXPECT_TRUE(primary_root->Contains(launcher_window)); 741 EXPECT_TRUE(primary_root->Contains(launcher_window));
742 EXPECT_FALSE(secondary_root->Contains(launcher_window)); 742 EXPECT_FALSE(secondary_root->Contains(launcher_window));
743 EXPECT_NE(primary_root, secondary_root); 743 EXPECT_NE(primary_root, secondary_root);
744 EXPECT_EQ(primary_display.id(), 744 EXPECT_EQ(primary_display.id(),
745 Shell::GetScreen()->GetDisplayNearestPoint( 745 Shell::GetScreen()->GetDisplayNearestPoint(
746 gfx::Point(-100, -100)).id()); 746 gfx::Point(-100, -100)).id());
747 EXPECT_EQ(primary_display.id(), 747 EXPECT_EQ(primary_display.id(),
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 if (!SupportsMultipleDisplays()) 843 if (!SupportsMultipleDisplays())
844 return; 844 return;
845 845
846 DisplayController* display_controller = 846 DisplayController* display_controller =
847 Shell::GetInstance()->display_controller(); 847 Shell::GetInstance()->display_controller();
848 848
849 UpdateDisplay("200x200,200x200*2"); 849 UpdateDisplay("200x200,200x200*2");
850 gfx::Display primary_display = Shell::GetScreen()->GetPrimaryDisplay(); 850 gfx::Display primary_display = Shell::GetScreen()->GetPrimaryDisplay();
851 gfx::Display secondary_display = ScreenAsh::GetSecondaryDisplay(); 851 gfx::Display secondary_display = ScreenAsh::GetSecondaryDisplay();
852 852
853 aura::RootWindow* primary_root = 853 aura::Window* primary_root =
854 display_controller->GetRootWindowForDisplayId(primary_display.id()); 854 display_controller->GetRootWindowForDisplayId(primary_display.id());
855 aura::RootWindow* secondary_root = 855 aura::Window* secondary_root =
856 display_controller->GetRootWindowForDisplayId(secondary_display.id()); 856 display_controller->GetRootWindowForDisplayId(secondary_display.id());
857 EXPECT_NE(primary_root, secondary_root); 857 EXPECT_NE(primary_root, secondary_root);
858 858
859 test::CursorManagerTestApi test_api(Shell::GetInstance()->cursor_manager()); 859 test::CursorManagerTestApi test_api(Shell::GetInstance()->cursor_manager());
860 860
861 EXPECT_EQ(1.0f, 861 EXPECT_EQ(1.0f, primary_root->GetDispatcher()->AsRootWindowHostDelegate()->
862 primary_root->AsRootWindowHostDelegate()->GetDeviceScaleFactor()); 862 GetDeviceScaleFactor());
863 primary_root->MoveCursorTo(gfx::Point(50, 50)); 863 primary_root->MoveCursorTo(gfx::Point(50, 50));
864 EXPECT_EQ(1.0f, test_api.GetDisplay().device_scale_factor()); 864 EXPECT_EQ(1.0f, test_api.GetDisplay().device_scale_factor());
865 EXPECT_EQ(2.0f, 865 EXPECT_EQ(2.0f, secondary_root->GetDispatcher()->AsRootWindowHostDelegate()->
866 secondary_root->AsRootWindowHostDelegate()->GetDeviceScaleFactor()); 866 GetDeviceScaleFactor());
867 secondary_root->MoveCursorTo(gfx::Point(50, 50)); 867 secondary_root->MoveCursorTo(gfx::Point(50, 50));
868 EXPECT_EQ(2.0f, test_api.GetDisplay().device_scale_factor()); 868 EXPECT_EQ(2.0f, test_api.GetDisplay().device_scale_factor());
869 869
870 // Switch primary and secondary 870 // Switch primary and secondary
871 display_controller->SetPrimaryDisplay(secondary_display); 871 display_controller->SetPrimaryDisplay(secondary_display);
872 872
873 // Cursor's device scale factor should be updated accroding to the swap of 873 // Cursor's device scale factor should be updated accroding to the swap of
874 // primary and secondary. 874 // primary and secondary.
875 EXPECT_EQ(1.0f, 875 EXPECT_EQ(1.0f, secondary_root->GetDispatcher()->AsRootWindowHostDelegate()->
876 secondary_root->AsRootWindowHostDelegate()->GetDeviceScaleFactor()); 876 GetDeviceScaleFactor());
877 secondary_root->MoveCursorTo(gfx::Point(50, 50)); 877 secondary_root->MoveCursorTo(gfx::Point(50, 50));
878 EXPECT_EQ(1.0f, test_api.GetDisplay().device_scale_factor()); 878 EXPECT_EQ(1.0f, test_api.GetDisplay().device_scale_factor());
879 primary_root->MoveCursorTo(gfx::Point(50, 50)); 879 primary_root->MoveCursorTo(gfx::Point(50, 50));
880 EXPECT_EQ(2.0f, 880 EXPECT_EQ(2.0f, primary_root->GetDispatcher()->AsRootWindowHostDelegate()->
881 primary_root->AsRootWindowHostDelegate()->GetDeviceScaleFactor()); 881 GetDeviceScaleFactor());
882 EXPECT_EQ(2.0f, test_api.GetDisplay().device_scale_factor()); 882 EXPECT_EQ(2.0f, test_api.GetDisplay().device_scale_factor());
883 883
884 // Deleting 2nd display. 884 // Deleting 2nd display.
885 UpdateDisplay("200x200"); 885 UpdateDisplay("200x200");
886 RunAllPendingInMessageLoop(); // RootWindow is deleted in a posted task. 886 RunAllPendingInMessageLoop(); // RootWindow is deleted in a posted task.
887 887
888 // Cursor's device scale factor should be updated even without moving cursor. 888 // Cursor's device scale factor should be updated even without moving cursor.
889 EXPECT_EQ(1.0f, test_api.GetDisplay().device_scale_factor()); 889 EXPECT_EQ(1.0f, test_api.GetDisplay().device_scale_factor());
890 890
891 primary_root->MoveCursorTo(gfx::Point(50, 50)); 891 primary_root->MoveCursorTo(gfx::Point(50, 50));
892 EXPECT_EQ(1.0f, 892 EXPECT_EQ(1.0f, primary_root->GetDispatcher()->AsRootWindowHostDelegate()->
893 primary_root->AsRootWindowHostDelegate()->GetDeviceScaleFactor()); 893 GetDeviceScaleFactor());
894 EXPECT_EQ(1.0f, test_api.GetDisplay().device_scale_factor()); 894 EXPECT_EQ(1.0f, test_api.GetDisplay().device_scale_factor());
895 } 895 }
896 896
897 TEST_F(DisplayControllerTest, OverscanInsets) { 897 TEST_F(DisplayControllerTest, OverscanInsets) {
898 if (!SupportsMultipleDisplays()) 898 if (!SupportsMultipleDisplays())
899 return; 899 return;
900 900
901 DisplayController* display_controller = 901 DisplayController* display_controller =
902 Shell::GetInstance()->display_controller(); 902 Shell::GetInstance()->display_controller();
903 TestEventHandler event_handler; 903 TestEventHandler event_handler;
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
1161 EXPECT_EQ("aura_root_0", GetXWindowName(primary)); 1161 EXPECT_EQ("aura_root_0", GetXWindowName(primary));
1162 EXPECT_EQ("aura_root_x", GetXWindowName(secondary)); 1162 EXPECT_EQ("aura_root_x", GetXWindowName(secondary));
1163 1163
1164 // Switching back to single display. 1164 // Switching back to single display.
1165 UpdateDisplay("300x400"); 1165 UpdateDisplay("300x400");
1166 EXPECT_EQ("aura_root_0", GetXWindowName(Shell::GetPrimaryRootWindow())); 1166 EXPECT_EQ("aura_root_0", GetXWindowName(Shell::GetPrimaryRootWindow()));
1167 } 1167 }
1168 #endif 1168 #endif
1169 1169
1170 } // namespace ash 1170 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698