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

Side by Side Diff: ipc/ipc_fuzzing_tests.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_unittest.cc ('k') | ipc/ipc_perftest_support.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 <stdint.h> 5 #include <stdint.h>
6 #include <stdio.h> 6 #include <stdio.h>
7 7
8 #include <limits> 8 #include <limits>
9 #include <memory> 9 #include <memory>
10 #include <sstream> 10 #include <sstream>
11 #include <string> 11 #include <string>
12 12
13 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
14 #include "base/run_loop.h"
14 #include "base/strings/string16.h" 15 #include "base/strings/string16.h"
15 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
16 #include "base/threading/platform_thread.h" 17 #include "base/threading/platform_thread.h"
17 #include "build/build_config.h" 18 #include "build/build_config.h"
18 #include "ipc/ipc_test_base.h" 19 #include "ipc/ipc_test_base.h"
19 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
20 21
21 // IPC messages for testing ---------------------------------------------------- 22 // IPC messages for testing ----------------------------------------------------
22 23
23 #define IPC_MESSAGE_IMPL 24 #define IPC_MESSAGE_IMPL
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 last_msg_ = NULL; 238 last_msg_ = NULL;
238 return true; 239 return true;
239 } 240 }
240 241
241 bool ExpectMsgNotHandled(uint32_t type_id) { 242 bool ExpectMsgNotHandled(uint32_t type_id) {
242 return ExpectMessage(type_id, MsgUnhandled::ID); 243 return ExpectMessage(type_id, MsgUnhandled::ID);
243 } 244 }
244 245
245 private: 246 private:
246 bool MsgHandlerInternal(uint32_t type_id) { 247 bool MsgHandlerInternal(uint32_t type_id) {
247 base::MessageLoop::current()->Run(); 248 base::RunLoop().Run();
248 if (NULL == last_msg_) 249 if (NULL == last_msg_)
249 return false; 250 return false;
250 if (FUZZER_ROUTING_ID != last_msg_->routing_id()) 251 if (FUZZER_ROUTING_ID != last_msg_->routing_id())
251 return false; 252 return false;
252 return (type_id == last_msg_->type()); 253 return (type_id == last_msg_->type());
253 } 254 }
254 255
255 IPC::Message* last_msg_; 256 IPC::Message* last_msg_;
256 }; 257 };
257 258
258 // Runs the fuzzing server child mode. Returns when the preset number of 259 // Runs the fuzzing server child mode. Returns when the preset number of
259 // messages have been received. 260 // messages have been received.
260 MULTIPROCESS_IPC_TEST_CLIENT_MAIN(FuzzServerClient) { 261 MULTIPROCESS_IPC_TEST_CLIENT_MAIN(FuzzServerClient) {
261 base::MessageLoopForIO main_message_loop; 262 base::MessageLoopForIO main_message_loop;
262 FuzzerServerListener listener; 263 FuzzerServerListener listener;
263 std::unique_ptr<IPC::Channel> channel(IPC::Channel::CreateClient( 264 std::unique_ptr<IPC::Channel> channel(IPC::Channel::CreateClient(
264 IPCTestBase::GetChannelName("FuzzServerClient"), &listener)); 265 IPCTestBase::GetChannelName("FuzzServerClient"), &listener));
265 CHECK(channel->Connect()); 266 CHECK(channel->Connect());
266 listener.Init(channel.get()); 267 listener.Init(channel.get());
267 base::MessageLoop::current()->Run(); 268 base::RunLoop().Run();
268 return 0; 269 return 0;
269 } 270 }
270 271
271 class IPCFuzzingTest : public IPCTestBase { 272 class IPCFuzzingTest : public IPCTestBase {
272 }; 273 };
273 274
274 // This test makes sure that the FuzzerClientListener and FuzzerServerListener 275 // This test makes sure that the FuzzerClientListener and FuzzerServerListener
275 // are working properly by generating two well formed IPC calls. 276 // are working properly by generating two well formed IPC calls.
276 TEST_F(IPCFuzzingTest, SanityTest) { 277 TEST_F(IPCFuzzingTest, SanityTest) {
277 Init("FuzzServerClient"); 278 Init("FuzzServerClient");
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 // thrown out of sync by the extra argument. 352 // thrown out of sync by the extra argument.
352 msg = new MsgClassIS(3, base::ASCIIToUTF16("expect three")); 353 msg = new MsgClassIS(3, base::ASCIIToUTF16("expect three"));
353 sender()->Send(msg); 354 sender()->Send(msg);
354 EXPECT_TRUE(listener.ExpectMessage(3, MsgClassIS::ID)); 355 EXPECT_TRUE(listener.ExpectMessage(3, MsgClassIS::ID));
355 356
356 EXPECT_TRUE(WaitForClientShutdown()); 357 EXPECT_TRUE(WaitForClientShutdown());
357 DestroyChannel(); 358 DestroyChannel();
358 } 359 }
359 360
360 } // namespace 361 } // namespace
OLDNEW
« no previous file with comments | « ipc/ipc_channel_unittest.cc ('k') | ipc/ipc_perftest_support.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698