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

Side by Side 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 unified diff | Download patch
OLDNEW
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 <vector>
6
5 #include "ash/ash_switches.h" 7 #include "ash/ash_switches.h"
6 #include "ash/content/display/screen_orientation_controller_chromeos.h" 8 #include "ash/content/display/screen_orientation_controller_chromeos.h"
7 #include "ash/display/display_info.h" 9 #include "ash/display/display_info.h"
8 #include "ash/display/display_manager.h" 10 #include "ash/display/display_manager.h"
9 #include "ash/shell.h" 11 #include "ash/shell.h"
10 #include "ash/test/ash_test_base.h" 12 #include "ash/test/ash_test_base.h"
11 #include "ash/test/ash_test_helper.h" 13 #include "ash/test/ash_test_helper.h"
14 #include "ash/test/display_manager_test_api.h"
12 #include "ash/test/test_shell_delegate.h" 15 #include "ash/test/test_shell_delegate.h"
13 #include "ash/test/test_system_tray_delegate.h" 16 #include "ash/test/test_system_tray_delegate.h"
14 #include "ash/wm/maximize_mode/maximize_mode_controller.h" 17 #include "ash/wm/maximize_mode/maximize_mode_controller.h"
15 #include "base/command_line.h" 18 #include "base/command_line.h"
16 #include "base/memory/scoped_ptr.h" 19 #include "base/memory/scoped_ptr.h"
20 #include "base/strings/stringprintf.h"
jonross 2015/04/24 17:08:30 nit: needed?
bruthig 2015/04/24 18:06:34 Done.
17 #include "chromeos/accelerometer/accelerometer_reader.h" 21 #include "chromeos/accelerometer/accelerometer_reader.h"
18 #include "chromeos/accelerometer/accelerometer_types.h" 22 #include "chromeos/accelerometer/accelerometer_types.h"
19 #include "content/public/browser/browser_context.h" 23 #include "content/public/browser/browser_context.h"
20 #include "content/public/browser/web_contents.h" 24 #include "content/public/browser/web_contents.h"
21 #include "content/public/test/test_browser_context.h" 25 #include "content/public/test/test_browser_context.h"
22 #include "third_party/WebKit/public/platform/WebScreenOrientationLockType.h" 26 #include "third_party/WebKit/public/platform/WebScreenOrientationLockType.h"
23 #include "ui/aura/window.h" 27 #include "ui/aura/window.h"
24 #include "ui/gfx/display.h" 28 #include "ui/gfx/display.h"
25 #include "ui/message_center/message_center.h" 29 #include "ui/message_center/message_center.h"
26 #include "ui/views/test/webview_test_helper.h" 30 #include "ui/views/test/webview_test_helper.h"
27 #include "ui/views/view.h" 31 #include "ui/views/view.h"
28 #include "ui/views/views_delegate.h" 32 #include "ui/views/views_delegate.h"
29 #include "ui/wm/public/activation_client.h" 33 #include "ui/wm/public/activation_client.h"
30 34
31 namespace ash { 35 namespace ash {
32 36
33 namespace { 37 namespace {
34 38
35 const float kDegreesToRadians = 3.1415926f / 180.0f; 39 const float kDegreesToRadians = 3.1415926f / 180.0f;
36 const float kMeanGravity = 9.8066f; 40 const float kMeanGravity = 9.8066f;
37 41
42 DisplayInfo CreateDisplayInfo(int64 id, const gfx::Rect& bounds) {
43 DisplayInfo info(id, "dummy", false);
44 info.SetBounds(bounds);
45 return info;
46 }
47
38 void EnableMaximizeMode(bool enable) { 48 void EnableMaximizeMode(bool enable) {
39 Shell::GetInstance() 49 Shell::GetInstance()
40 ->maximize_mode_controller() 50 ->maximize_mode_controller()
41 ->EnableMaximizeModeWindowManager(enable); 51 ->EnableMaximizeModeWindowManager(enable);
42 } 52 }
43 53
44 bool RotationLocked() { 54 bool RotationLocked() {
45 return Shell::GetInstance() 55 return Shell::GetInstance()
46 ->screen_orientation_controller() 56 ->screen_orientation_controller()
47 ->rotation_locked(); 57 ->rotation_locked();
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 // Should not crash, even thought there is no internal display. 598 // Should not crash, even thought there is no internal display.
589 SetInternalDisplayRotation(gfx::Display::ROTATE_180); 599 SetInternalDisplayRotation(gfx::Display::ROTATE_180);
590 EXPECT_FALSE(RotationLocked()); 600 EXPECT_FALSE(RotationLocked());
591 601
592 // With an internal display now available, functionality should resume. 602 // With an internal display now available, functionality should resume.
593 gfx::Display::SetInternalDisplayId(internal_display_id); 603 gfx::Display::SetInternalDisplayId(internal_display_id);
594 SetInternalDisplayRotation(gfx::Display::ROTATE_90); 604 SetInternalDisplayRotation(gfx::Display::ROTATE_90);
595 EXPECT_TRUE(RotationLocked()); 605 EXPECT_TRUE(RotationLocked());
596 } 606 }
597 607
608 // 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
609 TEST_F(ScreenOrientationControllerTest, RotateInactiveDisplay) {
610 const int64 kInternalDisplayId = 9;
611 const int64 kExternalDisplayId = 10;
612 const gfx::Display::Rotation kNewRotation = gfx::Display::ROTATE_180;
613
614 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
615
616 const DisplayInfo internal_display_info =
617 CreateDisplayInfo(kInternalDisplayId, gfx::Rect(0, 0, 500, 500));
618 const DisplayInfo external_display_info =
619 CreateDisplayInfo(kExternalDisplayId, gfx::Rect(1, 1, 500, 500));
620
621 std::vector<DisplayInfo> display_info_list_two_active;
622 display_info_list_two_active.push_back(internal_display_info);
623 display_info_list_two_active.push_back(external_display_info);
624
625 std::vector<DisplayInfo> display_info_list_one_active;
626 display_info_list_one_active.push_back(external_display_info);
627
628 // The DisplayInfo list with two active displays needs to be added first so
629 // that the DisplayManager can track the |internal_display_info| as inactive
630 // instead of non-existent.
631 ash::Shell::GetInstance()->display_manager()->UpdateDisplays(
632 display_info_list_two_active);
633 ash::Shell::GetInstance()->display_manager()->UpdateDisplays(
634 display_info_list_one_active);
635
636 test::DisplayManagerTestApi(display_manager)
637 .SetInternalDisplayId(kInternalDisplayId);
638
639 ASSERT_NE(kNewRotation, display_manager->GetDisplayInfo(kInternalDisplayId)
640 .GetActiveRotation());
641
642 delegate()->SetDisplayRotation(kNewRotation,
643 gfx::Display::ROTATION_SOURCE_ACTIVE);
644
645 // TODO(bruthig): Uncomment when www.crbug.com/480703 is fixed. This test
646 // still adds value by ensuring a crash does not occur. See
647 // www.crbug.com/479503.
648 // ASSERT_EQ(kNewRotation, display_manager->GetDisplayInfo(kInternalDisplayId)
649 // .GetActiveRotation());
650 }
651
598 } // namespace ash 652 } // namespace ash
OLDNEW
« 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