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

Unified Diff: webkit/plugins/ppapi/time_conversion_unittest.cc

Issue 11567013: Fix PPAPI time conversion code to handle epoch times. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ppapi/shared_impl/time_conversion_unittest.cc ('k') | webkit/tools/test_shell/test_shell.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/plugins/ppapi/time_conversion_unittest.cc
diff --git a/webkit/plugins/ppapi/time_conversion_unittest.cc b/webkit/plugins/ppapi/time_conversion_unittest.cc
deleted file mode 100644
index 84ad697f63db56d80f6f0e6b37354f505bdf3111..0000000000000000000000000000000000000000
--- a/webkit/plugins/ppapi/time_conversion_unittest.cc
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright (c) 2012 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 <math.h>
-#include <stdlib.h>
-
-#include "ppapi/shared_impl/time_conversion.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace ppapi {
-
-// Slop we'll allow in two Time "internal values" to consider them equal.
-// Double conversion can introduce rounding errors. The internal values are in
-// microseconds, so an error here is very small.
-static const int kTimeInternalValueSlop = 2;
-
-// Same as above in double-precision seconds units.
-static const double kTimeSecondsSlop =
- static_cast<double>(kTimeInternalValueSlop) /
- base::Time::kMicrosecondsPerSecond;
-
-TEST(TimeConversion, Time) {
- // Should be able to round-trip.
- base::Time now = base::Time::Now();
- base::Time converted = ppapi::PPTimeToTime(TimeToPPTime(now));
- EXPECT_GE(kTimeInternalValueSlop,
- abs(static_cast<int>((converted - now).ToInternalValue())));
-
- // Units should be in seconds.
- base::Time one_second_from_now = now + base::TimeDelta::FromSeconds(1);
- double converted_one_second_from_now =
- ppapi::TimeToPPTime(one_second_from_now) - ppapi::TimeToPPTime(now);
- EXPECT_GE(kTimeSecondsSlop, fabs(converted_one_second_from_now - 1));
-}
-
-TEST(TimeConversion, EventTime) {
- // Should be able to round-trip.
- base::Time now = base::Time::Now();
- double event_now = now.ToDoubleT();
- double converted =
- ppapi::EventTimeToPPTimeTicks(ppapi::PPTimeTicksToEventTime(event_now));
- EXPECT_GE(kTimeSecondsSlop, fabs(converted - event_now));
-
- // Units should be in seconds.
- base::Time one_second_from_now = now + base::TimeDelta::FromSeconds(1);
- double event_one_second_from_now = one_second_from_now.ToDoubleT();
- EXPECT_GE(kTimeSecondsSlop,
- 1.0 - ppapi::EventTimeToPPTimeTicks(event_one_second_from_now) -
- ppapi::EventTimeToPPTimeTicks(event_now));
-}
-
-} // namespace ppapi
« no previous file with comments | « ppapi/shared_impl/time_conversion_unittest.cc ('k') | webkit/tools/test_shell/test_shell.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698