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

Side by Side Diff: ipc/ipc_channel_unittest.cc

Issue 2087163003: Remove calls to deprecated MessageLoop methods in ipc. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: manual changes Created 4 years, 6 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 | « ipc/ipc_channel_proxy_unittest.cc ('k') | ipc/ipc_fuzzing_tests.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 (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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #endif 9 #endif
10 10
11 #include <stdint.h> 11 #include <stdint.h>
12 12
13 #include <memory> 13 #include <memory>
14 #include <string> 14 #include <string>
15 15
16 #include "base/pickle.h" 16 #include "base/pickle.h"
17 #include "base/run_loop.h"
17 #include "base/strings/string16.h" 18 #include "base/strings/string16.h"
18 #include "base/strings/utf_string_conversions.h" 19 #include "base/strings/utf_string_conversions.h"
19 #include "base/threading/thread.h" 20 #include "base/threading/thread.h"
20 #include "ipc/ipc_test_base.h" 21 #include "ipc/ipc_test_base.h"
21 #include "ipc/ipc_test_channel_listener.h" 22 #include "ipc/ipc_test_channel_listener.h"
22 23
23 namespace { 24 namespace {
24 25
25 class IPCChannelTest : public IPCTestBase { 26 class IPCChannelTest : public IPCTestBase {
26 }; 27 };
27 28
28 TEST_F(IPCChannelTest, ChannelTest) { 29 TEST_F(IPCChannelTest, ChannelTest) {
29 Init("GenericClient"); 30 Init("GenericClient");
30 31
31 // Set up IPC channel and start client. 32 // Set up IPC channel and start client.
32 IPC::TestChannelListener listener; 33 IPC::TestChannelListener listener;
33 CreateChannel(&listener); 34 CreateChannel(&listener);
34 listener.Init(sender()); 35 listener.Init(sender());
35 ASSERT_TRUE(ConnectChannel()); 36 ASSERT_TRUE(ConnectChannel());
36 ASSERT_TRUE(StartClient()); 37 ASSERT_TRUE(StartClient());
37 38
38 IPC::TestChannelListener::SendOneMessage(sender(), "hello from parent"); 39 IPC::TestChannelListener::SendOneMessage(sender(), "hello from parent");
39 40
40 // Run message loop. 41 // Run message loop.
41 base::MessageLoop::current()->Run(); 42 base::RunLoop().Run();
42 43
43 // Close the channel so the client's OnChannelError() gets fired. 44 // Close the channel so the client's OnChannelError() gets fired.
44 channel()->Close(); 45 channel()->Close();
45 46
46 EXPECT_TRUE(WaitForClientShutdown()); 47 EXPECT_TRUE(WaitForClientShutdown());
47 DestroyChannel(); 48 DestroyChannel();
48 } 49 }
49 50
50 // TODO(viettrungluu): Move to a separate IPCChannelWinTest. 51 // TODO(viettrungluu): Move to a separate IPCChannelWinTest.
51 #if defined(OS_WIN) 52 #if defined(OS_WIN)
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 // Set up IPC channel proxy. 99 // Set up IPC channel proxy.
99 IPC::TestChannelListener listener; 100 IPC::TestChannelListener listener;
100 CreateChannelProxy(&listener, thread.task_runner().get()); 101 CreateChannelProxy(&listener, thread.task_runner().get());
101 listener.Init(sender()); 102 listener.Init(sender());
102 103
103 ASSERT_TRUE(StartClient()); 104 ASSERT_TRUE(StartClient());
104 105
105 IPC::TestChannelListener::SendOneMessage(sender(), "hello from parent"); 106 IPC::TestChannelListener::SendOneMessage(sender(), "hello from parent");
106 107
107 // Run message loop. 108 // Run message loop.
108 base::MessageLoop::current()->Run(); 109 base::RunLoop().Run();
109 110
110 EXPECT_TRUE(WaitForClientShutdown()); 111 EXPECT_TRUE(WaitForClientShutdown());
111 112
112 // Destroy the channel proxy before shutting down the thread. 113 // Destroy the channel proxy before shutting down the thread.
113 DestroyChannelProxy(); 114 DestroyChannelProxy();
114 thread.Stop(); 115 thread.Stop();
115 } 116 }
116 117
117 class ChannelListenerWithOnConnectedSend : public IPC::TestChannelListener { 118 class ChannelListenerWithOnConnectedSend : public IPC::TestChannelListener {
118 public: 119 public:
(...skipping 19 matching lines...) Expand all
138 // Set up IPC channel and start client. 139 // Set up IPC channel and start client.
139 ChannelListenerWithOnConnectedSend listener; 140 ChannelListenerWithOnConnectedSend listener;
140 CreateChannel(&listener); 141 CreateChannel(&listener);
141 listener.Init(sender()); 142 listener.Init(sender());
142 ASSERT_TRUE(ConnectChannel()); 143 ASSERT_TRUE(ConnectChannel());
143 ASSERT_TRUE(StartClient()); 144 ASSERT_TRUE(StartClient());
144 145
145 IPC::TestChannelListener::SendOneMessage(sender(), "hello from parent"); 146 IPC::TestChannelListener::SendOneMessage(sender(), "hello from parent");
146 147
147 // Run message loop. 148 // Run message loop.
148 base::MessageLoop::current()->Run(); 149 base::RunLoop().Run();
149 150
150 // Close the channel so the client's OnChannelError() gets fired. 151 // Close the channel so the client's OnChannelError() gets fired.
151 channel()->Close(); 152 channel()->Close();
152 153
153 EXPECT_TRUE(WaitForClientShutdown()); 154 EXPECT_TRUE(WaitForClientShutdown());
154 DestroyChannel(); 155 DestroyChannel();
155 } 156 }
156 157
157 MULTIPROCESS_IPC_TEST_CLIENT_MAIN(GenericClient) { 158 MULTIPROCESS_IPC_TEST_CLIENT_MAIN(GenericClient) {
158 base::MessageLoopForIO main_message_loop; 159 base::MessageLoopForIO main_message_loop;
159 IPC::TestChannelListener listener; 160 IPC::TestChannelListener listener;
160 161
161 // Set up IPC channel. 162 // Set up IPC channel.
162 std::unique_ptr<IPC::Channel> channel(IPC::Channel::CreateClient( 163 std::unique_ptr<IPC::Channel> channel(IPC::Channel::CreateClient(
163 IPCTestBase::GetChannelName("GenericClient"), &listener)); 164 IPCTestBase::GetChannelName("GenericClient"), &listener));
164 CHECK(channel->Connect()); 165 CHECK(channel->Connect());
165 listener.Init(channel.get()); 166 listener.Init(channel.get());
166 IPC::TestChannelListener::SendOneMessage(channel.get(), "hello from child"); 167 IPC::TestChannelListener::SendOneMessage(channel.get(), "hello from child");
167 168
168 base::MessageLoop::current()->Run(); 169 base::RunLoop().Run();
169 return 0; 170 return 0;
170 } 171 }
171 172
172 } // namespace 173 } // namespace
OLDNEW
« no previous file with comments | « ipc/ipc_channel_proxy_unittest.cc ('k') | ipc/ipc_fuzzing_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698