summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJean-Baptiste Queru <jbq@google.com>2009-12-21 15:52:57 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2009-12-21 15:52:57 -0800
commit5237f019b9f3fa1f4001dc1ad27d7781d3032985 (patch)
treebc6443db97d2c7473fc9b7dfd34537c80b8a43db /tests
parent223bd7af9832971075ba9fd9b0e41b7d693bd791 (diff)
parentc4978805dc8837570701629a9b8098e80804ad34 (diff)
downloadframeworks_base-5237f019b9f3fa1f4001dc1ad27d7781d3032985.zip
frameworks_base-5237f019b9f3fa1f4001dc1ad27d7781d3032985.tar.gz
frameworks_base-5237f019b9f3fa1f4001dc1ad27d7781d3032985.tar.bz2
am c4978805: merge from open-source master
Merge commit 'c4978805dc8837570701629a9b8098e80804ad34' * commit 'c4978805dc8837570701629a9b8098e80804ad34': ImageButton example doesn't work. Default state should be at the last. Time.parse3339 range checking and proper 'sec-frac' skip
Diffstat (limited to 'tests')
-rw-r--r--tests/AndroidTests/src/com/android/unit_tests/TimeTest.java81
1 files changed, 81 insertions, 0 deletions
diff --git a/tests/AndroidTests/src/com/android/unit_tests/TimeTest.java b/tests/AndroidTests/src/com/android/unit_tests/TimeTest.java
index 110caa4..3b33a99 100644
--- a/tests/AndroidTests/src/com/android/unit_tests/TimeTest.java
+++ b/tests/AndroidTests/src/com/android/unit_tests/TimeTest.java
@@ -20,6 +20,7 @@ import android.test.suitebuilder.annotation.SmallTest;
import android.test.suitebuilder.annotation.Suppress;
import android.text.format.Time;
import android.util.Log;
+import android.util.TimeFormatException;
import junit.framework.TestCase;
@@ -354,6 +355,86 @@ public class TimeTest extends TestCase {
}
@SmallTest
+ public void testParse33390() throws Exception {
+ Time t = new Time(Time.TIMEZONE_UTC);
+
+ t.parse3339("1980-05-23");
+ if (!t.allDay || t.year != 1980 || t.month != 05 || t.monthDay != 23) {
+ fail("Did not parse all-day date correctly");
+ }
+
+ t.parse3339("1980-05-23T09:50:50");
+ if (t.allDay || t.year != 1980 || t.month != 05 || t.monthDay != 23 ||
+ t.hour != 9 || t.minute != 50 || t.second != 50 ||
+ t.gmtoff != 0) {
+ fail("Did not parse timezone-offset-less date correctly");
+ }
+
+ t.parse3339("1980-05-23T09:50:50Z");
+ if (t.allDay || t.year != 1980 || t.month != 05 || t.monthDay != 23 ||
+ t.hour != 9 || t.minute != 50 || t.second != 50 ||
+ t.gmtoff != 0) {
+ fail("Did not parse UTC date correctly");
+ }
+
+ t.parse3339("1980-05-23T09:50:50.0Z");
+ if (t.allDay || t.year != 1980 || t.month != 05 || t.monthDay != 23 ||
+ t.hour != 9 || t.minute != 50 || t.second != 50 ||
+ t.gmtoff != 0) {
+ fail("Did not parse UTC date correctly");
+ }
+
+ t.parse3339("1980-05-23T09:50:50.12Z");
+ if (t.allDay || t.year != 1980 || t.month != 05 || t.monthDay != 23 ||
+ t.hour != 9 || t.minute != 50 || t.second != 50 ||
+ t.gmtoff != 0) {
+ fail("Did not parse UTC date correctly");
+ }
+
+ t.parse3339("1980-05-23T09:50:50.123Z");
+ if (t.allDay || t.year != 1980 || t.month != 05 || t.monthDay != 23 ||
+ t.hour != 9 || t.minute != 50 || t.second != 50 ||
+ t.gmtoff != 0) {
+ fail("Did not parse UTC date correctly");
+ }
+
+ t.parse3339("1980-05-23T09:50:50-06:00");
+ if (t.allDay || t.year != 1980 || t.month != 05 || t.monthDay != 23 ||
+ t.hour != 9 || t.minute != 50 || t.second != 50 ||
+ t.gmtoff != -6*3600) {
+ fail("Did not parse timezone-offset date correctly");
+ }
+
+ t.parse3339("1980-05-23T09:50:50.123-06:00");
+ if (t.allDay || t.year != 1980 || t.month != 05 || t.monthDay != 23 ||
+ t.hour != 9 || t.minute != 50 || t.second != 50 ||
+ t.gmtoff != -6*3600) {
+ fail("Did not parse timezone-offset date correctly");
+ }
+
+ try {
+ t.parse3339("1980");
+ fail("Did not throw error on truncated input length");
+ } catch (TimeFormatException e) {
+ // Successful
+ }
+
+ try {
+ t.parse3339("1980-05-23T09:50:50.123+");
+ fail("Did not throw error on truncated timezone offset");
+ } catch (TimeFormatException e1) {
+ // Successful
+ }
+
+ try {
+ t.parse3339("1980-05-23T09:50:50.123+05:0");
+ fail("Did not throw error on truncated timezone offset");
+ } catch (TimeFormatException e1) {
+ // Successful
+ }
+ }
+
+ @SmallTest
public void testSet0() throws Exception {
Time t = new Time(Time.TIMEZONE_UTC);
t.set(1000L);