OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/api/system_display/display_info_provider.h" | 5 #include "extensions/browser/api/system_display/display_info_provider.h" |
6 | 6 |
7 #include "ash/ash_switches.h" | |
8 #include "ash/content/display/screen_orientation_controller_chromeos.h" | |
7 #include "ash/display/display_controller.h" | 9 #include "ash/display/display_controller.h" |
8 #include "ash/display/display_manager.h" | 10 #include "ash/display/display_manager.h" |
9 #include "ash/screen_util.h" | 11 #include "ash/screen_util.h" |
10 #include "ash/shell.h" | 12 #include "ash/shell.h" |
11 #include "ash/test/ash_test_base.h" | 13 #include "ash/test/ash_test_base.h" |
12 #include "ash/test/display_manager_test_api.h" | 14 #include "ash/test/display_manager_test_api.h" |
15 #include "ash/wm/maximize_mode/maximize_mode_controller.h" | |
16 #include "base/command_line.h" | |
13 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
14 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" |
15 #include "extensions/common/api/system_display.h" | 19 #include "extensions/common/api/system_display.h" |
16 #include "ui/gfx/display.h" | 20 #include "ui/gfx/display.h" |
17 #include "ui/gfx/geometry/rect.h" | 21 #include "ui/gfx/geometry/rect.h" |
18 | 22 |
19 namespace extensions { | 23 namespace extensions { |
20 namespace { | 24 namespace { |
21 | 25 |
22 class DisplayInfoProviderChromeosTest : public ash::test::AshTestBase { | 26 class DisplayInfoProviderChromeosTest : public ash::test::AshTestBase { |
23 public: | 27 public: |
24 DisplayInfoProviderChromeosTest() {} | 28 DisplayInfoProviderChromeosTest() {} |
25 | 29 |
26 ~DisplayInfoProviderChromeosTest() override {} | 30 ~DisplayInfoProviderChromeosTest() override {} |
27 | 31 |
32 void SetUp() override { | |
33 base::CommandLine::ForCurrentProcess()->AppendSwitch( | |
34 ash::switches::kAshUseFirstDisplayAsInternal); | |
35 ash::test::AshTestBase::SetUp(); | |
36 } | |
37 | |
28 protected: | 38 protected: |
29 void CallSetDisplayUnitInfo( | 39 void CallSetDisplayUnitInfo( |
30 const std::string& display_id, | 40 const std::string& display_id, |
31 const core_api::system_display::DisplayProperties& info, | 41 const core_api::system_display::DisplayProperties& info, |
32 bool* success, | 42 bool* success, |
33 std::string* error) { | 43 std::string* error) { |
34 // Reset error messsage. | 44 // Reset error messsage. |
35 (*error).clear(); | 45 (*error).clear(); |
36 *success = DisplayInfoProvider::Get()->SetInfo(display_id, info, error); | 46 *success = DisplayInfoProvider::Get()->SetInfo(display_id, info, error); |
37 } | 47 } |
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
706 base::Int64ToString(secondary.id()), info, &success, &error); | 716 base::Int64ToString(secondary.id()), info, &success, &error); |
707 | 717 |
708 ASSERT_TRUE(success); | 718 ASSERT_TRUE(success); |
709 EXPECT_TRUE(error.empty()); | 719 EXPECT_TRUE(error.empty()); |
710 | 720 |
711 EXPECT_EQ("0,0 300x500", secondary.bounds().ToString()); | 721 EXPECT_EQ("0,0 300x500", secondary.bounds().ToString()); |
712 EXPECT_EQ(gfx::Display::ROTATE_0, secondary.rotation()); | 722 EXPECT_EQ(gfx::Display::ROTATE_0, secondary.rotation()); |
713 EXPECT_EQ(ash::Shell::GetScreen()->GetPrimaryDisplay().id(), secondary.id()); | 723 EXPECT_EQ(ash::Shell::GetScreen()->GetPrimaryDisplay().id(), secondary.id()); |
714 } | 724 } |
715 | 725 |
726 // Tests that rotation changes made during Maximize Mode lock the display | |
727 // against accelerometer rotations. | |
728 TEST_F(DisplayInfoProviderChromeosTest, SetRotationDuringMaximizeMode) { | |
729 ash::Shell::GetInstance() | |
730 ->maximize_mode_controller() | |
731 ->EnableMaximizeModeWindowManager(true); | |
732 | |
pkotwicz
2015/04/24 17:27:59
Can you add a comment that entering maximized mode
jonross
2015/04/27 14:51:52
Done.
| |
733 ASSERT_FALSE(ash::Shell::GetInstance() | |
734 ->screen_orientation_controller() | |
735 ->rotation_locked()); | |
736 | |
737 core_api::system_display::DisplayProperties info; | |
738 info.rotation.reset(new int(90)); | |
739 | |
740 bool success = false; | |
741 std::string error; | |
742 CallSetDisplayUnitInfo(base::Int64ToString(gfx::Display::InternalDisplayId()), | |
743 info, &success, &error); | |
744 | |
745 ASSERT_TRUE(success); | |
746 EXPECT_TRUE(error.empty()); | |
747 EXPECT_TRUE(ash::Shell::GetInstance() | |
748 ->screen_orientation_controller() | |
749 ->rotation_locked()); | |
750 } | |
pkotwicz
2015/04/24 17:27:59
I think that it would also be worth having a test
jonross
2015/04/27 14:51:52
Done.
| |
751 | |
716 TEST_F(DisplayInfoProviderChromeosTest, SetInvalidRotation) { | 752 TEST_F(DisplayInfoProviderChromeosTest, SetInvalidRotation) { |
717 UpdateDisplay("1200x600,600x1000*2"); | 753 UpdateDisplay("1200x600,600x1000*2"); |
718 | 754 |
719 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 755 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
720 core_api::system_display::DisplayProperties info; | 756 core_api::system_display::DisplayProperties info; |
721 info.rotation.reset(new int(91)); | 757 info.rotation.reset(new int(91)); |
722 | 758 |
723 bool success = false; | 759 bool success = false; |
724 std::string error; | 760 std::string error; |
725 CallSetDisplayUnitInfo( | 761 CallSetDisplayUnitInfo( |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
882 std::string error; | 918 std::string error; |
883 CallSetDisplayUnitInfo( | 919 CallSetDisplayUnitInfo( |
884 base::Int64ToString(internal_display_id), info, &success, &error); | 920 base::Int64ToString(internal_display_id), info, &success, &error); |
885 | 921 |
886 ASSERT_FALSE(success); | 922 ASSERT_FALSE(success); |
887 EXPECT_EQ("Overscan changes not allowed for the internal monitor.", error); | 923 EXPECT_EQ("Overscan changes not allowed for the internal monitor.", error); |
888 } | 924 } |
889 | 925 |
890 } // namespace | 926 } // namespace |
891 } // namespace extensions | 927 } // namespace extensions |
OLD | NEW |