OLD | NEW |
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/common/wm/maximize_mode/maximize_mode_controller.h" | 5 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "ash/common/ash_switches.h" | 11 #include "ash/common/ash_switches.h" |
12 #include "ash/common/system/tray/system_tray_delegate.h" | 12 #include "ash/common/system/tray/system_tray_delegate.h" |
13 #include "ash/common/test/test_system_tray_delegate.h" | 13 #include "ash/common/test/test_system_tray_delegate.h" |
14 #include "ash/common/wm/overview/window_selector_controller.h" | 14 #include "ash/common/wm/overview/window_selector_controller.h" |
15 #include "ash/common/wm_shell.h" | 15 #include "ash/common/wm_shell.h" |
16 #include "ash/display/display_manager.h" | |
17 #include "ash/shell.h" | 16 #include "ash/shell.h" |
18 #include "ash/test/ash_test_base.h" | 17 #include "ash/test/ash_test_base.h" |
19 #include "ash/test/display_manager_test_api.h" | |
20 #include "base/command_line.h" | 18 #include "base/command_line.h" |
21 #include "base/test/simple_test_tick_clock.h" | 19 #include "base/test/simple_test_tick_clock.h" |
22 #include "base/test/user_action_tester.h" | 20 #include "base/test/user_action_tester.h" |
23 #include "chromeos/accelerometer/accelerometer_reader.h" | 21 #include "chromeos/accelerometer/accelerometer_reader.h" |
24 #include "chromeos/accelerometer/accelerometer_types.h" | 22 #include "chromeos/accelerometer/accelerometer_types.h" |
| 23 #include "ui/display/manager/display_manager.h" |
| 24 #include "ui/display/test/display_manager_test_api.h" |
25 #include "ui/events/event_handler.h" | 25 #include "ui/events/event_handler.h" |
26 #include "ui/events/test/event_generator.h" | 26 #include "ui/events/test/event_generator.h" |
27 #include "ui/gfx/geometry/vector3d_f.h" | 27 #include "ui/gfx/geometry/vector3d_f.h" |
28 #include "ui/message_center/message_center.h" | 28 #include "ui/message_center/message_center.h" |
29 | 29 |
30 #if defined(USE_X11) | 30 #if defined(USE_X11) |
31 #include "ui/events/test/events_test_utils_x11.h" | 31 #include "ui/events/test/events_test_utils_x11.h" |
32 #endif | 32 #endif |
33 | 33 |
34 namespace ash { | 34 namespace ash { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 | 74 |
75 void SetUp() override { | 75 void SetUp() override { |
76 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 76 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
77 switches::kAshEnableTouchView); | 77 switches::kAshEnableTouchView); |
78 test::AshTestBase::SetUp(); | 78 test::AshTestBase::SetUp(); |
79 chromeos::AccelerometerReader::GetInstance()->RemoveObserver( | 79 chromeos::AccelerometerReader::GetInstance()->RemoveObserver( |
80 maximize_mode_controller()); | 80 maximize_mode_controller()); |
81 | 81 |
82 // Set the first display to be the internal display for the accelerometer | 82 // Set the first display to be the internal display for the accelerometer |
83 // screen rotation tests. | 83 // screen rotation tests. |
84 test::DisplayManagerTestApi(Shell::GetInstance()->display_manager()) | 84 display::test::DisplayManagerTestApi( |
| 85 Shell::GetInstance()->display_manager()) |
85 .SetFirstDisplayAsInternalDisplay(); | 86 .SetFirstDisplayAsInternalDisplay(); |
86 } | 87 } |
87 | 88 |
88 void TearDown() override { | 89 void TearDown() override { |
89 chromeos::AccelerometerReader::GetInstance()->AddObserver( | 90 chromeos::AccelerometerReader::GetInstance()->AddObserver( |
90 maximize_mode_controller()); | 91 maximize_mode_controller()); |
91 test::AshTestBase::TearDown(); | 92 test::AshTestBase::TearDown(); |
92 } | 93 } |
93 | 94 |
94 MaximizeModeController* maximize_mode_controller() { | 95 MaximizeModeController* maximize_mode_controller() { |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 WmShell::Get()->window_selector_controller()->ToggleOverview(); | 480 WmShell::Get()->window_selector_controller()->ToggleOverview(); |
480 | 481 |
481 UpdateDisplay("800x600"); | 482 UpdateDisplay("800x600"); |
482 EXPECT_FALSE(WmShell::Get()->window_selector_controller()->IsSelecting()); | 483 EXPECT_FALSE(WmShell::Get()->window_selector_controller()->IsSelecting()); |
483 EXPECT_EQ(w1->GetRootWindow(), w2->GetRootWindow()); | 484 EXPECT_EQ(w1->GetRootWindow(), w2->GetRootWindow()); |
484 } | 485 } |
485 | 486 |
486 // Test that the disabling of the internal display exits maximize mode, and that | 487 // Test that the disabling of the internal display exits maximize mode, and that |
487 // while disabled we do not re-enter maximize mode. | 488 // while disabled we do not re-enter maximize mode. |
488 TEST_F(MaximizeModeControllerTest, NoMaximizeModeWithDisabledInternalDisplay) { | 489 TEST_F(MaximizeModeControllerTest, NoMaximizeModeWithDisabledInternalDisplay) { |
489 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | |
490 UpdateDisplay("200x200, 200x200"); | 490 UpdateDisplay("200x200, 200x200"); |
491 const int64_t internal_display_id = | 491 const int64_t internal_display_id = |
492 test::DisplayManagerTestApi(Shell::GetInstance()->display_manager()) | 492 display::test::DisplayManagerTestApi(display_manager()) |
493 .SetFirstDisplayAsInternalDisplay(); | 493 .SetFirstDisplayAsInternalDisplay(); |
494 ASSERT_FALSE(IsMaximizeModeStarted()); | 494 ASSERT_FALSE(IsMaximizeModeStarted()); |
495 | 495 |
496 OpenLidToAngle(270.0f); | 496 OpenLidToAngle(270.0f); |
497 EXPECT_TRUE(IsMaximizeModeStarted()); | 497 EXPECT_TRUE(IsMaximizeModeStarted()); |
498 EXPECT_TRUE(AreEventsBlocked()); | 498 EXPECT_TRUE(AreEventsBlocked()); |
499 | 499 |
500 // Deactivate internal display to simulate Docked Mode. | 500 // Deactivate internal display to simulate Docked Mode. |
501 std::vector<display::ManagedDisplayInfo> secondary_only; | 501 std::vector<display::ManagedDisplayInfo> secondary_only; |
502 secondary_only.push_back( | 502 secondary_only.push_back(display_manager()->GetDisplayInfo( |
503 display_manager->GetDisplayInfo(display_manager->GetDisplayAt(1).id())); | 503 display_manager()->GetDisplayAt(1).id())); |
504 display_manager->OnNativeDisplaysChanged(secondary_only); | 504 display_manager()->OnNativeDisplaysChanged(secondary_only); |
505 ASSERT_FALSE(display_manager->IsActiveDisplayId(internal_display_id)); | 505 ASSERT_FALSE(display_manager()->IsActiveDisplayId(internal_display_id)); |
506 EXPECT_FALSE(IsMaximizeModeStarted()); | 506 EXPECT_FALSE(IsMaximizeModeStarted()); |
507 EXPECT_FALSE(AreEventsBlocked()); | 507 EXPECT_FALSE(AreEventsBlocked()); |
508 | 508 |
509 OpenLidToAngle(270.0f); | 509 OpenLidToAngle(270.0f); |
510 EXPECT_FALSE(IsMaximizeModeStarted()); | 510 EXPECT_FALSE(IsMaximizeModeStarted()); |
511 EXPECT_FALSE(AreEventsBlocked()); | 511 EXPECT_FALSE(AreEventsBlocked()); |
512 } | 512 } |
513 | 513 |
514 // Verify that the device won't exit touchview / maximize mode for unstable | 514 // Verify that the device won't exit touchview / maximize mode for unstable |
515 // angles when hinge is nearly vertical | 515 // angles when hinge is nearly vertical |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 // accelerometer updates which would normally cause it to exit do not. | 560 // accelerometer updates which would normally cause it to exit do not. |
561 TEST_F(MaximizeModeControllerSwitchesTest, IgnoreHingeAngles) { | 561 TEST_F(MaximizeModeControllerSwitchesTest, IgnoreHingeAngles) { |
562 maximize_mode_controller()->EnableMaximizeModeWindowManager(true); | 562 maximize_mode_controller()->EnableMaximizeModeWindowManager(true); |
563 | 563 |
564 // Would normally trigger an exit from maximize mode. | 564 // Would normally trigger an exit from maximize mode. |
565 OpenLidToAngle(90.0f); | 565 OpenLidToAngle(90.0f); |
566 EXPECT_TRUE(IsMaximizeModeStarted()); | 566 EXPECT_TRUE(IsMaximizeModeStarted()); |
567 } | 567 } |
568 | 568 |
569 } // namespace ash | 569 } // namespace ash |
OLD | NEW |