Skip to content

Commit

Permalink
Fastlane integration
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Pomepuy committed Sep 30, 2020
1 parent 73b9a42 commit ab41d93
Show file tree
Hide file tree
Showing 63 changed files with 1,118 additions and 168 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,4 @@ libvlc.pc
libvlc.pc.backup
libvlcpp.pc
lib/
/buildsystem/automation/certificates/
42 changes: 41 additions & 1 deletion application/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,21 @@ apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}

packagingOptions {
exclude 'META-INF/main.kotlin_module'
exclude 'META-INF/donations_debug.kotlin_module'
exclude 'META-INF/mediadb_debug.kotlin_module'
exclude 'META-INF/resources_debug.kotlin_module'
exclude 'META-INF/television_debug.kotlin_module'
pickFirst 'lib/armeabi-v7a/libc++_shared.so'
pickFirst 'lib/armeabi/libc++_shared.so'
pickFirst 'lib/arm64-v8a/libc++_shared.so'
Expand Down Expand Up @@ -40,7 +53,11 @@ android {
vectorDrawables.useSupportLibrary = true
multiDexEnabled true

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunner "org.videolan.vlc.MultidexTestRunner"
// The following argument makes the Android Test Orchestrator run its
// "pm clear" command after each test invocation. This command ensures
// that the app's state is completely cleared between tests.
testInstrumentationRunnerArguments clearPackageData: 'true'
}

signingConfigs {
Expand Down Expand Up @@ -135,4 +152,27 @@ android {
dependencies {
implementation project(':application:vlc-android')
implementation project(':application:television')
testImplementation project(':application:television')

androidTestApi "androidx.test.espresso:espresso-contrib:$rootProject.espressoVersion"
androidTestApi "androidx.test.espresso:espresso-core:$rootProject.espressoVersion"
androidTestApi "androidx.test.espresso:espresso-intents:$rootProject.espressoVersion"
testApi "junit:junit:$rootProject.ext.junitVersion"
androidTestApi "androidx.room:room-testing:$rootProject.ext.roomVersion"
testApi "androidx.arch.core:core-testing:$rootProject.ext.archVersion"
androidTestApi "androidx.arch.core:core-testing:$rootProject.ext.archVersion"
androidTestApi "androidx.test.ext:junit:$rootProject.ext.supportTest"
androidTestUtil "androidx.test:orchestrator:$rootProject.ext.orchestrator"
testApi "androidx.test:core:$rootProject.ext.testCore"
testApi "org.jetbrains.kotlinx:kotlinx-coroutines-test:$rootProject.ext.kotlinx_version"
testApi "org.mockito:mockito-core:$rootProject.ext.mockito"
testApi "io.mockk:mockk:$rootProject.ext.mockk"
testApi "org.powermock:powermock-api-mockito2:$rootProject.ext.powerMock"
testApi "org.powermock:powermock-module-junit4:$rootProject.ext.powerMock"
testApi "com.jraska.livedata:testing-ktx:$rootProject.ext.livedataTest"
testApi "org.robolectric:robolectric:$rootProject.ext.robolectric"
androidTestApi "com.android.support:multidex:1.0.3"
androidTestImplementation "androidx.test.uiautomator:uiautomator:2.2.0"
androidTestApi 'androidx.test:rules:1.3.0'
androidTestImplementation 'tools.fastlane:screengrab:2.0.0'
}
30 changes: 30 additions & 0 deletions application/app/src/androidTest/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!--
~ *************************************************************************
~ AndroidManifest.xml
~ **************************************************************************
~ Copyright © 2020 VLC authors and VideoLAN
~ Author: Nicolas POMEPUY
~ This program is free software; you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation; either version 2 of the License, or
~ (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program; if not, write to the Free Software
~ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
~ ***************************************************************************
~
~
-->

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="org.videolan.mobile.app">

<uses-sdk tools:overrideLibrary="android_libs.ub_uiautomator, tools.fastlane.screengrab" />
</manifest>

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@ import org.junit.runner.RunWith
import org.videolan.resources.util.startMedialibrary
import org.videolan.vlc.util.TestCoroutineContextProvider


@RunWith(AndroidJUnit4::class)
abstract class BaseUITest {
@Rule
@JvmField
val storagePermissionGrant = GrantPermissionRule.grant(
"android.permission.READ_EXTERNAL_STORAGE")


val context: Context = ApplicationProvider.getApplicationContext()

@Before
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* ************************************************************************
* DemoModeEnabler.kt
* *************************************************************************
* Copyright © 2020 VLC authors and VideoLAN
* Author: Nicolas POMEPUY
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
* **************************************************************************
*
*
*/

package org.videolan.vlc

import android.os.ParcelFileDescriptor
import androidx.test.platform.app.InstrumentationRegistry
import java.io.BufferedReader
import java.io.InputStreamReader

class DemoModeEnabler {

fun enable() {
executeShellCommand("settings put global sysui_demo_allowed 1")
sendCommand("exit")
sendCommand("enter")
sendCommand("notifications", "visible" to "false")
sendCommand("network", "wifi" to "show", "level" to "4", "fully" to "true")
sendCommand("network", "mobile" to "show", "level" to "4", "datatype" to "4g")
sendCommand("battery", "level" to "100", "plugged" to "true")
sendCommand("clock", "hhmm" to "1000")
}

fun disable() {
sendCommand("exit")
}

private fun sendCommand(command: String, vararg extras: Pair<String, Any>) {
val exec = StringBuilder("am broadcast -a com.android.systemui.demo -e command $command")
for ((key, value) in extras) {
exec.append(" -e $key $value")
}
executeShellCommand(exec.toString())
}

private fun executeShellCommand(command: String) {
waitForCompletion(InstrumentationRegistry.getInstrumentation().uiAutomation.executeShellCommand(command))
}

private fun waitForCompletion(descriptor: ParcelFileDescriptor) {
val reader = BufferedReader(InputStreamReader(ParcelFileDescriptor.AutoCloseInputStream(descriptor)))
reader.use {
it.readText()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* ************************************************************************
* DemoModeRule.kt
* *************************************************************************
* Copyright © 2020 VLC authors and VideoLAN
* Author: Nicolas POMEPUY
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
* **************************************************************************
*
*
*/

package org.videolan.vlc

import org.junit.rules.TestRule
import org.junit.runner.Description
import org.junit.runners.model.Statement

class DemoModeRule : TestRule {

private val helper = DemoModeEnabler()

override fun apply(base: Statement, description: Description): Statement = DemoModeStatement(base)

private inner class DemoModeStatement(private val base: Statement) : Statement() {
override fun evaluate() {
helper.enable()
base.evaluate()
helper.disable()
}
}
}
Loading

0 comments on commit ab41d93

Please sign in to comment.