-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
autotests: GenresListTest, PopularMovieTest #10
Open
sealisaa
wants to merge
3
commits into
master
Choose a base branch
from
sealisaa/autotests
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
3 commits
Select commit
Hold shift + click to select a range
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
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
47 changes: 47 additions & 0 deletions
47
app/src/androidTest/java/com/example/moviepicker/GenresListTest.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,47 @@ | ||
package com.example.moviepicker | ||
|
||
import androidx.test.ext.junit.rules.activityScenarioRule | ||
import com.example.moviepicker.pages.GenresScreen | ||
import com.example.moviepicker.pages.HomeScreen | ||
import com.kaspersky.kaspresso.testcases.api.testcase.TestCase | ||
import org.junit.Assert | ||
import org.junit.Rule | ||
import org.junit.Test | ||
|
||
class GenresListTest : TestCase() { | ||
private val genres = listOf( | ||
"Мультфильмы", | ||
"Триллеры", | ||
"Комедии", | ||
"Ужасы" | ||
) | ||
|
||
@get:Rule | ||
val activityRule = activityScenarioRule<MainActivity>() | ||
|
||
@Test | ||
fun checkGenresScreen() = run { | ||
step("Open genres screen") { | ||
HomeScreen { | ||
goToGenresTab() | ||
} | ||
} | ||
step("Check genres count") { | ||
GenresScreen { | ||
Assert.assertEquals(genres.size, rvGenres.getSize()) | ||
} | ||
} | ||
step("Check genres list") { | ||
GenresScreen { | ||
rvGenres { | ||
for (i in genres.indices) { | ||
childAt<GenresScreen.GenreScreen>(i) { | ||
genreButton.isVisible() | ||
genreButton.hasText(genres[i]) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
app/src/androidTest/java/com/example/moviepicker/PopularMovieTest.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,31 @@ | ||
package com.example.moviepicker | ||
|
||
import androidx.test.ext.junit.rules.activityScenarioRule | ||
import com.example.moviepicker.pages.HomeScreen | ||
import com.example.moviepicker.pages.MovieScreen | ||
import com.kaspersky.kaspresso.testcases.api.testcase.TestCase | ||
import org.junit.Rule | ||
import org.junit.Test | ||
|
||
class PopularMovieTest : TestCase() { | ||
private val movieIndex = 0 | ||
private var title = "Звёздные войны: Эпизод 1 — Скрытая угроза" | ||
|
||
@get:Rule | ||
val activityRule = activityScenarioRule<MainActivity>() | ||
|
||
@Test | ||
fun checkPopularMovieDescription() = run { | ||
step("Open popular movie description") { | ||
HomeScreen { | ||
goToMovieDescription(movieIndex) | ||
} | ||
} | ||
step("Check title in description") { | ||
MovieScreen { | ||
movieTitle.isVisible() | ||
movieTitle.containsText(title) | ||
} | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
app/src/androidTest/java/com/example/moviepicker/pages/GenresScreen.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,25 @@ | ||
package com.example.moviepicker.pages | ||
|
||
import android.view.View | ||
import com.example.moviepicker.R | ||
import com.kaspersky.kaspresso.screens.KScreen | ||
import io.github.kakaocup.kakao.recycler.KRecyclerItem | ||
import io.github.kakaocup.kakao.recycler.KRecyclerView | ||
import io.github.kakaocup.kakao.text.KButton | ||
import org.hamcrest.Matcher | ||
|
||
object GenresScreen : KScreen<GenresScreen>() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. хочется добавить лоадабл компонент |
||
override val layoutId: Int | ||
get() = R.layout.fragment_genres | ||
override val viewClass: Class<*>? | ||
get() = null | ||
|
||
val rvGenres = KRecyclerView( | ||
builder = { withId(R.id.genresRecyclerView) }, | ||
itemTypeBuilder = { itemType(::GenreScreen) } | ||
) | ||
|
||
class GenreScreen(matcher: Matcher<View>): KRecyclerItem<GenresScreen>(matcher) { | ||
val genreButton = KButton(matcher) { withId(R.id.genreButton) } | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. предлагаю не только искать элементы, а еще сами методы заносить в пейджи |
45 changes: 45 additions & 0 deletions
45
app/src/androidTest/java/com/example/moviepicker/pages/HomeScreen.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,45 @@ | ||
package com.example.moviepicker.pages | ||
|
||
import android.view.View | ||
import com.example.moviepicker.R | ||
import com.kaspersky.kaspresso.screens.KScreen | ||
import io.github.kakaocup.kakao.common.views.KView | ||
import io.github.kakaocup.kakao.recycler.KRecyclerItem | ||
import io.github.kakaocup.kakao.recycler.KRecyclerView | ||
import io.github.kakaocup.kakao.tabs.KTabLayout | ||
import io.github.kakaocup.kakao.text.KTextView | ||
import org.hamcrest.Matcher | ||
|
||
|
||
object HomeScreen : KScreen<HomeScreen>() { | ||
private val genresTabId = 1 | ||
|
||
override val layoutId | ||
get() = R.layout.fragment_home | ||
override val viewClass: Class<*>? | ||
get() = null | ||
|
||
private val tabLayout = KTabLayout { withId(R.id.homeTabLayout) } | ||
|
||
private val rvPopularMovies = KRecyclerView( | ||
builder = { withId(R.id.popularMoviesRecyclerView) }, | ||
itemTypeBuilder = { itemType(::PopularMovieScreen) } | ||
) | ||
|
||
class PopularMovieScreen(matcher: Matcher<View>): KRecyclerItem<PopularMovieScreen>(matcher) { | ||
val movieCard = KView(matcher) { withId(R.id.movieCard) } | ||
val movieTitle = KTextView(matcher) { withId(R.id.movieTitle) } | ||
} | ||
|
||
fun goToGenresTab() { | ||
this.tabLayout.selectTab(genresTabId) | ||
} | ||
|
||
fun goToMovieDescription(index: Int) { | ||
rvPopularMovies.childAt<PopularMovieScreen>(index) { | ||
movieCard.isVisible() | ||
movieCard.click() | ||
} | ||
} | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
app/src/androidTest/java/com/example/moviepicker/pages/MovieScreen.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,14 @@ | ||
package com.example.moviepicker.pages | ||
|
||
import com.example.moviepicker.R | ||
import com.kaspersky.kaspresso.screens.KScreen | ||
import io.github.kakaocup.kakao.text.KTextView | ||
|
||
object MovieScreen : KScreen<MovieScreen>() { | ||
override val layoutId: Int | ||
get() = R.layout.fragment_description | ||
override val viewClass: Class<*>? | ||
get() = null | ||
|
||
val movieTitle = KTextView { withId(R.id.movieName) } | ||
} |
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.
все таки я за то, чтобы выносить это в базовый тестовый класс