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 135: Topic issues fixes #285

Merged
merged 97 commits into from
Nov 7, 2019
Merged
Changes from 1 commit
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
e2ed1c4
multiple tabs
nikitamarysolomanpvt Oct 7, 2019
089ea5a
Merge branch 'develop' of https://github.com/oppia/oppia-android into…
nikitamarysolomanpvt Oct 14, 2019
43016b6
nit changes
nikitamarysolomanpvt Oct 17, 2019
3a1a350
nit changes
nikitamarysolomanpvt Oct 17, 2019
405a45e
nit changes
nikitamarysolomanpvt Oct 17, 2019
72c7360
nit changes
nikitamarysolomanpvt Oct 17, 2019
c5ffa61
nit changes
nikitamarysolomanpvt Oct 17, 2019
47e2efc
nit changes
nikitamarysolomanpvt Oct 17, 2019
b4ed9bb
nit changes
nikitamarysolomanpvt Oct 17, 2019
9dd39b9
nit changes
nikitamarysolomanpvt Oct 17, 2019
b2fca59
nit changes
nikitamarysolomanpvt Oct 17, 2019
f0cb60f
cust_args
nikitamarysolomanpvt Oct 18, 2019
2d21695
multiple tabs will getting topic id from home
nikitamarysolomanpvt Oct 29, 2019
93b889b
test cases,multiple tabs will getting topic id from home
nikitamarysolomanpvt Oct 29, 2019
3130323
nit
nikitamarysolomanpvt Oct 29, 2019
bbe7cf3
nit
nikitamarysolomanpvt Oct 29, 2019
046e297
nit
nikitamarysolomanpvt Oct 30, 2019
ba506ab
nit
nikitamarysolomanpvt Oct 30, 2019
6f228d1
nit
nikitamarysolomanpvt Oct 30, 2019
24be11b
separate test cases for all four tabs
nikitamarysolomanpvt Oct 30, 2019
bfa2b78
nit
nikitamarysolomanpvt Oct 30, 2019
0c6d5d8
nit
nikitamarysolomanpvt Oct 30, 2019
f8f84f1
nit
nikitamarysolomanpvt Oct 30, 2019
efae9f7
nit
nikitamarysolomanpvt Oct 30, 2019
1ecfc2f
nit
nikitamarysolomanpvt Oct 30, 2019
293aa52
nit
nikitamarysolomanpvt Oct 30, 2019
949f89e
nit
nikitamarysolomanpvt Oct 30, 2019
71ae233
nit
nikitamarysolomanpvt Oct 30, 2019
423dd37
Topic Overview see more click and tab switch
nikitamarysolomanpvt Oct 31, 2019
d3458e1
Topic Overview see more click and tab switch
nikitamarysolomanpvt Oct 31, 2019
032cfeb
Topic Overview see more click and tab switch
nikitamarysolomanpvt Oct 31, 2019
7084858
topic id todo's are implemented, test cases updated as per new data t…
nikitamarysolomanpvt Oct 31, 2019
bb42cf1
Topic Overview see more click and tab switch
nikitamarysolomanpvt Oct 31, 2019
b4b7763
nit
nikitamarysolomanpvt Oct 31, 2019
8c67e7e
nit
nikitamarysolomanpvt Oct 31, 2019
f4451ea
merged with develop
nikitamarysolomanpvt Oct 31, 2019
a598fc7
Merge branch 'develop' of https://github.com/oppia/oppia-android into…
nikitamarysolomanpvt Oct 31, 2019
203a5a2
merged with base branch
nikitamarysolomanpvt Oct 31, 2019
f1e3b48
merged with base branch
nikitamarysolomanpvt Oct 31, 2019
ad38ec6
nit
nikitamarysolomanpvt Oct 31, 2019
e137f99
revert back to develop
nikitamarysolomanpvt Oct 31, 2019
92a6b26
revert back to develop
nikitamarysolomanpvt Oct 31, 2019
413b811
revert back to develop
nikitamarysolomanpvt Oct 31, 2019
344e153
revert back to develop
nikitamarysolomanpvt Oct 31, 2019
8545a66
revert back to develop
nikitamarysolomanpvt Oct 31, 2019
2304174
revert back to develop
nikitamarysolomanpvt Oct 31, 2019
d5041b9
revert back to develop
nikitamarysolomanpvt Oct 31, 2019
4934518
revert back to develop
nikitamarysolomanpvt Oct 31, 2019
3410a17
revert back to develop
nikitamarysolomanpvt Oct 31, 2019
3e366b6
revert back to develop
nikitamarysolomanpvt Oct 31, 2019
12da7e9
revert back to develop
nikitamarysolomanpvt Oct 31, 2019
41903fb
revert back to develop
nikitamarysolomanpvt Oct 31, 2019
2339b10
revert back to develop
nikitamarysolomanpvt Oct 31, 2019
bd1949f
revert back to develop
nikitamarysolomanpvt Oct 31, 2019
8599de6
revert back to develop
nikitamarysolomanpvt Oct 31, 2019
edf1a95
revert back to develop
nikitamarysolomanpvt Oct 31, 2019
f19daa8
revert back to develop
nikitamarysolomanpvt Oct 31, 2019
916ccc2
nit changes
nikitamarysolomanpvt Nov 2, 2019
afdabd5
nit changes,
nikitamarysolomanpvt Nov 2, 2019
549a0b1
nit changes
nikitamarysolomanpvt Nov 2, 2019
758b7e6
nit changes
nikitamarysolomanpvt Nov 2, 2019
5b7312a
nit changes
nikitamarysolomanpvt Nov 2, 2019
45bc1d6
nit changes
nikitamarysolomanpvt Nov 2, 2019
0d5c057
nit changes
nikitamarysolomanpvt Nov 2, 2019
33753cc
nit changes
nikitamarysolomanpvt Nov 4, 2019
89b274a
set title on the basis of selected topic in topic screen.other nit ch…
nikitamarysolomanpvt Nov 5, 2019
1827e95
nit
nikitamarysolomanpvt Nov 5, 2019
d21250e
Merge branches 'develop' and 'topic-player-multiple-tabs' of https://…
nikitamarysolomanpvt Nov 5, 2019
e0c6b06
Merge branches 'develop' and 'topic-player-multiple-tabs' of https://…
nikitamarysolomanpvt Nov 5, 2019
3230c2f
Merge branches 'develop' and 'topic-player-multiple-tabs' of https://…
nikitamarysolomanpvt Nov 5, 2019
9695194
nit
nikitamarysolomanpvt Nov 5, 2019
40e449e
nit
nikitamarysolomanpvt Nov 5, 2019
51350f2
nit
nikitamarysolomanpvt Nov 5, 2019
10593a7
nit
nikitamarysolomanpvt Nov 5, 2019
772f98c
Merge branches 'develop' and 'topic-player-multiple-tabs' of https://…
nikitamarysolomanpvt Nov 5, 2019
f6569ff
Merge branches 'develop' and 'topic-player-multiple-tabs' of https://…
nikitamarysolomanpvt Nov 5, 2019
bacebd2
nit in TopicFragmentPresenter changed var to val in line number 69
nikitamarysolomanpvt Nov 5, 2019
a0c01af
Merge branches 'develop' and 'topic_issues_fixs' of https://github.co…
nikitamarysolomanpvt Nov 5, 2019
7d44c0a
nit
nikitamarysolomanpvt Nov 5, 2019
8cede53
shorten stackoverflow link,testcase method name change
nikitamarysolomanpvt Nov 5, 2019
61fe4d5
nit changes suggested by Rajat
nikitamarysolomanpvt Nov 5, 2019
83ad843
merged with develop
nikitamarysolomanpvt Nov 6, 2019
1aa955e
nit
nikitamarysolomanpvt Nov 6, 2019
5a2508c
Merge branches 'topic-player-multiple-tabs' and 'topic_issues_fixs' o…
nikitamarysolomanpvt Nov 6, 2019
e6b4532
nit
nikitamarysolomanpvt Nov 6, 2019
f806cc8
used enum to set current tab in TopicFragmentPresenter.
nikitamarysolomanpvt Nov 6, 2019
aedfd66
Merge branches 'develop' and 'topic_issues_fixs' of https://github.co…
nikitamarysolomanpvt Nov 6, 2019
321496c
nit
nikitamarysolomanpvt Nov 7, 2019
79a5dcf
nit
nikitamarysolomanpvt Nov 7, 2019
534905e
nit
nikitamarysolomanpvt Nov 7, 2019
94240b2
nit
nikitamarysolomanpvt Nov 7, 2019
d122006
Merge branch 'develop' of https://github.com/oppia/oppia-android into…
nikitamarysolomanpvt Nov 7, 2019
9faff37
nit
nikitamarysolomanpvt Nov 7, 2019
bb6f4ce
nit
nikitamarysolomanpvt Nov 7, 2019
5c6ebe7
nit
nikitamarysolomanpvt Nov 7, 2019
1cc1af3
nit
nikitamarysolomanpvt Nov 7, 2019
7e93850
Merge branches 'develop' and 'topic_issues_fixs' of https://github.co…
nikitamarysolomanpvt Nov 7, 2019
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
separate test cases for all four tabs
  • Loading branch information
nikitamarysolomanpvt committed Oct 30, 2019
commit 24be11b98d3239a52da204fe75bbebfa4461284d
213 changes: 206 additions & 7 deletions app/src/sharedTest/java/org/oppia/app/topic/TopicFragmentTest.kt
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ package org.oppia.app.topic
import android.app.Application
import android.content.Context
import android.content.res.Configuration
import android.view.View
import androidx.annotation.UiThread
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.ext.junit.runners.AndroidJUnit4
@@ -12,20 +13,28 @@ import org.junit.Test
import org.junit.runner.RunWith
import org.oppia.app.R
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.PerformException
import androidx.test.espresso.action.ViewActions
import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers.isCompletelyDisplayed
import androidx.test.espresso.matcher.ViewMatchers.isDescendantOfA
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.isEnabled
import androidx.test.espresso.matcher.ViewMatchers.withText
import com.google.android.material.tabs.TabLayout
import dagger.BindsInstance
import dagger.Component
import dagger.Module
import dagger.Provides
import kotlinx.coroutines.CoroutineDispatcher
import org.hamcrest.CoreMatchers.allOf
import org.hamcrest.Description
import org.hamcrest.Matcher
import org.hamcrest.Matchers
import org.hamcrest.TypeSafeMatcher
import org.oppia.app.recyclerview.RecyclerViewMatcher.Companion.atPosition
import org.oppia.app.utility.EspressoTestsMatchers.matchCurrentTabTitle
import org.oppia.util.threading.BackgroundDispatcher
import org.oppia.util.threading.BlockingDispatcher
import javax.inject.Singleton
@@ -57,7 +66,54 @@ class TopicFragmentTest {

@Test
@UiThread
fun testTopicActivity_clickOnTabs_isTabSwitchAndContentMatched() {
fun testTopicActivity_showsTopicActivityWithMultipleTabs_isTabLayoutDisplayedWithOverviewTabSelectedWhenOpenedFirstTime() {
activityTestRule.launchActivity(null)

onView(
allOf(
withText("OVERVIEW"),
isDescendantOfA(withId(R.id.topic_tabs_container))
)
)
onView(withId(R.id.topic_tabs_container)).check(matches(matchCurrentTabTitle("OVERVIEW")))
}

@Test
@UiThread
fun testTopicActivity_isOverviewTabSelectedAndContentMatched() {
activityTestRule.launchActivity(null)
onView(
allOf(
withText("OVERVIEW"),
isDescendantOfA(withId(R.id.topic_tabs_container))
)
)
onView(withId(R.id.topic_tabs_container)).check(matches(matchCurrentTabTitle("OVERVIEW")))
onView(withId(R.id.topic_name_text_view)).check(
matches(
withText(
Matchers.containsString(topicName)
)
)
)
}

@Test
@UiThread
fun testTopicActivity_clickOnPlayTab_isTabSwitchedToPlayTabAndTabIsSelected() {
activityTestRule.launchActivity(null)
onView(
allOf(
withText("PLAY"),
isDescendantOfA(withId(R.id.topic_tabs_container))
)
).perform(click())
onView(withId(R.id.topic_tabs_container)).check(matches(matchCurrentTabTitle("PLAY")))
}

@Test
@UiThread
fun testTopicActivity_clickOnPlayTab_isPlayTabIsSelectedAndContentMatched() {
activityTestRule.launchActivity(null)
onView(
allOf(
@@ -66,13 +122,51 @@ class TopicFragmentTest {
)
).perform(click())
onView(withText("First Story")).check(matches(isDisplayed()))
}

@Test
@UiThread
fun testTopicActivity_clickOnTrainTab_isSwitchToTrainTabAndTrainTabIsSelected() {
activityTestRule.launchActivity(null)
onView(
allOf(
withText("TRAIN"),
isDescendantOfA(withId(R.id.topic_tabs_container))
)
).perform(click())
onView(withId(R.id.topic_tabs_container)).check(matches(matchCurrentTabTitle("TRAIN")))
}

@Test
@UiThread
fun testTopicActivity_clickOnTrainTab_isTrainTabIsSelectedAndContentMatched() {
activityTestRule.launchActivity(null)
onView(
allOf(
withText("TRAIN"),
isDescendantOfA(withId(R.id.topic_tabs_container))
)
).perform(click())
onView(withText("Master These Skills")).check(matches(isDisplayed()))
}

@Test
@UiThread
fun testTopicActivity_clickOnReviewTab_isSwitchToReviewTabAndReviewTabIsSelected() {
activityTestRule.launchActivity(null)
onView(
allOf(
withText("REVIEW"),
isDescendantOfA(withId(R.id.topic_tabs_container))
)
).perform(click())
onView(withId(R.id.topic_tabs_container)).check(matches(matchCurrentTabTitle("REVIEW")))
}

@Test
@UiThread
fun testTopicActivity_clickOnReviewTab_isReviewTabIsSelectedAndContentMatched() {
activityTestRule.launchActivity(null)
onView(
allOf(
withText("REVIEW"),
@@ -83,8 +177,40 @@ class TopicFragmentTest {
allOf(
atPosition(R.id.review_skill_recycler_view, 0).also { withText("An important skill") },
isDescendantOfA(withId(R.id.review_skill_recycler_view))
).also { withId(R.id.skill_name) }
)
).also { withId(R.id.skill_name) })
}

@Test
@UiThread
fun testTopicActivity_showsTopicActivityWithMultipleTabs_clickOnOverviewTab_isTabLayoutDisplayedWithOverviewTabSelected() {
activityTestRule.launchActivity(null)
onView(
allOf(
withText("REVIEW"),
isDescendantOfA(withId(R.id.topic_tabs_container))
)
).perform(click())
onView(
allOf(
withText("OVERVIEW"),
isDescendantOfA(withId(R.id.topic_tabs_container))
)
).perform(click())

onView(withId(R.id.topic_tabs_container)).check(matches(matchCurrentTabTitle("OVERVIEW")))

}

@Test
@UiThread
fun testTopicActivity_clickOnOverviewTab_isOverviewTabSelectedAndContentMatched() {
activityTestRule.launchActivity(null)
onView(
allOf(
withText("REVIEW"),
isDescendantOfA(withId(R.id.topic_tabs_container))
)
).perform(click())
onView(
allOf(
withText("OVERVIEW"),
@@ -98,12 +224,11 @@ class TopicFragmentTest {
)
)
)

}

@Test
@UiThread
fun testTopicActivity_clickOnTabs_configurationChange_isSameTabAndItsDataDisplayed() {
fun testTopicActivity_clickOnPlayTab_configurationChange_isSameTabAndItsDataDisplayed() {
activityTestRule.launchActivity(null)
onView(
allOf(
@@ -113,13 +238,87 @@ class TopicFragmentTest {
).perform(click())
onView(withText("First Story")).check(matches(isDisplayed()))
activityTestRule.activity.requestedOrientation = Configuration.ORIENTATION_LANDSCAPE
onView(withId(R.id.topic_tabs_container)).check(matches(matchCurrentTabTitle("PLAY")))
onView(withText("First Story")).check(matches(isDisplayed()))
}

@Test
@UiThread
fun testTopicActivity_clickOnTrainTab_configurationChange_isSameTabAndItsDataDisplayed() {
activityTestRule.launchActivity(null)
onView(
allOf(
withText("PLAY"),
withText("TRAIN"),
isDescendantOfA(withId(R.id.topic_tabs_container))
)
).perform(click())
onView(withText("Master These Skills")).check(matches(isDisplayed()))
activityTestRule.activity.requestedOrientation = Configuration.ORIENTATION_LANDSCAPE
onView(
allOf(
withText("TRAIN"),
isDisplayed()
)
)
onView(withText("First Story")).check(matches(isDisplayed()))
onView(withText("Master These Skills")).check(matches(isDisplayed()))
}

fun testTopicActivity_clickOnReviewTab_configurationChange_isSameTabAndItsDataDisplayed() {
activityTestRule.launchActivity(null)
onView(
allOf(
withText("REVIEW"),
isDescendantOfA(withId(R.id.topic_tabs_container))
)
).perform(click())
onView(allOf(
atPosition(R.id.review_skill_recycler_view, 0).also { withText("An important skill") },
isDescendantOfA(withId(R.id.review_skill_recycler_view))
).also { withId(R.id.skill_name) })
activityTestRule.activity.requestedOrientation = Configuration.ORIENTATION_LANDSCAPE
onView(
allOf(
withText("REVIEW"),
isDisplayed()
)
)
onView(allOf(
atPosition(R.id.review_skill_recycler_view, 0).also { withText("An important skill") },
isDescendantOfA(withId(R.id.review_skill_recycler_view))
).also { withId(R.id.skill_name) })
}

@Test
@UiThread
fun testTopicActivity_clickOnOverviewTab_configurationChange_isSameTabAndItsDataDisplayed() {
activityTestRule.launchActivity(null)
onView(
allOf(
withText("OVERVIEW"),
isDescendantOfA(withId(R.id.topic_tabs_container))
)
).perform(click())
onView(withId(R.id.topic_name_text_view)).check(
matches(
withText(
Matchers.containsString(topicName)
)
)
)
activityTestRule.activity.requestedOrientation = Configuration.ORIENTATION_LANDSCAPE
onView(
allOf(
withText("OVERVIEW"),
isDisplayed()
)
)
onView(withId(R.id.topic_name_text_view)).check(
matches(
withText(
Matchers.containsString(topicName)
)
)
)
}

@Module
Original file line number Diff line number Diff line change
@@ -2,11 +2,15 @@ package org.oppia.app.utility

import android.view.View
import org.hamcrest.Matcher
import org.oppia.app.utility.TabMatcher.Companion.matchCurrentTabTitleCheck

// https://medium.com/@dbottillo/android-ui-test-espresso-matcher-for-imageview-1a28c832626f#.4snjg8frw
/** This object mainly facilitates as bridge between test-cases and various custom test-matchers. */
object EspressoTestsMatchers {

fun matchCurrentTabTitle(tabTitle: String): Matcher<View> {
return matchCurrentTabTitleCheck(tabTitle)
}
fun withDrawable(resourceId: Int): Matcher<View> {
return DrawableMatcher(resourceId)
}
54 changes: 54 additions & 0 deletions app/src/sharedTest/java/org/oppia/app/utility/TabMatcher.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package org.oppia.app.utility

import android.view.View
import org.hamcrest.Description
import org.hamcrest.TypeSafeMatcher
import android.graphics.Bitmap
import android.graphics.Canvas
import android.graphics.drawable.Drawable
import android.widget.ImageView
import androidx.test.espresso.PerformException
import com.google.android.material.tabs.TabLayout
import org.hamcrest.Matcher

/** This class mainly provides a custom matcher to test whether the current tab title is correctly selected in TabLayout. */
class TabMatcher {
companion object {
fun matchCurrentTabTitleCheck(tabTitle: String): Matcher<View> {
return object : TypeSafeMatcher<View>() {
override fun describeTo(description: Description?) {
description?.appendText("unable to match title of current selected tab with $tabTitle")
}

override fun matchesSafely(item: View?): Boolean {
val tabLayout = item as TabLayout
val tabAtIndex: TabLayout.Tab = tabLayout.getTabAt(tabLayout.selectedTabPosition)
?: throw PerformException.Builder()
.withCause(Throwable("No tab at index ${tabLayout.selectedTabPosition}"))
.build()

return tabAtIndex.text.toString().contains(tabTitle, true)
}
}
}

fun matchTabTitleAtPosition(tabTitle: String, tabIndex: Int): Matcher<View> {
return object : TypeSafeMatcher<View>() {
override fun describeTo(description: Description?) {
description?.appendText("unable to select tab at index $tabIndex and match title with $tabTitle")
}

override fun matchesSafely(item: View?): Boolean {
val tabLayout = item as TabLayout
val tabAtIndex: TabLayout.Tab = tabLayout.getTabAt(tabIndex)
?: throw PerformException.Builder()
.withCause(Throwable("No tab at index $tabIndex"))
.build()

return tabAtIndex.text.toString().contains(tabTitle, true)
}
}
}
}

}