Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(104)

Side by Side Diff: base/android/application_status_listener_unittest.cc

Issue 1113953002: Revert of base: Remove use of MessageLoopProxy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | base/async_socket_io_handler_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #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.h" 10 #include "base/message_loop/message_loop_proxy.h"
11 #include "base/run_loop.h" 11 #include "base/run_loop.h"
12 #include "base/synchronization/waitable_event.h" 12 #include "base/synchronization/waitable_event.h"
13 #include "base/threading/thread.h" 13 #include "base/threading/thread.h"
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 15
16 namespace base { 16 namespace base {
17 namespace android { 17 namespace android {
18 18
19 namespace { 19 namespace {
20 20
(...skipping 21 matching lines...) Expand all
42 MultiThreadedTest() 42 MultiThreadedTest()
43 : state_(kInvalidApplicationState), 43 : state_(kInvalidApplicationState),
44 event_(false, false), 44 event_(false, false),
45 thread_("ApplicationStatusTest thread"), 45 thread_("ApplicationStatusTest thread"),
46 main_() { 46 main_() {
47 } 47 }
48 48
49 void Run() { 49 void Run() {
50 // Start the thread and tell it to register for events. 50 // Start the thread and tell it to register for events.
51 thread_.Start(); 51 thread_.Start();
52 thread_.task_runner()->PostTask( 52 thread_.message_loop()
53 FROM_HERE, base::Bind(&MultiThreadedTest::RegisterThreadForEvents, 53 ->PostTask(FROM_HERE,
54 base::Bind(&MultiThreadedTest::RegisterThreadForEvents,
54 base::Unretained(this))); 55 base::Unretained(this)));
55 56
56 // Wait for its completion. 57 // Wait for its completion.
57 event_.Wait(); 58 event_.Wait();
58 59
59 // Change state, then wait for the thread to modify state. 60 // Change state, then wait for the thread to modify state.
60 ApplicationStatusListener::NotifyApplicationStateChange( 61 ApplicationStatusListener::NotifyApplicationStateChange(
61 APPLICATION_STATE_HAS_RUNNING_ACTIVITIES); 62 APPLICATION_STATE_HAS_RUNNING_ACTIVITIES);
62 event_.Wait(); 63 event_.Wait();
63 EXPECT_EQ(APPLICATION_STATE_HAS_RUNNING_ACTIVITIES, state_); 64 EXPECT_EQ(APPLICATION_STATE_HAS_RUNNING_ACTIVITIES, state_);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 EXPECT_EQ(APPLICATION_STATE_HAS_DESTROYED_ACTIVITIES, result); 121 EXPECT_EQ(APPLICATION_STATE_HAS_DESTROYED_ACTIVITIES, result);
121 } 122 }
122 123
123 TEST(ApplicationStatusListenerTest, TwoThreads) { 124 TEST(ApplicationStatusListenerTest, TwoThreads) {
124 MultiThreadedTest test; 125 MultiThreadedTest test;
125 test.Run(); 126 test.Run();
126 } 127 }
127 128
128 } // namespace android 129 } // namespace android
129 } // namespace base 130 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/async_socket_io_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698