Skip to content

Commit

Permalink
Add tests for profile picture upload
Browse files Browse the repository at this point in the history
  • Loading branch information
adhiamboperes committed Apr 9, 2024
1 parent 027d912 commit 0d7980f
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.oppia.android.app.onboarding

import android.app.Application
import android.content.Context
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.Lifecycle
import androidx.test.core.app.ActivityScenario
Expand All @@ -11,6 +12,8 @@ import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.action.ViewActions.closeSoftKeyboard
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.intent.Intents
import androidx.test.espresso.intent.Intents.intended
import androidx.test.espresso.intent.matcher.IntentMatchers.hasAction
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.isRoot
import androidx.test.espresso.matcher.ViewMatchers.withId
Expand Down Expand Up @@ -358,6 +361,29 @@ class CreateProfileFragmentTest {
}
}

@Test
fun testFragment_tapToAddPictureClicked_hasGalleryIntent() {
launchNewLearnerProfileActivity().use {
onView(withText(R.string.create_profile_activity_profile_picture_prompt))
.perform(click())
testCoroutineDispatchers.runCurrent()
intended(hasAction(Intent.ACTION_PICK))
}
}

@Config(qualifiers = "land")
@Test
fun testProfileProgressFragment_imageSelectAvatar_configChange_checkGalleryIntent() {
launchNewLearnerProfileActivity().use {
onView(isRoot()).perform(orientationLandscape())
testCoroutineDispatchers.runCurrent()
onView(withText(R.string.create_profile_activity_profile_picture_prompt))
.perform(click())
testCoroutineDispatchers.runCurrent()
intended(hasAction(Intent.ACTION_PICK))
}
}

private fun launchNewLearnerProfileActivity():
ActivityScenario<CreateProfileActivity>? {
val scenario = ActivityScenario.launch<CreateProfileActivity>(
Expand Down

0 comments on commit 0d7980f

Please sign in to comment.