- readme.md added

- Snapshot tests added for readme.md
 - UI corrections during snapshots
This commit is contained in:
2024-07-02 19:23:09 +01:00
parent d79a31a9b5
commit 9141db3afe
20 changed files with 305 additions and 336 deletions

View File

@@ -21,7 +21,7 @@ class TestAppClass : AtlasApp() {
private val mockingNetworkInterceptor = MockingNetworkInterceptor(idlingResources)
lateinit var database: AppDatabase
lateinit var locationProvider: MockLocationProvider
private val locationProvider: MockLocationProvider = MockLocationProvider()
override fun onCreate() {
super.onCreate()
@@ -38,7 +38,6 @@ class TestAppClass : AtlasApp() {
}
override fun createLocationModule(): LocationProvider {
locationProvider = MockLocationProvider()
return locationProvider
}

View File

@@ -0,0 +1,35 @@
package com.appttude.h_mal.atlas_weather.robot
import com.appttude.h_mal.atlas_weather.BaseTestRobot
import com.appttude.h_mal.atlas_weather.R
fun furtherInfoScreen(func: FurtherInfoScreen.() -> Unit) = FurtherInfoScreen().apply { func() }
class FurtherInfoScreen : BaseTestRobot() {
fun verifyMaxTemperature(temperature: Int) =
matchText(R.id.maxtemp, StringBuilder().append(temperature).append("°").toString())
fun verifyAverageTemperature(temperature: Int) =
matchText(R.id.averagetemp, StringBuilder().append(temperature).append("°").toString())
fun verifyMinTemperature(temperature: Int) =
matchText(R.id.minimumtemp, StringBuilder().append(temperature).append("°").toString())
fun verifyWindSpeed(speedText: String) =
matchText(R.id.windtext, speedText)
fun verifyHumidity(humidity: Int) =
matchText(R.id.humiditytext, humidity.toString())
fun verifyPrecipitation(precipitation: Int) =
matchText(R.id.preciptext, precipitation.toString())
fun verifyCloudCoverage(coverage: Int) =
matchText(R.id.cloudtext, coverage.toString())
fun verifyUvIndex(uv: Int) =
matchText(R.id.uvtext, uv.toString())
fun verifySunrise(sunrise: String) =
matchText(R.id.sunrisetext, sunrise)
fun verifySunset(sunset: String) =
matchText(R.id.sunsettext, sunset)
fun refresh() = pullToRefresh(R.id.swipe_refresh)
fun isDisplayed() = matchViewWaitFor(R.id.maxtemp)
}

View File

@@ -0,0 +1,55 @@
package com.appttude.h_mal.atlas_weather.robot
import androidx.recyclerview.widget.RecyclerView.ViewHolder
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.assertion.ViewAssertions
import androidx.test.espresso.contrib.RecyclerViewActions
import androidx.test.espresso.matcher.RootMatchers.isDialog
import androidx.test.espresso.matcher.ViewMatchers
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withText
import com.appttude.h_mal.atlas_weather.BaseTestRobot
import com.appttude.h_mal.atlas_weather.R
import com.appttude.h_mal.atlas_weather.helpers.EspressoHelper.waitForView
import com.appttude.h_mal.atlas_weather.model.types.UnitType
fun settingsScreen(func: SettingsScreen.() -> Unit) = SettingsScreen().apply { func() }
class SettingsScreen : BaseTestRobot() {
fun selectWeatherUnits(unitType: UnitType) {
onView(withId(androidx.preference.R.id.recycler_view))
.perform(
RecyclerViewActions.actionOnItem<ViewHolder>(
ViewMatchers.hasDescendant(withText(R.string.weather_units)),
click()))
val label = when (unitType) {
UnitType.METRIC -> "Metric"
UnitType.IMPERIAL -> "Imperial"
}
onView(withText(label))
.inRoot(isDialog())
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))
.perform(click())
}
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)
fun verifyUnableToRetrieve() {
matchText(R.id.header_text, R.string.retrieve_warning)
matchText(R.id.body_text, R.string.empty_retrieve_warning)
}
fun isDisplayed() {
waitForView(
withText("Metric")
)
}
}

View File

@@ -0,0 +1,24 @@
package com.appttude.h_mal.atlas_weather.robot
import com.appttude.h_mal.atlas_weather.BaseTestRobot
import com.appttude.h_mal.atlas_weather.R
import com.appttude.h_mal.atlas_weather.ui.home.adapter.forecastDaily.ViewHolderForecastDaily
fun weatherScreen(func: WeatherScreen.() -> Unit) = WeatherScreen().apply { func() }
class WeatherScreen : 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)
fun isDisplayed() = matchViewWaitFor(R.id.temp_main_4)
fun verifyUnableToRetrieve() {
matchText(R.id.header_text, R.string.retrieve_warning)
matchText(R.id.body_text, R.string.empty_retrieve_warning)
}
fun tapDayInformationByPosition(position: Int) {
clickSubViewInRecycler<ViewHolderForecastDaily>(R.id.forecast_listview, position)
}
}

View File

@@ -0,0 +1,50 @@
package com.appttude.h_mal.atlas_weather.snapshot
import android.annotation.TargetApi
import androidx.test.filters.SmallTest
import com.appttude.h_mal.atlas_weather.BaseTest
import com.appttude.h_mal.atlas_weather.ui.MainActivity
import com.appttude.h_mal.atlas_weather.utils.Stubs
import com.appttude.h_mal.atlas_weather.robot.furtherInfoScreen
import com.appttude.h_mal.atlas_weather.robot.settingsScreen
import com.appttude.h_mal.atlas_weather.robot.weatherScreen
import org.junit.Test
import tools.fastlane.screengrab.Screengrab
@SmallTest
@TargetApi(27)
class SnapshotCaptureTest : BaseTest<MainActivity>(MainActivity::class.java) {
override fun beforeLaunch() {
stubEndpoint("https://api.openweathermap.org/data/2.5/onecall", Stubs.Metric)
stubLocation("London", 51.51, -0.13)
clearPrefs()
}
@Test
fun homeAndFurtherInfoPageCapture() {
weatherScreen {
isDisplayed()
Screengrab.screenshot("HomeScreen")
tapDayInformationByPosition(4)
}
furtherInfoScreen {
isDisplayed()
Screengrab.screenshot("FurtherInfoScreen")
}
}
@Test
fun settingsPageCapture() {
weatherScreen {
isDisplayed()
openMenuItem()
}
settingsScreen {
stubEndpoint("https://api.openweathermap.org/data/2.5/onecall", Stubs.Imperial)
Screengrab.screenshot("SettingsScreen")
}
}
}

View File

@@ -21,7 +21,7 @@ class TestAppClass : MonoApp() {
private val mockingNetworkInterceptor = MockingNetworkInterceptor(idlingResources)
lateinit var database: AppDatabase
lateinit var locationProvider: MockLocationProvider
private val locationProvider: MockLocationProvider = MockLocationProvider()
override fun onCreate() {
super.onCreate()
@@ -38,7 +38,6 @@ class TestAppClass : MonoApp() {
}
override fun createLocationModule(): LocationProvider {
locationProvider = MockLocationProvider()
return locationProvider
}

View File

@@ -0,0 +1,51 @@
package com.appttude.h_mal.atlas_weather.snapshot
import android.annotation.TargetApi
import androidx.test.filters.SmallTest
import com.appttude.h_mal.atlas_weather.BaseTest
import com.appttude.h_mal.atlas_weather.ui.MainActivity
import com.appttude.h_mal.atlas_weather.utils.Stubs
import com.appttude.h_mal.monoWeather.robot.furtherInfoScreen
import com.appttude.h_mal.monoWeather.robot.settingsScreen
import com.appttude.h_mal.monoWeather.robot.weatherScreen
import org.junit.Test
import tools.fastlane.screengrab.Screengrab
@SmallTest
@TargetApi(27)
class SnapshotCaptureTest : BaseTest<MainActivity>(MainActivity::class.java) {
override fun beforeLaunch() {
stubEndpoint("https://api.openweathermap.org/data/2.5/onecall", Stubs.Metric)
stubLocation("London", 51.51, -0.13)
clearPrefs()
}
@Test
fun homeAndFurtherInfoPageCapture() {
weatherScreen {
isDisplayed()
Screengrab.screenshot("HomeScreen")
tapDayInformationByPosition(4)
}
furtherInfoScreen {
isDisplayed()
Screengrab.screenshot("FurtherInfoScreen")
}
}
@Test
fun settingsPageCapture() {
weatherScreen {
isDisplayed()
openMenuItem()
}
settingsScreen {
stubEndpoint("https://api.openweathermap.org/data/2.5/onecall", Stubs.Imperial)
Screengrab.screenshot("SettingsScreen")
}
}
}

View File

@@ -24,7 +24,6 @@ class HomePageUITest : BaseTest<MainActivity>(MainActivity::class.java) {
isDisplayed()
verifyCurrentTemperature(2)
verifyCurrentLocation("Mock Location")
Screengrab.screenshot("HomeScreen")
}
}
@@ -40,7 +39,6 @@ class HomePageUITest : BaseTest<MainActivity>(MainActivity::class.java) {
isDisplayed()
verifyMaxTemperature(12)
verifyAverageTemperature(9)
Screengrab.screenshot("FurtherInfoScreen")
}
}
@@ -57,7 +55,6 @@ class HomePageUITest : BaseTest<MainActivity>(MainActivity::class.java) {
settingsScreen {
selectWeatherUnits(UnitType.IMPERIAL)
goBack()
Screengrab.screenshot("SettingsScreen")
}
weatherScreen {
isDisplayed()

View File

@@ -1,320 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<FrameLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="12dp"
android:layout_weight="2">
<ImageView
style="@style/icon_style__further_details"
android:src="@drawable/somethingnew" />
</FrameLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="@string/max" />
<TextView
android:id="@+id/maxtemp"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
tools:text="11" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="@string/average" />
<TextView
android:id="@+id/averagetemp"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
tools:text="11" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="@string/min" />
<TextView
android:id="@+id/minimumtemp"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
tools:text="11" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<FrameLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="12dp"
android:layout_weight="2">
<ImageView
style="@style/icon_style__further_details"
android:src="@drawable/breeze" />
</FrameLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_weight="3">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="Wind: " />
<TextView
android:id="@+id/windtext"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:text="7mph" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<FrameLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="12dp"
android:layout_weight="2">
<ImageView
style="@style/icon_style__further_details"
android:src="@drawable/water_drop" />
</FrameLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="Humidity: " />
<TextView
android:id="@+id/humiditytext"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:text="85%" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="Precip: " />
<TextView
android:id="@+id/preciptext"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:text="11mm" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<FrameLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="12dp"
android:layout_weight="2">
<ImageView
style="@style/icon_style__further_details"
android:src="@drawable/sunrise" />
</FrameLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="UV: " />
<TextView
android:id="@+id/uvtext"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:text="7" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="Sunrise:" />
<TextView
android:id="@+id/sunrisetext"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:text="05:30am" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="Sunset:" />
<TextView
android:id="@+id/sunsettext"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:text="06:12pm" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
</FrameLayout>

View File

@@ -58,5 +58,5 @@
<fragment
android:id="@+id/settings_fragment"
android:name="com.appttude.h_mal.atlas_weather.ui.settings.SettingsFragment"
android:label="SettingsFragment" />
android:label="Settings" />
</navigation>

View File

@@ -58,6 +58,6 @@
<fragment
android:id="@+id/settings_fragment"
android:name="com.appttude.h_mal.monoWeather.ui.settings.SettingsFragment"
android:label="SettingsFragment" />
android:label="Settings" />
</navigation>

View File

@@ -43,7 +43,7 @@ platform :android do
package_name: "com.appttude.h_mal.atlas_weather")
end
desc "Capture screenshots"
desc "Capture screenshots on MonoWeather"
lane :screenGrabMonoWeather do
build_android_app(
task: 'assemble',
@@ -61,6 +61,29 @@ platform :android do
app_apk_path: "app/build/outputs/apk/monoWeather/debug/app-monoWeather-debug.apk",
tests_apk_path: "app/build/outputs/apk/androidTest/monoWeather/debug/app-monoWeather-debug-androidTest.apk",
test_instrumentation_runner: "com.appttude.h_mal.atlas_weather.application.TestRunner",
use_tests_in_packages: "com.appttude.h_mal.atlas_weather.snapshot"
)
end
desc "Capture screenshots on AtlasWeather"
lane :screenGrabAtlasWeather do
build_android_app(
task: 'assemble',
build_type: 'Debug',
flavor: 'AtlasWeather',
)
build_android_app(
task: 'assemble',
build_type: 'AndroidTest',
flavor: 'AtlasWeather',
)
screengrab(
app_package_name: "com.appttude.h_mal.atlas_weather",
locales: ["en-UK"],
app_apk_path: "app/build/outputs/apk/atlasWeather/debug/app-atlasWeather-debug.apk",
tests_apk_path: "app/build/outputs/apk/androidTest/atlasWeather/debug/app-atlasWeather-debug-androidTest.apk",
test_instrumentation_runner: "com.appttude.h_mal.atlas_weather.application.TestRunner",
use_tests_in_packages: "com.appttude.h_mal.atlas_weather.snapshot"
)
end
end

56
fastlane/README.md Normal file
View File

@@ -0,0 +1,56 @@
fastlane documentation
----
# Installation
Make sure you have the latest version of the Xcode command line tools installed:
```sh
xcode-select --install
```
For _fastlane_ installation instructions, see [Installing _fastlane_](https://docs.fastlane.tools/#installing-fastlane)
# Available Actions
## Android
### android deployMonoWeather
```sh
[bundle exec] fastlane android deployMonoWeather
```
Deploy a new Mono Weather version to the Google Play
### android deployAtlasWeather
```sh
[bundle exec] fastlane android deployAtlasWeather
```
Deploy a new Atlas Weather version to the Google Play
### android screenGrabMonoWeather
```sh
[bundle exec] fastlane android screenGrabMonoWeather
```
Capture screenshots on MonoWeather
### android screenGrabAtlasWeather
```sh
[bundle exec] fastlane android screenGrabAtlasWeather
```
Capture screenshots on AtlasWeather
----
This README.md is auto-generated and will be re-generated every time [_fastlane_](https://fastlane.tools) is run.
More information about _fastlane_ can be found on [fastlane.tools](https://fastlane.tools).
The documentation of _fastlane_ can be found on [docs.fastlane.tools](https://docs.fastlane.tools).

View File

@@ -15,13 +15,13 @@ Weather-apps contains two weather apps - Atlas weather and Mono weather. They ar
## Screenshots
### Atlas Weather
![Home Screen](screenshots/home.png)
![Forecast Screen](screenshots/forecast.png)
![Settings Screen](screenshots/settings.png)
![Home Screen](screenshots/atlas/home.png)
![Forecast Screen](screenshots/atlas/forecast.png)
![Settings Screen](screenshots/atlas/settings.png)
### Mono Weather
![Home Screen](screenshots/home.png)
![Forecast Screen](screenshots/forecast.png)
![Settings Screen](screenshots/settings.png)
![Home Screen](screenshots/mono/home.png)
![Forecast Screen](screenshots/mono/forecast.png)
![Settings Screen](screenshots/mono/settings.png)
## Usage

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

BIN
screenshots/atlas/home.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
screenshots/mono/home.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB