OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/system/chromeos/power/power_event_observer.h" | 5 #include "ash/system/chromeos/power/power_event_observer.h" |
6 | 6 |
| 7 #include <memory> |
| 8 |
7 #include "ash/shell.h" | 9 #include "ash/shell.h" |
8 #include "ash/test/ash_test_base.h" | 10 #include "ash/test/ash_test_base.h" |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "base/time/time.h" | 11 #include "base/time/time.h" |
11 #include "chromeos/dbus/dbus_thread_manager.h" | 12 #include "chromeos/dbus/dbus_thread_manager.h" |
12 #include "chromeos/dbus/power_manager_client.h" | 13 #include "chromeos/dbus/power_manager_client.h" |
13 #include "ui/aura/window.h" | 14 #include "ui/aura/window.h" |
14 #include "ui/aura/window_tree_host.h" | 15 #include "ui/aura/window_tree_host.h" |
15 #include "ui/compositor/compositor.h" | 16 #include "ui/compositor/compositor.h" |
16 | 17 |
17 namespace ash { | 18 namespace ash { |
18 | 19 |
19 class PowerEventObserverTest : public test::AshTestBase { | 20 class PowerEventObserverTest : public test::AshTestBase { |
(...skipping 16 matching lines...) Expand all Loading... |
36 int GetNumVisibleCompositors() { | 37 int GetNumVisibleCompositors() { |
37 int result = 0; | 38 int result = 0; |
38 for (const auto& window : Shell::GetAllRootWindows()) { | 39 for (const auto& window : Shell::GetAllRootWindows()) { |
39 if (window->GetHost()->compositor()->IsVisible()) | 40 if (window->GetHost()->compositor()->IsVisible()) |
40 ++result; | 41 ++result; |
41 } | 42 } |
42 | 43 |
43 return result; | 44 return result; |
44 } | 45 } |
45 | 46 |
46 scoped_ptr<PowerEventObserver> observer_; | 47 std::unique_ptr<PowerEventObserver> observer_; |
47 | 48 |
48 private: | 49 private: |
49 DISALLOW_COPY_AND_ASSIGN(PowerEventObserverTest); | 50 DISALLOW_COPY_AND_ASSIGN(PowerEventObserverTest); |
50 }; | 51 }; |
51 | 52 |
52 TEST_F(PowerEventObserverTest, LockBeforeSuspend) { | 53 TEST_F(PowerEventObserverTest, LockBeforeSuspend) { |
53 chromeos::PowerManagerClient* client = | 54 chromeos::PowerManagerClient* client = |
54 chromeos::DBusThreadManager::Get()->GetPowerManagerClient(); | 55 chromeos::DBusThreadManager::Get()->GetPowerManagerClient(); |
55 ASSERT_EQ(0, client->GetNumPendingSuspendReadinessCallbacks()); | 56 ASSERT_EQ(0, client->GetNumPendingSuspendReadinessCallbacks()); |
56 | 57 |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 // request. The real PowerManagerClient would reset its internal counter in | 153 // request. The real PowerManagerClient would reset its internal counter in |
153 // this situation but the stub client is not that smart. | 154 // this situation but the stub client is not that smart. |
154 EXPECT_EQ(2, client->GetNumPendingSuspendReadinessCallbacks()); | 155 EXPECT_EQ(2, client->GetNumPendingSuspendReadinessCallbacks()); |
155 | 156 |
156 observer_->OnLockAnimationsComplete(); | 157 observer_->OnLockAnimationsComplete(); |
157 EXPECT_EQ(1, client->GetNumPendingSuspendReadinessCallbacks()); | 158 EXPECT_EQ(1, client->GetNumPendingSuspendReadinessCallbacks()); |
158 EXPECT_EQ(0, GetNumVisibleCompositors()); | 159 EXPECT_EQ(0, GetNumVisibleCompositors()); |
159 } | 160 } |
160 | 161 |
161 } // namespace ash | 162 } // namespace ash |
OLD | NEW |