Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix part of #5485: Create means for verifying Fragment Arguments #5537

Closed
wants to merge 35 commits into from
Closed
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
d819e70
Merge pull request #1 from oppia/develop
subhajitxyz Jul 23, 2024
c6f54ea
Merge branch 'oppia:develop' into develop
subhajitxyz Jul 27, 2024
d44015b
Merge remote-tracking branch 'upstream/develop' into develop
subhajitxyz Aug 17, 2024
d604bc2
Merge pull request #2 from oppia/develop
subhajitxyz Aug 26, 2024
cc0ddef
Merge pull request #3 from oppia/develop
subhajitxyz Aug 26, 2024
52c6bb1
Merge pull request #4 from oppia/develop
subhajitxyz Aug 29, 2024
773c810
Merge remote-tracking branch 'upstream/develop' into develop
subhajitxyz Sep 5, 2024
56af5ae
Merge pull request #5 from oppia/develop
subhajitxyz Sep 16, 2024
96b6f44
Tests are added for fragment arguments and onsaveinstance
subhajitxyz Sep 16, 2024
6afebe6
Corrected TopicInfoFragmentTest
subhajitxyz Sep 16, 2024
2ecb6b2
Solved code formatting
subhajitxyz Sep 16, 2024
70e0674
Solved Klint issue
subhajitxyz Sep 16, 2024
b7bd4e6
Correct Kdoc formatting
subhajitxyz Sep 17, 2024
002ceba
Changes as per review suggestion
subhajitxyz Sep 21, 2024
07ec171
Merge remote-tracking branch 'upstream/develop' into fragment-tests-p…
subhajitxyz Sep 21, 2024
b261b7c
Made changes in PoliciesFragmentTest
subhajitxyz Sep 22, 2024
906e8c8
Fix Kdoc in PoliciesFragment
subhajitxyz Sep 22, 2024
19dc149
Merge branch 'develop' into fragment-tests-part3
BenHenning Oct 18, 2024
8c580ac
do correction as per review
subhajitxyz Nov 19, 2024
f3aea03
Fix Part of #4938: Language Selection Config and New Profile Creation…
adhiamboperes Oct 18, 2024
e09e428
Fixes multiple onboarding events issue (#5551)
kkmurerwa Oct 21, 2024
820569c
Fix #5547 : Added Developer Onboarding Notification (#5549)
Mayank77maruti Oct 23, 2024
ab0977c
Fix #5473: Add wiki guide for upgrading the app's compile/target SDK …
BenHenning Oct 25, 2024
17e6174
Localisation updates from https://translatewiki.net. (#5274)
translatewiki Oct 28, 2024
fe46540
Fix #5329: Add color formatting to static check messages (#5540)
dattasneha Oct 29, 2024
94fd8be
Fix #2652 : Improve splash screen implementation with new drawable an…
TanishMoral11 Oct 30, 2024
492a54c
fix
subhajitxyz Nov 19, 2024
a4aeed9
fix
subhajitxyz Nov 19, 2024
168c98d
Fixes #5484: Multiple substitutions specified in non-positional forma…
jainv4156 Nov 4, 2024
e78a3fa
Fix #4419: Remove TODO Marked Files And Other Alpha Kenya Related Fil…
XichengSpencer Nov 6, 2024
2fdb5c6
Localisation updates from https://translatewiki.net. (#5569)
translatewiki Nov 7, 2024
ec3f615
Fix #5232: ConsoleLogger overwrites local log file for each line writ…
manas-yu Nov 11, 2024
368af6c
Fix #5566: Handle action_required status in code coverage (#5574)
manas-yu Nov 14, 2024
9d4edf0
Fixes #3641 Use finish() instead of intent for smoother navigation (#…
theayushyadav11 Nov 15, 2024
2837f94
Fix#3146 : Create a generic utility for filtering enums (#5529)
whyash8 Nov 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ class LicenseTextViewerFragment : InjectableFragment() {

companion object {
/** Argument key for LicenseTextViewerFragment. */
private const val LICENSE_TEXT_VIEWER_FRAGMENT_ARGUMENTS_KEY =
"LicenseTextViewerFragment.arguments"
const val LICENSE_TEXT_VIEWER_FRAGMENT_ARGUMENTS_KEY = "LicenseTextViewerFragment.arguments"

/** Returns an instance of [LicenseTextViewerFragment]. */
fun newInstance(dependencyIndex: Int, licenseIndex: Int): LicenseTextViewerFragment {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import org.oppia.android.util.extensions.getProto
import org.oppia.android.util.extensions.putProto
import javax.inject.Inject

private const val POLICIES_FRAGMENT_POLICY_PAGE_ARGUMENT_PROTO = "PoliciesFragment.policy_page"
/** Argument key for PoliciesFragment. */
const val POLICIES_FRAGMENT_POLICY_PAGE_ARGUMENT_PROTO = "PoliciesFragment.policy_page"

/** Fragment that contains policies flow of the app. */
class PoliciesFragment : InjectableFragment() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,14 @@ class TopicLessonsFragment :
) {
topicLessonsFragmentPresenter.selectChapterSummary(storyId, explorationId, chapterPlayState)
}

/** Returns the [currentExpandedChapterListIndex] stored in the fragment. */
fun getCurrentExpandedChapterListIndex(): Int? {
return currentExpandedChapterListIndex
}

/** Returns the [isDefaultStoryExpanded] stored in the fragment. */
fun getIsDefaultStoryExpanded(): Boolean {
return isDefaultStoryExpanded
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than exposing internal state variables for test verification, is it possible to verify that the UI is in the correct state such that we can infer these? For example, could we check that the (expected) default story is currently expanded?

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import android.view.ViewParent
import android.widget.FrameLayout
import androidx.appcompat.app.AppCompatActivity
import androidx.core.widget.NestedScrollView
import androidx.drawerlayout.widget.DrawerLayout
import androidx.test.core.app.ActivityScenario.launch
import androidx.test.core.app.ApplicationProvider
import androidx.test.espresso.Espresso.onView
Expand All @@ -23,6 +24,7 @@ import androidx.test.espresso.matcher.ViewMatchers.isClickable
import androidx.test.espresso.matcher.ViewMatchers.isRoot
import androidx.test.espresso.util.HumanReadables
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.google.common.truth.Truth.assertThat
import dagger.Component
import org.hamcrest.Matcher
import org.hamcrest.Matchers
Expand All @@ -44,6 +46,7 @@ import org.oppia.android.app.application.ApplicationStartupListenerModule
import org.oppia.android.app.application.testing.TestingBuildFlavorModule
import org.oppia.android.app.devoptions.DeveloperOptionsModule
import org.oppia.android.app.devoptions.DeveloperOptionsStarterModule
import org.oppia.android.app.model.AdministratorControlsFragmentArguments
import org.oppia.android.app.player.state.itemviewmodel.SplitScreenInteractionModule
import org.oppia.android.app.recyclerview.RecyclerViewMatcher.Companion.atPositionOnView
import org.oppia.android.app.recyclerview.RecyclerViewMatcher.Companion.scrollToPosition
Expand Down Expand Up @@ -98,6 +101,7 @@ import org.oppia.android.testing.time.FakeOppiaClockModule
import org.oppia.android.util.accessibility.AccessibilityTestModule
import org.oppia.android.util.caching.AssetModule
import org.oppia.android.util.caching.testing.CachingTestModule
import org.oppia.android.util.extensions.getProto
import org.oppia.android.util.gcsresource.GcsResourceModule
import org.oppia.android.util.locale.LocaleProdModule
import org.oppia.android.util.logging.EventLoggingConfigurationModule
Expand Down Expand Up @@ -434,6 +438,36 @@ class AdministratorControlsFragmentTest {
}
}

@Test
fun testAdministratorControlsFragment_fragmentLoaded_verifyCorrectArgumentsPassed() {
launch<AdministratorControlsFragmentTestActivity>(
createAdministratorControlsFragmentTestActivityIntent(
profileId = internalProfileId
)
).use { scenario ->
testCoroutineDispatchers.runCurrent()
scenario.onActivity { activity ->

val administratorControlsFragment = activity.supportFragmentManager
.findFragmentById(R.id.administrator_controls_fragment_test_activity_fragment_container)
as AdministratorControlsFragment
val isMultipane = activity
.findViewById<DrawerLayout>(R.id.administrator_controls_activity_drawer_layout) != null

val arguments = checkNotNull(administratorControlsFragment.arguments) {
"Expected arguments to be passed to AdministratorControlsFragment"
}
val args = arguments.getProto(
ADMINISTRATOR_CONTROLS_FRAGMENT_ARGUMENTS_KEY,
AdministratorControlsFragmentArguments.getDefaultInstance()
)
val receivedIsMultipane = args.isMultipane

assertThat(receivedIsMultipane).isEqualTo(isMultipane)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will 'isMultipane' always be true/false based on the configuration of the test? It would probably be more robust to set up the test such that we can always verify true/false as expected per the test setup (and add a second test for the opposite case so that both 'true' and 'false' are explicitly verified).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BenHenning , Please check, Could we do like this way?
Create variable isMultipane in AdministratorControlsFragmentTestActivityPresenter.
while testing for ismultipane true, i am setting isMultipane true and calling presenter.handleOnCreate().

/** The presenter for [AdministratorControlsFragmentTestActivity]. */
@ActivityScope
class AdministratorControlsFragmentTestActivityPresenter @Inject constructor(
  private val activity: AppCompatActivity
) {
  var isMultipane = false

  /** Initializes the [AdministratorControlsFragmentTestActivity] and sets the navigation drawer. */
  fun handleOnCreate() {
    activity.setContentView(R.layout.administrator_controls_fragment_test_activity)
    activity.supportFragmentManager.beginTransaction().replace(
      R.id.administrator_controls_fragment_test_activity_fragment_container,
      AdministratorControlsFragment.newInstance(isMultipane)
    ).commitNow()
  }
}

///testing when is multipane is set true.

@Test
  fun testFragmentArguments_afterCreationWithIsMultipaneTrue_areCorrect() {
    launch<AdministratorControlsFragmentTestActivity>(
      createAdministratorControlsFragmentTestActivityIntent(
        profileId = internalProfileId
      )
    ).use { scenario ->
      testCoroutineDispatchers.runCurrent()
      scenario.onActivity { activity ->
        val presenter = activity.administratorControlsFragmentTestActivityPresenter
        presenter.isMultipane = true // Set `isMultipane` to true
        presenter.handleOnCreate()

        val administratorControlsFragment = activity.supportFragmentManager
          .findFragmentById(R.id.administrator_controls_fragment_test_activity_fragment_container)
          as AdministratorControlsFragment

        val arguments = checkNotNull(administratorControlsFragment.arguments) {
          "Expected arguments to be passed to AdministratorControlsFragment"
        }
        val args = arguments.getProto(
          ADMINISTRATOR_CONTROLS_FRAGMENT_ARGUMENTS_KEY,
          AdministratorControlsFragmentArguments.getDefaultInstance()
        )
        val receivedIsMultipane = args.isMultipane

        assertThat(receivedIsMultipane).isEqualTo(true)
      }
    }
  }

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that will work--the activity lifecycle methods need to be handled by Android (and specifically Robolectric when running the tests locally).

Normally multi-pane is automatically determined in production code by checking whether the current device is a tablet. We're able to configure tests to run with a tablet display environment (using per-test qualifiers). Would that work in this case? Here's one example of such a test configuration:

fun testHelpFragment_defaultTabletConfig_displaysMultipaneOptions() {

}
}
}

private fun clickAutoUpdateTopicContainer() {
onView(
atPositionOnView(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ import org.oppia.android.util.networking.NetworkConnectionDebugUtilModule
import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule
import org.oppia.android.util.parser.html.HtmlParserEntityTypeModule
import org.oppia.android.util.parser.image.ImageParsingModule
import org.oppia.android.util.profile.CurrentUserProfileIdIntentDecorator.extractCurrentUserProfileId
import org.robolectric.annotation.Config
import org.robolectric.annotation.LooperMode
import javax.inject.Inject
Expand Down Expand Up @@ -1650,6 +1651,31 @@ class RecentlyPlayedFragmentTest {
}
}

@Test
fun testRecentlyPlayedFragment_fragmentLoaded_verifyCorrectArgumentsPassed() {
ActivityScenario.launch<RecentlyPlayedActivity>(
createRecentlyPlayedActivityIntent(
internalProfileId = internalProfileId,
RecentlyPlayedActivityTitle.STORIES_FOR_YOU
)
).use { scenario ->
testCoroutineDispatchers.runCurrent()
scenario.onActivity { activity ->

val recentlyPlayedFragment = activity.supportFragmentManager
.findFragmentById(R.id.recently_played_fragment_placeholder) as RecentlyPlayedFragment

val arguments = checkNotNull(recentlyPlayedFragment.arguments) {
"Expected arguments to be passed to RecentlyPlayedFragment"
}
val profileId = arguments.extractCurrentUserProfileId()
val receivedInternalProfileId = profileId.internalId

assertThat(receivedInternalProfileId).isEqualTo(internalProfileId)
}
}
}

private fun setUpTestFragment(activity: RecentlyPlayedActivity) {
activity.supportFragmentManager
.beginTransaction()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ import org.oppia.android.app.devoptions.DeveloperOptionsModule
import org.oppia.android.app.devoptions.DeveloperOptionsStarterModule
import org.oppia.android.app.model.OppiaLanguage
import org.oppia.android.app.model.ProfileId
import org.oppia.android.app.model.StateFragmentArguments
import org.oppia.android.app.model.WrittenTranslationLanguageSelection
import org.oppia.android.app.player.state.itemviewmodel.SplitScreenInteractionModule
import org.oppia.android.app.player.state.itemviewmodel.StateItemViewModel
Expand Down Expand Up @@ -177,6 +178,7 @@ import org.oppia.android.util.accessibility.AccessibilityTestModule
import org.oppia.android.util.caching.AssetModule
import org.oppia.android.util.caching.LoadImagesFromAssets
import org.oppia.android.util.caching.LoadLessonProtosFromAssets
import org.oppia.android.util.extensions.getProto
import org.oppia.android.util.gcsresource.GcsResourceModule
import org.oppia.android.util.locale.LocaleProdModule
import org.oppia.android.util.logging.EventLoggingConfigurationModule
Expand Down Expand Up @@ -5004,6 +5006,39 @@ class StateFragmentTest {
}
}

@Test
fun testStateFragment_fragmentLoaded_verifyCorrectArgumentsPassed() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fun testStateFragment_fragmentLoaded_verifyCorrectArgumentsPassed() {
fun testFragmentArguments_afterCreation_areCorrect() {

Slightly more deliberate way to name what's being tested. Ditto for all other tests in this PR.

setUpTestWithLanguageSwitchingFeatureOff()
launchForExploration(
FRACTIONS_EXPLORATION_ID_1,
shouldSavePartialProgress = false
).use { scenario ->
testCoroutineDispatchers.unregisterIdlingResource()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why unregister the idling resource? This seems rather unusual.

startPlayingExploration()

scenario.onActivity { activity ->
val stateFragment = activity.supportFragmentManager
.findFragmentById(R.id.state_fragment_placeholder) as StateFragment

val args =
stateFragment.arguments?.getProto(
StateFragment.STATE_FRAGMENT_ARGUMENTS_KEY,
StateFragmentArguments.getDefaultInstance()
)

val receivedInternalProfileId = args?.internalProfileId ?: -1
val receivedTopicId = args?.topicId!!
val receivedStoryId = args.storyId!!
val reveivedExplorationId = args.explorationId!!

assertThat(receivedInternalProfileId).isEqualTo(profileId.internalId)
assertThat(receivedTopicId).isEqualTo(TEST_TOPIC_ID_0)
assertThat(receivedStoryId).isEqualTo(TEST_STORY_ID_0)
assertThat(reveivedExplorationId).isEqualTo(FRACTIONS_EXPLORATION_ID_1)
}
}
}

private fun addShadowMediaPlayerException(dataSource: Any, exception: Exception) {
val classLoader = StateFragmentTest::class.java.classLoader!!
val shadowMediaPlayerClass = classLoader.loadClass("org.robolectric.shadows.ShadowMediaPlayer")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ import org.oppia.android.app.application.ApplicationStartupListenerModule
import org.oppia.android.app.application.testing.TestingBuildFlavorModule
import org.oppia.android.app.devoptions.DeveloperOptionsModule
import org.oppia.android.app.devoptions.DeveloperOptionsStarterModule
import org.oppia.android.app.model.PoliciesActivityParams
import org.oppia.android.app.model.PoliciesFragmentArguments
import org.oppia.android.app.model.PolicyPage
import org.oppia.android.app.player.state.itemviewmodel.SplitScreenInteractionModule
import org.oppia.android.app.shim.ViewBindingShimModule
Expand Down Expand Up @@ -101,6 +103,8 @@ import org.oppia.android.testing.time.FakeOppiaClockModule
import org.oppia.android.util.accessibility.AccessibilityTestModule
import org.oppia.android.util.caching.AssetModule
import org.oppia.android.util.caching.testing.CachingTestModule
import org.oppia.android.util.extensions.getProto
import org.oppia.android.util.extensions.getProtoExtra
import org.oppia.android.util.gcsresource.DefaultResourceBucketName
import org.oppia.android.util.gcsresource.GcsResourceModule
import org.oppia.android.util.locale.LocaleProdModule
Expand Down Expand Up @@ -325,6 +329,44 @@ class PoliciesFragmentTest {
}
}

@Test
fun testPoliciesFragment_fragmentLoaded_verifyCorrectArgumentsPassed() {
launch<PoliciesFragmentTestActivity>(
createPoliciesFragmentTestIntent(
getApplicationContext(),
PolicyPage.TERMS_OF_SERVICE
)
).use { scenario ->
testCoroutineDispatchers.runCurrent()
scenario.onActivity { activity ->

val policiesFragment = activity.supportFragmentManager
.findFragmentById(R.id.policies_fragment_placeholder) as PoliciesFragment

val policiesActivityParams = activity.intent.getProtoExtra(
PoliciesFragmentTestActivity.POLICIES_FRAGMENT_TEST_POLICY_PAGE_PARAMS_PROTO,
PoliciesActivityParams.getDefaultInstance()
)
val policiesFragmentArguments =
PoliciesFragmentArguments
.newBuilder()
.setPolicyPage(policiesActivityParams.policyPage)
.build()

val args = checkNotNull(policiesFragment.arguments) {
"Expected arguments to be passed to PoliciesFragment"
}
val receivedPolicies =
args.getProto(
POLICIES_FRAGMENT_POLICY_PAGE_ARGUMENT_PROTO,
PoliciesFragmentArguments.getDefaultInstance()
)

assertThat(receivedPolicies).isEqualTo(policiesFragmentArguments)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer checking the properties of the proto rather than the whole thing (since it helps make the test more deliberate and contextual).

}
}
}

private fun setUpTestApplicationComponent() {
getApplicationContext<TestApplication>().inject(this)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule
import org.oppia.android.util.parser.html.HtmlParserEntityTypeModule
import org.oppia.android.util.parser.image.GlideImageLoaderModule
import org.oppia.android.util.parser.image.ImageParsingModule
import org.oppia.android.util.profile.CurrentUserProfileIdIntentDecorator.extractCurrentUserProfileId
import org.oppia.android.util.profile.PROFILE_ID_INTENT_DECORATOR
import org.robolectric.annotation.Config
import org.robolectric.annotation.LooperMode
Expand Down Expand Up @@ -826,6 +827,27 @@ class ProfileProgressFragmentTest {
}
}

@Test
fun testProfileProgressFragment_fragmentLoaded_verifyCorrectArgumentsPassed() {
launch<ProfileProgressActivity>(
createProfileProgressActivityIntent(internalProfileId)
).use { scenario ->
testCoroutineDispatchers.runCurrent()
scenario.onActivity { activity ->

val profileProgressFragment = activity.supportFragmentManager
.findFragmentById(R.id.profile_progress_fragment_placeholder) as ProfileProgressFragment

val args = checkNotNull(profileProgressFragment.arguments) {
"Expected arguments to be passed to ProfileProgressFragment"
}
val receivedInternalProfileId = args.extractCurrentUserProfileId().internalId

assertThat(receivedInternalProfileId).isEqualTo(internalProfileId)
}
}
}

private fun createGalleryPickActivityResultStub(): Instrumentation.ActivityResult {
val resources: Resources = context.resources
val imageUri = Uri.parse(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import androidx.test.espresso.matcher.ViewMatchers.isRoot
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.google.common.truth.Truth.assertThat
import dagger.Component
import org.junit.After
import org.junit.Before
Expand All @@ -31,6 +32,8 @@ import org.oppia.android.app.application.testing.TestingBuildFlavorModule
import org.oppia.android.app.devoptions.DeveloperOptionsModule
import org.oppia.android.app.devoptions.DeveloperOptionsStarterModule
import org.oppia.android.app.help.thirdparty.LicenseTextViewerActivity
import org.oppia.android.app.help.thirdparty.LicenseTextViewerFragment
import org.oppia.android.app.model.LicenseTextViewerFragmentArguments
import org.oppia.android.app.player.state.itemviewmodel.SplitScreenInteractionModule
import org.oppia.android.app.shim.ViewBindingShimModule
import org.oppia.android.app.translation.testing.ActivityRecreatorTestModule
Expand Down Expand Up @@ -77,6 +80,7 @@ import org.oppia.android.testing.time.FakeOppiaClockModule
import org.oppia.android.util.accessibility.AccessibilityTestModule
import org.oppia.android.util.caching.AssetModule
import org.oppia.android.util.caching.testing.CachingTestModule
import org.oppia.android.util.extensions.getProto
import org.oppia.android.util.gcsresource.GcsResourceModule
import org.oppia.android.util.locale.LocaleProdModule
import org.oppia.android.util.logging.EventLoggingConfigurationModule
Expand Down Expand Up @@ -317,6 +321,36 @@ class LicenseTextViewerFragmentTest {
}
}

@Test
fun testLicenseTextViewerFragment_fragmentLoaded_verifyCorrectArgumentsPassed() {
launch<LicenseTextViewerActivity>(
createLicenseTextViewerActivity(
dependencyIndex = 3,
licenseIndex = 1
)
).use { scenario ->
testCoroutineDispatchers.runCurrent()
scenario.onActivity { activity ->

val licenseTextViewerFragment = activity.supportFragmentManager
.findFragmentById(R.id.license_text_viewer_fragment_placeholder)
as LicenseTextViewerFragment
val arguments = checkNotNull(licenseTextViewerFragment.arguments) {
"Expected arguments to be passed to LicenseTextViewerFragment"
}
val args = arguments.getProto(
LicenseTextViewerFragment.LICENSE_TEXT_VIEWER_FRAGMENT_ARGUMENTS_KEY,
LicenseTextViewerFragmentArguments.getDefaultInstance()
)
val receivedDependencyIndex = args.dependencyIndex
val receivedLicenseIndex = args.licenseIndex

assertThat(receivedDependencyIndex).isEqualTo(3)
assertThat(receivedLicenseIndex).isEqualTo(1)
}
}
}

private fun createLicenseTextViewerActivity(dependencyIndex: Int, licenseIndex: Int): Intent {
return LicenseTextViewerActivity.createLicenseTextViewerActivityIntent(
ApplicationProvider.getApplicationContext(),
Expand Down
Loading
Loading