OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/wm/power_button_controller.h" | 5 #include "ash/wm/power_button_controller.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/test/ash_test_base.h" | 8 #include "ash/test/ash_test_base.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/time.h" | 10 #include "base/time.h" |
11 #include "ui/aura/root_window.h" | 11 #include "ui/aura/root_window.h" |
| 12 #include "ui/gfx/rect.h" |
| 13 #include "ui/gfx/size.h" |
12 | 14 |
13 namespace ash { | 15 namespace ash { |
14 namespace test { | 16 namespace test { |
15 | 17 |
16 // Fake implementation of PowerButtonControllerDelegate that just logs requests | 18 // Fake implementation of PowerButtonControllerDelegate that just logs requests |
17 // to lock the screen and shut down the device. | 19 // to lock the screen and shut down the device. |
18 class TestPowerButtonControllerDelegate : public PowerButtonControllerDelegate { | 20 class TestPowerButtonControllerDelegate : public PowerButtonControllerDelegate { |
19 public: | 21 public: |
20 TestPowerButtonControllerDelegate() | 22 TestPowerButtonControllerDelegate() |
21 : num_lock_requests_(0), | 23 : num_lock_requests_(0), |
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 PowerButtonController::ANIMATION_FAST_CLOSE)); | 520 PowerButtonController::ANIMATION_FAST_CLOSE)); |
519 EXPECT_TRUE(test_api_->BackgroundLayerIsVisible()); | 521 EXPECT_TRUE(test_api_->BackgroundLayerIsVisible()); |
520 EXPECT_FALSE(Shell::GetRootWindow()->cursor_shown()); | 522 EXPECT_FALSE(Shell::GetRootWindow()->cursor_shown()); |
521 | 523 |
522 EXPECT_EQ(0, delegate_->num_shutdown_requests()); | 524 EXPECT_EQ(0, delegate_->num_shutdown_requests()); |
523 EXPECT_TRUE(test_api_->real_shutdown_timer_is_running()); | 525 EXPECT_TRUE(test_api_->real_shutdown_timer_is_running()); |
524 test_api_->trigger_real_shutdown_timeout(); | 526 test_api_->trigger_real_shutdown_timeout(); |
525 EXPECT_EQ(1, delegate_->num_shutdown_requests()); | 527 EXPECT_EQ(1, delegate_->num_shutdown_requests()); |
526 } | 528 } |
527 | 529 |
| 530 // Test that the background layer is resized in response to root window resizes. |
| 531 TEST_F(PowerButtonControllerTest, ResizeBackgroundLayer) { |
| 532 controller_->OnPowerButtonEvent(true, base::TimeTicks::Now()); |
| 533 EXPECT_EQ(Shell::GetRootWindow()->bounds().ToString(), |
| 534 test_api_->GetBackgroundLayerBounds().ToString()); |
| 535 |
| 536 const gfx::Size kNewSize(400, 300); |
| 537 Shell::GetRootWindow()->SetHostSize(kNewSize); |
| 538 EXPECT_EQ(gfx::Rect(kNewSize).ToString(), |
| 539 test_api_->GetBackgroundLayerBounds().ToString()); |
| 540 } |
| 541 |
528 } // namespace test | 542 } // namespace test |
529 } // namespace ash | 543 } // namespace ash |
OLD | NEW |