1 /*
2  * Copyright (C) 2013 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 libcore.libcore.icu;
18 
19 import static org.junit.Assert.assertNotNull;
20 import static org.junit.Assume.assumeNoException;
21 
22 import libcore.icu.DateIntervalFormat;
23 import libcore.test.annotation.NonCts;
24 import libcore.test.reasons.NonCtsReasons;
25 
26 import org.junit.Test;
27 import org.junit.runner.RunWith;
28 import org.junit.runners.JUnit4;
29 
30 @NonCts(bug = 287231726, reason = NonCtsReasons.INTERNAL_APIS)
31 @RunWith(JUnit4.class)
32 public class DateIntervalFormatTest {
33     private static final long MINUTE = 60 * 1000;
34     private static final long HOUR = 60 * MINUTE;
35     private static final long DAY = 24 * HOUR;
36 
37     private static final int FORMAT_SHOW_TIME = 0x00001;
38 
39     @Test
testFormatDateRange()40     public void testFormatDateRange() {
41         try {
42             Class.forName("android.text.format.DateIntervalFormat");
43         } catch (ClassNotFoundException e) {
44             // JUnit should ignore this test, instead of failing the test.
45             // It happens when the boot class path has frameworks.jar.
46             assumeNoException(e);
47         }
48 
49         String olsonId = "America/Los_Angeles";
50         String result = DateIntervalFormat.formatDateRange(0, DAY, FORMAT_SHOW_TIME, olsonId);
51 
52         // We can't assert the value because it's using the default locale, which could varies
53         // on different devices.
54         assertNotNull(result);
55     }
56 }
57