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

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