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

Unified Diff: ash/content/display/screen_orientation_controller_chromeos_unittest.cc

Issue 1108473002: Fixed the ScreenOrientationController so that it doesn't crash by animating (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
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 342e9585b8e2a104d96fbf366eb3bcf35735a74e..cf350fe84fe1b17ba67953b95426b6391b5b5cf3 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"
@@ -14,6 +16,7 @@
#include "ash/wm/maximize_mode/maximize_mode_controller.h"
#include "base/command_line.h"
#include "base/memory/scoped_ptr.h"
+#include "base/strings/stringprintf.h"
#include "chromeos/accelerometer/accelerometer_reader.h"
#include "chromeos/accelerometer/accelerometer_types.h"
#include "content/public/browser/browser_context.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()
@@ -608,4 +617,41 @@ TEST_F(ScreenOrientationControllerTest, InternalDisplayNotAvailableAtStartup) {
EXPECT_TRUE(RotationLocked());
}
+// Verifies that rotating an inactive Display does not crash. See
+// www.crbug.com/479503.
+TEST_F(ScreenOrientationControllerTest, RotateInactiveDisplayShouldNotCrash) {
+ const int64 kInternalDisplayId = gfx::Display::InternalDisplayId();
+ const int64 kExternalDisplayId = 10;
jonross 2015/04/24 14:18:08 Can this ever be the id of the internal display? I
bruthig 2015/04/24 16:17:13 Originally I had the assert to verify that kIntern
+ const gfx::Display::Rotation kNewRotation = gfx::Display::ROTATE_180;
+
+ ASSERT_NE(kInternalDisplayId, gfx::Display::kInvalidDisplayID);
+ ASSERT_NE(Shell::GetInstance()
+ ->display_manager()
+ ->GetDisplayInfo(kInternalDisplayId)
+ .rotation(),
+ kNewRotation);
+
+ 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);
+
+ delegate()->SetDisplayRotation(kNewRotation);
+}
+
} // namespace ash

Powered by Google App Engine
This is Rietveld 408576698