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

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: 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
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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
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->AllocUninitializedData(static_cast<uint32_t>(data.size()));
152 if (!data.empty()) 152 if (!data.empty())
153 memcpy(message->mutable_data(), &data[0], data.size()); 153 memcpy(message->buffer()->Allocate(data.size()), &data[0], data.size());
154 message->mutable_handles()->resize(num_handles); 154 message->mutable_handles()->resize(num_handles);
155 155
156 return true; 156 return true;
157 } 157 }
158 158
159 void RunValidationTests(const std::string& prefix, 159 void RunValidationTests(const std::string& prefix,
160 MessageReceiver* test_message_receiver) { 160 MessageReceiver* test_message_receiver) {
161 std::vector<std::string> names = 161 std::vector<std::string> names =
162 EnumerateSourceRootRelativeDirectory(GetPath("", "")); 162 EnumerateSourceRootRelativeDirectory(GetPath("", ""));
163 std::vector<std::string> tests = GetMatchingTests(names, prefix); 163 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))); 483 static_cast<StructWithEnum::EnumWithin>(2)));
484 EXPECT_TRUE(StructWithEnum::EnumWithin_IsValidValue( 484 EXPECT_TRUE(StructWithEnum::EnumWithin_IsValidValue(
485 static_cast<StructWithEnum::EnumWithin>(3))); 485 static_cast<StructWithEnum::EnumWithin>(3)));
486 EXPECT_FALSE(StructWithEnum::EnumWithin_IsValidValue( 486 EXPECT_FALSE(StructWithEnum::EnumWithin_IsValidValue(
487 static_cast<StructWithEnum::EnumWithin>(4))); 487 static_cast<StructWithEnum::EnumWithin>(4)));
488 } 488 }
489 489
490 } // namespace 490 } // namespace
491 } // namespace test 491 } // namespace test
492 } // namespace mojo 492 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698