Skip to content

Commit

Permalink
Make avatarUrl optional, fix testContributorClick
Browse files Browse the repository at this point in the history
  • Loading branch information
ianhanniballake committed Feb 15, 2019
1 parent 1c641f5 commit 9acce5e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.rule.ActivityTestRule
import androidx.test.runner.AndroidJUnit4
import androidx.navigation.NavController
import androidx.navigation.fragment.FragmentNavigator
import com.android.example.github.R
import com.android.example.github.binding.FragmentBindingAdapters
import com.android.example.github.testing.SingleFragmentActivity
Expand All @@ -50,7 +51,9 @@ import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.ArgumentMatchers.any
import org.mockito.ArgumentMatchers.anyString
import org.mockito.ArgumentMatchers.eq
import org.mockito.Mockito.`when`
import org.mockito.Mockito.doNothing
import org.mockito.Mockito.mock
Expand Down Expand Up @@ -173,7 +176,8 @@ class RepoFragmentTest {
setContributors("aa", "bb", "cc")
onView(withText("cc")).perform(click())
verify(repoFragment.navController).navigate(
RepoFragmentDirections.showUser("cc")
eq(RepoFragmentDirections.showUser("cc")),
any(FragmentNavigator.Extras::class.java)
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class RepoFragment : Fragment(), Injectable {
imageView to contributor.login
)
navController().navigate(
RepoFragmentDirections.showUser(contributor.login, contributor.avatarUrl ?: ""),
RepoFragmentDirections.showUser(contributor.login, contributor.avatarUrl),
extras
)
}
Expand Down
5 changes: 3 additions & 2 deletions GithubBrowserSample/app/src/main/res/navigation/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
android:label="SearchFragment" >
<action
android:id="@+id/showRepo"
destination="@+id/repoFragment"
app:destination="@id/repoFragment" />
</fragment>
<fragment
Expand All @@ -50,7 +49,9 @@
app:argType="string"/>
<argument
android:name="avatarUrl"
app:argType="string"/>
android:defaultValue="@null"
app:argType="string"
app:nullable="true" />
<action
android:id="@+id/showRepo"
app:destination="@id/repoFragment" />
Expand Down

0 comments on commit 9acce5e

Please sign in to comment.