| 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 "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/threading/platform_thread.h" | 12 #include "base/threading/platform_thread.h" |
| 13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "mojo/edk/system/awakable.h" | 14 #include "mojo/edk/system/awakable.h" |
| 15 #include "mojo/edk/system/core_test_base.h" | 15 #include "mojo/edk/system/core_test_base.h" |
| 16 | 16 |
| 17 namespace mojo { | 17 namespace mojo { |
| 18 namespace system { | 18 namespace system { |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 const MojoHandleSignalsState kEmptyMojoHandleSignalsState = {0u, 0u}; | 21 const MojoHandleSignalsState kEmptyMojoHandleSignalsState = {0u, 0u}; |
| 22 const MojoHandleSignalsState kFullMojoHandleSignalsState = {~0u, ~0u}; | 22 const MojoHandleSignalsState kFullMojoHandleSignalsState = {~0u, ~0u}; |
| 23 const MojoHandleSignals kAllSignals = MOJO_HANDLE_SIGNAL_READABLE | | 23 const MojoHandleSignals kAllSignals = MOJO_HANDLE_SIGNAL_READABLE | |
| 24 MOJO_HANDLE_SIGNAL_WRITABLE | | 24 MOJO_HANDLE_SIGNAL_WRITABLE | |
| 25 MOJO_HANDLE_SIGNAL_PEER_CLOSED; | 25 MOJO_HANDLE_SIGNAL_PEER_CLOSED; |
| 26 | 26 |
| 27 typedef test::CoreTestBase CoreTest; | 27 using CoreTest = test::CoreTestBase; |
| 28 | 28 |
| 29 TEST_F(CoreTest, GetTimeTicksNow) { | 29 TEST_F(CoreTest, GetTimeTicksNow) { |
| 30 const MojoTimeTicks start = core()->GetTimeTicksNow(); | 30 const MojoTimeTicks start = core()->GetTimeTicksNow(); |
| 31 EXPECT_NE(static_cast<MojoTimeTicks>(0), start) | 31 EXPECT_NE(static_cast<MojoTimeTicks>(0), start) |
| 32 << "GetTimeTicksNow should return nonzero value"; | 32 << "GetTimeTicksNow should return nonzero value"; |
| 33 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(15)); | 33 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(15)); |
| 34 const MojoTimeTicks finish = core()->GetTimeTicksNow(); | 34 const MojoTimeTicks finish = core()->GetTimeTicksNow(); |
| 35 // Allow for some fuzz in sleep. | 35 // Allow for some fuzz in sleep. |
| 36 EXPECT_GE((finish - start), static_cast<MojoTimeTicks>(8000)) | 36 EXPECT_GE((finish - start), static_cast<MojoTimeTicks>(8000)) |
| 37 << "Sleeping should result in increasing time ticks"; | 37 << "Sleeping should result in increasing time ticks"; |
| (...skipping 1270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1308 EXPECT_EQ(MOJO_RESULT_BUSY, waiter.result); | 1308 EXPECT_EQ(MOJO_RESULT_BUSY, waiter.result); |
| 1309 | 1309 |
| 1310 EXPECT_EQ(MOJO_RESULT_OK, core()->Close(h)); | 1310 EXPECT_EQ(MOJO_RESULT_OK, core()->Close(h)); |
| 1311 } | 1311 } |
| 1312 | 1312 |
| 1313 // TODO(vtl): Test |DuplicateBufferHandle()| and |MapBuffer()|. | 1313 // TODO(vtl): Test |DuplicateBufferHandle()| and |MapBuffer()|. |
| 1314 | 1314 |
| 1315 } // namespace | 1315 } // namespace |
| 1316 } // namespace system | 1316 } // namespace system |
| 1317 } // namespace mojo | 1317 } // namespace mojo |
| OLD | NEW |