Skip to content

Commit d520685

Browse files
authored
Merge pull request #1 from mrcsxsiq/master
Updating project with base mrcsxsiq
2 parents 27a96cc + 4f44d77 commit d520685

25 files changed

+518
-50
lines changed

.idea/codeStyles/Project.xml

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/compiler.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/jarRepositories.xml

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,21 @@ Also available in Play Store
3939
## Screenshots
4040

4141
<p align="center">
42-
<img src="screenshots/home.png" width="270" alt="Home">
43-
<img src="screenshots/pokedex.png" width="270" alt="Pokedex">
44-
<img src="screenshots/pokedex-fab.png" width="270" alt="Pokedex FAB">
42+
<img src="screenshots/home.png" width="250" alt="Home">
43+
<img src="screenshots/pokedex.png" width="250" alt="Pokedex">
44+
<img src="screenshots/pokedex-fab.png" width="250" alt="Pokedex FAB">
4545
</p>
4646

4747
<p align="center">
48-
<img src="screenshots/pokedex-fab-search.png" width="270" alt="Pokedex Search">
49-
<img src="screenshots/pokedex-fab-generation.png" width="270" alt="Pokedex Generation">
50-
<img src="screenshots/pokemon-info-about.png" width="270" alt="Pokemon Info - About">
48+
<img src="screenshots/pokedex-fab-search.png" width="250" alt="Pokedex Search">
49+
<img src="screenshots/pokedex-fab-generation.png" width="250" alt="Pokedex Generation">
50+
<img src="screenshots/pokemon-info-about.png" width="250" alt="Pokemon Info - About">
5151
</p>
5252

5353
<p align="center">
54-
<img src="screenshots/pokemon-info-base-stats.png" width="270" alt="Pokemon Info - Base Stats">
55-
<img src="screenshots/pokemon-info-evolution.png" width="270" alt="Pokemon Info - Evolution">
56-
<img src="screenshots/news-detail.png" width="270" alt="News Detail">
54+
<img src="screenshots/pokemon-info-base-stats.png" width="250" alt="Pokemon Info - Base Stats">
55+
<img src="screenshots/pokemon-info-evolution.png" width="250" alt="Pokemon Info - Evolution">
56+
<img src="screenshots/news-detail.png" width="250" alt="News Detail">
5757
</p>
5858

5959
## Development Roadmap
@@ -105,12 +105,13 @@ Also available in Play Store
105105

106106
## Contributors
107107

108-
| [<img src="https://avatars3.githubusercontent.com/u/12054216?s=115&v=4" width="48"><br><sub>@zsmb13</sub>](https://github.com/zsmb13) | [<img src="https://avatars0.githubusercontent.com/u/8435541?s=115&v=4" width="48"><br><sub>@aesean</sub>](https://github.com/aesean) | [<img src="https://avatars1.githubusercontent.com/u/988405?s=115&v=4" width="48"><br><sub>@STFBEE</sub>](https://github.com/STFBEE) | [<img src="https://avatars1.githubusercontent.com/u/25616312?s=115&v=4" width="48"><br><sub>@CorneilleEdi</sub>](https://github.com/CorneilleEdi) | [<img src="https://avatars2.githubusercontent.com/u/15768474?s=115&v=4" width="48"><br><sub>@naufalprakoso</sub>](https://github.com/naufalprakoso) | [<img src="https://user-images.githubusercontent.com/95717/60592969-5da81680-9d67-11e9-92a3-8664ee0e2eda.png" width="48"><br><sub>You</sub>](https://github.com/mrcsxsiq/Kotlin-Pokedex/pulls) |
108+
| [<img src="https://avatars3.githubusercontent.com/u/12054216?s=115&v=4" width="48"><br><sub>@zsmb13</sub>](https://github.com/zsmb13) | [<img src="https://avatars0.githubusercontent.com/u/8435541?s=115&v=4" width="48"><br><sub>@aesean</sub>](https://github.com/aesean) | [<img src="https://avatars1.githubusercontent.com/u/988405?s=115&v=4" width="48"><br><sub>@STFBEE</sub>](https://github.com/STFBEE) | [<img src="https://avatars1.githubusercontent.com/u/25616312?s=115&v=4" width="48"><br><sub>@CorneilleEdi</sub>](https://github.com/CorneilleEdi) | [<img src="https://avatars2.githubusercontent.com/u/15768474?s=115&v=4" width="48"><br><sub>@naufalprakoso</sub>](https://github.com/naufalprakoso) | [<img src="https://avatars0.githubusercontent.com/u/3823933?s=115&v=4" width="48"><br><sub>@szugyi</sub>](https://github.com/szugyi)|
109109
| :---: | :---: | :---: | :---: | :---: | :---: |
110+
[<img src="https://avatars0.githubusercontent.com/u/43280759?s=115&v=4" width="48"><br><sub>@sudo-dev-pedro</sub>](https://github.com/sudo-dev-pedro) | [<img src="https://avatars0.githubusercontent.com/u/3484814?s=115&v=4" width="48"><br><sub>@pedrofsn</sub>](https://github.com/pedrofsn) | [<img src="https://user-images.githubusercontent.com/95717/60592969-5da81680-9d67-11e9-92a3-8664ee0e2eda.png" width="48"><br><sub>You</sub>](https://github.com/mrcsxsiq/Kotlin-Pokedex/pulls) |
110111

111112
## Author
112113

113-
| [<img src="https://avatars3.githubusercontent.com/u/993608?s=115&v=4" width="48"><br><sub>@mrcsxsiq</sub>](https://github.com/mrcxsiq) |
114+
| [<img src="https://avatars3.githubusercontent.com/u/993608?s=115&v=4" width="48"><br><sub>@mrcsxsiq</sub>](https://github.com/mrcsxsiq) |
114115
| :---: |
115116

116117
## License

app/build.gradle.kts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ android {
1111
compileSdkVersion(29)
1212
buildToolsVersion("29.0.3")
1313
defaultConfig {
14-
applicationId = "dev.marcosfarias.pokedex"
14+
applicationId = "dev.marcosfarias.pokedex"
1515
minSdkVersion(23)
1616
targetSdkVersion(29)
1717
versionCode = 1
@@ -21,7 +21,10 @@ android {
2121
buildTypes {
2222
getByName("release") {
2323
isMinifyEnabled = false
24-
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
24+
proguardFiles(
25+
getDefaultProguardFile("proguard-android-optimize.txt"),
26+
"proguard-rules.pro"
27+
)
2528
}
2629
}
2730
kotlinOptions {
@@ -36,10 +39,12 @@ dependencies {
3639
// Architecture
3740
implementation("androidx.core:core-ktx:1.2.0")
3841
implementation("androidx.appcompat:appcompat:1.1.0")
39-
implementation("androidx.navigation:navigation-ui:2.2.2")
40-
implementation("androidx.navigation:navigation-ui-ktx:2.2.2")
41-
implementation("androidx.navigation:navigation-fragment:2.2.2")
42-
implementation("androidx.navigation:navigation-fragment-ktx:2.2.2")
42+
43+
implementation("androidx.navigation:navigation-ui:2.3.5")
44+
implementation("androidx.navigation:navigation-ui-ktx:2.3.5")
45+
implementation("androidx.navigation:navigation-fragment:2.3.5")
46+
implementation("androidx.navigation:navigation-fragment-ktx:2.3.5")
47+
4348
implementation("androidx.lifecycle:lifecycle-extensions:2.2.0")
4449
implementation("androidx.constraintlayout:constraintlayout:1.1.3")
4550
implementation("androidx.coordinatorlayout:coordinatorlayout:1.1.0")
@@ -72,4 +77,9 @@ dependencies {
7277
testImplementation("junit:junit:4.12")
7378
androidTestImplementation("androidx.test.ext:junit:1.1.1")
7479
androidTestImplementation("androidx.test.espresso:espresso-core:3.2.0")
80+
androidTestImplementation("com.android.support.test.espresso:espresso-contrib:2.0")
81+
androidTestImplementation("androidx.navigation:navigation-testing:2.3.5")
82+
debugImplementation("androidx.fragment:fragment-testing:1.3.2")
83+
androidTestImplementation ("io.mockk:mockk-android:1.9.3")
84+
7585
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package dev.marcosfarias.pokedex
2+
3+
import android.content.res.Resources
4+
import androidx.fragment.app.testing.launchFragmentInContainer
5+
import androidx.navigation.Navigation
6+
import androidx.navigation.testing.TestNavHostController
7+
import androidx.test.core.app.ApplicationProvider
8+
import androidx.test.platform.app.InstrumentationRegistry
9+
import dev.marcosfarias.pokedex.model.Pokemon
10+
import dev.marcosfarias.pokedex.robots.BaseRobot
11+
import dev.marcosfarias.pokedex.ui.dashboard.DashboardFragment
12+
import io.mockk.mockk
13+
import org.junit.Before
14+
import org.junit.Test
15+
16+
class DashboardTests : BaseRobot() {
17+
val pokemon = Pokemon()
18+
lateinit var navHost: TestNavHostController
19+
20+
private val resources: Resources by lazy {
21+
InstrumentationRegistry.getInstrumentation().targetContext.resources
22+
}
23+
24+
@Before
25+
fun setup() {
26+
pokemon.apply {
27+
id = "001"
28+
name = "Bulbasaur"
29+
}
30+
31+
// Create a TestNavHostController
32+
navHost = TestNavHostController(ApplicationProvider.getApplicationContext())
33+
launchFragmentInContainer(themeResId = R.style.AppTheme) {
34+
DashboardFragment().also { fragment ->
35+
// In addition to returning a new instance of our Fragment, // get a callback whenever the fragment’s view is created // or destroyed so that we can set the NavController
36+
fragment.viewLifecycleOwnerLiveData.observeForever { viewLifecycleOwner ->
37+
if (viewLifecycleOwner != null) {
38+
// The fragment’s view has just been created
39+
navHost.setGraph(R.navigation.mobile_navigation)
40+
navHost.setCurrentDestination(R.id.navigation_dashboard)
41+
Navigation.setViewNavController(fragment.requireView(), navHost)
42+
}
43+
}
44+
}
45+
}
46+
}
47+
48+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package dev.marcosfarias.pokedex
2+
3+
import android.content.res.Resources
4+
import androidx.fragment.app.testing.launchFragmentInContainer
5+
import androidx.navigation.Navigation
6+
import androidx.navigation.testing.TestNavHostController
7+
import androidx.test.core.app.ApplicationProvider
8+
import androidx.test.platform.app.InstrumentationRegistry
9+
import dev.marcosfarias.pokedex.robots.BaseRobot
10+
import dev.marcosfarias.pokedex.ui.newsdetail.NewsDetailFragment
11+
import org.junit.Before
12+
import org.junit.Test
13+
14+
class FragmentNewsDetailsTest: BaseRobot() {
15+
16+
lateinit var navHost: TestNavHostController
17+
18+
private val resources: Resources by lazy {
19+
InstrumentationRegistry.getInstrumentation().targetContext.resources
20+
}
21+
22+
@Before
23+
fun setup() {
24+
// Create a TestNavHostController
25+
navHost = TestNavHostController(ApplicationProvider.getApplicationContext())
26+
launchFragmentInContainer(themeResId = R.style.AppTheme) {
27+
NewsDetailFragment().also { fragment ->
28+
// In addition to returning a new instance of our Fragment, // get a callback whenever the fragment’s view is created // or destroyed so that we can set the NavController
29+
fragment.viewLifecycleOwnerLiveData.observeForever { viewLifecycleOwner ->
30+
if (viewLifecycleOwner != null) {
31+
// The fragment’s view has just been created
32+
navHost.setGraph(R.navigation.mobile_navigation)
33+
Navigation.setViewNavController(fragment.requireView(), navHost)
34+
}
35+
}
36+
}
37+
}
38+
}
39+
40+
@Test
41+
fun verifyIfTitleTextIsDisplayed() {
42+
isViewDisplayed(R.id.txtNewsTitle)
43+
}
44+
45+
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
package dev.marcosfarias.pokedex
2+
3+
import android.content.res.Resources
4+
import androidx.fragment.app.testing.launchFragmentInContainer
5+
import androidx.navigation.Navigation
6+
import androidx.navigation.testing.TestNavHostController
7+
import androidx.test.core.app.ApplicationProvider
8+
import androidx.test.ext.junit.runners.AndroidJUnit4
9+
import androidx.test.platform.app.InstrumentationRegistry
10+
import dev.marcosfarias.pokedex.robots.BaseRobot
11+
import dev.marcosfarias.pokedex.ui.home.HomeFragment
12+
import junit.framework.Assert.assertEquals
13+
import org.junit.Before
14+
import org.junit.Test
15+
import org.junit.runner.RunWith
16+
17+
@RunWith(AndroidJUnit4::class)
18+
class HomeTest : BaseRobot() {
19+
lateinit var navHost: TestNavHostController
20+
21+
private val resources: Resources by lazy {
22+
InstrumentationRegistry.getInstrumentation().targetContext.resources
23+
}
24+
25+
@Before
26+
fun setup() {
27+
// Create a TestNavHostController
28+
navHost = TestNavHostController(ApplicationProvider.getApplicationContext())
29+
launchFragmentInContainer(themeResId = R.style.AppTheme) {
30+
HomeFragment().also { fragment ->
31+
// In addition to returning a new instance of our Fragment, // get a callback whenever the fragment’s view is created // or destroyed so that we can set the NavController
32+
fragment.viewLifecycleOwnerLiveData.observeForever { viewLifecycleOwner ->
33+
if (viewLifecycleOwner != null) {
34+
// The fragment’s view has just been created
35+
navHost.setGraph(R.navigation.mobile_navigation)
36+
Navigation.setViewNavController(fragment.requireView(), navHost)
37+
}
38+
}
39+
}
40+
}
41+
}
42+
43+
44+
@Test
45+
fun testingNavigation() {
46+
assertEquals(navHost.graph.id, R.id.mobile_navigation)
47+
}
48+
49+
@Test
50+
fun verifyIfRecyclerViewMenuIsDisplayed() {
51+
isViewDisplayed(R.id.recyclerViewMenu)
52+
}
53+
54+
@Test
55+
fun verifyIfRecyclerViewTextIsDisplayed() {
56+
isRecyclerViewItemDisplayed(
57+
R.id.recyclerViewMenu,
58+
resources.getString(R.string.menu_item_1))
59+
}
60+
61+
@Test
62+
fun verifyIfRecyclerViewNewsIsDisplayed() {
63+
isViewDisplayed(R.id.recyclerViewNews)
64+
}
65+
66+
@Test
67+
fun verifyIfRecyclerViewItemIsDisplayed() {
68+
onClickItem(R.id.recyclerViewNews)
69+
}
70+
71+
@Test
72+
fun testingTitleAndSearchBarText() {
73+
testViewText(
74+
R.id.search_title,
75+
resources.getString(R.string.main_title)
76+
)
77+
78+
testViewText(
79+
R.id.search_text,
80+
resources.getString(R.string.main_search)
81+
)
82+
}
83+
}

0 commit comments

Comments
 (0)