mirror of
https://github.com/hmalik144/Weather-apps.git
synced 2026-03-18 15:36:04 +00:00
Refactor flavours (#17)
- Fastlane completed - Circleci config completed - Flavours build completed
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
package com.appttude.h_mal.monoWeather
|
||||
|
||||
import androidx.test.espresso.Espresso
|
||||
import androidx.test.espresso.action.ViewActions
|
||||
import androidx.test.espresso.assertion.ViewAssertions
|
||||
import androidx.test.espresso.matcher.RootMatchers
|
||||
import androidx.test.espresso.matcher.ViewMatchers
|
||||
import com.appttude.h_mal.atlas_weather.BaseTest
|
||||
import com.appttude.h_mal.atlas_weather.ui.MainActivity
|
||||
|
||||
open class MonoBaseTest: BaseTest<MainActivity>(MainActivity::class.java) {
|
||||
|
||||
override fun afterLaunch() {
|
||||
// Dismiss dialog on start up
|
||||
Espresso.onView(ViewMatchers.withText("AGREE"))
|
||||
.inRoot(RootMatchers.isDialog())
|
||||
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))
|
||||
.perform(ViewActions.click())
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.appttude.h_mal.monoWeather.robot
|
||||
|
||||
import com.appttude.h_mal.atlas_weather.R
|
||||
import com.appttude.h_mal.atlas_weather.BaseTestRobot
|
||||
|
||||
fun homeScreen(func: HomeScreenRobot.() -> Unit) = HomeScreenRobot().apply { func() }
|
||||
class HomeScreenRobot : BaseTestRobot() {
|
||||
fun verifyCurrentTemperature(temperature: Int) = matchText(R.id.temp_main_4, temperature.toString())
|
||||
fun verifyCurrentLocation(location: String) = matchText(R.id.location_main_4, location)
|
||||
fun refresh() = pullToRefresh(R.id.swipe_refresh)
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.appttude.h_mal.monoWeather.robot
|
||||
|
||||
import com.appttude.h_mal.atlas_weather.R
|
||||
import com.appttude.h_mal.atlas_weather.BaseTestRobot
|
||||
|
||||
fun widgetPermissionScreen(func: WidgetPermissionScreenRobot.() -> Unit) =
|
||||
WidgetPermissionScreenRobot().apply { func() }
|
||||
|
||||
class WidgetPermissionScreenRobot : BaseTestRobot() {
|
||||
fun declarationDisplayed() = matchDisplayed(R.id.declaration_text)
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.appttude.h_mal.monoWeather.tests
|
||||
|
||||
|
||||
import com.appttude.h_mal.monoWeather.robot.homeScreen
|
||||
import com.appttude.h_mal.atlas_weather.utils.Stubs
|
||||
import com.appttude.h_mal.monoWeather.MonoBaseTest
|
||||
import org.junit.Test
|
||||
|
||||
class HomePageUITest : MonoBaseTest() {
|
||||
|
||||
override fun beforeLaunch() {
|
||||
stubEndpoint("https://api.openweathermap.org/data/2.5/onecall", Stubs.Valid)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun loadApp_validWeatherResponse_returnsValidPage() {
|
||||
homeScreen {
|
||||
verifyCurrentTemperature(2)
|
||||
verifyCurrentLocation("Mock Location")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.appttude.h_mal.monoWeather.tests
|
||||
|
||||
import android.appwidget.AppWidgetManager
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import androidx.test.rule.ActivityTestRule
|
||||
import com.appttude.h_mal.atlas_weather.BaseTest
|
||||
import com.appttude.h_mal.monoWeather.robot.widgetPermissionScreen
|
||||
import com.appttude.h_mal.monoWeather.ui.widget.WidgetLocationPermissionActivity
|
||||
import org.junit.Test
|
||||
|
||||
|
||||
class WidgetLocationPermissionActivityTest : BaseTest<WidgetLocationPermissionActivity>(
|
||||
activity = WidgetLocationPermissionActivity::class.java,
|
||||
intentBundle = Bundle().apply {
|
||||
putInt(AppWidgetManager.EXTRA_APPWIDGET_ID, 112)
|
||||
}
|
||||
) {
|
||||
|
||||
@Test
|
||||
fun demo_test() {
|
||||
widgetPermissionScreen {
|
||||
declarationDisplayed()
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user