-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
complete database test (1 task completed)
- Loading branch information
1 parent
c101393
commit 9dc8f4f
Showing
18 changed files
with
259 additions
and
69 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
58 changes: 58 additions & 0 deletions
58
app/src/androidTest/java/mk/kotlin/travel_padc_assignment/instrumentedTests/DatabaseTests.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,58 @@ | ||
package mk.kotlin.travel_padc_assignment.instrumentedTests | ||
|
||
import android.content.Context | ||
import androidx.room.Room | ||
import androidx.test.core.app.ApplicationProvider | ||
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner | ||
import mk.kotlin.travel_padc_assignment.datas.vos.CountryVO | ||
import mk.kotlin.travel_padc_assignment.datas.vos.DataVO | ||
import mk.kotlin.travel_padc_assignment.persistances.TourDB | ||
import mk.kotlin.travel_padc_assignment.persistances.TourDao | ||
import org.junit.After | ||
import org.junit.Before | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import java.util.* | ||
|
||
@RunWith(AndroidJUnit4ClassRunner::class) | ||
class DatabaseTest { | ||
|
||
private lateinit var mDao: TourDao | ||
private lateinit var db: TourDB | ||
|
||
@Before | ||
fun createDb() { | ||
val context = ApplicationProvider.getApplicationContext<Context>() | ||
db = Room.inMemoryDatabaseBuilder( | ||
context, TourDB::class.java | ||
).build() | ||
mDao = db.TourDao() | ||
} | ||
|
||
@After | ||
fun closeDb() { | ||
db.close() | ||
} | ||
|
||
@Test | ||
fun insertIntoDatabaseTest() { | ||
val countryone = CountryVO() | ||
countryone.name="Myanmar" | ||
countryone.average_rating=4.0 | ||
countryone.description="Hi desc" | ||
countryone.location="Yangon" | ||
|
||
val countrytwo = CountryVO() | ||
countrytwo.name="United state" | ||
countrytwo.average_rating=5.0 | ||
countrytwo.description="Hi desc" | ||
countrytwo.location="American" | ||
|
||
mDao.insertAllData(Arrays.asList(countryone,countrytwo)) | ||
|
||
assert(mDao.getTourById(countryone.name).value?.name == countryone.name) | ||
} | ||
|
||
|
||
} | ||
|
2 changes: 2 additions & 0 deletions
2
...rc/androidTest/java/mk/kotlin/travel_padc_assignment/instrumentedTests/NetworkCallTest.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,2 @@ | ||
package mk.kotlin.travel_padc_assignment.instrumentedTests | ||
|
53 changes: 53 additions & 0 deletions
53
app/src/androidTest/java/mk/kotlin/travel_padc_assignment/uiTests/GoToDeatilTest.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,53 @@ | ||
package mk.kotlin.travel_padc_assignment.uiTests | ||
|
||
import android.content.Intent | ||
import androidx.test.espresso.Espresso | ||
import androidx.test.espresso.action.ViewActions | ||
import androidx.test.espresso.assertion.ViewAssertions | ||
import androidx.test.espresso.contrib.RecyclerViewActions | ||
import androidx.test.espresso.matcher.ViewMatchers | ||
import androidx.test.espresso.matcher.ViewMatchers.withId | ||
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner | ||
import androidx.test.rule.ActivityTestRule | ||
import mk.kotlin.travel_padc_assignment.R | ||
import mk.kotlin.travel_padc_assignment.activities.MainActivity | ||
import mk.kotlin.travel_padc_assignment.viewmodels.viewholders.CountryViewHolder | ||
import mk.kotlin.travel_padc_assignment.viewmodels.viewholders.PopularTourViewHolder | ||
import org.junit.Before | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
|
||
@RunWith(AndroidJUnit4ClassRunner::class) | ||
class GoToDetailTest { | ||
private val activityTestRule = ActivityTestRule<MainActivity>(MainActivity::class.java) | ||
|
||
@Before | ||
open fun setUp() { | ||
activityTestRule.launchActivity(Intent()) | ||
} | ||
|
||
@Test | ||
fun tapOnPopularListRecyclerview_navigateToDetails() { | ||
Espresso.onView(withId(R.id.mainRecyler)) | ||
.perform( | ||
RecyclerViewActions.actionOnItemAtPosition<PopularTourViewHolder>(0, | ||
ViewActions.click() | ||
)) | ||
|
||
Espresso.onView(withId(R.id.tvLocation)) | ||
.check(ViewAssertions.matches(ViewMatchers.isDisplayed())) | ||
} | ||
@Test | ||
fun tapOnCountryListRecyclerview_navigateToDetails() { | ||
Espresso.onView(withId(R.id.mainRecyler)) | ||
.perform( | ||
RecyclerViewActions.actionOnItemAtPosition<CountryViewHolder>(0, | ||
ViewActions.click() | ||
)) | ||
|
||
Espresso.onView(withId(R.id.tvLocation)) | ||
.check(ViewAssertions.matches(ViewMatchers.isDisplayed())) | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
app/src/androidTest/java/mk/kotlin/travel_padc_assignment/uiTests/firstMatcher.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,27 @@ | ||
package mk.kotlin.travel_padc_assignment.uiTests | ||
|
||
|
||
import org.hamcrest.BaseMatcher | ||
import org.hamcrest.Description | ||
import org.hamcrest.Matcher | ||
|
||
fun <T> first(matcher: Matcher<T>): Matcher<T> { | ||
return object :BaseMatcher<T>(){ | ||
|
||
var isFirst : Boolean = true | ||
|
||
override fun describeTo(description: Description?) { | ||
description?.appendText(FIRST_ITEM_DESCRIPTION) | ||
} | ||
|
||
override fun matches(item: Any?): Boolean { | ||
if (isFirst && matcher.matches(item)) { | ||
isFirst = false | ||
return true | ||
} | ||
return false | ||
} | ||
} | ||
} | ||
|
||
const val FIRST_ITEM_DESCRIPTION = "Return The First Matching Item" |
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
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
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
Oops, something went wrong.