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

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

Issue 597413002: Mojo: NULL -> nullptr in mojo/system and mojo/embedder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: EXPECT_TRUE Created 6 years, 3 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/system/core_test_base.cc ('k') | mojo/system/data_pipe.cc » ('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 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 #include "mojo/system/core.h" 5 #include "mojo/system/core.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <limits> 9 #include <limits>
10 10
(...skipping 1079 matching lines...) Expand 10 before | Expand all | Expand 10 after
1090 num_bytes = 1u; 1090 num_bytes = 1u;
1091 EXPECT_EQ(MOJO_RESULT_OK, 1091 EXPECT_EQ(MOJO_RESULT_OK,
1092 core()->ReadData(ch, 1092 core()->ReadData(ch,
1093 UserPointer<void>(elements), 1093 UserPointer<void>(elements),
1094 MakeUserPointer(&num_bytes), 1094 MakeUserPointer(&num_bytes),
1095 MOJO_READ_DATA_FLAG_NONE)); 1095 MOJO_READ_DATA_FLAG_NONE));
1096 EXPECT_EQ('A', elements[0]); 1096 EXPECT_EQ('A', elements[0]);
1097 EXPECT_EQ(-1, elements[1]); 1097 EXPECT_EQ(-1, elements[1]);
1098 1098
1099 // Two-phase write. 1099 // Two-phase write.
1100 void* write_ptr = NULL; 1100 void* write_ptr = nullptr;
1101 num_bytes = 0u; 1101 num_bytes = 0u;
1102 ASSERT_EQ(MOJO_RESULT_OK, 1102 ASSERT_EQ(MOJO_RESULT_OK,
1103 core()->BeginWriteData(ph, 1103 core()->BeginWriteData(ph,
1104 MakeUserPointer(&write_ptr), 1104 MakeUserPointer(&write_ptr),
1105 MakeUserPointer(&num_bytes), 1105 MakeUserPointer(&num_bytes),
1106 MOJO_WRITE_DATA_FLAG_NONE)); 1106 MOJO_WRITE_DATA_FLAG_NONE));
1107 // We count on the default options providing a decent buffer size. 1107 // We count on the default options providing a decent buffer size.
1108 ASSERT_GE(num_bytes, 3u); 1108 ASSERT_GE(num_bytes, 3u);
1109 1109
1110 // Trying to do a normal write during a two-phase write should fail. 1110 // Trying to do a normal write during a two-phase write should fail.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1143 // Discard two characters. 1143 // Discard two characters.
1144 num_bytes = 2; 1144 num_bytes = 2;
1145 EXPECT_EQ(MOJO_RESULT_OK, 1145 EXPECT_EQ(MOJO_RESULT_OK,
1146 core()->ReadData( 1146 core()->ReadData(
1147 ch, 1147 ch,
1148 NullUserPointer(), 1148 NullUserPointer(),
1149 MakeUserPointer(&num_bytes), 1149 MakeUserPointer(&num_bytes),
1150 MOJO_READ_DATA_FLAG_DISCARD | MOJO_READ_DATA_FLAG_ALL_OR_NONE)); 1150 MOJO_READ_DATA_FLAG_DISCARD | MOJO_READ_DATA_FLAG_ALL_OR_NONE));
1151 1151
1152 // Read the remaining two characters, in two-phase mode (all-or-none). 1152 // Read the remaining two characters, in two-phase mode (all-or-none).
1153 const void* read_ptr = NULL; 1153 const void* read_ptr = nullptr;
1154 num_bytes = 2; 1154 num_bytes = 2;
1155 ASSERT_EQ(MOJO_RESULT_OK, 1155 ASSERT_EQ(MOJO_RESULT_OK,
1156 core()->BeginReadData(ch, 1156 core()->BeginReadData(ch,
1157 MakeUserPointer(&read_ptr), 1157 MakeUserPointer(&read_ptr),
1158 MakeUserPointer(&num_bytes), 1158 MakeUserPointer(&num_bytes),
1159 MOJO_READ_DATA_FLAG_ALL_OR_NONE)); 1159 MOJO_READ_DATA_FLAG_ALL_OR_NONE));
1160 // Note: Count on still being able to do the contiguous read here. 1160 // Note: Count on still being able to do the contiguous read here.
1161 ASSERT_EQ(2u, num_bytes); 1161 ASSERT_EQ(2u, num_bytes);
1162 1162
1163 // Discarding right now should fail. 1163 // Discarding right now should fail.
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
1354 MOJO_READ_MESSAGE_FLAG_NONE)); 1354 MOJO_READ_MESSAGE_FLAG_NONE));
1355 EXPECT_EQ(kHelloSize, num_bytes); 1355 EXPECT_EQ(kHelloSize, num_bytes);
1356 EXPECT_STREQ(kHello, buffer); 1356 EXPECT_STREQ(kHello, buffer);
1357 1357
1358 ph = ph_received; 1358 ph = ph_received;
1359 ph_received = MOJO_HANDLE_INVALID; 1359 ph_received = MOJO_HANDLE_INVALID;
1360 ch = ch_received; 1360 ch = ch_received;
1361 ch_received = MOJO_HANDLE_INVALID; 1361 ch_received = MOJO_HANDLE_INVALID;
1362 1362
1363 // Make sure that |ph| can't be sent if it's in a two-phase write. 1363 // Make sure that |ph| can't be sent if it's in a two-phase write.
1364 void* write_ptr = NULL; 1364 void* write_ptr = nullptr;
1365 num_bytes = 0; 1365 num_bytes = 0;
1366 ASSERT_EQ(MOJO_RESULT_OK, 1366 ASSERT_EQ(MOJO_RESULT_OK,
1367 core()->BeginWriteData(ph, 1367 core()->BeginWriteData(ph,
1368 MakeUserPointer(&write_ptr), 1368 MakeUserPointer(&write_ptr),
1369 MakeUserPointer(&num_bytes), 1369 MakeUserPointer(&num_bytes),
1370 MOJO_WRITE_DATA_FLAG_NONE)); 1370 MOJO_WRITE_DATA_FLAG_NONE));
1371 ASSERT_GE(num_bytes, 1u); 1371 ASSERT_GE(num_bytes, 1u);
1372 EXPECT_EQ(MOJO_RESULT_BUSY, 1372 EXPECT_EQ(MOJO_RESULT_BUSY,
1373 core()->WriteMessage(h_passing[0], 1373 core()->WriteMessage(h_passing[0],
1374 UserPointer<const void>(kHello), 1374 UserPointer<const void>(kHello),
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1413 // Wait for |ch| to be readable. 1413 // Wait for |ch| to be readable.
1414 hss = kEmptyMojoHandleSignalsState; 1414 hss = kEmptyMojoHandleSignalsState;
1415 EXPECT_EQ( 1415 EXPECT_EQ(
1416 MOJO_RESULT_OK, 1416 MOJO_RESULT_OK,
1417 core()->Wait( 1417 core()->Wait(
1418 ch, MOJO_HANDLE_SIGNAL_READABLE, 1000000000, MakeUserPointer(&hss))); 1418 ch, MOJO_HANDLE_SIGNAL_READABLE, 1000000000, MakeUserPointer(&hss)));
1419 EXPECT_EQ(MOJO_HANDLE_SIGNAL_READABLE, hss.satisfied_signals); 1419 EXPECT_EQ(MOJO_HANDLE_SIGNAL_READABLE, hss.satisfied_signals);
1420 EXPECT_EQ(MOJO_HANDLE_SIGNAL_READABLE, hss.satisfiable_signals); 1420 EXPECT_EQ(MOJO_HANDLE_SIGNAL_READABLE, hss.satisfiable_signals);
1421 1421
1422 // Make sure that |ch| can't be sent if it's in a two-phase read. 1422 // Make sure that |ch| can't be sent if it's in a two-phase read.
1423 const void* read_ptr = NULL; 1423 const void* read_ptr = nullptr;
1424 num_bytes = 1; 1424 num_bytes = 1;
1425 ASSERT_EQ(MOJO_RESULT_OK, 1425 ASSERT_EQ(MOJO_RESULT_OK,
1426 core()->BeginReadData(ch, 1426 core()->BeginReadData(ch,
1427 MakeUserPointer(&read_ptr), 1427 MakeUserPointer(&read_ptr),
1428 MakeUserPointer(&num_bytes), 1428 MakeUserPointer(&num_bytes),
1429 MOJO_READ_DATA_FLAG_ALL_OR_NONE)); 1429 MOJO_READ_DATA_FLAG_ALL_OR_NONE));
1430 EXPECT_EQ(MOJO_RESULT_BUSY, 1430 EXPECT_EQ(MOJO_RESULT_BUSY,
1431 core()->WriteMessage(h_passing[0], 1431 core()->WriteMessage(h_passing[0],
1432 UserPointer<const void>(kHello), 1432 UserPointer<const void>(kHello),
1433 kHelloSize, 1433 kHelloSize,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1477 EXPECT_EQ(MOJO_RESULT_OK, core()->Close(h_passing[1])); 1477 EXPECT_EQ(MOJO_RESULT_OK, core()->Close(h_passing[1]));
1478 EXPECT_EQ(MOJO_RESULT_OK, core()->Close(ph)); 1478 EXPECT_EQ(MOJO_RESULT_OK, core()->Close(ph));
1479 EXPECT_EQ(MOJO_RESULT_OK, core()->Close(ch)); 1479 EXPECT_EQ(MOJO_RESULT_OK, core()->Close(ch));
1480 } 1480 }
1481 1481
1482 // TODO(vtl): Test |DuplicateBufferHandle()| and |MapBuffer()|. 1482 // TODO(vtl): Test |DuplicateBufferHandle()| and |MapBuffer()|.
1483 1483
1484 } // namespace 1484 } // namespace
1485 } // namespace system 1485 } // namespace system
1486 } // namespace mojo 1486 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/system/core_test_base.cc ('k') | mojo/system/data_pipe.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698