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

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

Issue 15367003: Create a mirror window. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: win fix 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
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_manager.h" 5 #include "ash/display/display_manager.h"
6 6
7 #include "ash/display/display_controller.h" 7 #include "ash/display/display_controller.h"
8 #include "ash/screen_ash.h" 8 #include "ash/screen_ash.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/test/ash_test_base.h" 10 #include "ash/test/ash_test_base.h"
11 #include "ash/test/display_manager_test_api.h" 11 #include "ash/test/display_manager_test_api.h"
12 #include "ash/test/mirror_window_test_api.h"
12 #include "base/format_macros.h" 13 #include "base/format_macros.h"
13 #include "base/stringprintf.h" 14 #include "base/stringprintf.h"
14 #include "ui/aura/env.h" 15 #include "ui/aura/env.h"
15 #include "ui/aura/root_window.h" 16 #include "ui/aura/root_window.h"
16 #include "ui/aura/test/event_generator.h" 17 #include "ui/aura/test/event_generator.h"
17 #include "ui/aura/window_observer.h" 18 #include "ui/aura/window_observer.h"
18 #include "ui/gfx/display_observer.h" 19 #include "ui/gfx/display_observer.h"
19 #include "ui/gfx/display.h" 20 #include "ui/gfx/display.h"
20 21
21 namespace ash { 22 namespace ash {
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 UpdateDisplay("100x200/r,300x400/l"); 706 UpdateDisplay("100x200/r,300x400/l");
706 EXPECT_EQ("1,1 100x200", 707 EXPECT_EQ("1,1 100x200",
707 GetDisplayInfoAt(0).bounds_in_pixel().ToString()); 708 GetDisplayInfoAt(0).bounds_in_pixel().ToString());
708 EXPECT_EQ("200x100", 709 EXPECT_EQ("200x100",
709 GetDisplayInfoAt(0).size_in_pixel().ToString()); 710 GetDisplayInfoAt(0).size_in_pixel().ToString());
710 711
711 EXPECT_EQ("1,201 300x400", 712 EXPECT_EQ("1,201 300x400",
712 GetDisplayInfoAt(1).bounds_in_pixel().ToString()); 713 GetDisplayInfoAt(1).bounds_in_pixel().ToString());
713 EXPECT_EQ("400x300", 714 EXPECT_EQ("400x300",
714 GetDisplayInfoAt(1).size_in_pixel().ToString()); 715 GetDisplayInfoAt(1).size_in_pixel().ToString());
716 reset();
715 UpdateDisplay("100x200/b,300x400"); 717 UpdateDisplay("100x200/b,300x400");
718 EXPECT_EQ("2 0 0", GetCountSummary());
719 reset();
720
716 EXPECT_EQ("1,1 100x200", 721 EXPECT_EQ("1,1 100x200",
717 GetDisplayInfoAt(0).bounds_in_pixel().ToString()); 722 GetDisplayInfoAt(0).bounds_in_pixel().ToString());
718 EXPECT_EQ("100x200", 723 EXPECT_EQ("100x200",
719 GetDisplayInfoAt(0).size_in_pixel().ToString()); 724 GetDisplayInfoAt(0).size_in_pixel().ToString());
720 725
721 EXPECT_EQ("1,201 300x400", 726 EXPECT_EQ("1,201 300x400",
722 GetDisplayInfoAt(1).bounds_in_pixel().ToString()); 727 GetDisplayInfoAt(1).bounds_in_pixel().ToString());
723 EXPECT_EQ("300x400", 728 EXPECT_EQ("300x400",
724 GetDisplayInfoAt(1).size_in_pixel().ToString()); 729 GetDisplayInfoAt(1).size_in_pixel().ToString());
730
731 UpdateDisplay("200x200");
732 EXPECT_EQ("1 0 1", GetCountSummary());
733 reset();
734
735 UpdateDisplay("200x200/l");
736 EXPECT_EQ("1 0 0", GetCountSummary());
725 } 737 }
726 738
727 TEST_F(DisplayManagerTest, UIScale) { 739 TEST_F(DisplayManagerTest, UIScale) {
728 UpdateDisplay("1280x800"); 740 UpdateDisplay("1280x800");
729 int64 display_id = Shell::GetScreen()->GetPrimaryDisplay().id(); 741 int64 display_id = Shell::GetScreen()->GetPrimaryDisplay().id();
730 display_manager()->SetDisplayUIScale(display_id, 1.125f); 742 display_manager()->SetDisplayUIScale(display_id, 1.125f);
731 EXPECT_EQ(1.0, GetDisplayInfoAt(0).ui_scale()); 743 EXPECT_EQ(1.0, GetDisplayInfoAt(0).ui_scale());
732 display_manager()->SetDisplayUIScale(display_id, 0.8f); 744 display_manager()->SetDisplayUIScale(display_id, 0.8f);
733 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).ui_scale()); 745 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).ui_scale());
734 display_manager()->SetDisplayUIScale(display_id, 0.75f); 746 display_manager()->SetDisplayUIScale(display_id, 0.75f);
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
832 EXPECT_EQ("150,225", env->last_mouse_location().ToString()); 844 EXPECT_EQ("150,225", env->last_mouse_location().ToString());
833 845
834 // Test on 2nd display. 846 // Test on 2nd display.
835 UpdateDisplay("600x400,400x300*2"); 847 UpdateDisplay("600x400,400x300*2");
836 generator2.MoveMouseToInHost(200, 100); 848 generator2.MoveMouseToInHost(200, 100);
837 EXPECT_EQ("700,50", env->last_mouse_location().ToString()); 849 EXPECT_EQ("700,50", env->last_mouse_location().ToString());
838 UpdateDisplay("600x400,400x300*2@1.5"); 850 UpdateDisplay("600x400,400x300*2@1.5");
839 EXPECT_EQ("750,75", env->last_mouse_location().ToString()); 851 EXPECT_EQ("750,75", env->last_mouse_location().ToString());
840 } 852 }
841 853
854 TEST_F(DisplayManagerTest, SoftwareMirroring) {
James Cook 2013/05/21 08:07:41 Hooray, new code has a new test!
855 UpdateDisplay("300x400,400x500");
856
857 test::MirrorWindowTestApi test_api;
858 EXPECT_EQ(NULL, test_api.GetRootWindow());
859
860 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
861 display_manager->SetSoftwareMirroring(true);
862 display_manager->UpdateDisplays();
863 EXPECT_EQ(1U, display_manager->GetNumDisplays());
864 EXPECT_EQ("0,0 300x400",
865 Shell::GetScreen()->GetPrimaryDisplay().bounds().ToString());
866 EXPECT_EQ("400x500", test_api.GetRootWindow()->GetHostSize().ToString());
867 EXPECT_TRUE(display_manager->IsMirrored());
868
869 display_manager->SetMirrorMode(false);
870 EXPECT_EQ(NULL, test_api.GetRootWindow());
871 EXPECT_EQ(2U, display_manager->GetNumDisplays());
872 EXPECT_FALSE(display_manager->IsMirrored());
873 }
874
842 } // namespace internal 875 } // namespace internal
843 } // namespace ash 876 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698