summaryrefslogtreecommitdiffstats
path: root/core/tests/coretests
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2012-11-13 16:23:59 -0800
committerJeff Sharkey <jsharkey@android.com>2012-11-13 17:26:39 -0800
commit53f6e8a9b95a1fe5229295ade4989339d577de08 (patch)
treea999a27132f6f334cbf9fa7ca68bb27213aaef8c /core/tests/coretests
parent0349ae92a5d61bd72223878b90b00d2ebdc2485f (diff)
downloadframeworks_base-53f6e8a9b95a1fe5229295ade4989339d577de08.zip
frameworks_base-53f6e8a9b95a1fe5229295ade4989339d577de08.tar.gz
frameworks_base-53f6e8a9b95a1fe5229295ade4989339d577de08.tar.bz2
Utility to format human-friendly durations.
Bug: 6777872 Change-Id: Ie7ebcb456306f4f88b4707030dd7beda3fc90368
Diffstat (limited to 'core/tests/coretests')
-rw-r--r--core/tests/coretests/src/android/text/format/DateUtilsTest.java48
1 files changed, 48 insertions, 0 deletions
diff --git a/core/tests/coretests/src/android/text/format/DateUtilsTest.java b/core/tests/coretests/src/android/text/format/DateUtilsTest.java
new file mode 100644
index 0000000..cf42bb1
--- /dev/null
+++ b/core/tests/coretests/src/android/text/format/DateUtilsTest.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.text.format;
+
+import android.test.suitebuilder.annotation.SmallTest;
+
+import junit.framework.TestCase;
+
+public class DateUtilsTest extends TestCase {
+ @SmallTest
+ public void testFormatDurationSeconds() throws Exception {
+ assertEquals("0 seconds", DateUtils.formatDuration(0));
+ assertEquals("0 seconds", DateUtils.formatDuration(1));
+ assertEquals("0 seconds", DateUtils.formatDuration(499));
+ assertEquals("1 second", DateUtils.formatDuration(500));
+ assertEquals("1 second", DateUtils.formatDuration(1000));
+ assertEquals("2 seconds", DateUtils.formatDuration(1500));
+ }
+
+ @SmallTest
+ public void testFormatDurationMinutes() throws Exception {
+ assertEquals("59 seconds", DateUtils.formatDuration(59000));
+ assertEquals("60 seconds", DateUtils.formatDuration(59500));
+ assertEquals("1 minute", DateUtils.formatDuration(60000));
+ assertEquals("2 minutes", DateUtils.formatDuration(120000));
+ }
+
+ @SmallTest
+ public void testFormatDurationHours() throws Exception {
+ assertEquals("59 minutes", DateUtils.formatDuration(3540000));
+ assertEquals("1 hour", DateUtils.formatDuration(3600000));
+ assertEquals("48 hours", DateUtils.formatDuration(172800000));
+ }
+}