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

Side by Side Diff: mojo/public/cpp/bindings/tests/validation_unittest.cc

Issue 1524613002: [mojo] Use base::Pickle for Message storage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: happy compiler happy robots Created 5 years 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 | « mojo/public/cpp/bindings/message.h ('k') | third_party/mojo/mojo_public.gyp » ('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 <stdio.h> 5 #include <stdio.h>
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 bool ReadTestCase(const std::string& test, 141 bool ReadTestCase(const std::string& test,
142 Message* message, 142 Message* message,
143 std::string* expected) { 143 std::string* expected) {
144 std::vector<uint8_t> data; 144 std::vector<uint8_t> data;
145 size_t num_handles; 145 size_t num_handles;
146 if (!ReadAndParseDataFile(GetPath(test, ".data"), &data, &num_handles) || 146 if (!ReadAndParseDataFile(GetPath(test, ".data"), &data, &num_handles) ||
147 !ReadResultFile(GetPath(test, ".expected"), expected)) { 147 !ReadResultFile(GetPath(test, ".expected"), expected)) {
148 return false; 148 return false;
149 } 149 }
150 150
151 message->AllocUninitializedData(static_cast<uint32_t>(data.size())); 151 message->Initialize(static_cast<uint32_t>(data.size()),
152 false /* zero_initialized */);
152 if (!data.empty()) 153 if (!data.empty())
153 memcpy(message->mutable_data(), &data[0], data.size()); 154 memcpy(message->buffer()->Allocate(data.size()), &data[0], data.size());
154 message->mutable_handles()->resize(num_handles); 155 message->mutable_handles()->resize(num_handles);
155 156
156 return true; 157 return true;
157 } 158 }
158 159
159 void RunValidationTests(const std::string& prefix, 160 void RunValidationTests(const std::string& prefix,
160 MessageReceiver* test_message_receiver) { 161 MessageReceiver* test_message_receiver) {
161 std::vector<std::string> names = 162 std::vector<std::string> names =
162 EnumerateSourceRootRelativeDirectory(GetPath("", "")); 163 EnumerateSourceRootRelativeDirectory(GetPath("", ""));
163 std::vector<std::string> tests = GetMatchingTests(names, prefix); 164 std::vector<std::string> tests = GetMatchingTests(names, prefix);
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 static_cast<StructWithEnum::EnumWithin>(2))); 484 static_cast<StructWithEnum::EnumWithin>(2)));
484 EXPECT_TRUE(StructWithEnum::EnumWithin_IsValidValue( 485 EXPECT_TRUE(StructWithEnum::EnumWithin_IsValidValue(
485 static_cast<StructWithEnum::EnumWithin>(3))); 486 static_cast<StructWithEnum::EnumWithin>(3)));
486 EXPECT_FALSE(StructWithEnum::EnumWithin_IsValidValue( 487 EXPECT_FALSE(StructWithEnum::EnumWithin_IsValidValue(
487 static_cast<StructWithEnum::EnumWithin>(4))); 488 static_cast<StructWithEnum::EnumWithin>(4)));
488 } 489 }
489 490
490 } // namespace 491 } // namespace
491 } // namespace test 492 } // namespace test
492 } // namespace mojo 493 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/message.h ('k') | third_party/mojo/mojo_public.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698