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

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

Issue 795593004: Update mojo sdk to rev cc531b32182099a5a034a99daff35ed5d38a61c8 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More workarounds for MSVC Created 5 years, 11 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/edk/system/core_test_base.cc ('k') | mojo/edk/system/endpoint_relayer.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
11 #include "base/bind.h"
11 #include "base/threading/platform_thread.h" 12 #include "base/threading/platform_thread.h"
12 #include "base/time/time.h" 13 #include "base/time/time.h"
14 #include "mojo/edk/system/awakable.h"
13 #include "mojo/edk/system/core_test_base.h" 15 #include "mojo/edk/system/core_test_base.h"
14 16
15 namespace mojo { 17 namespace mojo {
16 namespace system { 18 namespace system {
17 namespace { 19 namespace {
18 20
19 const MojoHandleSignalsState kEmptyMojoHandleSignalsState = {0u, 0u}; 21 const MojoHandleSignalsState kEmptyMojoHandleSignalsState = {0u, 0u};
20 const MojoHandleSignalsState kFullMojoHandleSignalsState = {~0u, ~0u}; 22 const MojoHandleSignalsState kFullMojoHandleSignalsState = {~0u, ~0u};
21 const MojoHandleSignals kAllSignals = MOJO_HANDLE_SIGNAL_READABLE | 23 const MojoHandleSignals kAllSignals = MOJO_HANDLE_SIGNAL_READABLE |
22 MOJO_HANDLE_SIGNAL_WRITABLE | 24 MOJO_HANDLE_SIGNAL_WRITABLE |
(...skipping 1246 matching lines...) Expand 10 before | Expand all | Expand 10 after
1269 // Complete the two-phase read. 1271 // Complete the two-phase read.
1270 EXPECT_EQ('x', static_cast<const char*>(read_ptr)[0]); 1272 EXPECT_EQ('x', static_cast<const char*>(read_ptr)[0]);
1271 EXPECT_EQ(MOJO_RESULT_OK, core()->EndReadData(ch, 1)); 1273 EXPECT_EQ(MOJO_RESULT_OK, core()->EndReadData(ch, 1));
1272 1274
1273 EXPECT_EQ(MOJO_RESULT_OK, core()->Close(h_passing[0])); 1275 EXPECT_EQ(MOJO_RESULT_OK, core()->Close(h_passing[0]));
1274 EXPECT_EQ(MOJO_RESULT_OK, core()->Close(h_passing[1])); 1276 EXPECT_EQ(MOJO_RESULT_OK, core()->Close(h_passing[1]));
1275 EXPECT_EQ(MOJO_RESULT_OK, core()->Close(ph)); 1277 EXPECT_EQ(MOJO_RESULT_OK, core()->Close(ph));
1276 EXPECT_EQ(MOJO_RESULT_OK, core()->Close(ch)); 1278 EXPECT_EQ(MOJO_RESULT_OK, core()->Close(ch));
1277 } 1279 }
1278 1280
1281 struct TestAsyncWaiter {
1282 TestAsyncWaiter() : result(MOJO_RESULT_UNKNOWN) {}
1283
1284 void Awake(MojoResult r) { result = r; }
1285
1286 MojoResult result;
1287 };
1288
1289 TEST_F(CoreTest, AsyncWait) {
1290 TestAsyncWaiter waiter;
1291 MockHandleInfo info;
1292 MojoHandle h = CreateMockHandle(&info);
1293
1294 EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION,
1295 core()->AsyncWait(h, MOJO_HANDLE_SIGNAL_READABLE,
1296 base::Bind(&TestAsyncWaiter::Awake,
1297 base::Unretained(&waiter))));
1298 EXPECT_EQ(0u, info.GetAddedAwakableSize());
1299
1300 info.AllowAddAwakable(true);
1301 EXPECT_EQ(MOJO_RESULT_OK,
1302 core()->AsyncWait(h, MOJO_HANDLE_SIGNAL_READABLE,
1303 base::Bind(&TestAsyncWaiter::Awake,
1304 base::Unretained(&waiter))));
1305 EXPECT_EQ(1u, info.GetAddedAwakableSize());
1306
1307 EXPECT_FALSE(info.GetAddedAwakableAt(0)->Awake(MOJO_RESULT_BUSY, 0));
1308 EXPECT_EQ(MOJO_RESULT_BUSY, waiter.result);
1309
1310 EXPECT_EQ(MOJO_RESULT_OK, core()->Close(h));
1311 }
1312
1279 // TODO(vtl): Test |DuplicateBufferHandle()| and |MapBuffer()|. 1313 // TODO(vtl): Test |DuplicateBufferHandle()| and |MapBuffer()|.
1280 1314
1281 } // namespace 1315 } // namespace
1282 } // namespace system 1316 } // namespace system
1283 } // namespace mojo 1317 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/core_test_base.cc ('k') | mojo/edk/system/endpoint_relayer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698