Skip to content

Commit 0d7980f

Browse files
committed
Add tests for profile picture upload
1 parent 027d912 commit 0d7980f

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

app/src/sharedTest/java/org/oppia/android/app/onboarding/CreateProfileFragmentTest.kt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package org.oppia.android.app.onboarding
22

33
import android.app.Application
44
import android.content.Context
5+
import android.content.Intent
56
import androidx.appcompat.app.AppCompatActivity
67
import androidx.lifecycle.Lifecycle
78
import androidx.test.core.app.ActivityScenario
@@ -11,6 +12,8 @@ import androidx.test.espresso.action.ViewActions.click
1112
import androidx.test.espresso.action.ViewActions.closeSoftKeyboard
1213
import androidx.test.espresso.assertion.ViewAssertions.matches
1314
import androidx.test.espresso.intent.Intents
15+
import androidx.test.espresso.intent.Intents.intended
16+
import androidx.test.espresso.intent.matcher.IntentMatchers.hasAction
1417
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
1518
import androidx.test.espresso.matcher.ViewMatchers.isRoot
1619
import androidx.test.espresso.matcher.ViewMatchers.withId
@@ -358,6 +361,29 @@ class CreateProfileFragmentTest {
358361
}
359362
}
360363

364+
@Test
365+
fun testFragment_tapToAddPictureClicked_hasGalleryIntent() {
366+
launchNewLearnerProfileActivity().use {
367+
onView(withText(R.string.create_profile_activity_profile_picture_prompt))
368+
.perform(click())
369+
testCoroutineDispatchers.runCurrent()
370+
intended(hasAction(Intent.ACTION_PICK))
371+
}
372+
}
373+
374+
@Config(qualifiers = "land")
375+
@Test
376+
fun testProfileProgressFragment_imageSelectAvatar_configChange_checkGalleryIntent() {
377+
launchNewLearnerProfileActivity().use {
378+
onView(isRoot()).perform(orientationLandscape())
379+
testCoroutineDispatchers.runCurrent()
380+
onView(withText(R.string.create_profile_activity_profile_picture_prompt))
381+
.perform(click())
382+
testCoroutineDispatchers.runCurrent()
383+
intended(hasAction(Intent.ACTION_PICK))
384+
}
385+
}
386+
361387
private fun launchNewLearnerProfileActivity():
362388
ActivityScenario<CreateProfileActivity>? {
363389
val scenario = ActivityScenario.launch<CreateProfileActivity>(

0 commit comments

Comments
 (0)