Skip to content

Commit

Permalink
Merge pull request #333 from ytai/ModernizeScreenshots
Browse files Browse the repository at this point in the history
Modernize screenshots
  • Loading branch information
hannesa2 authored Mar 31, 2023
2 parents 9e94864 + 0d181f5 commit 9332282
Show file tree
Hide file tree
Showing 17 changed files with 69 additions and 272 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/Android-CI-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
distribution: 'adopt'
java-version: 11
- name: Install Android SDK
uses: malinskiy/action-android/install-sdk@release/0.1.2
uses: malinskiy/action-android/install-sdk@release/0.1.4
- name: Build project
run: ./gradlew clean build
env:
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/Android-CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ jobs:
distribution: 'adopt'
java-version: ${{ matrix.java_version }}
- name: Install Android SDK
uses: malinskiy/action-android/install-sdk@release/0.1.2
uses: malinskiy/action-android/install-sdk@release/0.1.4
- name: Run tests
run: ./gradlew test
env:
VERSION: ${{ github.ref }}
- name: Run instrumentation tests
uses: malinskiy/action-android/emulator-run-cmd@release/0.1.2
uses: malinskiy/action-android/emulator-run-cmd@release/0.1.4
env:
VERSION: ${{ github.ref }}
with:
Expand All @@ -51,7 +51,9 @@ jobs:
if: ${{ always() }}
with:
name: IOIO-Screenshots
path: applications/screenshots/adb/
path: |
applications/**/build/outputs/connected_android_test_additional_output/debugAndroidTest/connected
applications/**/build/outputs/androidTest-results/connected
Check:
name: Check
runs-on: ubuntu-latest
Expand All @@ -66,7 +68,7 @@ jobs:
distribution: 'adopt'
java-version: 11
- name: Install Android SDK
uses: malinskiy/action-android/install-sdk@release/0.1.2
uses: malinskiy/action-android/install-sdk@release/0.1.4
- name: Code checks
run: ./gradlew check
- name: Archive Lint report
Expand Down
3 changes: 0 additions & 3 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
* <p>
* This class implements a common life-cycle for applications interacting with
* IOIO devices. Usage is as follows:
* <ul>
* <li>Create an instance of {@link IOIOPcApplicationHelper}, passing a
* {@link IOIOLooperProvider} to the constructor.</li>
* <li>When the application starts, call {@link #start()}, which will in turn
Expand Down
2 changes: 1 addition & 1 deletion IOIOLibPC/src/main/java/ioio/lib/util/pc/IOIOSwingApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* creating an instance of this class, and calling its
* {@code void go(String[] args)} method.</li>
* <li>Implement {@code Window createMainWindow(String args[])} with code to create your main window.
* For proper cleanup on exit, make sure to set {@link JFrame.DISPOSE_ON_CLOSE} as the default close operation of your window.</li>
* For proper cleanup on exit, make sure to set JFrame.DISPOSE_ON_CLOSE as the default close operation of your window.</li>
* <li>Implement
* {@code IOIOLooper createIOIOLooper(String connectionType, Object extra)} with
* code that should run on IOIO-dedicated threads.</li>
Expand Down
52 changes: 5 additions & 47 deletions applications/HelloIOIO/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ android {
versionName getTag()

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunnerArguments useTestStorageService: 'true'
}

}
Expand All @@ -21,51 +22,8 @@ dependencies {
implementation project(':IOIOLibAndroidAccessory')
implementation project(':IOIOLibAndroidDevice')

androidTestImplementation 'com.github.AppDevNext:Moka:1.1'
androidTestImplementation "androidx.test.ext:junit:1.1.3"
androidTestImplementation 'androidx.test:runner:1.4.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.4.0'
androidTestImplementation "androidx.test.ext:junit-ktx:1.1.5"
androidTestUtil "androidx.test.services:test-services:1.4.2"
androidTestImplementation "androidx.test.espresso:espresso-core:3.5.1"
// androidTestImplementation "androidx.test:rules:1.5.0" // GrantPermissionRule
}

def adbDirectory = '/storage/emulated/0/Download' // api 28
//def adbDirectory = '/storage/self/primary/Download' // api 21
def reportsDirectory = "$projectDir/../screenshots/adb"

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

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

def fetchScreenshotsTask = task('fetchScreenshots', type: Exec, group: 'reporting') {
println "fetchScreenshotsTask"
executable "${android.getAdbExe().toString()}"
args 'pull', adbDirectory + '/.', reportsDirectory

dependsOn {
createScreenshotDirectoryTask
}

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

tasks.whenTaskAdded { task ->
if (task.name == 'connectedDebugAndroidTest' || task.name == 'connectedCodeDebugAndroidTest') {
task.mustRunAfter {
clearScreenshotsTask
createScreenshotDirectoryTask
}
task.finalizedBy {
fetchScreenshotsTask
}
}
}
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
package ioio.examples.hello

import android.Manifest
import androidx.test.core.graphics.writeToTestStorage
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.ext.junit.rules.ActivityScenarioRule
import androidx.test.espresso.screenshot.captureToBitmap
import androidx.test.ext.junit.rules.activityScenarioRule
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.rule.GrantPermissionRule
import com.moka.utils.Screenshot
import org.junit.Rule
import org.junit.Test
import org.junit.rules.TestName
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
class HelloIOIOSmokeTest {

@get:Rule
var activityScenarioRule = ActivityScenarioRule(MainActivity::class.java)
val activityScenarioRule = activityScenarioRule<MainActivity>()

@get:Rule
val grantPermissionRule: GrantPermissionRule = GrantPermissionRule.grant(
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.READ_EXTERNAL_STORAGE)
var nameRule = TestName()

@Test
fun smokeTestSimplyStart() {
onView(withId(R.id.button)).check(matches(isDisplayed()))
Screenshot.takeScreenshot("smoke")
onView(ViewMatchers.isRoot())
.captureToBitmap()
.writeToTestStorage("${javaClass.simpleName}_${nameRule.methodName}")
}
}
9 changes: 0 additions & 9 deletions applications/HelloIOIO/src/debug/AndroidManifest.xml

This file was deleted.

53 changes: 6 additions & 47 deletions applications/HolidayIOIO/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,59 +12,18 @@ android {
versionName getTag()

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunnerArguments useTestStorageService: 'true'
}
}

dependencies {
implementation project(':IOIOLibAndroidBluetooth')
implementation project(':IOIOLibAndroidAccessory')
implementation project(':IOIOLibAndroidDevice')
implementation 'androidx.test:rules:1.5.0'

androidTestImplementation 'com.github.AppDevNext:Moka:1.1'
androidTestImplementation "androidx.test.ext:junit:1.1.3"
androidTestImplementation 'androidx.test:runner:1.4.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.4.0'
}

def adbDirectory = '/storage/emulated/0/Download' // api 28
//def adbDirectory = '/storage/self/primary/Download' // api 21
def reportsDirectory = "$projectDir/../screenshots/adb"

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

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

def fetchScreenshotsTask = task('fetchScreenshots', type: Exec, group: 'reporting') {
println "fetchScreenshotsTask"
executable "${android.getAdbExe().toString()}"
args 'pull', adbDirectory + '/.', reportsDirectory

dependsOn {
createScreenshotDirectoryTask
}

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

tasks.whenTaskAdded { task ->
if (task.name == 'connectedDebugAndroidTest' || task.name == 'connectedCodeDebugAndroidTest') {
task.mustRunAfter {
clearScreenshotsTask
createScreenshotDirectoryTask
}
task.finalizedBy {
fetchScreenshotsTask
}
}
androidTestImplementation "androidx.test.ext:junit-ktx:1.1.5"
androidTestUtil "androidx.test.services:test-services:1.4.2"
androidTestImplementation "androidx.test.espresso:espresso-core:3.5.1"
androidTestImplementation "androidx.test:rules:1.5.0" // GrantPermissionRule
}
Original file line number Diff line number Diff line change
@@ -1,32 +1,38 @@
package ioio.examples.holiday

import android.Manifest
import androidx.test.core.graphics.writeToTestStorage
import androidx.test.espresso.Espresso
import androidx.test.espresso.assertion.ViewAssertions
import androidx.test.espresso.matcher.ViewMatchers
import androidx.test.ext.junit.rules.ActivityScenarioRule
import androidx.test.espresso.screenshot.captureToBitmap
import androidx.test.ext.junit.rules.activityScenarioRule
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.rule.GrantPermissionRule
import com.moka.utils.Screenshot
import org.junit.Rule
import org.junit.Test
import org.junit.rules.TestName
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
class HolidayIOIOSmokeTest {

@get:Rule
var activityScenarioRule = ActivityScenarioRule(HolidayIOIOActivity::class.java)
val activityScenarioRule = activityScenarioRule<HolidayIOIOActivity>()

var nameRule = TestName()


@get:Rule
val grantPermissionRule: GrantPermissionRule = GrantPermissionRule.grant(
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.CAMERA,
Manifest.permission.READ_EXTERNAL_STORAGE)
Manifest.permission.CAMERA
)

@Test
fun smokeTestSimplyStart() {
Espresso.onView(ViewMatchers.withId(R.id.frequencySeekBar)).check(ViewAssertions.matches(ViewMatchers.isDisplayed()))
Screenshot.takeScreenshot("smoke")
Espresso.onView(ViewMatchers.isRoot())
.captureToBitmap()
.writeToTestStorage("${javaClass.simpleName}_${nameRule.methodName}")
}
}
9 changes: 0 additions & 9 deletions applications/HolidayIOIO/src/debug/AndroidManifest.xml

This file was deleted.

52 changes: 4 additions & 48 deletions applications/IOIOManager/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ android {
versionName getTag()

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunnerArguments useTestStorageService: 'true'
}

buildTypes {
Expand All @@ -28,52 +29,7 @@ dependencies {
implementation project(':IOIOLibAndroidAccessory')
implementation project(':IOIOLibAndroidDevice')

androidTestImplementation 'com.github.AppDevNext:Moka:1.1'
androidTestImplementation "androidx.test.ext:junit:1.1.3"
androidTestImplementation 'androidx.test:runner:1.4.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.4.0'
androidTestImplementation "androidx.test.ext:junit-ktx:1.1.5"
androidTestUtil "androidx.test.services:test-services:1.4.2"
androidTestImplementation "androidx.test.espresso:espresso-core:3.5.1"
}

def adbDirectory = '/storage/emulated/0/Download' // api 28
//def adbDirectory = '/storage/self/primary/Download' // api 21
def reportsDirectory = "$projectDir/../screenshots/adb"

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

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

def fetchScreenshotsTask = task('fetchScreenshots', type: Exec, group: 'reporting') {
println "fetchScreenshotsTask"
executable "${android.getAdbExe().toString()}"
args 'pull', adbDirectory + '/.', reportsDirectory

dependsOn {
createScreenshotDirectoryTask
}

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

tasks.whenTaskAdded { task ->
if (task.name == 'connectedDebugAndroidTest' || task.name == 'connectedCodeDebugAndroidTest') {
task.mustRunAfter {
clearScreenshotsTask
createScreenshotDirectoryTask
}
task.finalizedBy {
fetchScreenshotsTask
}
}
}

Loading

0 comments on commit 9332282

Please sign in to comment.