|
15 | 15 | */
|
16 | 16 | package com.google.android.material.datepicker;
|
17 | 17 |
|
| 18 | +import static androidx.test.espresso.Espresso.onView; |
| 19 | +import static androidx.test.espresso.assertion.ViewAssertions.matches; |
| 20 | +import static androidx.test.espresso.matcher.ViewMatchers.isEnabled; |
| 21 | +import static androidx.test.espresso.matcher.ViewMatchers.withTagValue; |
18 | 22 | import static com.google.android.material.datepicker.MaterialDatePickerTestUtils.findFirstVisibleItem;
|
19 | 23 | import static org.hamcrest.Matchers.lessThan;
|
| 24 | +import static org.hamcrest.Matchers.not; |
| 25 | +import static org.hamcrest.core.IsEqual.equalTo; |
20 | 26 | import static org.junit.Assert.assertEquals;
|
21 | 27 | import static org.junit.Assert.assertFalse;
|
22 | 28 | import static org.junit.Assert.assertThat;
|
@@ -141,4 +147,44 @@ public void accessibility_daySelection_notScrollable() {
|
141 | 147 |
|
142 | 148 | assertFalse(nodeInfo.isScrollable());
|
143 | 149 | }
|
| 150 | + |
| 151 | + @Test |
| 152 | + public void previousButtonDisabledAtStartBoundary() { |
| 153 | + MaterialDatePickerTestUtils.clickPrev(); |
| 154 | + onView(withTagValue(equalTo(MaterialCalendar.NAVIGATION_PREV_TAG))) |
| 155 | + .check(matches(not(isEnabled()))); |
| 156 | + } |
| 157 | + |
| 158 | + @Test |
| 159 | + public void nextButtonDisabledAtEndBoundary() { |
| 160 | + MaterialDatePickerTestUtils.clickNext(); |
| 161 | + MaterialDatePickerTestUtils.clickNext(); |
| 162 | + MaterialDatePickerTestUtils.clickNext(); |
| 163 | + onView(withTagValue(equalTo(MaterialCalendar.NAVIGATION_NEXT_TAG))) |
| 164 | + .check(matches(not(isEnabled()))); |
| 165 | + } |
| 166 | + |
| 167 | + @Test |
| 168 | + public void nextButtonEnabledAtStartBoundary() { |
| 169 | + MaterialDatePickerTestUtils.clickPrev(); |
| 170 | + onView(withTagValue(equalTo(MaterialCalendar.NAVIGATION_NEXT_TAG))) |
| 171 | + .check(matches(isEnabled())); |
| 172 | + } |
| 173 | + |
| 174 | + @Test |
| 175 | + public void previousButtonEnabledAtEndBoundary() { |
| 176 | + MaterialDatePickerTestUtils.clickNext(); |
| 177 | + MaterialDatePickerTestUtils.clickNext(); |
| 178 | + MaterialDatePickerTestUtils.clickNext(); |
| 179 | + onView(withTagValue(equalTo(MaterialCalendar.NAVIGATION_PREV_TAG))) |
| 180 | + .check(matches(isEnabled())); |
| 181 | + } |
| 182 | + |
| 183 | + @Test |
| 184 | + public void navigationButtonsEnabledInMiddleOfBoundary() { |
| 185 | + onView(withTagValue(equalTo(MaterialCalendar.NAVIGATION_NEXT_TAG))) |
| 186 | + .check(matches(isEnabled())); |
| 187 | + onView(withTagValue(equalTo(MaterialCalendar.NAVIGATION_NEXT_TAG))) |
| 188 | + .check(matches(isEnabled())); |
| 189 | + } |
144 | 190 | }
|
0 commit comments