diff options
author | dmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-11 20:32:53 +0000 |
---|---|---|
committer | dmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-11 20:32:53 +0000 |
commit | 97f706cbef77c8b5fae821ecf2bc990def9b99f0 (patch) | |
tree | 33fd6b04d5ed083a2b82c817467240dd1d0d1009 /ppapi/tests/test_core.cc | |
parent | 3f0b679e7d5ed5d91d128a6c600cfc58c3fc9fe5 (diff) | |
download | chromium_src-97f706cbef77c8b5fae821ecf2bc990def9b99f0.zip chromium_src-97f706cbef77c8b5fae821ecf2bc990def9b99f0.tar.gz chromium_src-97f706cbef77c8b5fae821ecf2bc990def9b99f0.tar.bz2 |
Fix resolution of GetTimeTicks.
Add a test to make sure Time and TimeTicks return increasing times. A similar test is failing in NaCl when I try to roll DEPS.
BUG=88935
TEST=test_core.cc
Review URL: http://codereview.chromium.org/7329047
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@92050 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/tests/test_core.cc')
-rw-r--r-- | ppapi/tests/test_core.cc | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/ppapi/tests/test_core.cc b/ppapi/tests/test_core.cc new file mode 100644 index 0000000..82f93613 --- /dev/null +++ b/ppapi/tests/test_core.cc @@ -0,0 +1,65 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ppapi/tests/test_core.h" + +#if defined(_MSC_VER) +#include <windows.h> +#else +#include <unistd.h> +#endif + +#include "ppapi/cpp/core.h" +#include "ppapi/cpp/module.h" +#include "ppapi/tests/testing_instance.h" + +namespace { + +void PlatformSleep(int duration_ms) { +#if defined(_MSC_VER) + ::Sleep(duration_ms); +#else + usleep(duration_ms * 1000); +#endif +} + +} // namespace + +REGISTER_TEST_CASE(Core); + +bool TestCore::Init() { + return true; +} + +void TestCore::RunTest() { + RUN_TEST(Time); + RUN_TEST(TimeTicks); +} + +std::string TestCore::TestTime() { + pp::Core* core = pp::Module::Get()->core(); + PP_Time time1 = core->GetTime(); + ASSERT_TRUE(time1 > 0); + + PlatformSleep(100); // 0.1 second + + PP_Time time2 = core->GetTime(); + ASSERT_TRUE(time2 > time1); + + PASS(); +} + +std::string TestCore::TestTimeTicks() { + pp::Core* core = pp::Module::Get()->core(); + PP_Time time1 = core->GetTimeTicks(); + ASSERT_TRUE(time1 > 0); + + PlatformSleep(100); // 0.1 second + + PP_Time time2 = core->GetTimeTicks(); + ASSERT_TRUE(time2 > time1); + + PASS(); +} + |