diff options
author | Tyler Gunn <tgunn@google.com> | 2014-05-14 15:09:30 -0700 |
---|---|---|
committer | Tyler Gunn <tgunn@google.com> | 2014-05-14 15:09:30 -0700 |
commit | c0b94eb2be0da73ee546c6a7bdd99ab60334d1fc (patch) | |
tree | 098b269590a2f469024b6c6ffa51f4fbd7f12cf3 /tests | |
parent | 1ada7ad61e5a0541aaa4813e8ae090b356216ca6 (diff) | |
download | android_packages_apps_ContactsCommon-c0b94eb2be0da73ee546c6a7bdd99ab60334d1fc.tar.gz android_packages_apps_ContactsCommon-c0b94eb2be0da73ee546c6a7bdd99ab60334d1fc.tar.bz2 android_packages_apps_ContactsCommon-c0b94eb2be0da73ee546c6a7bdd99ab60334d1fc.zip |
Adding day group headings in the call log which group call log entries
under 4 headings, "Today", "Yesterday", "Last week", "Other".
Bug: 13962594
Change-Id: Iba10211c1f6e162309063f9944b437c543013b7f
Diffstat (limited to 'tests')
-rw-r--r-- | tests/src/com/android/contacts/common/util/DateUtilTests.java | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/tests/src/com/android/contacts/common/util/DateUtilTests.java b/tests/src/com/android/contacts/common/util/DateUtilTests.java new file mode 100644 index 00000000..c225780e --- /dev/null +++ b/tests/src/com/android/contacts/common/util/DateUtilTests.java @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2014 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 com.android.contacts.common.util; + +import junit.framework.TestCase; + +import android.test.suitebuilder.annotation.SmallTest; +import android.text.format.Time; + +/** + * Unit tests for {@link com.android.contacts.common.util.DateUtils}. + */ +@SmallTest +public class DateUtilTests extends TestCase { + + /** + * Test ability to get the word "Yesterday". + */ + public void testGetYesterday() { + assertEquals("Yesterday", DateUtils.getYesterdayString()); + } + + /** + * Test ability to get the word "Today". + */ + public void testGetToday() { + assertEquals("Yesterday", DateUtils.getYesterdayString()); + } + + /** + * Test date differences which are in the same day. + */ + public void testDayDiffNone() { + Time time = new Time(); + long date1 = System.currentTimeMillis(); + long date2 = System.currentTimeMillis() + android.text.format.DateUtils.HOUR_IN_MILLIS; + assertEquals(0, DateUtils.getDayDifference(time, date1, date2)); + assertEquals(0, DateUtils.getDayDifference(time, date2, date1)); + } + + /** + * Test date differences which are a day apart. + */ + public void testDayDiffOne() { + Time time = new Time(); + long date1 = System.currentTimeMillis(); + long date2 = date1 + android.text.format.DateUtils.DAY_IN_MILLIS; + assertEquals(1, DateUtils.getDayDifference(time, date1, date2)); + assertEquals(1, DateUtils.getDayDifference(time, date2, date1)); + } + + /** + * Test date differences which are two days apart. + */ + public void testDayDiffTwo() { + Time time = new Time(); + long date1 = System.currentTimeMillis(); + long date2 = date1 + 2*android.text.format.DateUtils.DAY_IN_MILLIS; + assertEquals(2, DateUtils.getDayDifference(time, date1, date2)); + assertEquals(2, DateUtils.getDayDifference(time, date2, date1)); + } +} |