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

Side by Side Diff: mojo/system/raw_channel_posix_unittest.cc

Issue 60103005: Mojo: First stab at making MessagePipes work across OS pipes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
OLDNEW
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 // TODO(vtl): Factor out the POSIX-specific bits of this test (once we have a 5 // TODO(vtl): Factor out the POSIX-specific bits of this test (once we have a
6 // non-POSIX implementation). 6 // non-POSIX implementation).
7 7
8 #include "mojo/system/raw_channel.h" 8 #include "mojo/system/raw_channel.h"
9 9
10 #include <fcntl.h> 10 #include <fcntl.h>
(...skipping 27 matching lines...) Expand all
38 #include "testing/gtest/include/gtest/gtest.h" 38 #include "testing/gtest/include/gtest/gtest.h"
39 39
40 namespace mojo { 40 namespace mojo {
41 namespace system { 41 namespace system {
42 namespace { 42 namespace {
43 43
44 MessageInTransit* MakeTestMessage(uint32_t num_bytes) { 44 MessageInTransit* MakeTestMessage(uint32_t num_bytes) {
45 std::vector<unsigned char> bytes(num_bytes, 0); 45 std::vector<unsigned char> bytes(num_bytes, 0);
46 for (size_t i = 0; i < num_bytes; i++) 46 for (size_t i = 0; i < num_bytes; i++)
47 bytes[i] = static_cast<unsigned char>(i + num_bytes); 47 bytes[i] = static_cast<unsigned char>(i + num_bytes);
48 return MessageInTransit::Create(bytes.data(), num_bytes); 48 return MessageInTransit::Create(
49 MessageInTransit::TYPE_MESSAGE_PIPE_ENDPOINT,
50 MessageInTransit::SUBTYPE_MESSAGE_PIPE_ENDPOINT_DATA,
51 bytes.data(), num_bytes);
49 } 52 }
50 53
51 bool CheckMessageData(const void* bytes, uint32_t num_bytes) { 54 bool CheckMessageData(const void* bytes, uint32_t num_bytes) {
52 const unsigned char* b = static_cast<const unsigned char*>(bytes); 55 const unsigned char* b = static_cast<const unsigned char*>(bytes);
53 for (uint32_t i = 0; i < num_bytes; i++) { 56 for (uint32_t i = 0; i < num_bytes; i++) {
54 if (b[i] != static_cast<unsigned char>(i + num_bytes)) 57 if (b[i] != static_cast<unsigned char>(i + num_bytes))
55 return false; 58 return false;
56 } 59 }
57 return true; 60 return true;
58 } 61 }
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 FROM_HERE, 554 FROM_HERE,
552 base::Bind(&RawChannel::Shutdown, 555 base::Bind(&RawChannel::Shutdown,
553 base::Unretained(rc.get()))); 556 base::Unretained(rc.get())));
554 557
555 EXPECT_FALSE(rc->WriteMessage(MakeTestMessage(1))); 558 EXPECT_FALSE(rc->WriteMessage(MakeTestMessage(1)));
556 } 559 }
557 560
558 } // namespace 561 } // namespace
559 } // namespace system 562 } // namespace system
560 } // namespace mojo 563 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698