• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.documentsui.util;
18 
19 import static org.junit.Assert.assertEquals;
20 
21 import org.junit.Test;
22 
23 public class FormatUtilsTest {
24     @Test
testFormatDuration_seconds()25     public void testFormatDuration_seconds() {
26         assertEquals("0 seconds", FormatUtils.formatDuration(0));
27         assertEquals("0 seconds", FormatUtils.formatDuration(1));
28         assertEquals("0 seconds", FormatUtils.formatDuration(499));
29         assertEquals("1 second", FormatUtils.formatDuration(500));
30         assertEquals("1 second", FormatUtils.formatDuration(1000));
31         assertEquals("2 seconds", FormatUtils.formatDuration(1500));
32     }
33 
34     @Test
testFormatDuration_Minutes()35     public void testFormatDuration_Minutes() {
36         assertEquals("59 seconds", FormatUtils.formatDuration(59000));
37         assertEquals("60 seconds", FormatUtils.formatDuration(59500));
38         assertEquals("1 minute", FormatUtils.formatDuration(60000));
39         assertEquals("1 minute", FormatUtils.formatDuration(65000));
40         assertEquals("2 minutes", FormatUtils.formatDuration(90000));
41         assertEquals("2 minutes", FormatUtils.formatDuration(120000));
42     }
43 
44     @Test
testFormatDuration_Hours()45     public void testFormatDuration_Hours() {
46         assertEquals("59 minutes", FormatUtils.formatDuration(3540000));
47         assertEquals("1 hour", FormatUtils.formatDuration(3600000));
48         assertEquals("1 hour", FormatUtils.formatDuration(3660000));
49         assertEquals("2 hours", FormatUtils.formatDuration(5400000));
50         assertEquals("48 hours", FormatUtils.formatDuration(172800000));
51     }
52 
53 }
54