-
-
Notifications
You must be signed in to change notification settings - Fork 26
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
added testcases for LazyVideos and the corresponding .ccz as well #2568
Open
kbo001
wants to merge
19
commits into
master
Choose a base branch
from
kb/lazy_videos
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
1cfc4f3
added testcases for LazyVideos and the corresponding .ccz as well
kbo001 1d3d1fd
match drawables
shubham1g5 12ca21f
fix drawable matcher
shubham1g5 fa7911c
Adds drawable matching for image button
shubham1g5 9cd7ef2
cleaned up unused codes and imports
kbo001 b10e271
Merge branch 'master' into kb/lazy_videos
shubham1g5 415c1be
formating
shubham1g5 c6abf00
spacing
shubham1g5 9eb3beb
fixes drawable matcher to be able to perform clicks
shubham1g5 219c4f9
added steps to validate video player for all remaining questions in t…
kbo001 9da6232
Merge branch 'master' into kb/lazy_videos
shubham1g5 9cc5425
match drawables based on tag
shubham1g5 7d1d220
updated lazy_videos_tests.ccz, added new functions in LazyVideosTest…
kbo001 a765570
removed Intent.ACTION_SEND steps from testVideosWithNoReference()
kbo001 8667c49
added lazy_videos_no_viedo.ccz, updated setup() and removed if condit…
kbo001 452ad55
deleted lazy_videos_tests.ccz
kbo001 aa4d59d
removed commented }
kbo001 236dd72
added some wait time for downloading the videos and added download vi…
kbo001 df0a4c6
commented the sleep and if statements
kbo001 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
172 changes: 172 additions & 0 deletions
172
app/instrumentation-tests/src/org/commcare/androidTests/LazyVideosTests.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
package org.commcare.androidTests | ||
|
||
|
||
import android.content.Intent | ||
import android.os.Build | ||
import android.util.Log | ||
import androidx.test.espresso.Espresso | ||
import androidx.test.espresso.Espresso.onView | ||
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.RootMatchers | ||
import androidx.test.espresso.matcher.ViewMatchers | ||
import androidx.test.espresso.matcher.ViewMatchers.* | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import androidx.test.filters.LargeTest | ||
import androidx.test.filters.SdkSuppress | ||
import androidx.test.platform.app.InstrumentationRegistry | ||
import androidx.test.uiautomator.UiDevice | ||
import org.commcare.CommCareApplication | ||
import org.commcare.annotations.BrowserstackTests | ||
import org.commcare.dalvik.R | ||
import org.commcare.utils.CustomMatchers | ||
import org.commcare.utils.InstrumentationUtility | ||
import org.commcare.utils.isPresent | ||
import org.hamcrest.CoreMatchers | ||
import org.hamcrest.Matchers.* | ||
import org.junit.After | ||
import org.junit.Assert.assertTrue | ||
import org.junit.Before | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
|
||
@RunWith(AndroidJUnit4::class) | ||
@LargeTest | ||
@BrowserstackTests | ||
class LazyVideosTests : BaseTest() { | ||
|
||
companion object { | ||
const val CCZ_NAME = "lazy_videos_no_videos.ccz" | ||
const val APP_NAME = "Lazy Videos" | ||
} | ||
|
||
@Before | ||
fun setup() { | ||
if (CommCareApplication.instance().currentApp == null) { | ||
InstrumentationUtility.installApp(CCZ_NAME) | ||
} else { | ||
InstrumentationUtility.uninstallCurrentApp() | ||
InstrumentationUtility.installApp(CCZ_NAME) | ||
} | ||
Espresso.pressBack() | ||
updateApp() | ||
} | ||
|
||
@After | ||
fun tearDown() { | ||
InstrumentationUtility.logout() | ||
} | ||
|
||
@Test | ||
fun testVideosWithReferences() { | ||
testVideosWithValidReference() | ||
testVideosWithNoReferences() | ||
} | ||
|
||
private fun updateApp(){ | ||
InstrumentationUtility.openOptionsMenu() | ||
onView(withText("Go To App Manager")) | ||
.perform(click()) | ||
onView(withText(APP_NAME)).perform(click()) | ||
onView(withText("Update")) | ||
.perform(click()) | ||
InstrumentationUtility.waitForView(withSubstring("Update to version")) | ||
gotoLogin() | ||
} | ||
|
||
private fun gotoLogin() { | ||
for (i in 0..2) { // Try atmost 3 times. | ||
if (onView(withId(R.id.edit_username)).isPresent()) { | ||
return | ||
} else { | ||
Espresso.pressBack() | ||
} | ||
} | ||
} | ||
private fun testVideosWithValidReference() { | ||
InstrumentationUtility.login("test1", "123") | ||
InstrumentationUtility.openForm(1, 0) | ||
InstrumentationUtility.waitForView(withId(R.id.video_button)) | ||
onView(withTagValue(CoreMatchers.`is`(R.drawable.update_download_icon))).check(matches(isDisplayed())) | ||
InstrumentationUtility.stubIntentWithAction(Intent.ACTION_SEND) | ||
onView(withTagValue(CoreMatchers.`is`(R.drawable.update_download_icon))).perform(click()) | ||
// InstrumentationUtility.sleep(1) | ||
InstrumentationUtility.waitForView(withSubstring("Download started"),5000) | ||
// InstrumentationUtility.sleep(2) | ||
InstrumentationUtility.waitForView(withSubstring("Download in Progress"), 5000) | ||
// InstrumentationUtility.sleep(2) | ||
InstrumentationUtility.waitForView(withSubstring("Download complete"), 5000) | ||
InstrumentationUtility.waitForView(withTagValue(CoreMatchers.`is`(android.R.drawable.ic_media_play))) | ||
InstrumentationUtility.stubIntentWithAction(Intent.ACTION_VIEW) | ||
onView(withId(R.id.video_button)).perform(click()) | ||
InstrumentationUtility.nextPage() | ||
InstrumentationUtility.sleep(5) | ||
assertTrue(onView(allOf(withId(R.id.inline_video_view))).isPresent()) | ||
InstrumentationUtility.nextPage() | ||
InstrumentationUtility.waitForView(CustomMatchers.withDrawable( | ||
CommCareApplication.instance(), | ||
R.drawable.icon_info_outline_lightcool | ||
)) | ||
|
||
onView( | ||
CustomMatchers.withDrawable( | ||
CommCareApplication.instance(), | ||
R.drawable.icon_info_outline_lightcool | ||
) | ||
).perform(click()) | ||
// if(onView(withTagValue(CoreMatchers.`is`(R.drawable.update_download_icon))).isPresent()){ | ||
onView(withTagValue(CoreMatchers.`is`(R.drawable.update_download_icon))).perform(click()) | ||
// InstrumentationUtility.sleep(1) | ||
InstrumentationUtility.waitForView(withSubstring("Download started"),5000) | ||
// InstrumentationUtility.sleep(2) | ||
InstrumentationUtility.waitForView(withSubstring("Download in Progress"), 5000) | ||
// InstrumentationUtility.sleep(2) | ||
InstrumentationUtility.waitForView(withSubstring("Download complete"), 5000) | ||
// } | ||
onView(withTagValue(CoreMatchers.`is`(android.R.drawable.ic_media_play))).check(matches(isDisplayed())) | ||
InstrumentationUtility.stubIntentWithAction(Intent.ACTION_VIEW) | ||
onView(withId(R.id.video_button)).perform(click()) | ||
onView(withText("OK")).perform(click()) | ||
InstrumentationUtility.nextPage() | ||
|
||
onView( | ||
CustomMatchers.withDrawable( | ||
CommCareApplication.instance(), | ||
R.drawable.icon_info_outline_lightcool | ||
) | ||
).perform(click()) | ||
// if(onView(withTagValue(CoreMatchers.`is`(R.drawable.update_download_icon))).isPresent()){ | ||
onView(withTagValue(CoreMatchers.`is`(R.drawable.update_download_icon))).perform(click()) | ||
// InstrumentationUtility.sleep(1) | ||
InstrumentationUtility.waitForView(withSubstring("Download started"),5000) | ||
// InstrumentationUtility.sleep(2) | ||
InstrumentationUtility.waitForView(withSubstring("Download in Progress"), 5000) | ||
// InstrumentationUtility.sleep(2) | ||
InstrumentationUtility.waitForView(withSubstring("Download complete"), 5000) | ||
// } | ||
onView(withTagValue(CoreMatchers.`is`(android.R.drawable.ic_media_play))).check(matches(isDisplayed())) | ||
InstrumentationUtility.stubIntentWithAction(Intent.ACTION_VIEW) | ||
onView(withId(R.id.video_button)).perform(click()) | ||
onView(withText("OK")).perform(click()) | ||
InstrumentationUtility.submitForm() | ||
assertTrue(onView(withText("1 form sent to server!")).isPresent()) | ||
InstrumentationUtility.logout() | ||
} | ||
|
||
private fun testVideosWithNoReferences() { | ||
UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()) | ||
InstrumentationUtility.login("test1", "123") | ||
InstrumentationUtility.openForm(1, 1) | ||
InstrumentationUtility.waitForView(withText(R.string.video_download_prompt)) | ||
onView(withTagValue(CoreMatchers.`is`(R.drawable.update_download_icon))).check(matches(isDisplayed())) | ||
onView(withId(R.id.video_button)).perform(click()) | ||
InstrumentationUtility.waitForView(withText(R.string.download_complete)) | ||
InstrumentationUtility.waitForView(withText("Media not found in the application")) | ||
InstrumentationUtility.nextPage() | ||
assertTrue(onView(withId(R.id.missing_media_view)).isPresent()) | ||
InstrumentationUtility.submitForm() | ||
assertTrue(onView(withText("1 form sent to server!")).isPresent()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
curious why are not we using the norma
installApp()
method as other tests ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if
installApp()
is used then the app is not uninstalled everytime and the videos remains in the app, hence failing the tests.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
got it, it would be good to add a comment above this line stating this as It's not very obvious.