Index: ash/content/display/screen_orientation_controller_chromeos_unittest.cc |
diff --git a/ash/content/display/screen_orientation_controller_chromeos_unittest.cc b/ash/content/display/screen_orientation_controller_chromeos_unittest.cc |
index 27ec3d609a0ea61d321317648372d6b9f1c01b4f..487d44c2dfd3bee4a531a32975f9420c99643d56 100644 |
--- a/ash/content/display/screen_orientation_controller_chromeos_unittest.cc |
+++ b/ash/content/display/screen_orientation_controller_chromeos_unittest.cc |
@@ -2,6 +2,8 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
+#include <vector> |
+ |
#include "ash/ash_switches.h" |
#include "ash/content/display/screen_orientation_controller_chromeos.h" |
#include "ash/display/display_info.h" |
@@ -9,6 +11,7 @@ |
#include "ash/shell.h" |
#include "ash/test/ash_test_base.h" |
#include "ash/test/ash_test_helper.h" |
+#include "ash/test/display_manager_test_api.h" |
#include "ash/test/test_shell_delegate.h" |
#include "ash/test/test_system_tray_delegate.h" |
#include "ash/wm/maximize_mode/maximize_mode_controller.h" |
@@ -35,6 +38,12 @@ namespace { |
const float kDegreesToRadians = 3.1415926f / 180.0f; |
const float kMeanGravity = 9.8066f; |
+DisplayInfo CreateDisplayInfo(int64 id, const gfx::Rect& bounds) { |
+ DisplayInfo info(id, "dummy", false); |
+ info.SetBounds(bounds); |
+ return info; |
+} |
+ |
void EnableMaximizeMode(bool enable) { |
Shell::GetInstance() |
->maximize_mode_controller() |
@@ -595,4 +604,48 @@ TEST_F(ScreenOrientationControllerTest, InternalDisplayNotAvailableAtStartup) { |
EXPECT_TRUE(RotationLocked()); |
} |
+// Verifies rotating an inactive Display is sucessful. |
+TEST_F(ScreenOrientationControllerTest, RotateInactiveDisplay) { |
+ const int64 kInternalDisplayId = 9; |
+ const int64 kExternalDisplayId = 10; |
+ const gfx::Display::Rotation kNewRotation = gfx::Display::ROTATE_180; |
+ |
+ DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
+ |
+ const DisplayInfo internal_display_info = |
+ CreateDisplayInfo(kInternalDisplayId, gfx::Rect(0, 0, 500, 500)); |
+ const DisplayInfo external_display_info = |
+ CreateDisplayInfo(kExternalDisplayId, gfx::Rect(1, 1, 500, 500)); |
+ |
+ std::vector<DisplayInfo> display_info_list_two_active; |
+ display_info_list_two_active.push_back(internal_display_info); |
+ display_info_list_two_active.push_back(external_display_info); |
+ |
+ std::vector<DisplayInfo> display_info_list_one_active; |
+ display_info_list_one_active.push_back(external_display_info); |
+ |
+ // The DisplayInfo list with two active displays needs to be added first so |
+ // that the DisplayManager can track the |internal_display_info| as inactive |
+ // instead of non-existent. |
+ ash::Shell::GetInstance()->display_manager()->UpdateDisplays( |
+ display_info_list_two_active); |
+ ash::Shell::GetInstance()->display_manager()->UpdateDisplays( |
+ display_info_list_one_active); |
+ |
+ test::DisplayManagerTestApi(display_manager) |
+ .SetInternalDisplayId(kInternalDisplayId); |
+ |
+ ASSERT_NE(kNewRotation, display_manager->GetDisplayInfo(kInternalDisplayId) |
oshima
2015/04/24 18:34:42
EXPECT_NE?
bruthig
2015/04/24 19:05:07
I used an ASSERT here because this is verifying th
|
+ .GetActiveRotation()); |
+ |
+ delegate()->SetDisplayRotation(kNewRotation, |
oshima
2015/04/24 18:34:42
I assume this is for the next condition? If so, en
bruthig
2015/04/24 19:05:07
This line is the only line in the test that is act
oshima
2015/04/24 20:01:28
Ah, sorry my misunderstanding.
|
+ gfx::Display::ROTATION_SOURCE_ACTIVE); |
+ |
+ // TODO(bruthig): Uncomment when www.crbug.com/480703 is fixed. This test |
+ // still adds value by ensuring a crash does not occur. See |
+ // www.crbug.com/479503. |
+ // ASSERT_EQ(kNewRotation, display_manager->GetDisplayInfo(kInternalDisplayId) |
+ // .GetActiveRotation()); |
+} |
+ |
} // namespace ash |