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

Side by Side Diff: ash/content/display/screen_orientation_controller_chromeos_unittest.cc

Issue 2445583002: Relocate display_manager from ash to ui (Closed)
Patch Set: fix windows build Created 4 years, 1 month 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
« no previous file with comments | « ash/autoclick/autoclick_unittest.cc ('k') | ash/dip_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "ash/display/screen_orientation_controller_chromeos.h" 5 #include "ash/display/screen_orientation_controller_chromeos.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/common/ash_switches.h" 10 #include "ash/common/ash_switches.h"
11 #include "ash/common/test/test_system_tray_delegate.h" 11 #include "ash/common/test/test_system_tray_delegate.h"
12 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" 12 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h"
13 #include "ash/common/wm_shell.h" 13 #include "ash/common/wm_shell.h"
14 #include "ash/content/shell_content_state.h" 14 #include "ash/content/shell_content_state.h"
15 #include "ash/display/display_manager.h"
16 #include "ash/shell.h" 15 #include "ash/shell.h"
17 #include "ash/system/chromeos/screen_layout_observer.h" 16 #include "ash/system/chromeos/screen_layout_observer.h"
18 #include "ash/test/ash_test_base.h" 17 #include "ash/test/ash_test_base.h"
19 #include "ash/test/ash_test_environment_content.h" 18 #include "ash/test/ash_test_environment_content.h"
20 #include "ash/test/ash_test_helper.h" 19 #include "ash/test/ash_test_helper.h"
21 #include "ash/test/content/test_shell_content_state.h" 20 #include "ash/test/content/test_shell_content_state.h"
22 #include "ash/test/display_manager_test_api.h"
23 #include "ash/test/test_shell_delegate.h" 21 #include "ash/test/test_shell_delegate.h"
24 #include "base/command_line.h" 22 #include "base/command_line.h"
25 #include "chromeos/accelerometer/accelerometer_reader.h" 23 #include "chromeos/accelerometer/accelerometer_reader.h"
26 #include "chromeos/accelerometer/accelerometer_types.h" 24 #include "chromeos/accelerometer/accelerometer_types.h"
27 #include "content/public/browser/browser_context.h" 25 #include "content/public/browser/browser_context.h"
28 #include "content/public/browser/web_contents.h" 26 #include "content/public/browser/web_contents.h"
29 #include "content/public/test/test_browser_context.h" 27 #include "content/public/test/test_browser_context.h"
30 #include "third_party/WebKit/public/platform/modules/screen_orientation/WebScree nOrientationLockType.h" 28 #include "third_party/WebKit/public/platform/modules/screen_orientation/WebScree nOrientationLockType.h"
31 #include "ui/aura/window.h" 29 #include "ui/aura/window.h"
32 #include "ui/display/display.h" 30 #include "ui/display/display.h"
33 #include "ui/display/display_switches.h" 31 #include "ui/display/display_switches.h"
32 #include "ui/display/manager/display_manager.h"
34 #include "ui/display/manager/managed_display_info.h" 33 #include "ui/display/manager/managed_display_info.h"
34 #include "ui/display/test/display_manager_test_api.h"
35 #include "ui/message_center/message_center.h" 35 #include "ui/message_center/message_center.h"
36 #include "ui/views/test/webview_test_helper.h" 36 #include "ui/views/test/webview_test_helper.h"
37 #include "ui/views/view.h" 37 #include "ui/views/view.h"
38 #include "ui/views/views_delegate.h" 38 #include "ui/views/views_delegate.h"
39 #include "ui/wm/public/activation_client.h" 39 #include "ui/wm/public/activation_client.h"
40 40
41 namespace ash { 41 namespace ash {
42 42
43 namespace { 43 namespace {
44 44
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 417
418 // The ScreenLayoutObserver class that is responsible for adding/updating 418 // The ScreenLayoutObserver class that is responsible for adding/updating
419 // MessageCenter notifications is only added to the SystemTray on ChromeOS. 419 // MessageCenter notifications is only added to the SystemTray on ChromeOS.
420 // Tests that the screen rotation notifications are suppressed when 420 // Tests that the screen rotation notifications are suppressed when
421 // triggered by the accelerometer. 421 // triggered by the accelerometer.
422 TEST_F(ScreenOrientationControllerTest, BlockRotationNotifications) { 422 TEST_F(ScreenOrientationControllerTest, BlockRotationNotifications) {
423 EnableMaximizeMode(true); 423 EnableMaximizeMode(true);
424 Shell::GetInstance() 424 Shell::GetInstance()
425 ->screen_layout_observer() 425 ->screen_layout_observer()
426 ->set_show_notifications_for_testing(true); 426 ->set_show_notifications_for_testing(true);
427 test::DisplayManagerTestApi(display_manager()) 427 display::test::DisplayManagerTestApi(display_manager())
428 .SetFirstDisplayAsInternalDisplay(); 428 .SetFirstDisplayAsInternalDisplay();
429 429
430 message_center::MessageCenter* message_center = 430 message_center::MessageCenter* message_center =
431 message_center::MessageCenter::Get(); 431 message_center::MessageCenter::Get();
432 432
433 EXPECT_EQ(0u, message_center->NotificationCount()); 433 EXPECT_EQ(0u, message_center->NotificationCount());
434 EXPECT_FALSE(message_center->HasPopupNotifications()); 434 EXPECT_FALSE(message_center->HasPopupNotifications());
435 435
436 // Make sure notifications are still displayed when 436 // Make sure notifications are still displayed when
437 // adjusting the screen rotation directly when in maximize mode 437 // adjusting the screen rotation directly when in maximize mode
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 ASSERT_FALSE(message_center->HasPopupNotifications()); 470 ASSERT_FALSE(message_center->HasPopupNotifications());
471 SetInternalDisplayRotation(display::Display::ROTATE_180); 471 SetInternalDisplayRotation(display::Display::ROTATE_180);
472 EXPECT_EQ(display::Display::ROTATE_180, GetCurrentInternalDisplayRotation()); 472 EXPECT_EQ(display::Display::ROTATE_180, GetCurrentInternalDisplayRotation());
473 EXPECT_EQ(1u, message_center->NotificationCount()); 473 EXPECT_EQ(1u, message_center->NotificationCount());
474 EXPECT_TRUE(message_center->HasPopupNotifications()); 474 EXPECT_TRUE(message_center->HasPopupNotifications());
475 } 475 }
476 476
477 // Tests that if a user has set a display rotation that it is restored upon 477 // Tests that if a user has set a display rotation that it is restored upon
478 // exiting maximize mode. 478 // exiting maximize mode.
479 TEST_F(ScreenOrientationControllerTest, ResetUserRotationUponExit) { 479 TEST_F(ScreenOrientationControllerTest, ResetUserRotationUponExit) {
480 test::DisplayManagerTestApi(display_manager()) 480 display::test::DisplayManagerTestApi(display_manager())
481 .SetFirstDisplayAsInternalDisplay(); 481 .SetFirstDisplayAsInternalDisplay();
482 482
483 SetInternalDisplayRotation(display::Display::ROTATE_90); 483 SetInternalDisplayRotation(display::Display::ROTATE_90);
484 EnableMaximizeMode(true); 484 EnableMaximizeMode(true);
485 485
486 TriggerLidUpdate(gfx::Vector3dF(0.0f, kMeanGravity, 0.0f)); 486 TriggerLidUpdate(gfx::Vector3dF(0.0f, kMeanGravity, 0.0f));
487 EXPECT_EQ(display::Display::ROTATE_180, GetCurrentInternalDisplayRotation()); 487 EXPECT_EQ(display::Display::ROTATE_180, GetCurrentInternalDisplayRotation());
488 488
489 EnableMaximizeMode(false); 489 EnableMaximizeMode(false);
490 EXPECT_EQ(display::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); 490 EXPECT_EQ(display::Display::ROTATE_90, GetCurrentInternalDisplayRotation());
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 EXPECT_EQ(display::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); 597 EXPECT_EQ(display::Display::ROTATE_0, GetCurrentInternalDisplayRotation());
598 598
599 TriggerLidUpdate(gfx::Vector3dF(0.0f, kMeanGravity, 0.0f)); 599 TriggerLidUpdate(gfx::Vector3dF(0.0f, kMeanGravity, 0.0f));
600 EXPECT_EQ(display::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); 600 EXPECT_EQ(display::Display::ROTATE_0, GetCurrentInternalDisplayRotation());
601 } 601 }
602 602
603 // Tests that when MaximizeMode is triggered before the internal display is 603 // Tests that when MaximizeMode is triggered before the internal display is
604 // ready, that ScreenOrientationController still begins listening to events, 604 // ready, that ScreenOrientationController still begins listening to events,
605 // which require an internal display to be acted upon. 605 // which require an internal display to be acted upon.
606 TEST_F(ScreenOrientationControllerTest, InternalDisplayNotAvailableAtStartup) { 606 TEST_F(ScreenOrientationControllerTest, InternalDisplayNotAvailableAtStartup) {
607 test::DisplayManagerTestApi(display_manager()) 607 display::test::DisplayManagerTestApi(display_manager())
608 .SetFirstDisplayAsInternalDisplay(); 608 .SetFirstDisplayAsInternalDisplay();
609 609
610 int64_t internal_display_id = display::Display::InternalDisplayId(); 610 int64_t internal_display_id = display::Display::InternalDisplayId();
611 display::Display::SetInternalDisplayId(display::Display::kInvalidDisplayID); 611 display::Display::SetInternalDisplayId(display::Display::kInvalidDisplayID);
612 612
613 EnableMaximizeMode(true); 613 EnableMaximizeMode(true);
614 614
615 // Should not crash, even though there is no internal display. 615 // Should not crash, even though there is no internal display.
616 SetDisplayRotationById(internal_display_id, display::Display::ROTATE_180); 616 SetDisplayRotationById(internal_display_id, display::Display::ROTATE_180);
617 EXPECT_FALSE(RotationLocked()); 617 EXPECT_FALSE(RotationLocked());
(...skipping 26 matching lines...) Expand all
644 644
645 std::vector<display::ManagedDisplayInfo> display_info_list_one_active; 645 std::vector<display::ManagedDisplayInfo> display_info_list_one_active;
646 display_info_list_one_active.push_back(external_display_info); 646 display_info_list_one_active.push_back(external_display_info);
647 647
648 // The display::ManagedDisplayInfo list with two active displays needs to be 648 // The display::ManagedDisplayInfo list with two active displays needs to be
649 // added first so that the DisplayManager can track the 649 // added first so that the DisplayManager can track the
650 // |internal_display_info| as inactive instead of non-existent. 650 // |internal_display_info| as inactive instead of non-existent.
651 display_manager()->UpdateDisplaysWith(display_info_list_two_active); 651 display_manager()->UpdateDisplaysWith(display_info_list_two_active);
652 display_manager()->UpdateDisplaysWith(display_info_list_one_active); 652 display_manager()->UpdateDisplaysWith(display_info_list_one_active);
653 653
654 test::ScopedSetInternalDisplayId set_internal(display_manager(), 654 display::test::ScopedSetInternalDisplayId set_internal(display_manager(),
655 kInternalDisplayId); 655 kInternalDisplayId);
656 656
657 ASSERT_NE(kNewRotation, display_manager() 657 ASSERT_NE(kNewRotation, display_manager()
658 ->GetDisplayInfo(kInternalDisplayId) 658 ->GetDisplayInfo(kInternalDisplayId)
659 .GetActiveRotation()); 659 .GetActiveRotation());
660 660
661 Shell::GetInstance()->screen_orientation_controller()->SetDisplayRotation( 661 Shell::GetInstance()->screen_orientation_controller()->SetDisplayRotation(
662 kNewRotation, display::Display::ROTATION_SOURCE_ACTIVE); 662 kNewRotation, display::Display::ROTATION_SOURCE_ACTIVE);
663 663
664 EXPECT_EQ(kNewRotation, display_manager() 664 EXPECT_EQ(kNewRotation, display_manager()
665 ->GetDisplayInfo(kInternalDisplayId) 665 ->GetDisplayInfo(kInternalDisplayId)
666 .GetActiveRotation()); 666 .GetActiveRotation());
667 } 667 }
668 668
669 } // namespace ash 669 } // namespace ash
OLDNEW
« no previous file with comments | « ash/autoclick/autoclick_unittest.cc ('k') | ash/dip_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698