| OLD | NEW |
| 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 "mojo/edk/platform/thread_utils.h" |
| 11 #include "mojo/edk/system/awakable.h" | 12 #include "mojo/edk/system/awakable.h" |
| 12 #include "mojo/edk/system/core_test_base.h" | 13 #include "mojo/edk/system/core_test_base.h" |
| 13 #include "mojo/edk/system/test/sleep.h" | 14 #include "mojo/edk/system/test/timeouts.h" |
| 14 #include "mojo/public/cpp/system/macros.h" | 15 #include "mojo/public/cpp/system/macros.h" |
| 15 | 16 |
| 17 using mojo::platform::ThreadSleep; |
| 18 |
| 16 namespace mojo { | 19 namespace mojo { |
| 17 namespace system { | 20 namespace system { |
| 18 namespace { | 21 namespace { |
| 19 | 22 |
| 20 const MojoHandleSignalsState kEmptyMojoHandleSignalsState = {0u, 0u}; | 23 const MojoHandleSignalsState kEmptyMojoHandleSignalsState = {0u, 0u}; |
| 21 const MojoHandleSignalsState kFullMojoHandleSignalsState = {~0u, ~0u}; | 24 const MojoHandleSignalsState kFullMojoHandleSignalsState = {~0u, ~0u}; |
| 22 const MojoHandleSignals kAllSignals = MOJO_HANDLE_SIGNAL_READABLE | | 25 const MojoHandleSignals kAllSignals = MOJO_HANDLE_SIGNAL_READABLE | |
| 23 MOJO_HANDLE_SIGNAL_WRITABLE | | 26 MOJO_HANDLE_SIGNAL_WRITABLE | |
| 24 MOJO_HANDLE_SIGNAL_PEER_CLOSED; | 27 MOJO_HANDLE_SIGNAL_PEER_CLOSED; |
| 25 | 28 |
| 26 using CoreTest = test::CoreTestBase; | 29 using CoreTest = test::CoreTestBase; |
| 27 | 30 |
| 28 TEST_F(CoreTest, GetTimeTicksNow) { | 31 TEST_F(CoreTest, GetTimeTicksNow) { |
| 29 const MojoTimeTicks start = core()->GetTimeTicksNow(); | 32 const MojoTimeTicks start = core()->GetTimeTicksNow(); |
| 30 EXPECT_NE(static_cast<MojoTimeTicks>(0), start) | 33 EXPECT_NE(static_cast<MojoTimeTicks>(0), start) |
| 31 << "GetTimeTicksNow should return nonzero value"; | 34 << "GetTimeTicksNow should return nonzero value"; |
| 32 test::SleepMilliseconds(15u); | 35 ThreadSleep(test::DeadlineFromMilliseconds(15u)); |
| 33 const MojoTimeTicks finish = core()->GetTimeTicksNow(); | 36 const MojoTimeTicks finish = core()->GetTimeTicksNow(); |
| 34 // Allow for some fuzz in sleep. | 37 // Allow for some fuzz in sleep. |
| 35 EXPECT_GE((finish - start), static_cast<MojoTimeTicks>(8000)) | 38 EXPECT_GE((finish - start), static_cast<MojoTimeTicks>(8000)) |
| 36 << "Sleeping should result in increasing time ticks"; | 39 << "Sleeping should result in increasing time ticks"; |
| 37 } | 40 } |
| 38 | 41 |
| 39 TEST_F(CoreTest, Basic) { | 42 TEST_F(CoreTest, Basic) { |
| 40 MockHandleInfo info; | 43 MockHandleInfo info; |
| 41 | 44 |
| 42 EXPECT_EQ(0u, info.GetCtorCallCount()); | 45 EXPECT_EQ(0u, info.GetCtorCallCount()); |
| (...skipping 1264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1307 EXPECT_EQ(MOJO_RESULT_BUSY, waiter.result); | 1310 EXPECT_EQ(MOJO_RESULT_BUSY, waiter.result); |
| 1308 | 1311 |
| 1309 EXPECT_EQ(MOJO_RESULT_OK, core()->Close(h)); | 1312 EXPECT_EQ(MOJO_RESULT_OK, core()->Close(h)); |
| 1310 } | 1313 } |
| 1311 | 1314 |
| 1312 // TODO(vtl): Test |DuplicateBufferHandle()| and |MapBuffer()|. | 1315 // TODO(vtl): Test |DuplicateBufferHandle()| and |MapBuffer()|. |
| 1313 | 1316 |
| 1314 } // namespace | 1317 } // namespace |
| 1315 } // namespace system | 1318 } // namespace system |
| 1316 } // namespace mojo | 1319 } // namespace mojo |
| OLD | NEW |