-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a test to verify that a chooser is opened for exporting the pro…
…file
- Loading branch information
1 parent
2041ba3
commit 583918f
Showing
3 changed files
with
66 additions
and
9 deletions.
There are no files selected for viewing
8 changes: 4 additions & 4 deletions
8
androidTest/java/org/aprsdroid/app/ExampleInstrumentedTest.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
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,51 @@ | ||
package org.aprsdroid.app; | ||
|
||
import static androidx.test.espresso.Espresso.onView; | ||
import static androidx.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu; | ||
import static androidx.test.espresso.action.ViewActions.click; | ||
import static androidx.test.espresso.intent.matcher.IntentMatchers.hasAction; | ||
import static androidx.test.espresso.matcher.ViewMatchers.withText; | ||
import static org.hamcrest.Matchers.allOf; | ||
|
||
import android.app.Instrumentation; | ||
import android.content.Intent; | ||
import android.util.Log; | ||
|
||
import androidx.test.core.app.ActivityScenario; | ||
import androidx.test.espresso.intent.Intents; | ||
import androidx.test.ext.junit.runners.AndroidJUnit4; | ||
import androidx.test.platform.app.InstrumentationRegistry; | ||
|
||
import org.junit.After; | ||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
@RunWith(AndroidJUnit4.class) | ||
public class ProfileTests { | ||
@Before public void setUp() { | ||
Intents.init(); | ||
} | ||
|
||
@After public void tearDown() { | ||
Intents.release(); | ||
} | ||
|
||
@Test | ||
public void testThatExportProfileOpensTheChooser() { | ||
ActivityScenario scenario = ActivityScenario.launch(PrefsAct.class); | ||
Assert.assertEquals(1, Intents.getIntents().size()); | ||
Intents.intending(hasAction(Intent.ACTION_CHOOSER)).respondWith(new Instrumentation.ActivityResult(0, null)); | ||
Assert.assertEquals(1, Intents.getIntents().size()); | ||
openActionBarOverflowOrOptionsMenu(InstrumentationRegistry.getInstrumentation().getTargetContext()); | ||
onView(withText(R.string.profile_export)) | ||
.perform(click()); | ||
Intents.intended(hasAction(Intent.ACTION_MAIN)); // Validate the activity launch | ||
Intents.intended(allOf(hasAction(Intent.ACTION_CHOOSER))); | ||
Assert.assertEquals(2, Intents.getIntents().size()); | ||
Log.d("DDD", Intents.getIntents().get(0).toString()); | ||
Log.d("DDD", Intents.getIntents().get(1).toString()); | ||
Intents.assertNoUnverifiedIntents(); | ||
} | ||
} |
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