Search in sources :

Example 26 with Time

use of android.text.format.Time in project robolectric by robolectric.

the class ShadowTimeTest method shouldHaveCopyConstructor.

@Test
public void shouldHaveCopyConstructor() throws Exception {
    Time t = new Time();
    t.setToNow();
    Time t2 = new Time(t);
    assertEquals(t.timezone, t2.timezone);
    assertEquals(t.year, t2.year);
    assertEquals(t.month, t2.month);
    assertEquals(t.monthDay, t2.monthDay);
    assertEquals(t.hour, t2.hour);
    assertEquals(t.minute, t2.minute);
    assertEquals(t.second, t2.second);
}
Also used : Time(android.text.format.Time) Test(org.junit.Test)

Example 27 with Time

use of android.text.format.Time in project robolectric by robolectric.

the class ShadowTimeTest method shouldClear.

@Test
public void shouldClear() throws Exception {
    Time t = new Time();
    t.setToNow();
    t.clear("UTC");
    assertEquals("UTC", t.timezone);
    assertEquals(0, t.year);
    assertEquals(0, t.month);
    assertEquals(0, t.monthDay);
    assertEquals(0, t.hour);
    assertEquals(0, t.minute);
    assertEquals(0, t.second);
    assertEquals(0, t.weekDay);
    assertEquals(0, t.yearDay);
    assertEquals(0, t.gmtoff);
    assertEquals(-1, t.isDst);
}
Also used : Time(android.text.format.Time) Test(org.junit.Test)

Example 28 with Time

use of android.text.format.Time in project robolectric by robolectric.

the class ShadowTimeTest method shouldHaveSet6Args.

@Test
public void shouldHaveSet6Args() throws Exception {
    Time t = new Time();
    t.set(1, 1, 1, 1, 1, 2000);
    assertEquals(t.year, 2000);
    assertEquals(t.month, 1);
    assertEquals(t.monthDay, 1);
    assertEquals(t.second, 1);
    assertEquals(t.minute, 1);
    assertEquals(t.hour, 1);
}
Also used : Time(android.text.format.Time) Test(org.junit.Test)

Example 29 with Time

use of android.text.format.Time in project robolectric by robolectric.

the class ShadowTimeTest method shouldHaveParseShort.

@Test
public void shouldHaveParseShort() throws Exception {
    Time t = new Time();
    t.parse("20081013");
    assertEquals(2008, t.year);
    assertEquals(9, t.month);
    assertEquals(13, t.monthDay);
    assertEquals(0, t.hour);
    assertEquals(0, t.minute);
    assertEquals(0, t.second);
}
Also used : Time(android.text.format.Time) Test(org.junit.Test)

Example 30 with Time

use of android.text.format.Time in project robolectric by robolectric.

the class ShadowTimeTest method shouldParseRfc3339.

@Test
public void shouldParseRfc3339() {
    for (String tz : Arrays.asList("Europe/Berlin", "America/Los Angeles", "Australia/Adelaide")) {
        String desc = "Eval when local timezone is " + tz;
        TimeZone.setDefault(TimeZone.getTimeZone(tz));
        Time t = new Time("Europe/Berlin");
        assertTrue(desc, t.parse3339("2008-10-13T16:30:50Z"));
        assertEquals(desc, 2008, t.year);
        assertEquals(desc, 9, t.month);
        assertEquals(desc, 13, t.monthDay);
        assertEquals(desc, 16, t.hour);
        assertEquals(desc, 30, t.minute);
        assertEquals(desc, 50, t.second);
        assertEquals(desc, "UTC", t.timezone);
        assertFalse(desc, t.allDay);
        t = new Time("Europe/Berlin");
        assertTrue(desc, t.parse3339("2008-10-13T16:30:50.000+07:00"));
        assertEquals(desc, 2008, t.year);
        assertEquals(desc, 9, t.month);
        assertEquals(desc, 13, t.monthDay);
        assertEquals(desc, 9, t.hour);
        assertEquals(desc, 30, t.minute);
        assertEquals(desc, 50, t.second);
        assertEquals(desc, "UTC", t.timezone);
        assertFalse(desc, t.allDay);
        t = new Time("Europe/Berlin");
        assertFalse(desc, t.parse3339("2008-10-13"));
        assertEquals(desc, 2008, t.year);
        assertEquals(desc, 9, t.month);
        assertEquals(desc, 13, t.monthDay);
        assertEquals(desc, 0, t.hour);
        assertEquals(desc, 0, t.minute);
        assertEquals(desc, 0, t.second);
        assertEquals(desc, "Europe/Berlin", t.timezone);
        assertTrue(desc, t.allDay);
    }
}
Also used : Time(android.text.format.Time) Test(org.junit.Test)

Aggregations

Time (android.text.format.Time)394 SmallTest (android.test.suitebuilder.annotation.SmallTest)97 Test (org.junit.Test)25 ArrayList (java.util.ArrayList)23 Date (java.util.Date)21 NetworkPolicy (android.net.NetworkPolicy)16 TrustedTime (android.util.TrustedTime)16 TextView (android.widget.TextView)15 Bundle (android.os.Bundle)13 TimeFormatException (android.util.TimeFormatException)13 Suppress (android.test.suitebuilder.annotation.Suppress)12 View (android.view.View)12 Paint (android.graphics.Paint)11 IOException (java.io.IOException)11 Matcher (java.util.regex.Matcher)9 IntentFilter (android.content.IntentFilter)7 File (java.io.File)7 DateFormat (java.text.DateFormat)7 SimpleDateFormat (java.text.SimpleDateFormat)7 ContentValues (android.content.ContentValues)6