Chromium Code Reviews

Side by Side Diff: mojo/public/platform/native/system_impl_private_unittest.cc

Issue 1885663002: EDK: Add implementation of data pipe producer write threshold stuff. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« no previous file with comments | « mojo/public/c/system/tests/core_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 // This file tests the C API, but using the explicit MojoSystemImpl parameter. 5 // This file tests the C API, but using the explicit MojoSystemImpl parameter.
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "mojo/public/platform/native/system_impl_private.h" 9 #include "mojo/public/platform/native/system_impl_private.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 150 matching lines...)
161 EXPECT_EQ(MOJO_HANDLE_SIGNAL_NONE, state.satisfied_signals); 161 EXPECT_EQ(MOJO_HANDLE_SIGNAL_NONE, state.satisfied_signals);
162 EXPECT_EQ(MOJO_HANDLE_SIGNAL_READABLE | MOJO_HANDLE_SIGNAL_PEER_CLOSED | 162 EXPECT_EQ(MOJO_HANDLE_SIGNAL_READABLE | MOJO_HANDLE_SIGNAL_PEER_CLOSED |
163 MOJO_HANDLE_SIGNAL_READ_THRESHOLD, 163 MOJO_HANDLE_SIGNAL_READ_THRESHOLD,
164 state.satisfiable_signals); 164 state.satisfiable_signals);
165 165
166 // The producer |hp| should be writable. 166 // The producer |hp| should be writable.
167 EXPECT_EQ( 167 EXPECT_EQ(
168 MOJO_RESULT_OK, 168 MOJO_RESULT_OK,
169 MojoSystemImplWait(sys0, hp, MOJO_HANDLE_SIGNAL_WRITABLE, 0, &state)); 169 MojoSystemImplWait(sys0, hp, MOJO_HANDLE_SIGNAL_WRITABLE, 0, &state));
170 170
171 EXPECT_EQ(MOJO_HANDLE_SIGNAL_WRITABLE, state.satisfied_signals); 171 EXPECT_EQ(MOJO_HANDLE_SIGNAL_WRITABLE | MOJO_HANDLE_SIGNAL_WRITE_THRESHOLD,
172 EXPECT_EQ(MOJO_HANDLE_SIGNAL_WRITABLE | MOJO_HANDLE_SIGNAL_PEER_CLOSED, 172 state.satisfied_signals);
173 EXPECT_EQ(MOJO_HANDLE_SIGNAL_WRITABLE | MOJO_HANDLE_SIGNAL_PEER_CLOSED |
174 MOJO_HANDLE_SIGNAL_WRITE_THRESHOLD,
173 state.satisfiable_signals); 175 state.satisfiable_signals);
174 176
175 // Try to read from |hc|. 177 // Try to read from |hc|.
176 buffer_size = static_cast<uint32_t>(sizeof(buffer)); 178 buffer_size = static_cast<uint32_t>(sizeof(buffer));
177 EXPECT_EQ(MOJO_RESULT_SHOULD_WAIT, 179 EXPECT_EQ(MOJO_RESULT_SHOULD_WAIT,
178 MojoSystemImplReadData(sys1, hc, buffer, &buffer_size, 180 MojoSystemImplReadData(sys1, hc, buffer, &buffer_size,
179 MOJO_READ_DATA_FLAG_NONE)); 181 MOJO_READ_DATA_FLAG_NONE));
180 182
181 // Try to begin a two-phase read from |hc|. 183 // Try to begin a two-phase read from |hc|.
182 read_pointer = nullptr; 184 read_pointer = nullptr;
(...skipping 77 matching lines...)
260 EXPECT_EQ(MOJO_HANDLE_SIGNAL_PEER_CLOSED, state.satisfiable_signals); 262 EXPECT_EQ(MOJO_HANDLE_SIGNAL_PEER_CLOSED, state.satisfiable_signals);
261 263
262 EXPECT_EQ(MOJO_RESULT_OK, MojoSystemImplClose(sys1, hc)); 264 EXPECT_EQ(MOJO_RESULT_OK, MojoSystemImplClose(sys1, hc));
263 265
264 // TODO(vtl): Test the other way around -- closing the consumer should make 266 // TODO(vtl): Test the other way around -- closing the consumer should make
265 // the producer never-writable? 267 // the producer never-writable?
266 268
267 // 2 SystemImpls are leaked... 269 // 2 SystemImpls are leaked...
268 } 270 }
269 271
272 // TODO(vtl): Once thunks are in:
273 // TEST(SystemImplTest, DataPipeWriteThreshold) { ... }
274
270 TEST(SystemImplTest, DataPipeReadThreshold) { 275 TEST(SystemImplTest, DataPipeReadThreshold) {
271 MojoSystemImpl sys0 = MojoSystemImplCreateImpl(); 276 MojoSystemImpl sys0 = MojoSystemImplCreateImpl();
272 MojoSystemImpl sys1 = MojoSystemImplCreateImpl(); 277 MojoSystemImpl sys1 = MojoSystemImplCreateImpl();
273 EXPECT_NE(sys0, sys1); 278 EXPECT_NE(sys0, sys1);
274 279
275 MojoHandle hp = MOJO_HANDLE_INVALID; 280 MojoHandle hp = MOJO_HANDLE_INVALID;
276 MojoHandle hc = MOJO_HANDLE_INVALID; 281 MojoHandle hc = MOJO_HANDLE_INVALID;
277 EXPECT_EQ(MOJO_RESULT_OK, 282 EXPECT_EQ(MOJO_RESULT_OK,
278 MojoSystemImplCreateDataPipe(sys0, nullptr, &hp, &hc)); 283 MojoSystemImplCreateDataPipe(sys0, nullptr, &hp, &hc));
279 EXPECT_NE(hp, MOJO_HANDLE_INVALID); 284 EXPECT_NE(hp, MOJO_HANDLE_INVALID);
(...skipping 203 matching lines...)
483 // Unmap it. 488 // Unmap it.
484 EXPECT_EQ(MOJO_RESULT_OK, MojoSystemImplUnmapBuffer(sys1, pointer)); 489 EXPECT_EQ(MOJO_RESULT_OK, MojoSystemImplUnmapBuffer(sys1, pointer));
485 490
486 EXPECT_EQ(MOJO_RESULT_OK, MojoSystemImplClose(sys1, h1)); 491 EXPECT_EQ(MOJO_RESULT_OK, MojoSystemImplClose(sys1, h1));
487 492
488 // 2 SystemImpls are leaked... 493 // 2 SystemImpls are leaked...
489 } 494 }
490 495
491 } // namespace 496 } // namespace
492 } // namespace mojo 497 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/c/system/tests/core_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine