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

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

Issue 703273002: Update mojo sdk to rev 04a510fb37db10642e156957f9b2c11c2f6442ac (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix content/child -> mojo/common linking Created 6 years, 1 month 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/edk/system/channel_info.cc ('k') | mojo/edk/system/data_pipe.h » ('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/edk/system/core.h" 5 #include "mojo/edk/system/core.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <limits> 9 #include <limits>
10 10
(...skipping 1066 matching lines...) Expand 10 before | Expand all | Expand 10 after
1077 EXPECT_EQ(2u, num_bytes); 1077 EXPECT_EQ(2u, num_bytes);
1078 1078
1079 // Consumer should now be readable. 1079 // Consumer should now be readable.
1080 hss = kEmptyMojoHandleSignalsState; 1080 hss = kEmptyMojoHandleSignalsState;
1081 EXPECT_EQ( 1081 EXPECT_EQ(
1082 MOJO_RESULT_OK, 1082 MOJO_RESULT_OK,
1083 core()->Wait(ch, MOJO_HANDLE_SIGNAL_READABLE, 0, MakeUserPointer(&hss))); 1083 core()->Wait(ch, MOJO_HANDLE_SIGNAL_READABLE, 0, MakeUserPointer(&hss)));
1084 EXPECT_EQ(MOJO_HANDLE_SIGNAL_READABLE, hss.satisfied_signals); 1084 EXPECT_EQ(MOJO_HANDLE_SIGNAL_READABLE, hss.satisfied_signals);
1085 EXPECT_EQ(MOJO_HANDLE_SIGNAL_READABLE, hss.satisfiable_signals); 1085 EXPECT_EQ(MOJO_HANDLE_SIGNAL_READABLE, hss.satisfiable_signals);
1086 1086
1087 // Peek one character.
1088 elements[0] = -1;
1089 elements[1] = -1;
1090 num_bytes = 1u;
1091 EXPECT_EQ(MOJO_RESULT_OK,
1092 core()->ReadData(
1093 ch,
1094 UserPointer<void>(elements),
1095 MakeUserPointer(&num_bytes),
1096 MOJO_READ_DATA_FLAG_NONE | MOJO_READ_DATA_FLAG_PEEK));
1097 EXPECT_EQ('A', elements[0]);
1098 EXPECT_EQ(-1, elements[1]);
1099
1087 // Read one character. 1100 // Read one character.
1088 elements[0] = -1; 1101 elements[0] = -1;
1089 elements[1] = -1; 1102 elements[1] = -1;
1090 num_bytes = 1u; 1103 num_bytes = 1u;
1091 EXPECT_EQ(MOJO_RESULT_OK, 1104 EXPECT_EQ(MOJO_RESULT_OK,
1092 core()->ReadData(ch, 1105 core()->ReadData(ch,
1093 UserPointer<void>(elements), 1106 UserPointer<void>(elements),
1094 MakeUserPointer(&num_bytes), 1107 MakeUserPointer(&num_bytes),
1095 MOJO_READ_DATA_FLAG_NONE)); 1108 MOJO_READ_DATA_FLAG_NONE));
1096 EXPECT_EQ('A', elements[0]); 1109 EXPECT_EQ('A', elements[0]);
(...skipping 27 matching lines...) Expand all
1124 1137
1125 // Query how much data we have. 1138 // Query how much data we have.
1126 num_bytes = 0; 1139 num_bytes = 0;
1127 EXPECT_EQ(MOJO_RESULT_OK, 1140 EXPECT_EQ(MOJO_RESULT_OK,
1128 core()->ReadData(ch, 1141 core()->ReadData(ch,
1129 NullUserPointer(), 1142 NullUserPointer(),
1130 MakeUserPointer(&num_bytes), 1143 MakeUserPointer(&num_bytes),
1131 MOJO_READ_DATA_FLAG_QUERY)); 1144 MOJO_READ_DATA_FLAG_QUERY));
1132 EXPECT_EQ(4u, num_bytes); 1145 EXPECT_EQ(4u, num_bytes);
1133 1146
1147 // Try to query with peek. Should fail.
1148 num_bytes = 0;
1149 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT,
1150 core()->ReadData(
1151 ch,
1152 NullUserPointer(),
1153 MakeUserPointer(&num_bytes),
1154 MOJO_READ_DATA_FLAG_QUERY | MOJO_READ_DATA_FLAG_PEEK));
1155 EXPECT_EQ(0u, num_bytes);
1156
1134 // Try to discard ten characters, in all-or-none mode. Should fail. 1157 // Try to discard ten characters, in all-or-none mode. Should fail.
1135 num_bytes = 10; 1158 num_bytes = 10;
1136 EXPECT_EQ(MOJO_RESULT_OUT_OF_RANGE, 1159 EXPECT_EQ(MOJO_RESULT_OUT_OF_RANGE,
1137 core()->ReadData( 1160 core()->ReadData(
1138 ch, 1161 ch,
1139 NullUserPointer(), 1162 NullUserPointer(),
1140 MakeUserPointer(&num_bytes), 1163 MakeUserPointer(&num_bytes),
1141 MOJO_READ_DATA_FLAG_DISCARD | MOJO_READ_DATA_FLAG_ALL_OR_NONE)); 1164 MOJO_READ_DATA_FLAG_DISCARD | MOJO_READ_DATA_FLAG_ALL_OR_NONE));
1142 1165
1166 // Try to discard two characters, in peek mode. Should fail.
1167 num_bytes = 2;
1168 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT,
1169 core()->ReadData(
1170 ch,
1171 NullUserPointer(),
1172 MakeUserPointer(&num_bytes),
1173 MOJO_READ_DATA_FLAG_DISCARD | MOJO_READ_DATA_FLAG_PEEK));
1174
1143 // Discard two characters. 1175 // Discard two characters.
1144 num_bytes = 2; 1176 num_bytes = 2;
1145 EXPECT_EQ(MOJO_RESULT_OK, 1177 EXPECT_EQ(MOJO_RESULT_OK,
1146 core()->ReadData( 1178 core()->ReadData(
1147 ch, 1179 ch,
1148 NullUserPointer(), 1180 NullUserPointer(),
1149 MakeUserPointer(&num_bytes), 1181 MakeUserPointer(&num_bytes),
1150 MOJO_READ_DATA_FLAG_DISCARD | MOJO_READ_DATA_FLAG_ALL_OR_NONE)); 1182 MOJO_READ_DATA_FLAG_DISCARD | MOJO_READ_DATA_FLAG_ALL_OR_NONE));
1151 1183
1184 // Try a two-phase read of the remaining two bytes with peek. Should fail.
1185 const void* read_ptr = nullptr;
1186 num_bytes = 2;
1187 ASSERT_EQ(MOJO_RESULT_INVALID_ARGUMENT,
1188 core()->BeginReadData(ch,
1189 MakeUserPointer(&read_ptr),
1190 MakeUserPointer(&num_bytes),
1191 MOJO_READ_DATA_FLAG_PEEK));
1192
1152 // Read the remaining two characters, in two-phase mode (all-or-none). 1193 // Read the remaining two characters, in two-phase mode (all-or-none).
1153 const void* read_ptr = nullptr;
1154 num_bytes = 2; 1194 num_bytes = 2;
1155 ASSERT_EQ(MOJO_RESULT_OK, 1195 ASSERT_EQ(MOJO_RESULT_OK,
1156 core()->BeginReadData(ch, 1196 core()->BeginReadData(ch,
1157 MakeUserPointer(&read_ptr), 1197 MakeUserPointer(&read_ptr),
1158 MakeUserPointer(&num_bytes), 1198 MakeUserPointer(&num_bytes),
1159 MOJO_READ_DATA_FLAG_ALL_OR_NONE)); 1199 MOJO_READ_DATA_FLAG_ALL_OR_NONE));
1160 // Note: Count on still being able to do the contiguous read here. 1200 // Note: Count on still being able to do the contiguous read here.
1161 ASSERT_EQ(2u, num_bytes); 1201 ASSERT_EQ(2u, num_bytes);
1162 1202
1163 // Discarding right now should fail. 1203 // Discarding right now should fail.
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
1477 EXPECT_EQ(MOJO_RESULT_OK, core()->Close(h_passing[1])); 1517 EXPECT_EQ(MOJO_RESULT_OK, core()->Close(h_passing[1]));
1478 EXPECT_EQ(MOJO_RESULT_OK, core()->Close(ph)); 1518 EXPECT_EQ(MOJO_RESULT_OK, core()->Close(ph));
1479 EXPECT_EQ(MOJO_RESULT_OK, core()->Close(ch)); 1519 EXPECT_EQ(MOJO_RESULT_OK, core()->Close(ch));
1480 } 1520 }
1481 1521
1482 // TODO(vtl): Test |DuplicateBufferHandle()| and |MapBuffer()|. 1522 // TODO(vtl): Test |DuplicateBufferHandle()| and |MapBuffer()|.
1483 1523
1484 } // namespace 1524 } // namespace
1485 } // namespace system 1525 } // namespace system
1486 } // namespace mojo 1526 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/channel_info.cc ('k') | mojo/edk/system/data_pipe.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698