Skip to content

Commit

Permalink
Merge pull request #133 from pravinyo/screenshot_job
Browse files Browse the repository at this point in the history
UI fixes and testing enhancement
  • Loading branch information
pravinyo authored May 31, 2020
2 parents 33a6ce9 + 417984c commit 9c70718
Show file tree
Hide file tree
Showing 43 changed files with 244 additions and 140 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/Build-InstrumentationTest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: AudioBook InstrumentationTest

on:
push:
branches:
- 'ci_instrumentation_test'

jobs:
instrumentationJob:
name: Run Instrumentation Tests
runs-on: ubuntu-18.04

steps:
- uses: actions/checkout@v1
- name: set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8

- uses: malinskiy/action-android/install-sdk@release/0.0.6
- run: adb devices
- run: echo $ANDROID_HOME

- uses: malinskiy/action-android/emulator-run-cmd@release/0.0.6
with:
cmd: ./gradlew connectedDebugAndroidTest
api: 25
tag: default
abi: x86
- name: Save logcat output
uses: actions/upload-artifact@master
if: failure()
with:
name: logcat
path: artifacts/logcat.log
40 changes: 39 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ android {
returnDefaultValues = true
}

adbOptions {
installOptions '-g', '-r'
}

// dynamicFeatures = [":feature_book", ":feature_book_details"]


Expand Down Expand Up @@ -99,4 +103,38 @@ dependencies {
androidTestImplementation(TestLibraryDependency.ANDROID_X_EXT_TESTING)
androidTestImplementation(TestLibraryDependency.ESPRESSO_CORE)
androidTestImplementation(TestLibraryDependency.ESPRESSO_CONTRIB)
}
}

def reportsDirectory = "$buildDir/reports/androidTests/connected"

def clearScreenshotsTask = task('clearScreenshots', type: Exec) {
executable "${android.getAdbExe().toString()}"
args 'shell', 'rm', '-r', '/sdcard/Pictures/audioBook_test_folder'
}

def createScreenshotDirectoryTask = task('createScreenshotDirectory', type: Exec, group: 'reporting') {
executable "${android.getAdbExe().toString()}"
args 'shell', 'mkdir', '-p', '/sdcard/Pictures/audioBook_test_folder'
}

def fetchScreenshotsTask = task('fetchScreenshots', type: Exec, group: 'reporting') {
executable "${android.getAdbExe().toString()}"
args 'pull', '/sdcard/Pictures/audioBook_test_folder/.', reportsDirectory
finalizedBy {
clearScreenshotsTask
}

dependsOn {
createScreenshotDirectoryTask
}

doFirst {
new File(reportsDirectory).mkdirs()
}
}

task copyScreenshotToMachine{ task ->
task.finalizedBy {
fetchScreenshotsTask
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ import androidx.test.espresso.Espresso.pressBack
import androidx.test.espresso.IdlingRegistry
import androidx.test.espresso.action.ViewActions.*
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.contrib.NavigationViewActions
import androidx.test.espresso.contrib.RecyclerViewActions.actionOnItemAtPosition
import androidx.test.espresso.contrib.RecyclerViewActions.scrollToPosition
import androidx.test.espresso.matcher.ViewMatchers.*
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.LargeTest
import com.allsoftdroid.audiobook.R
import com.allsoftdroid.audiobook.presentation.utils.TakeScreenshotUtils.takeScreenshot
import com.allsoftdroid.common.test.DataBindingIdlingResource
import com.allsoftdroid.common.test.EspressoIdlingResource
import com.allsoftdroid.common.test.monitorActivity
Expand Down Expand Up @@ -46,7 +48,10 @@ class MainActivityTest{

onView(withId(R.id.toolbar_title)).check(matches(withText("Latest Audio Books")))

onView(withId(R.id.toolbar_downloads)).perform(click())
onView(withId(R.id.toolbar_nav_hamburger)).perform(click())

onView(withId(R.id.nav_view))
.perform(NavigationViewActions.navigateTo(R.id.nav_item_downloads))

pressBack()

Expand All @@ -70,13 +75,16 @@ class MainActivityTest{
onView(withId(R.id.toolbar_book_search)).perform(click())

onView(withId(R.id.et_toolbar_search)).check(matches(isDisplayed()))
onView(withId(R.id.et_toolbar_search)).perform(clearText(), typeText("poem"))
onView(withId(R.id.et_toolbar_search)).perform(clearText(), typeText("penny catechism"))

onView(withId(R.id.iv_search)).check(matches(isDisplayed()))
onView(withId(R.id.iv_search)).perform(click())


Thread.sleep(7000)
Thread.sleep(4000)

takeScreenshot(parentFolderPath = "Search", screenShotName = "search_results")

onView(withId(R.id.recycler_view_books))
.check(matches(hasMinimumChildCount(1)))

Expand All @@ -89,14 +97,20 @@ class MainActivityTest{
dataBindingIdlingResource.monitorActivity(activityScenario)

Thread.sleep(10000)

takeScreenshot(parentFolderPath = "MainScreen", screenShotName = "MainScreen")

onView(withId(R.id.recycler_view_books))
.perform(actionOnItemAtPosition<RecyclerView.ViewHolder>(0,click()))
.perform(actionOnItemAtPosition<RecyclerView.ViewHolder>(3,click()))

onView(withId(R.id.tv_toolbar_title)).check(matches(isDisplayed()))

onView(withId(R.id.btn_toolbar_back_arrow)).check(matches(isDisplayed()))

onView(withId(R.id.textView_description)).check(matches(isDisplayed()))
onView(withId(R.id.textView_book_intro)).check(matches(isDisplayed()))

Thread.sleep(4000)
takeScreenshot(parentFolderPath = "Book details", screenShotName = "BookDetails")

pressBack()

Expand Down Expand Up @@ -126,22 +140,38 @@ class MainActivityTest{

Thread.sleep(10000)
onView(withId(R.id.recycler_view_books))
.perform(actionOnItemAtPosition<RecyclerView.ViewHolder>(0,click()))
.perform(actionOnItemAtPosition<RecyclerView.ViewHolder>(3,click()))

onView(withId(R.id.tv_toolbar_title)).check(matches(isDisplayed()))

onView(withId(R.id.btn_toolbar_back_arrow)).check(matches(isDisplayed()))

onView(withId(R.id.textView_description)).check(matches(isDisplayed()))
onView(withId(R.id.textView_book_intro)).check(matches(isDisplayed()))

Thread.sleep(4000)
onView(withId(R.id.recyclerView))
.perform(actionOnItemAtPosition<RecyclerView.ViewHolder>(0,click()))


Thread.sleep(2000)
onView(withId(R.id.miniPlayerContainer)).check(matches(isDisplayed()))
takeScreenshot(parentFolderPath = "MiniPlayer", screenShotName = "MiniPlayer")

activityScenario.close()
}

@Test
fun listen_later_from_BookDetailsScreen_DisplayInUi(){
val activityScenario = ActivityScenario.launch(MainActivity::class.java)
dataBindingIdlingResource.monitorActivity(activityScenario)

onView(withId(R.id.toolbar_nav_hamburger)).perform(click())

onView(withId(R.id.nav_view))
.perform(NavigationViewActions.navigateTo(R.id.nav_item_listen_later))

Thread.sleep(2000)

takeScreenshot(parentFolderPath = "Listenlater", screenShotName = "listen_later")

activityScenario.close()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.allsoftdroid.audiobook.presentation.utils

import android.os.Environment.DIRECTORY_PICTURES
import android.os.Environment.getExternalStoragePublicDirectory
import androidx.test.runner.screenshot.BasicScreenCaptureProcessor
import java.io.File

class ScreenCaptureProcessor(parentFolderPath: String) : BasicScreenCaptureProcessor() {

init {
this.mDefaultScreenshotPath = File(
File(
getExternalStoragePublicDirectory(DIRECTORY_PICTURES),
"audioBook_test_folder"
).absolutePath,
"screenshots/$parentFolderPath"
)
}

override fun getFilename(prefix: String): String = prefix
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.allsoftdroid.audiobook.presentation.utils

import androidx.test.runner.screenshot.Screenshot
import timber.log.Timber
import java.io.IOException

object TakeScreenshotUtils {
fun takeScreenshot(parentFolderPath: String = "", screenShotName: String) {
Timber.d("Taking screenshot of '$screenShotName'")
val screenCapture = Screenshot.capture()
val processors = setOf(ScreenCaptureProcessor(parentFolderPath))
try {
screenCapture.apply {
name = screenShotName
process(processors)
}
Timber.d("Screenshot taken")
} catch (ex: IOException) {
Timber.d("Could not take the screenshot: $ex")
}
}
}
Binary file modified app/src/main/res/drawable/launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/mipmap-hdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/mipmap-mdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/mipmap-xhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
<color name="colorPrimary">#000</color>
<color name="colorPrimaryDark">#000</color>
<color name="colorAccent">#35D807</color>
<color name="splash_background">#302BC9</color>
<color name="splash_background">#cc66ff</color>
</resources>
2 changes: 2 additions & 0 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ dependencies {

api(LibraryDependency.KOIN)

implementation(LibraryDependency.LOTTIE)

//test rules
implementation(TestLibraryDependency.JUNIT)
implementation(TestLibraryDependency.COROUTINES_TEST)
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion common/src/main/res/drawable/book_search_outline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
android:width="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path android:fillColor="#FFFFFF" android:pathData="M15.5,12C18,12 20,14 20,16.5C20,17.38 19.75,18.21 19.31,18.9L22.39,22L21,23.39L17.88,20.32C17.19,20.75 16.37,21 15.5,21C13,21 11,19 11,16.5C11,14 13,12 15.5,12M15.5,14A2.5,2.5 0 0,0 13,16.5A2.5,2.5 0 0,0 15.5,19A2.5,2.5 0 0,0 18,16.5A2.5,2.5 0 0,0 15.5,14M13,4V12L10.5,9.75L8,12V4H6V20H10C10.54,20.81 11.23,21.5 12.03,22H6A2,2 0 0,1 4,20V4A2,2 0 0,1 6,2H18A2,2 0 0,1 20,4V11.81C19.42,11.26 18.75,10.81 18,10.5V4H13Z" />
<path android:fillColor="#000" android:pathData="M15.5,12C18,12 20,14 20,16.5C20,17.38 19.75,18.21 19.31,18.9L22.39,22L21,23.39L17.88,20.32C17.19,20.75 16.37,21 15.5,21C13,21 11,19 11,16.5C11,14 13,12 15.5,12M15.5,14A2.5,2.5 0 0,0 13,16.5A2.5,2.5 0 0,0 15.5,19A2.5,2.5 0 0,0 18,16.5A2.5,2.5 0 0,0 15.5,14M13,4V12L10.5,9.75L8,12V4H6V20H10C10.54,20.81 11.23,21.5 12.03,22H6A2,2 0 0,1 4,20V4A2,2 0 0,1 6,2H18A2,2 0 0,1 20,4V11.81C19.42,11.26 18.75,10.81 18,10.5V4H13Z" />
</vector>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<vector android:autoMirrored="true" android:height="24dp"
android:tint="#FEFFFD" android:viewportHeight="24.0"
android:tint="#000" android:viewportHeight="24.0"
android:viewportWidth="24.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M15.41,16.09l-4.58,-4.59 4.58,-4.59L14,5.5l-6,6 6,6z"/>
<path android:fillColor="#000" android:pathData="M15.41,16.09l-4.58,-4.59 4.58,-4.59L14,5.5l-6,6 6,6z"/>
</vector>
5 changes: 5 additions & 0 deletions common/src/main/res/drawable/ic_keyboard_arrow_left_white.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:autoMirrored="true" android:height="24dp"
android:tint="#fff" android:viewportHeight="24.0"
android:viewportWidth="24.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#fff" android:pathData="M15.41,16.09l-4.58,-4.59 4.58,-4.59L14,5.5l-6,6 6,6z"/>
</vector>
2 changes: 1 addition & 1 deletion feature_book/src/main/res/drawable/close.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
android:width="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path android:fillColor="#FFFFFF" android:pathData="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z" />
<path android:fillColor="#000" android:pathData="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z" />
</vector>
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
android:width="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path android:fillColor="#FAF9F9" android:pathData="M8.59,16.58L13.17,12L8.59,7.41L10,6L16,12L10,18L8.59,16.58Z" />
<path android:fillColor="#000" android:pathData="M8.59,16.58L13.17,12L8.59,7.41L10,6L16,12L10,18L8.59,16.58Z" />
</vector>
2 changes: 1 addition & 1 deletion feature_book/src/main/res/drawable/ic_refresh.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
android:width="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path android:fillColor="#FFFFFF" android:pathData="M17.65,6.35C16.2,4.9 14.21,4 12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20C15.73,20 18.84,17.45 19.73,14H17.65C16.83,16.33 14.61,18 12,18A6,6 0 0,1 6,12A6,6 0 0,1 12,6C13.66,6 15.14,6.69 16.22,7.78L13,11H20V4L17.65,6.35Z" />
<path android:fillColor="#000" android:pathData="M17.65,6.35C16.2,4.9 14.21,4 12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20C15.73,20 18.84,17.45 19.73,14H17.65C16.83,16.33 14.61,18 12,18A6,6 0 0,1 6,12A6,6 0 0,1 12,6C13.66,6 15.14,6.69 16.22,7.78L13,11H20V4L17.65,6.35Z" />
</vector>
2 changes: 1 addition & 1 deletion feature_book/src/main/res/drawable/ic_search_web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
android:width="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path android:fillColor="#FFFFFF" android:pathData="M15.5,14L20.5,19L19,20.5L14,15.5V14.71L13.73,14.43C12.59,15.41 11.11,16 9.5,16A6.5,6.5 0 0,1 3,9.5A6.5,6.5 0 0,1 9.5,3A6.5,6.5 0 0,1 16,9.5C16,11.11 15.41,12.59 14.43,13.73L14.71,14H15.5M9.5,4.5L8.95,4.53C8.71,5.05 8.34,5.93 8.07,7H10.93C10.66,5.93 10.29,5.05 10.05,4.53C9.87,4.5 9.69,4.5 9.5,4.5M13.83,7C13.24,5.97 12.29,5.17 11.15,4.78C11.39,5.31 11.7,6.08 11.93,7H13.83M5.17,7H7.07C7.3,6.08 7.61,5.31 7.85,4.78C6.71,5.17 5.76,5.97 5.17,7M4.5,9.5C4.5,10 4.58,10.53 4.73,11H6.87L6.75,9.5L6.87,8H4.73C4.58,8.47 4.5,9 4.5,9.5M14.27,11C14.42,10.53 14.5,10 14.5,9.5C14.5,9 14.42,8.47 14.27,8H12.13C12.21,8.5 12.25,9 12.25,9.5C12.25,10 12.21,10.5 12.13,11H14.27M7.87,8L7.75,9.5L7.87,11H11.13C11.21,10.5 11.25,10 11.25,9.5C11.25,9 11.21,8.5 11.13,8H7.87M9.5,14.5C9.68,14.5 9.86,14.5 10.03,14.47C10.28,13.95 10.66,13.07 10.93,12H8.07C8.34,13.07 8.72,13.95 8.97,14.47L9.5,14.5M13.83,12H11.93C11.7,12.92 11.39,13.69 11.15,14.22C12.29,13.83 13.24,13.03 13.83,12M5.17,12C5.76,13.03 6.71,13.83 7.85,14.22C7.61,13.69 7.3,12.92 7.07,12H5.17Z" />
<path android:fillColor="#000" android:pathData="M15.5,14L20.5,19L19,20.5L14,15.5V14.71L13.73,14.43C12.59,15.41 11.11,16 9.5,16A6.5,6.5 0 0,1 3,9.5A6.5,6.5 0 0,1 9.5,3A6.5,6.5 0 0,1 16,9.5C16,11.11 15.41,12.59 14.43,13.73L14.71,14H15.5M9.5,4.5L8.95,4.53C8.71,5.05 8.34,5.93 8.07,7H10.93C10.66,5.93 10.29,5.05 10.05,4.53C9.87,4.5 9.69,4.5 9.5,4.5M13.83,7C13.24,5.97 12.29,5.17 11.15,4.78C11.39,5.31 11.7,6.08 11.93,7H13.83M5.17,7H7.07C7.3,6.08 7.61,5.31 7.85,4.78C6.71,5.17 5.76,5.97 5.17,7M4.5,9.5C4.5,10 4.58,10.53 4.73,11H6.87L6.75,9.5L6.87,8H4.73C4.58,8.47 4.5,9 4.5,9.5M14.27,11C14.42,10.53 14.5,10 14.5,9.5C14.5,9 14.42,8.47 14.27,8H12.13C12.21,8.5 12.25,9 12.25,9.5C12.25,10 12.21,10.5 12.13,11H14.27M7.87,8L7.75,9.5L7.87,11H11.13C11.21,10.5 11.25,10 11.25,9.5C11.25,9 11.21,8.5 11.13,8H7.87M9.5,14.5C9.68,14.5 9.86,14.5 10.03,14.47C10.28,13.95 10.66,13.07 10.93,12H8.07C8.34,13.07 8.72,13.95 8.97,14.47L9.5,14.5M13.83,12H11.93C11.7,12.92 11.39,13.69 11.15,14.22C12.29,13.83 13.24,13.03 13.83,12M5.17,12C5.76,13.03 6.71,13.83 7.85,14.22C7.61,13.69 7.3,12.92 7.07,12H5.17Z" />
</vector>
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
android:width="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path android:fillColor="#FFFFFF" android:pathData="M3,6H21V8H3V6M3,11H21V13H3V11M3,16H21V18H3V16Z" />
<path android:fillColor="#000000" android:pathData="M3,6H21V8H3V6M3,11H21V13H3V11M3,16H21V18H3V16Z" />
</vector>
5 changes: 2 additions & 3 deletions feature_book/src/main/res/layout/fragment_audiobook_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.
android:layout_width="0dp"
android:layout_height="?actionBarSize"
app:layout_constraintEnd_toEndOf="parent"
android:background="@color/black"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:id="@+id/toolbar"
Expand All @@ -48,7 +47,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.

<TextView
android:id="@+id/toolbar_title"
android:textColor="@color/white"
android:textColor="@color/colorPrimary"
android:layout_width="0dp"
android:textAppearance="@style/TextAppearance.AppCompat.Large"
android:gravity="center"
Expand Down Expand Up @@ -102,7 +101,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.
android:ellipsize="end"
android:inputType="text"
android:layout_gravity="center_vertical"
android:textColor="@color/white"
android:textColor="@color/colorPrimaryDark"
android:layout_height="wrap_content"
android:hint="@string/type_here"
android:importantForAutofill="no" />
Expand Down
2 changes: 1 addition & 1 deletion feature_book/src/main/res/layout/nav_header_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
android:id="@+id/nav_header"
android:layout_width="match_parent"
android:layout_height="@dimen/nav_header_height"
android:background="@color/colorPrimaryDark"
android:background="@color/colorPrimary"
android:clickable="true"
android:focusable="true"
android:gravity="bottom"
Expand Down
6 changes: 3 additions & 3 deletions feature_book/src/main/res/menu/activity_main_drawer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

<item android:title="@string/menu_others">
<menu>
<item android:id="@+id/nav_item_history"
android:icon="@drawable/ic_history"
android:title="@string/history" />
<!-- <item android:id="@+id/nav_item_history"-->
<!-- android:icon="@drawable/ic_history"-->
<!-- android:title="@string/history" />-->
<item android:id="@+id/nav_item_settings"
android:icon="@drawable/ic_cog_outline"
android:title="@string/settings" />
Expand Down
Loading

0 comments on commit 9c70718

Please sign in to comment.