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

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: Fixed rebase errors. 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 27ec3d609a0ea61d321317648372d6b9f1c01b4f..db5be035486d0f95a481daa1c49806077d43ab37 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,11 +11,13 @@
#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"
#include "base/command_line.h"
#include "base/memory/scoped_ptr.h"
+#include "base/strings/stringprintf.h"
jonross 2015/04/24 17:08:30 nit: needed?
bruthig 2015/04/24 18:06:34 Done.
#include "chromeos/accelerometer/accelerometer_reader.h"
#include "chromeos/accelerometer/accelerometer_types.h"
#include "content/public/browser/browser_context.h"
@@ -35,6 +39,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 +605,48 @@ TEST_F(ScreenOrientationControllerTest, InternalDisplayNotAvailableAtStartup) {
EXPECT_TRUE(RotationLocked());
}
+// Verifies rotating an inactive Display is sucessful.
jonross 2015/04/24 17:08:30 Do we also need a full test of: -Set internal disp
bruthig 2015/04/24 18:06:34 Discussed offline. There shouldn't be any risk fr
+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)
+ .GetActiveRotation());
+
+ delegate()->SetDisplayRotation(kNewRotation,
+ 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
« no previous file with comments | « ash/content/display/screen_orientation_controller_chromeos.cc ('k') | ash/rotator/screen_rotation_animator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698