Fixed Date picker getBestDateTimePattern bug
diff --git a/robolectric-shadows/shadows-core/src/main/resources/org/robolectric/shadows/ShadowICU.java.vm b/robolectric-shadows/shadows-core/src/main/resources/org/robolectric/shadows/ShadowICU.java.vm
index b4074bf..4e8d4d6 100644
--- a/robolectric-shadows/shadows-core/src/main/resources/org/robolectric/shadows/ShadowICU.java.vm
+++ b/robolectric-shadows/shadows-core/src/main/resources/org/robolectric/shadows/ShadowICU.java.vm
@@ -19,12 +19,12 @@
#if ($api >= 21)
@Implementation
public static String getBestDateTimePattern(String skeleton, Locale locale) {
- return "h:mm a";
+ return skeleton;
}
#else
@Implementation
public static String getBestDateTimePattern(String skeleton, String locale) {
- return "h:mm a";
+ return skeleton;
}
#end
}
diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowICUTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowICUTest.java
index 9c7eb66..8c2270a 100644
--- a/robolectric/src/test/java/org/robolectric/shadows/ShadowICUTest.java
+++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowICUTest.java
@@ -15,8 +15,27 @@
Build.VERSION_CODES.LOLLIPOP })
public class ShadowICUTest {
- @Test
- public void getBestDateTimePattern_returnsReasonableValue() {
- assertThat(ICU.getBestDateTimePattern("hm", null)).isEqualTo("h:mm a");
- }
+ @Test
+ public void getBestDateTimePattern_returnsReasonableValue() {
+ assertThat(ICU.getBestDateTimePattern("hm", null)).isEqualTo("hm");
+ }
+
+ @Test
+ public void datePickerShouldNotCrashWhenAskingForBestDateTimePattern() {
+ ActivityController<DatePickerActivity> activityController = Robolectric.buildActivity(DatePickerActivity.class);
+ activityController.setup();
+ }
+
+ private static class DatePickerActivity extends Activity {
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ LinearLayout view = new LinearLayout(this);
+ view.setId(1);
+ DatePicker datePicker = new DatePicker(this);
+ view.addView(datePicker);
+
+ setContentView(view);
+ }
+ }
}
\ No newline at end of file