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

Side by Side Diff: ipc/ipc_channel_proxy_unittest.cc

Issue 1914143004: Re-enable multi-process IPC tests on Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mojo-android-tests
Patch Set: Rebase for commit. Created 4 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 | « ipc/ipc_channel_posix_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 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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <memory> 9 #include <memory>
10 10
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 266
267 bool DidListenerGetBadMessage() { 267 bool DidListenerGetBadMessage() {
268 return listener_->bad_message_received_; 268 return listener_->bad_message_received_;
269 } 269 }
270 270
271 private: 271 private:
272 std::unique_ptr<base::Thread> thread_; 272 std::unique_ptr<base::Thread> thread_;
273 std::unique_ptr<QuitListener> listener_; 273 std::unique_ptr<QuitListener> listener_;
274 }; 274 };
275 275
276 #if defined(OS_ANDROID) 276 TEST_F(IPCChannelProxyTest, MessageClassFilters) {
277 #define MAYBE_MessageClassFilters DISABLED_MessageClassFilters
278 #else
279 #define MAYBE_MessageClassFilters MessageClassFilters
280 #endif
281 TEST_F(IPCChannelProxyTest, MAYBE_MessageClassFilters) {
282 // Construct a filter per message class. 277 // Construct a filter per message class.
283 std::vector<scoped_refptr<MessageCountFilter> > class_filters; 278 std::vector<scoped_refptr<MessageCountFilter> > class_filters;
284 class_filters.push_back(make_scoped_refptr( 279 class_filters.push_back(make_scoped_refptr(
285 new MessageCountFilter(TestMsgStart))); 280 new MessageCountFilter(TestMsgStart)));
286 class_filters.push_back(make_scoped_refptr( 281 class_filters.push_back(make_scoped_refptr(
287 new MessageCountFilter(UtilityMsgStart))); 282 new MessageCountFilter(UtilityMsgStart)));
288 for (size_t i = 0; i < class_filters.size(); ++i) 283 for (size_t i = 0; i < class_filters.size(); ++i)
289 channel_proxy()->AddFilter(class_filters[i].get()); 284 channel_proxy()->AddFilter(class_filters[i].get());
290 285
291 // Send a message for each class; each filter should receive just one message. 286 // Send a message for each class; each filter should receive just one message.
292 sender()->Send(new TestMsg_Bounce()); 287 sender()->Send(new TestMsg_Bounce());
293 sender()->Send(new UtilityMsg_Bounce()); 288 sender()->Send(new UtilityMsg_Bounce());
294 289
295 // Send some messages not assigned to a specific or valid message class. 290 // Send some messages not assigned to a specific or valid message class.
296 sender()->Send(new WorkerMsg_Bounce); 291 sender()->Send(new WorkerMsg_Bounce);
297 292
298 // Each filter should have received just the one sent message of the 293 // Each filter should have received just the one sent message of the
299 // corresponding class. 294 // corresponding class.
300 SendQuitMessageAndWaitForIdle(); 295 SendQuitMessageAndWaitForIdle();
301 for (size_t i = 0; i < class_filters.size(); ++i) 296 for (size_t i = 0; i < class_filters.size(); ++i)
302 EXPECT_EQ(1U, class_filters[i]->messages_received()); 297 EXPECT_EQ(1U, class_filters[i]->messages_received());
303 } 298 }
304 299
305 #if defined(OS_ANDROID) 300 TEST_F(IPCChannelProxyTest, GlobalAndMessageClassFilters) {
306 #define MAYBE_GlobalAndMessageClassFilters DISABLED_GlobalAndMessageClassFilters
307 #else
308 #define MAYBE_GlobalAndMessageClassFilters GlobalAndMessageClassFilters
309 #endif
310 TEST_F(IPCChannelProxyTest, MAYBE_GlobalAndMessageClassFilters) {
311 // Add a class and global filter. 301 // Add a class and global filter.
312 scoped_refptr<MessageCountFilter> class_filter( 302 scoped_refptr<MessageCountFilter> class_filter(
313 new MessageCountFilter(TestMsgStart)); 303 new MessageCountFilter(TestMsgStart));
314 class_filter->set_message_filtering_enabled(false); 304 class_filter->set_message_filtering_enabled(false);
315 channel_proxy()->AddFilter(class_filter.get()); 305 channel_proxy()->AddFilter(class_filter.get());
316 306
317 scoped_refptr<MessageCountFilter> global_filter(new MessageCountFilter()); 307 scoped_refptr<MessageCountFilter> global_filter(new MessageCountFilter());
318 global_filter->set_message_filtering_enabled(false); 308 global_filter->set_message_filtering_enabled(false);
319 channel_proxy()->AddFilter(global_filter.get()); 309 channel_proxy()->AddFilter(global_filter.get());
320 310
321 // A message of class Test should be seen by both the global filter and 311 // A message of class Test should be seen by both the global filter and
322 // Test-specific filter. 312 // Test-specific filter.
323 sender()->Send(new TestMsg_Bounce); 313 sender()->Send(new TestMsg_Bounce);
324 314
325 // A message of a different class should be seen only by the global filter. 315 // A message of a different class should be seen only by the global filter.
326 sender()->Send(new UtilityMsg_Bounce); 316 sender()->Send(new UtilityMsg_Bounce);
327 317
328 // Flush all messages. 318 // Flush all messages.
329 SendQuitMessageAndWaitForIdle(); 319 SendQuitMessageAndWaitForIdle();
330 320
331 // The class filter should have received only the class-specific message. 321 // The class filter should have received only the class-specific message.
332 EXPECT_EQ(1U, class_filter->messages_received()); 322 EXPECT_EQ(1U, class_filter->messages_received());
333 323
334 // The global filter should have received both messages, as well as the final 324 // The global filter should have received both messages, as well as the final
335 // QUIT message. 325 // QUIT message.
336 EXPECT_EQ(3U, global_filter->messages_received()); 326 EXPECT_EQ(3U, global_filter->messages_received());
337 } 327 }
338 328
339 #if defined(OS_ANDROID) 329 TEST_F(IPCChannelProxyTest, FilterRemoval) {
340 #define MAYBE_FilterRemoval DISABLED_FilterRemoval
341 #else
342 #define MAYBE_FilterRemoval FilterRemoval
343 #endif
344 TEST_F(IPCChannelProxyTest, MAYBE_FilterRemoval) {
345 // Add a class and global filter. 330 // Add a class and global filter.
346 scoped_refptr<MessageCountFilter> class_filter( 331 scoped_refptr<MessageCountFilter> class_filter(
347 new MessageCountFilter(TestMsgStart)); 332 new MessageCountFilter(TestMsgStart));
348 scoped_refptr<MessageCountFilter> global_filter(new MessageCountFilter()); 333 scoped_refptr<MessageCountFilter> global_filter(new MessageCountFilter());
349 334
350 // Add and remove both types of filters. 335 // Add and remove both types of filters.
351 channel_proxy()->AddFilter(class_filter.get()); 336 channel_proxy()->AddFilter(class_filter.get());
352 channel_proxy()->AddFilter(global_filter.get()); 337 channel_proxy()->AddFilter(global_filter.get());
353 channel_proxy()->RemoveFilter(global_filter.get()); 338 channel_proxy()->RemoveFilter(global_filter.get());
354 channel_proxy()->RemoveFilter(class_filter.get()); 339 channel_proxy()->RemoveFilter(class_filter.get());
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 std::unique_ptr<IPC::Channel> channel(IPC::Channel::CreateClient( 429 std::unique_ptr<IPC::Channel> channel(IPC::Channel::CreateClient(
445 IPCTestBase::GetChannelName("ChannelProxyClient"), &listener)); 430 IPCTestBase::GetChannelName("ChannelProxyClient"), &listener));
446 CHECK(channel->Connect()); 431 CHECK(channel->Connect());
447 listener.Init(channel.get()); 432 listener.Init(channel.get());
448 433
449 base::MessageLoop::current()->Run(); 434 base::MessageLoop::current()->Run();
450 return 0; 435 return 0;
451 } 436 }
452 437
453 } // namespace 438 } // namespace
OLDNEW
« no previous file with comments | « ipc/ipc_channel_posix_unittest.cc ('k') | ipc/ipc_fuzzing_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698