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

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

Issue 1932083002: Mojo: Use new message APIs to reduce copying (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 4 years, 7 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 unified diff | Download patch
« no previous file with comments | « mojo/public/cpp/bindings/tests/connector_unittest.cc ('k') | mojo/public/cpp/system/BUILD.gn » ('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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 #include <stdio.h> 7 #include <stdio.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 std::vector<uint8_t> data; 148 std::vector<uint8_t> data;
149 size_t num_handles; 149 size_t num_handles;
150 if (!ReadAndParseDataFile(GetPath(test, ".data"), &data, &num_handles) || 150 if (!ReadAndParseDataFile(GetPath(test, ".data"), &data, &num_handles) ||
151 !ReadResultFile(GetPath(test, ".expected"), expected)) { 151 !ReadResultFile(GetPath(test, ".expected"), expected)) {
152 return false; 152 return false;
153 } 153 }
154 154
155 message->Initialize(static_cast<uint32_t>(data.size()), 155 message->Initialize(static_cast<uint32_t>(data.size()),
156 false /* zero_initialized */); 156 false /* zero_initialized */);
157 if (!data.empty()) 157 if (!data.empty())
158 memcpy(message->buffer()->Allocate(data.size()), &data[0], data.size()); 158 memcpy(message->mutable_data(), &data[0], data.size());
159 message->mutable_handles()->resize(num_handles); 159 message->mutable_handles()->resize(num_handles);
160 160
161 return true; 161 return true;
162 } 162 }
163 163
164 void RunValidationTests(const std::string& prefix, 164 void RunValidationTests(const std::string& prefix,
165 MessageReceiver* test_message_receiver) { 165 MessageReceiver* test_message_receiver) {
166 std::vector<std::string> names = 166 std::vector<std::string> names =
167 EnumerateSourceRootRelativeDirectory(GetPath("", "")); 167 EnumerateSourceRootRelativeDirectory(GetPath("", ""));
168 std::vector<std::string> tests = GetMatchingTests(names, prefix); 168 std::vector<std::string> tests = GetMatchingTests(names, prefix);
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 EXPECT_TRUE(IsKnownEnumValue(static_cast<StructWithEnum::EnumWithin>(0))); 490 EXPECT_TRUE(IsKnownEnumValue(static_cast<StructWithEnum::EnumWithin>(0)));
491 EXPECT_TRUE(IsKnownEnumValue(static_cast<StructWithEnum::EnumWithin>(1))); 491 EXPECT_TRUE(IsKnownEnumValue(static_cast<StructWithEnum::EnumWithin>(1)));
492 EXPECT_TRUE(IsKnownEnumValue(static_cast<StructWithEnum::EnumWithin>(2))); 492 EXPECT_TRUE(IsKnownEnumValue(static_cast<StructWithEnum::EnumWithin>(2)));
493 EXPECT_TRUE(IsKnownEnumValue(static_cast<StructWithEnum::EnumWithin>(3))); 493 EXPECT_TRUE(IsKnownEnumValue(static_cast<StructWithEnum::EnumWithin>(3)));
494 EXPECT_FALSE(IsKnownEnumValue(static_cast<StructWithEnum::EnumWithin>(4))); 494 EXPECT_FALSE(IsKnownEnumValue(static_cast<StructWithEnum::EnumWithin>(4)));
495 } 495 }
496 496
497 } // namespace 497 } // namespace
498 } // namespace test 498 } // namespace test
499 } // namespace mojo 499 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/tests/connector_unittest.cc ('k') | mojo/public/cpp/system/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698