Skip to content

Commit 139f35c

Browse files
Material Design Teamdrchen
authored andcommitted
[Tests] Update Robolectric to 4.7.3
PiperOrigin-RevId: 439903104
1 parent c5284c6 commit 139f35c

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ ext {
4646
espressoVersion = '3.1.0'
4747
mockitoCoreVersion = '2.25.0'
4848
truthVersion = '0.45'
49-
robolectricVersion = '4.3'
49+
robolectricVersion = '4.7.3'
5050

5151
// Enforce the use of prebuilt dependencies in all sub-projects. This is
5252
// required for the doclava dependency.

lib/javatests/com/google/android/material/datepicker/DateStringsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
package com.google.android.material.datepicker;
1717

18-
import static org.hamcrest.Matchers.is;
18+
import static org.hamcrest.core.Is.is;
1919
import static org.junit.Assert.assertThat;
2020

2121
import android.os.Build.VERSION_CODES;

lib/javatests/com/google/android/material/datepicker/RangeDateSelectorTest.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@
2323
import androidx.appcompat.app.AppCompatActivity;
2424
import android.view.LayoutInflater;
2525
import android.view.View;
26+
import android.view.ViewGroup;
2627
import android.widget.GridView;
2728
import android.widget.TextView.BufferType;
2829
import androidx.core.util.Pair;
2930
import androidx.test.core.app.ApplicationProvider;
3031
import com.google.android.material.internal.ParcelableTestUtils;
3132
import com.google.android.material.textfield.TextInputLayout;
33+
import java.text.SimpleDateFormat;
3234
import java.util.Calendar;
3335
import org.junit.Assert;
3436
import org.junit.Before;
@@ -81,12 +83,13 @@ public void textInputValid() {
8183
@Test
8284
public void textInputFormatError() {
8385
View root = getRootView();
86+
((ViewGroup) activity.findViewById(android.R.id.content)).addView(root);
87+
8488
TextInputLayout startTextInput = root.findViewById(R.id.mtrl_picker_text_input_range_start);
8589
TextInputLayout endTextInput = root.findViewById(R.id.mtrl_picker_text_input_range_end);
8690
startTextInput.getEditText().setText("22/22/2010", BufferType.EDITABLE);
8791
endTextInput.getEditText().setText("555-555-5555", BufferType.EDITABLE);
8892

89-
activity.setContentView(root);
9093
ShadowLooper.runUiThreadTasksIncludingDelayedTasks();
9194

9295
assertThat(startTextInput.getError()).isNotNull();
@@ -210,8 +213,12 @@ public void textInputHintValidWithPTLocale() {
210213
activity.setContentView(root);
211214
ShadowLooper.runUiThreadTasksIncludingDelayedTasks();
212215

213-
assertThat(startTextInput.getPlaceholderText().toString()).isEqualTo("dd-mm-aaaa");
214-
assertThat(endTextInput.getPlaceholderText().toString()).isEqualTo("dd-mm-aaaa");
216+
// Some JVMs format PT dates as dd-mm-aaaa, and some as dd/mm/aaaa. Derive the expected result
217+
// programatically to account for the difference.
218+
boolean slashDateFormat = new SimpleDateFormat().toLocalizedPattern().startsWith("dd/");
219+
String expectedDateFormat = slashDateFormat ? "dd/mm/aaaa" : "dd-mm-aaaa";
220+
assertThat(startTextInput.getPlaceholderText().toString()).isEqualTo(expectedDateFormat);
221+
assertThat(endTextInput.getPlaceholderText().toString()).isEqualTo(expectedDateFormat);
215222
}
216223

217224
private View getRootView() {

lib/javatests/com/google/android/material/datepicker/SingleDateSelectorTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
import com.google.android.material.R;
1919

20-
import static org.hamcrest.Matchers.is;
21-
import static org.hamcrest.Matchers.nullValue;
20+
import static org.hamcrest.core.Is.is;
21+
import static org.hamcrest.core.IsNull.nullValue;
2222
import static org.junit.Assert.assertThat;
2323

2424
import android.content.Context;

0 commit comments

Comments
 (0)