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 "base/android/application_status_listener.h" | 5 #include "base/android/application_status_listener.h" |
| 6 |
| 7 #include <memory> |
| 8 |
6 #include "base/bind.h" | 9 #include "base/bind.h" |
7 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
8 #include "base/logging.h" | 11 #include "base/logging.h" |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
11 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
12 #include "base/synchronization/waitable_event.h" | 14 #include "base/synchronization/waitable_event.h" |
13 #include "base/threading/thread.h" | 15 #include "base/threading/thread.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
15 | 17 |
16 namespace base { | 18 namespace base { |
17 namespace android { | 19 namespace android { |
18 | 20 |
19 namespace { | 21 namespace { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 void StoreStateAndSignal(ApplicationState state) { | 87 void StoreStateAndSignal(ApplicationState state) { |
86 ExpectOnThread(); | 88 ExpectOnThread(); |
87 state_ = state; | 89 state_ = state; |
88 event_.Signal(); | 90 event_.Signal(); |
89 } | 91 } |
90 | 92 |
91 ApplicationState state_; | 93 ApplicationState state_; |
92 base::WaitableEvent event_; | 94 base::WaitableEvent event_; |
93 base::Thread thread_; | 95 base::Thread thread_; |
94 base::MessageLoop main_; | 96 base::MessageLoop main_; |
95 scoped_ptr<ApplicationStatusListener> listener_; | 97 std::unique_ptr<ApplicationStatusListener> listener_; |
96 }; | 98 }; |
97 | 99 |
98 } // namespace | 100 } // namespace |
99 | 101 |
100 TEST(ApplicationStatusListenerTest, SingleThread) { | 102 TEST(ApplicationStatusListenerTest, SingleThread) { |
101 MessageLoop message_loop; | 103 MessageLoop message_loop; |
102 | 104 |
103 ApplicationState result = kInvalidApplicationState; | 105 ApplicationState result = kInvalidApplicationState; |
104 | 106 |
105 // Create a new listener that stores the new state into |result| on every | 107 // Create a new listener that stores the new state into |result| on every |
(...skipping 14 matching lines...) Expand all Loading... |
120 EXPECT_EQ(APPLICATION_STATE_HAS_DESTROYED_ACTIVITIES, result); | 122 EXPECT_EQ(APPLICATION_STATE_HAS_DESTROYED_ACTIVITIES, result); |
121 } | 123 } |
122 | 124 |
123 TEST(ApplicationStatusListenerTest, TwoThreads) { | 125 TEST(ApplicationStatusListenerTest, TwoThreads) { |
124 MultiThreadedTest test; | 126 MultiThreadedTest test; |
125 test.Run(); | 127 test.Run(); |
126 } | 128 } |
127 | 129 |
128 } // namespace android | 130 } // namespace android |
129 } // namespace base | 131 } // namespace base |
OLD | NEW |