Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 35 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,64 @@ language: android
jdk: oraclejdk8
env:
global:
- ANDROID_API=29
- ANDROID_BUILD_TOOLS=29.0.2
- ABI="default;armeabi-v7a"
- ANDROID_BUILD_TOOLS=28.0.3
- ADB_INSTALL_TIMEOUT=5
- EMULATOR_API_LEVEL=23
- SYSTEM_IMAGE=/usr/local/android-sdk/system-images/android-23/default/armeabi-v7a/kernel-ranchu
- ANDROID_SDK_ROOT=/usr/local/android-sdk

android:
components:
- tools
- platform-tools
- build-tools-$ANDROID_BUILD_TOOLS
- android-$ANDROID_API
- android-$EMULATOR_API_LEVEL
- extra-google-google_play_services
- extra-google-m2repository
- extra-android-m2repository
- sys-img-armeabi-v7a-addon-google_apis-google-$ANDROID_API_LEVEL
- sys-img-armeabi-v7a-addon-google_apis-google-$EMULATOR_API_LEVEL
- sys-img-armeabi-v7a-android-$EMULATOR_API_LEVEL

licenses:
- android-sdk-preview-license-.+
- android-sdk-license-.+
- google-gdk-license-.+

before_install:
- chmod +x gradlew
- chmod +x scripts/build_publish.sh
- chmod +x scripts/build_compile.sh
# Android test (screenshot) commands init
- yes | sdkmanager --sdk_root=$ANDROID_SDK_ROOT "tools" "build-tools;$ANDROID_BUILD_TOOLS" "extras;android;m2repository"
- export ANDROID_SDK=$ANDROID_SDK_ROOT
- export PATH=$ANDROID_SDK/emulator:$ANDROID_SDK/tools:$PATH
- export PATH=$ANDROID_SDK/tools/bin:$PATH
# Android test (screenshot) commands end
- ./gradlew dependencies || true

install:
# Android test (screenshot) commands init
- sudo -H pip install pillow
- sudo -H pip install pillowcase
# Android test (screenshot) commands end

cache:
directories:
- $HOME/.cache/pip
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/
before_cache:
- rm -f $HOME/.cache/pip/log/debug.log
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/

before_script:
- git lfs pull
- find /usr/local/android-sdk/system-images -type f
- echo no | android create avd --force -n test -k "system-images;android-$EMULATOR_API_LEVEL;$ABI" -c 100M
- emulator @test -kernel $SYSTEM_IMAGE -no-audio -no-window &
- android-wait-for-emulator
- adb shell input keyevent 82 &

script:
- ./scripts/build_publish.sh
Expand Down
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:3.5.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.facebook.testing.screenshot:plugin:0.11.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Expand All @@ -25,4 +26,4 @@ allprojects {

task clean(type: Delete) {
delete rootProject.buildDir
}
}
2 changes: 1 addition & 1 deletion scripts/build_publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ if [ $TRAVIS_BRANCH = "master" -a $TRAVIS_PULL_REQUEST = "false" ]; then
echo "We're on the master branch."
else
echo "We're not on the master branch."
./gradlew clean build -PdisablePreDex --stacktrace
./gradlew clean build :system:verifyDebugAndroidTestScreenshotTest -PdisablePreDex --stacktrace
fi

3 changes: 2 additions & 1 deletion system/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.facebook.testing.screenshot'
apply from: "$rootDir/publish.gradle"

android {
Expand All @@ -13,7 +14,7 @@ android {
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunner "com.selem.system.ScreenShotTestRunner"
consumerProguardFiles 'consumer-rules.pro'
}

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions system/src/androidTest/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.selem.system.test"
android:sharedUserId="com.selem.system.uid">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

<application android:requestLegacyExternalStorage="true"/>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package com.selem.system

import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import com.facebook.testing.screenshot.Screenshot
import com.facebook.testing.screenshot.ViewHelpers
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith
Expand All @@ -14,9 +16,18 @@ import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
fun greenView_checkDefaultState() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.selem.system.test", appContext.packageName)
// assertEquals("com.selem.system.test", appContext.packageName)

val greenView = GreenView(appContext)

ViewHelpers.setupView(greenView)
.setExactWidthDp(300)
.setExactHeightDp(100)
.layout()

Screenshot.snap(greenView).record()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.selem.system

import android.os.Bundle
import androidx.test.runner.AndroidJUnitRunner
import com.facebook.testing.screenshot.ScreenshotRunner

class ScreenShotTestRunner : AndroidJUnitRunner() {
override fun onCreate(arguments: Bundle?) {
super.onCreate(arguments)
ScreenshotRunner.onCreate(this, arguments)
}

override fun finish(resultCode: Int, results: Bundle?) {
ScreenshotRunner.onDestroy()
super.finish(resultCode, results)
}
}
6 changes: 5 additions & 1 deletion system/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
<manifest package="com.selem.system" />
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.selem.system"
android:sharedUserId="com.selem.system.uid">
</manifest>
16 changes: 16 additions & 0 deletions system/src/main/java/com/selem/system/GreenView.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.selem.system

import android.content.Context
import android.graphics.drawable.ColorDrawable
import android.util.AttributeSet
import android.view.View
import androidx.core.content.ContextCompat


class GreenView @JvmOverloads constructor(context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0): View(context, attrs, defStyleAttr) {
init {
background = ColorDrawable(ContextCompat.getColor(context, android.R.color.holo_green_light))
}
}