1 // BEGIN-INTERNAL 2 package org.robolectric.shadows; 3 4 import static com.google.common.truth.Truth.assertThat; 5 6 import static android.os.Build.VERSION_CODES.Q; 7 import static com.google.common.truth.Truth.assertThat; 8 9 import android.icu.util.TimeZone; 10 import androidx.test.ext.junit.runners.AndroidJUnit4; 11 import java.util.List; 12 import java.util.stream.Collectors; 13 import org.junit.Test; 14 import org.junit.runner.RunWith; 15 import org.robolectric.annotation.Config; 16 import org.robolectric.util.ReflectionHelpers; 17 import org.robolectric.util.ReflectionHelpers.ClassParameter; 18 19 /** Unit tests for {@link ShadowTimeZoneFinderQ}. */ 20 @RunWith(AndroidJUnit4.class) 21 public class ShadowTimeZoneFinderQTest { 22 23 @Test 24 @Config(minSdk = Q, maxSdk = Q) lookupTimeZonesByCountry_shouldReturnExpectedTimeZones()25 public void lookupTimeZonesByCountry_shouldReturnExpectedTimeZones() throws Exception { 26 Class<?> cls = Class.forName("libcore.timezone.TimeZoneFinder"); 27 Object timeZoneFinder = ReflectionHelpers.callStaticMethod(cls, "getInstance"); 28 List<TimeZone> timezones = 29 ReflectionHelpers.callInstanceMethod( 30 cls, 31 timeZoneFinder, 32 "lookupTimeZonesByCountry", 33 ClassParameter.from(String.class, "us")); 34 35 assertThat(timezones.stream().map(TimeZone::getID).collect(Collectors.toList())) 36 .containsAtLeast("America/Los_Angeles", "America/New_York", "Pacific/Honolulu"); 37 } 38 } 39 // END-INTERNAL 40