This repository has been archived by the owner on Feb 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a failing test for FileUriExposedException on Nougat
- Loading branch information
1 parent
9187962
commit 8fb5579
Showing
1 changed file
with
85 additions
and
0 deletions.
There are no files selected for viewing
85 changes: 85 additions & 0 deletions
85
...src/androidTestUitests/java/com/nononsenseapps/filepicker/sample/SelectMultipleFiles.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package com.nononsenseapps.filepicker.sample; | ||
|
||
|
||
import android.support.test.espresso.ViewInteraction; | ||
import android.support.test.rule.ActivityTestRule; | ||
import android.support.test.runner.AndroidJUnit4; | ||
import android.test.suitebuilder.annotation.LargeTest; | ||
|
||
import org.junit.Before; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static android.support.test.espresso.Espresso.onView; | ||
import static android.support.test.espresso.action.ViewActions.click; | ||
import static android.support.test.espresso.assertion.ViewAssertions.matches; | ||
import static android.support.test.espresso.contrib.RecyclerViewActions.actionOnItemAtPosition; | ||
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; | ||
import static android.support.test.espresso.matcher.ViewMatchers.withId; | ||
import static android.support.test.espresso.matcher.ViewMatchers.withParent; | ||
import static android.support.test.espresso.matcher.ViewMatchers.withText; | ||
import static com.nononsenseapps.filepicker.sample.PermissionGranter.allowPermissionsIfNeeded; | ||
import static org.hamcrest.Matchers.allOf; | ||
|
||
@LargeTest | ||
@RunWith(AndroidJUnit4.class) | ||
public class SelectMultipleFiles { | ||
|
||
@Rule | ||
public ActivityTestRule<NoNonsenseFilePickerTest> mActivityTestRule = | ||
new ActivityTestRule<>(NoNonsenseFilePickerTest.class); | ||
|
||
@Before | ||
public void allowPermissions() { | ||
allowPermissionsIfNeeded(mActivityTestRule.getActivity()); | ||
} | ||
|
||
/** | ||
* Should not throw on Android 24 | ||
*/ | ||
@Test | ||
public void selectTwoFilesDoesNotThrow() { | ||
ViewInteraction radioButton = onView( | ||
allOf(withId(R.id.radioFile), withText("Select file"), | ||
withParent(withId(R.id.radioGroup)), | ||
isDisplayed())); | ||
radioButton.perform(click()); | ||
|
||
ViewInteraction checkBox = onView( | ||
allOf(withId(R.id.checkAllowMultiple), withText("Multiple items"), isDisplayed())); | ||
checkBox.perform(click()); | ||
|
||
ViewInteraction button = onView( | ||
allOf(withId(R.id.button_sd), withText("Pick SD-card"), isDisplayed())); | ||
button.perform(click()); | ||
|
||
ViewInteraction recyclerView = onView( | ||
allOf(withId(android.R.id.list), isDisplayed())); | ||
|
||
// Refresh view (into dir, and out again) | ||
recyclerView.perform(actionOnItemAtPosition(1, click())); | ||
recyclerView.perform(actionOnItemAtPosition(0, click())); | ||
|
||
// Click on test dir | ||
recyclerView.perform(actionOnItemAtPosition(1, click())); | ||
// sub dir | ||
recyclerView.perform(actionOnItemAtPosition(1, click())); | ||
// Select first two | ||
recyclerView.perform(actionOnItemAtPosition(1, click())); | ||
recyclerView.perform(actionOnItemAtPosition(2, click())); | ||
|
||
// Click OK | ||
ViewInteraction okButton = onView( | ||
allOf(withId(R.id.nnf_button_ok), | ||
withParent(allOf(withId(R.id.nnf_button_container), | ||
withParent(withId(R.id.nnf_buttons_container)))), | ||
isDisplayed())); | ||
okButton.perform(click()); | ||
|
||
ViewInteraction textView = onView(withId(R.id.text)); | ||
textView.check(matches( | ||
withText("file:///storage/emulated/0/000000_nonsense-tests/A-dir/file-1.txt\n" + | ||
"file:///storage/emulated/0/000000_nonsense-tests/A-dir/file-0.txt"))); | ||
} | ||
} |