Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 26baa6a6 authored by Roozbeh Pournader's avatar Roozbeh Pournader
Browse files

Set and restore default timezone in DateUtilsTest

Previously, the tests assumed a GMT timezone without ever setting it.
Now we set the timezone to GMT on setup and restore the original
timezone on teardown.

Change-Id: Ia168335eac28f33c094581af2437ac635cb38bd9
Fixes: 64149941
Test: bit FrameworksCoreTests:android.text.format.DateUtilsTest (with non-GMT timezone)
parent d3525198
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import java.text.DateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;

@SmallTest
@RunWith(AndroidJUnit4.class)
@@ -40,16 +41,20 @@ public class DateUtilsTest {

    private static final LocaleList LOCALE_LIST_US = new LocaleList(Locale.US);
    private LocaleList mOriginalLocales;
    private TimeZone mOriginalTimeZone;

    @Before
    public void setup() {
        mOriginalLocales = Resources.getSystem().getConfiguration().getLocales();
        setLocales(LOCALE_LIST_US);
        mOriginalTimeZone = TimeZone.getDefault();
        TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
    }

    @After
    public void teardown() {
        setLocales(mOriginalLocales);
        TimeZone.setDefault(mOriginalTimeZone);
    }

    @Test