| 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/shell.h" | 16 #include "ash/shell.h" |
| 17 #include "ash/test/ash_test_base.h" | 17 #include "ash/test/ash_test_base.h" |
| 18 #include "base/command_line.h" | 18 #include "base/command_line.h" |
| 19 #include "base/run_loop.h" |
| 19 #include "base/test/simple_test_tick_clock.h" | 20 #include "base/test/simple_test_tick_clock.h" |
| 20 #include "base/test/user_action_tester.h" | 21 #include "base/test/user_action_tester.h" |
| 21 #include "chromeos/accelerometer/accelerometer_reader.h" | 22 #include "chromeos/accelerometer/accelerometer_reader.h" |
| 22 #include "chromeos/accelerometer/accelerometer_types.h" | 23 #include "chromeos/accelerometer/accelerometer_types.h" |
| 24 #include "chromeos/dbus/dbus_thread_manager.h" |
| 25 #include "chromeos/dbus/fake_power_manager_client.h" |
| 23 #include "ui/display/manager/display_manager.h" | 26 #include "ui/display/manager/display_manager.h" |
| 24 #include "ui/display/test/display_manager_test_api.h" | 27 #include "ui/display/test/display_manager_test_api.h" |
| 25 #include "ui/events/event_handler.h" | 28 #include "ui/events/event_handler.h" |
| 26 #include "ui/events/test/event_generator.h" | 29 #include "ui/events/test/event_generator.h" |
| 27 #include "ui/gfx/geometry/vector3d_f.h" | 30 #include "ui/gfx/geometry/vector3d_f.h" |
| 28 #include "ui/message_center/message_center.h" | 31 #include "ui/message_center/message_center.h" |
| 29 | 32 |
| 30 #if defined(USE_X11) | 33 #if defined(USE_X11) |
| 31 #include "ui/events/test/events_test_utils_x11.h" | 34 #include "ui/events/test/events_test_utils_x11.h" |
| 32 #endif | 35 #endif |
| (...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 576 kAccelerometerVerticalHingeUnstableAnglesTestData[i * 6 + 3], | 579 kAccelerometerVerticalHingeUnstableAnglesTestData[i * 6 + 3], |
| 577 kAccelerometerVerticalHingeUnstableAnglesTestData[i * 6 + 4], | 580 kAccelerometerVerticalHingeUnstableAnglesTestData[i * 6 + 4], |
| 578 kAccelerometerVerticalHingeUnstableAnglesTestData[i * 6 + 5]); | 581 kAccelerometerVerticalHingeUnstableAnglesTestData[i * 6 + 5]); |
| 579 TriggerBaseAndLidUpdate(base, lid); | 582 TriggerBaseAndLidUpdate(base, lid); |
| 580 // There are a lot of samples, so ASSERT rather than EXPECT to only generate | 583 // There are a lot of samples, so ASSERT rather than EXPECT to only generate |
| 581 // one failure rather than potentially hundreds. | 584 // one failure rather than potentially hundreds. |
| 582 ASSERT_TRUE(IsMaximizeModeStarted()); | 585 ASSERT_TRUE(IsMaximizeModeStarted()); |
| 583 } | 586 } |
| 584 } | 587 } |
| 585 | 588 |
| 589 // Tests that when a MaximizeModeController is created that cached tablet mode |
| 590 // state will trigger a mode update. |
| 591 TEST_F(MaximizeModeControllerTest, InitializedWhileTabletModeSwitchOn) { |
| 592 base::RunLoop().RunUntilIdle(); |
| 593 // FakePowerManagerClient is always installed for tests |
| 594 chromeos::FakePowerManagerClient* power_manager_client = |
| 595 static_cast<chromeos::FakePowerManagerClient*>( |
| 596 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()); |
| 597 power_manager_client->set_tablet_mode( |
| 598 chromeos::PowerManagerClient::TabletMode::ON); |
| 599 MaximizeModeController controller; |
| 600 EXPECT_FALSE(controller.IsMaximizeModeWindowManagerEnabled()); |
| 601 // PowerManagerClient callback is a posted task. |
| 602 base::RunLoop().RunUntilIdle(); |
| 603 EXPECT_TRUE(controller.IsMaximizeModeWindowManagerEnabled()); |
| 604 } |
| 605 |
| 586 } // namespace ash | 606 } // namespace ash |
| OLD | NEW |