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 <stdint.h> | 5 #include <stdint.h> |
6 #include <stdio.h> | 6 #include <stdio.h> |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 DispatcherVector dispatchers; | 233 DispatcherVector dispatchers; |
234 uint32_t num_dispatchers = 10; // Maximum number to receive. | 234 uint32_t num_dispatchers = 10; // Maximum number to receive. |
235 CHECK_EQ(mp->ReadMessage(0, UserPointer<void>(&read_buffer[0]), | 235 CHECK_EQ(mp->ReadMessage(0, UserPointer<void>(&read_buffer[0]), |
236 MakeUserPointer(&num_bytes), &dispatchers, | 236 MakeUserPointer(&num_bytes), &dispatchers, |
237 &num_dispatchers, MOJO_READ_MESSAGE_FLAG_NONE), | 237 &num_dispatchers, MOJO_READ_MESSAGE_FLAG_NONE), |
238 MOJO_RESULT_OK); | 238 MOJO_RESULT_OK); |
239 read_buffer.resize(num_bytes); | 239 read_buffer.resize(num_bytes); |
240 CHECK_EQ(read_buffer, std::string("go 1")); | 240 CHECK_EQ(read_buffer, std::string("go 1")); |
241 CHECK_EQ(num_dispatchers, 1u); | 241 CHECK_EQ(num_dispatchers, 1u); |
242 | 242 |
243 CHECK_EQ(dispatchers[0]->GetType(), Dispatcher::kTypeSharedBuffer); | 243 CHECK_EQ(dispatchers[0]->GetType(), Dispatcher::Type::SHARED_BUFFER); |
244 | 244 |
245 scoped_refptr<SharedBufferDispatcher> dispatcher( | 245 scoped_refptr<SharedBufferDispatcher> dispatcher( |
246 static_cast<SharedBufferDispatcher*>(dispatchers[0].get())); | 246 static_cast<SharedBufferDispatcher*>(dispatchers[0].get())); |
247 | 247 |
248 // Make a mapping. | 248 // Make a mapping. |
249 scoped_ptr<embedder::PlatformSharedBufferMapping> mapping; | 249 scoped_ptr<embedder::PlatformSharedBufferMapping> mapping; |
250 CHECK_EQ(dispatcher->MapBuffer(0, 100, MOJO_MAP_BUFFER_FLAG_NONE, &mapping), | 250 CHECK_EQ(dispatcher->MapBuffer(0, 100, MOJO_MAP_BUFFER_FLAG_NONE, &mapping), |
251 MOJO_RESULT_OK); | 251 MOJO_RESULT_OK); |
252 CHECK(mapping); | 252 CHECK(mapping); |
253 CHECK(mapping->GetBase()); | 253 CHECK(mapping->GetBase()); |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 mp->Close(0); | 417 mp->Close(0); |
418 | 418 |
419 read_buffer.resize(num_bytes); | 419 read_buffer.resize(num_bytes); |
420 char hello[32]; | 420 char hello[32]; |
421 int num_handles = 0; | 421 int num_handles = 0; |
422 sscanf(read_buffer.c_str(), "%s %d", hello, &num_handles); | 422 sscanf(read_buffer.c_str(), "%s %d", hello, &num_handles); |
423 CHECK_EQ(std::string("hello"), std::string(hello)); | 423 CHECK_EQ(std::string("hello"), std::string(hello)); |
424 CHECK_GT(num_handles, 0); | 424 CHECK_GT(num_handles, 0); |
425 | 425 |
426 for (int i = 0; i < num_handles; ++i) { | 426 for (int i = 0; i < num_handles; ++i) { |
427 CHECK_EQ(dispatchers[i]->GetType(), Dispatcher::kTypePlatformHandle); | 427 CHECK_EQ(dispatchers[i]->GetType(), Dispatcher::Type::PLATFORM_HANDLE); |
428 | 428 |
429 scoped_refptr<PlatformHandleDispatcher> dispatcher( | 429 scoped_refptr<PlatformHandleDispatcher> dispatcher( |
430 static_cast<PlatformHandleDispatcher*>(dispatchers[i].get())); | 430 static_cast<PlatformHandleDispatcher*>(dispatchers[i].get())); |
431 embedder::ScopedPlatformHandle h = dispatcher->PassPlatformHandle().Pass(); | 431 embedder::ScopedPlatformHandle h = dispatcher->PassPlatformHandle().Pass(); |
432 CHECK(h.is_valid()); | 432 CHECK(h.is_valid()); |
433 dispatcher->Close(); | 433 dispatcher->Close(); |
434 | 434 |
435 base::ScopedFILE fp(mojo::test::FILEFromPlatformHandle(h.Pass(), "r")); | 435 base::ScopedFILE fp(mojo::test::FILEFromPlatformHandle(h.Pass(), "r")); |
436 CHECK(fp); | 436 CHECK(fp); |
437 std::string fread_buffer(100, '\0'); | 437 std::string fread_buffer(100, '\0'); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 // Android multi-process tests are not executing the new process. This is flaky. | 511 // Android multi-process tests are not executing the new process. This is flaky. |
512 #if defined(OS_POSIX) && !defined(OS_ANDROID) | 512 #if defined(OS_POSIX) && !defined(OS_ANDROID) |
513 INSTANTIATE_TEST_CASE_P(PipeCount, | 513 INSTANTIATE_TEST_CASE_P(PipeCount, |
514 MultiprocessMessagePipeTestWithPipeCount, | 514 MultiprocessMessagePipeTestWithPipeCount, |
515 testing::Values(1u, 128u, 255u)); | 515 testing::Values(1u, 128u, 255u)); |
516 #endif | 516 #endif |
517 | 517 |
518 } // namespace | 518 } // namespace |
519 } // namespace system | 519 } // namespace system |
520 } // namespace mojo | 520 } // namespace mojo |
OLD | NEW |