diff --git a/app/src/androidTestAtlasWeather/java/com/appttude/h_mal/atlas_weather/application/TestAppClass.kt b/app/src/androidTestAtlasWeather/java/com/appttude/h_mal/atlas_weather/application/TestAppClass.kt index 0d55586..2a3d363 100644 --- a/app/src/androidTestAtlasWeather/java/com/appttude/h_mal/atlas_weather/application/TestAppClass.kt +++ b/app/src/androidTestAtlasWeather/java/com/appttude/h_mal/atlas_weather/application/TestAppClass.kt @@ -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 } diff --git a/app/src/androidTestAtlasWeather/java/com/appttude/h_mal/atlas_weather/robot/FurtherInfoScreen.kt b/app/src/androidTestAtlasWeather/java/com/appttude/h_mal/atlas_weather/robot/FurtherInfoScreen.kt new file mode 100644 index 0000000..6177bda --- /dev/null +++ b/app/src/androidTestAtlasWeather/java/com/appttude/h_mal/atlas_weather/robot/FurtherInfoScreen.kt @@ -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) +} \ No newline at end of file diff --git a/app/src/androidTestAtlasWeather/java/com/appttude/h_mal/atlas_weather/robot/SettingsRobot.kt b/app/src/androidTestAtlasWeather/java/com/appttude/h_mal/atlas_weather/robot/SettingsRobot.kt new file mode 100644 index 0000000..a69b125 --- /dev/null +++ b/app/src/androidTestAtlasWeather/java/com/appttude/h_mal/atlas_weather/robot/SettingsRobot.kt @@ -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( + 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") + ) + } +} \ No newline at end of file diff --git a/app/src/androidTestAtlasWeather/java/com/appttude/h_mal/atlas_weather/robot/WeatherScreen.kt b/app/src/androidTestAtlasWeather/java/com/appttude/h_mal/atlas_weather/robot/WeatherScreen.kt new file mode 100644 index 0000000..5ca9e0c --- /dev/null +++ b/app/src/androidTestAtlasWeather/java/com/appttude/h_mal/atlas_weather/robot/WeatherScreen.kt @@ -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(R.id.forecast_listview, position) + } +} \ No newline at end of file diff --git a/app/src/androidTestAtlasWeather/java/com/appttude/h_mal/atlas_weather/snapshot/SnapshotCaptureTest.kt b/app/src/androidTestAtlasWeather/java/com/appttude/h_mal/atlas_weather/snapshot/SnapshotCaptureTest.kt new file mode 100644 index 0000000..4eff728 --- /dev/null +++ b/app/src/androidTestAtlasWeather/java/com/appttude/h_mal/atlas_weather/snapshot/SnapshotCaptureTest.kt @@ -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::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") + } + } +} diff --git a/app/src/androidTestMonoWeather/java/com/appttude/h_mal/atlas_weather/application/TestAppClass.kt b/app/src/androidTestMonoWeather/java/com/appttude/h_mal/atlas_weather/application/TestAppClass.kt index ef1122f..9d796e1 100644 --- a/app/src/androidTestMonoWeather/java/com/appttude/h_mal/atlas_weather/application/TestAppClass.kt +++ b/app/src/androidTestMonoWeather/java/com/appttude/h_mal/atlas_weather/application/TestAppClass.kt @@ -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 } diff --git a/app/src/androidTestMonoWeather/java/com/appttude/h_mal/atlas_weather/snapshot/SnapshotCaptureTest.kt b/app/src/androidTestMonoWeather/java/com/appttude/h_mal/atlas_weather/snapshot/SnapshotCaptureTest.kt new file mode 100644 index 0000000..a5e17bc --- /dev/null +++ b/app/src/androidTestMonoWeather/java/com/appttude/h_mal/atlas_weather/snapshot/SnapshotCaptureTest.kt @@ -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::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") + } + } +} diff --git a/app/src/androidTestMonoWeather/java/com/appttude/h_mal/monoWeather/tests/HomePageUITest.kt b/app/src/androidTestMonoWeather/java/com/appttude/h_mal/monoWeather/tests/HomePageUITest.kt index 043ae7e..fbe8e39 100644 --- a/app/src/androidTestMonoWeather/java/com/appttude/h_mal/monoWeather/tests/HomePageUITest.kt +++ b/app/src/androidTestMonoWeather/java/com/appttude/h_mal/monoWeather/tests/HomePageUITest.kt @@ -24,7 +24,6 @@ class HomePageUITest : BaseTest(MainActivity::class.java) { isDisplayed() verifyCurrentTemperature(2) verifyCurrentLocation("Mock Location") - Screengrab.screenshot("HomeScreen") } } @@ -40,7 +39,6 @@ class HomePageUITest : BaseTest(MainActivity::class.java) { isDisplayed() verifyMaxTemperature(12) verifyAverageTemperature(9) - Screengrab.screenshot("FurtherInfoScreen") } } @@ -57,7 +55,6 @@ class HomePageUITest : BaseTest(MainActivity::class.java) { settingsScreen { selectWeatherUnits(UnitType.IMPERIAL) goBack() - Screengrab.screenshot("SettingsScreen") } weatherScreen { isDisplayed() diff --git a/app/src/atlasWeather/res/layout/activity_further_info.xml b/app/src/atlasWeather/res/layout/activity_further_info.xml deleted file mode 100644 index 53272d5..0000000 --- a/app/src/atlasWeather/res/layout/activity_further_info.xml +++ /dev/null @@ -1,320 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/atlasWeather/res/navigation/main_navigation.xml b/app/src/atlasWeather/res/navigation/main_navigation.xml index 88fa0b9..d4b33c1 100644 --- a/app/src/atlasWeather/res/navigation/main_navigation.xml +++ b/app/src/atlasWeather/res/navigation/main_navigation.xml @@ -58,5 +58,5 @@ + android:label="Settings" /> \ No newline at end of file diff --git a/app/src/monoWeather/res/navigation/main_navigation.xml b/app/src/monoWeather/res/navigation/main_navigation.xml index 2947463..4f165e2 100644 --- a/app/src/monoWeather/res/navigation/main_navigation.xml +++ b/app/src/monoWeather/res/navigation/main_navigation.xml @@ -58,6 +58,6 @@ + android:label="Settings" /> \ No newline at end of file diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 00d4eb4..1d13304 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -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 \ No newline at end of file diff --git a/fastlane/README.md b/fastlane/README.md new file mode 100644 index 0000000..0888f64 --- /dev/null +++ b/fastlane/README.md @@ -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). diff --git a/readme.md b/readme.md index ec7678b..67e5a21 100644 --- a/readme.md +++ b/readme.md @@ -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 diff --git a/screenshots/atlas/forecast.png b/screenshots/atlas/forecast.png new file mode 100644 index 0000000..e531f58 Binary files /dev/null and b/screenshots/atlas/forecast.png differ diff --git a/screenshots/atlas/home.png b/screenshots/atlas/home.png new file mode 100644 index 0000000..be4cbec Binary files /dev/null and b/screenshots/atlas/home.png differ diff --git a/screenshots/atlas/settings.png b/screenshots/atlas/settings.png new file mode 100644 index 0000000..0e42ff1 Binary files /dev/null and b/screenshots/atlas/settings.png differ diff --git a/screenshots/mono/forecast.png b/screenshots/mono/forecast.png new file mode 100644 index 0000000..ea96184 Binary files /dev/null and b/screenshots/mono/forecast.png differ diff --git a/screenshots/mono/home.png b/screenshots/mono/home.png new file mode 100644 index 0000000..e58fc4d Binary files /dev/null and b/screenshots/mono/home.png differ diff --git a/screenshots/mono/settings.png b/screenshots/mono/settings.png new file mode 100644 index 0000000..297495a Binary files /dev/null and b/screenshots/mono/settings.png differ