| 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 "base/android/activity_status.h" | 5 #include "base/android/activity_status.h" |
| 6 #include "base/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/callback_forward.h" | 7 #include "base/callback_forward.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 // Shared state for the multi-threaded test. | 36 // Shared state for the multi-threaded test. |
| 37 // This uses a thread to register for events and listen to them, while state | 37 // This uses a thread to register for events and listen to them, while state |
| 38 // changes are forced on the main thread. | 38 // changes are forced on the main thread. |
| 39 class MultiThreadedTest { | 39 class MultiThreadedTest { |
| 40 public: | 40 public: |
| 41 MultiThreadedTest() | 41 MultiThreadedTest() |
| 42 : activity_status_(ActivityStatus::GetInstance()), | 42 : activity_status_(ActivityStatus::GetInstance()), |
| 43 state_(kInvalidActivityState), | 43 state_(kInvalidActivityState), |
| 44 event_(false, false), | 44 event_(false, false), |
| 45 thread_("ActivityStatusTest thread"), | 45 thread_("ActivityStatusTest thread"), |
| 46 main_(), | 46 main_() { |
| 47 listener_(NULL) { | |
| 48 } | 47 } |
| 49 | 48 |
| 50 void Run() { | 49 void Run() { |
| 51 // Start the thread and tell it to register for events. | 50 // Start the thread and tell it to register for events. |
| 52 thread_.Start(); | 51 thread_.Start(); |
| 53 thread_.message_loop() | 52 thread_.message_loop() |
| 54 ->PostTask(FROM_HERE, | 53 ->PostTask(FROM_HERE, |
| 55 base::Bind(&MultiThreadedTest::RegisterThreadForEvents, | 54 base::Bind(&MultiThreadedTest::RegisterThreadForEvents, |
| 56 base::Unretained(this))); | 55 base::Unretained(this))); |
| 57 | 56 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 EXPECT_EQ(ACTIVITY_STATE_DESTROYED, result); | 119 EXPECT_EQ(ACTIVITY_STATE_DESTROYED, result); |
| 121 } | 120 } |
| 122 | 121 |
| 123 TEST(ActivityStatusTest, TwoThreads) { | 122 TEST(ActivityStatusTest, TwoThreads) { |
| 124 MultiThreadedTest test; | 123 MultiThreadedTest test; |
| 125 test.Run(); | 124 test.Run(); |
| 126 } | 125 } |
| 127 | 126 |
| 128 } // namespace android | 127 } // namespace android |
| 129 } // namespace base | 128 } // namespace base |
| OLD | NEW |