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 #137: Topic-play-tab low-fi (part-1) (Without expandable list) #260

Merged
merged 10 commits into from
Oct 24, 2019
Merged
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
Added test cases
  • Loading branch information
Rajat Talesra committed Oct 23, 2019
commit 95d05bc4881779f4d79a43c0ed13e4dc343f7034
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,24 @@ package org.oppia.app.topic.play

import android.app.Application
import android.content.Context
import android.content.res.Configuration
import androidx.test.core.app.ActivityScenario
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.hasDescendant
import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.rule.ActivityTestRule
import dagger.BindsInstance
import dagger.Component
import dagger.Module
import dagger.Provides
import kotlinx.coroutines.CoroutineDispatcher
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.oppia.app.R
import org.oppia.app.recyclerview.RecyclerViewMatcher.Companion.atPosition
import org.oppia.app.topic.TopicActivity
import org.oppia.util.threading.BackgroundDispatcher
import org.oppia.util.threading.BlockingDispatcher
Expand All @@ -25,13 +29,40 @@ import javax.inject.Singleton
@RunWith(AndroidJUnit4::class)
class TopicPlayFragmentTest {

// TODO(#137): Add following test-cases once story-progress function is implemented and expandable list is introduced.
rt4914 marked this conversation as resolved.
Show resolved Hide resolved
// Story progress is is displayed correctly.
rt4914 marked this conversation as resolved.
Show resolved Hide resolved
// Click on arrow to show and hide expandable list is working correctly.
// Expandable list is showing correct chapter names.
// Upon configuration change expanded list should remain expanded.
// Click on story-title or entire item should open [StoryActivity].
// Click on chapter in expandable list should start exploration.

@get:Rule
var activityTestRule: ActivityTestRule<TopicActivity> = ActivityTestRule(
TopicActivity::class.java, /* initialTouchMode= */ true, /* launchActivity= */ false
)

@Test
fun testTopicPlayFragment_loadFragmentWithTopicTestId0_storyName_isCorrect() {
ActivityScenario.launch(TopicActivity::class.java).use {
rt4914 marked this conversation as resolved.
Show resolved Hide resolved
onView(atPosition(R.id.story_summary_recycler_view, 0)).check(matches(hasDescendant(withText("First Story"))))
}
}

@Test
fun testTopicPlayFragment_loadFragment_textIsDisplayed() {
fun testTopicPlayFragment_loadFragmentWithTopicTestId0_chapterCount_isCorrect() {
ActivityScenario.launch(TopicActivity::class.java).use {
onView(withId(R.id.dummy_text_view)).check(matches(withText("This is dummy TextView for testing")))
onView(atPosition(R.id.story_summary_recycler_view, 0)).check(matches(hasDescendant(withText("1 Chapter"))))
}
}

@Test
fun testTopicPlayFragment_loadFragmentWithTopicTestId0_configurationChange_storyName_isCorrect() {
rt4914 marked this conversation as resolved.
Show resolved Hide resolved
activityTestRule.launchActivity(null)
activityTestRule.activity.requestedOrientation = Configuration.ORIENTATION_LANDSCAPE
onView(atPosition(R.id.story_summary_recycler_view, 0)).check(matches(hasDescendant(withText("1 Chapter"))))
}

@Module
class TestModule {
@Provides
Expand Down