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

Unified Diff: mojo/system/raw_channel_posix_unittest.cc

Issue 173333002: Mojo: Make MessageInTransit more opaque still. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/system/raw_channel_posix.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/system/raw_channel_posix_unittest.cc
diff --git a/mojo/system/raw_channel_posix_unittest.cc b/mojo/system/raw_channel_posix_unittest.cc
index 75470213f138a76beec3d240c6aab4fa567d0016..ab80487ccbc81bf90c3e3afeb0ee37c6e5019d7f 100644
--- a/mojo/system/raw_channel_posix_unittest.cc
+++ b/mojo/system/raw_channel_posix_unittest.cc
@@ -145,20 +145,21 @@ class TestMessageReaderAndChecker {
bytes_.insert(bytes_.end(), buffer, buffer + read_size);
// If we have the header....
- if (bytes_.size() >= sizeof(MessageInTransit)) {
- const MessageInTransit* message =
- reinterpret_cast<const MessageInTransit*>(bytes_.data());
- CHECK_EQ(reinterpret_cast<size_t>(message) %
- MessageInTransit::kMessageAlignment, 0u);
-
- if (message->data_size() != expected_size) {
- LOG(ERROR) << "Wrong size: " << message->data_size() << " instead of "
- << expected_size << " bytes.";
- return false;
- }
-
+ size_t message_size;
+ if (MessageInTransit::GetNextMessageSize(bytes_.data(), bytes_.size(),
+ &message_size)) {
// If we've read the whole message....
- if (bytes_.size() >= message->main_buffer_size()) {
+ if (bytes_.size() >= message_size) {
+ const MessageInTransit* message =
+ MessageInTransit::CreateReadOnlyFromBuffer(bytes_.data());
+ CHECK_EQ(message->main_buffer_size(), message_size);
+
+ if (message->data_size() != expected_size) {
+ LOG(ERROR) << "Wrong size: " << message_size << " instead of "
+ << expected_size << " bytes.";
+ return false;
+ }
+
if (!CheckMessageData(message->data(), message->data_size())) {
LOG(ERROR) << "Incorrect message data.";
return false;
« no previous file with comments | « mojo/system/raw_channel_posix.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698