Skip to content

Commit

Permalink
Merge branch 'Catrobat:develop' into PAINTROID-503
Browse files Browse the repository at this point in the history
  • Loading branch information
Lenkomotive authored Oct 5, 2023
2 parents 878b870 + 863a5db commit d451fa5
Show file tree
Hide file tree
Showing 172 changed files with 10,256 additions and 7,363 deletions.
48 changes: 46 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,25 @@ pipeline {
parameters {
string name: 'DEBUG_LABEL', defaultValue: '', description: 'For debugging when entered will be used as label to decide on which slaves the jobs will run.'
booleanParam name: 'BUILD_WITH_CATROID', defaultValue: false, description: 'When checked then the current Paintroid build will be built with the current develop branch of Catroid'
booleanParam name: 'DEVICE_TESTING', defaultValue: true, description: 'When selected UI-testing runs locally'
string name: 'CATROID_BRANCH', defaultValue: 'develop', description: 'The branch which to build catroid with, when BUILD_WITH_CATROID is checked.'
separator(name: "BROWSERSTACK", sectionHeader: "BrowserStack configuration",
separatorStyle: "border-width: 0",
sectionHeaderStyle: """
background-color: #ffff00;
text-align: center;
padding: 4px;
color: #000000;
font-size: 20px;
font-weight: normal;
font-family: 'Orienta', sans-serif;
letter-spacing: 1px;
font-style: italic;
""")
choice choices: ['AndroidDevices', 'Samsung Galaxy S23-13.0', 'Samsung Galaxy S23 Ultra-13.0', 'Samsung Galaxy S22 Ultra-12.0', 'Samsung Galaxy S22 Plus-12.0', 'Samsung Galaxy S22-12.0', 'Samsung Galaxy S21-12.0', 'Samsung Galaxy S21 Ultra-11.0', 'Samsung Galaxy S21-11.0', 'Samsung Galaxy S21 Plus-11.0', 'Samsung Galaxy S20-10.0', 'Samsung Galaxy S20 Plus-10.0', 'Samsung Galaxy S20 Ultra-10.0', 'Samsung Galaxy M52-11.0', 'Samsung Galaxy M32-11.0', 'Samsung Galaxy A52-11.0', 'Samsung Galaxy Note 20 Ultra-10.0', 'Samsung Galaxy Note 20-10.0', 'Samsung Galaxy A51-10.0', 'Samsung Galaxy A11-10.0', 'Samsung Galaxy S10e-9.0', 'Samsung Galaxy S10 Plus-9.0', 'Samsung Galaxy S10-9.0', 'Samsung Galaxy Note 10 Plus-9.0', 'Samsung Galaxy Note 10-9.0', 'Samsung Galaxy A10-9.0', 'Samsung Galaxy Note 9-8.1', 'Samsung Galaxy J7 Prime-8.1', 'Samsung Galaxy S9 Plus-9.0', 'Samsung Galaxy S9 Plus-8.0', 'Samsung Galaxy S9-8.0', 'Samsung Galaxy Note 8-7.1', 'Samsung Galaxy A8-7.1', 'Samsung Galaxy S8 Plus-7.0', 'Samsung Galaxy S8-7.0', 'Samsung Galaxy S7-6.0', 'Samsung Galaxy S6-5.0', 'Samsung Galaxy Tab S8-12.0', 'Samsung Galaxy Tab S7-11.0', 'Samsung Galaxy Tab S7-10.0', 'Samsung Galaxy Tab S6-9.0', 'Samsung Galaxy Tab S5e-9.0', 'Samsung Galaxy Tab S4-8.1', 'Google Pixel 7 Pro-13.0', 'Google Pixel 7-13.0', 'Google Pixel 6 Pro-13.0', 'Google Pixel 6 Pro-12.0', 'Google Pixel 6-12.0', 'Google Pixel 5-12.0', 'Google Pixel 5-11.0', 'Google Pixel 4-11.0', 'Google Pixel 4 XL-10.0', 'Google Pixel 4-10.0', 'Google Pixel 3-10.0', 'Google Pixel 3a XL-9.0', 'Google Pixel 3a-9.0', 'Google Pixel 3 XL-9.0', 'Google Pixel 3-9.0', 'Google Pixel 2-9.0', 'Google Pixel 2-8.0', 'Google Pixel-7.1', 'Google Nexus 5-4.4', 'OnePlus 9-11.0', 'OnePlus 8-10.0', 'OnePlus 7T-10.0', 'OnePlus 7-9.0', 'OnePlus 6T-9.0', 'Xiaomi Redmi Note 11-11.0', 'Xiaomi Redmi Note 9-10.0', 'Xiaomi Redmi Note 8-9.0', 'Xiaomi Redmi Note 7-9.0', 'Motorola Moto G71 5G-11.0', 'Motorola Moto G9 Play-10.0', 'Motorola Moto G7 Play-9.0', 'Vivo Y21-11.0', 'Vivo Y50-10.0', 'Oppo Reno 6-11.0', 'Oppo A96-11.0', 'Oppo Reno 3 Pro-10.0', 'Huawei P30-9.0'], description: 'Available Android Devices on BrowserStack', name: 'BROWSERSTACK_ANDROID_DEVICES'
booleanParam name: 'BROWSERSTACK_TESTING', defaultValue: false, description: 'When selected testing runs over Browserstack'
choice choices: ['1', '2', '3', '4',' 5'], description: 'Number of Shards for running tests on BrowserStack. <a href="https://app-automate.browserstack.com/dashboard/v2/builds/">BrowserStack Dashboard</a>', name: 'BROWSERSTACK_SHARDS'

}

agent {
Expand All @@ -39,6 +57,8 @@ pipeline {
}
}

tools {nodejs "NodeJS"}

options {
timeout(time: 2, unit: 'HOURS')
timestamps()
Expand All @@ -59,13 +79,22 @@ pipeline {
}
}

stage('Build Test-APK') {
steps {
sh "./gradlew -Pindependent='#$env.BUILD_NUMBER $env.BRANCH_NAME' assembleAndroidTest"
archiveArtifacts 'Paintroid/build/outputs/apk/androidTest/debug/*.apk'
renameApks("${env.BRANCH_NAME}-${env.BUILD_NUMBER}")
plot csvFileName: 'dexcount.csv', csvSeries: [[displayTableFlag: false, exclusionValues: '', file: 'Paintroid/build/outputs/dexcount/*.csv', inclusionFlag: 'OFF', url: '']], group: 'APK Stats', numBuilds: '180', style: 'line', title: 'dexcount'
}
}

stage('Build with Catroid') {
when {
expression {
params.BUILD_WITH_CATROID
}
}

steps {
sh './gradlew publishToMavenLocal -Psnapshot'
sh 'rm -rf Catroid; mkdir Catroid'
Expand Down Expand Up @@ -100,6 +129,18 @@ pipeline {
}
}

stage('Browserstack testing') {
when {
expression { params.BROWSERSTACK_TESTING == true }
}
steps {
withCredentials([usernamePassword(credentialsId: 'browserstack', passwordVariable: 'BROWSERSTACK_ACCESS_KEY', usernameVariable: 'BROWSERSTACK_USERNAME')]) {
script {
browserStack('app/build/outputs/apk/debug/', 'Paintroid/build/outputs/apk/androidTest/debug/', 'Paintroid')
}
}
}
}
stage('Tests') {
stages {
stage('Unit Tests') {
Expand All @@ -114,6 +155,9 @@ pipeline {
}

stage('Device Tests') {
when {
expression { params.DEVICE_TESTING == true }
}
steps {
sh "echo no | avdmanager create avd --force --name android28 --package 'system-images;android-28;default;x86_64' --skin 1080x1920"
sh "/home/user/android/sdk/emulator/emulator -no-window -no-boot-anim -noaudio -avd android28 > /dev/null 2>&1 &"
Expand Down Expand Up @@ -146,4 +190,4 @@ pipeline {
notifyChat()
}
}
}
}
3 changes: 2 additions & 1 deletion Jenkinsfile.releaseAPK
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ pipeline {
./gradlew publishToMavenLocal
'''
}
archiveArtifacts artifacts: '**/*-release.aar'
archiveArtifacts artifacts: 'Paintroid/build/outputs/aar/Paintroid-signedRelease.aar'
archiveArtifacts artifacts: 'colorpicker/build/outputs/aar/colorpicker-signedRelease.aar'
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Paintroid/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ dependencies {
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.8'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.8'
implementation 'androidx.exifinterface:exifinterface:1.3.2'
implementation 'com.esotericsoftware:kryo:5.1.1'
implementation 'com.esotericsoftware:kryo:5.5.0'
implementation 'id.zelory:compressor:2.1.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ package org.catrobat.paintroid.test.espresso
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.rule.ActivityTestRule
import org.catrobat.paintroid.MainActivity
import org.catrobat.paintroid.test.espresso.util.wrappers.ToolBarViewInteraction.onToolBarView
import org.catrobat.paintroid.test.espresso.util.wrappers.ToolBarViewInteraction.Companion.onToolBarView
import org.catrobat.paintroid.test.utils.ScreenshotOnFailRule
import org.catrobat.paintroid.tools.ToolType
import org.junit.Assert
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import org.catrobat.paintroid.common.CATROBAT_IMAGE_ENDING
import org.catrobat.paintroid.test.espresso.util.DrawingSurfaceLocationProvider
import org.catrobat.paintroid.test.espresso.util.EspressoUtils
import org.catrobat.paintroid.test.espresso.util.UiInteractions
import org.catrobat.paintroid.test.espresso.util.wrappers.DrawingSurfaceInteraction.onDrawingSurfaceView
import org.catrobat.paintroid.test.espresso.util.wrappers.DrawingSurfaceInteraction.Companion.onDrawingSurfaceView
import org.catrobat.paintroid.test.espresso.util.wrappers.TopBarViewInteraction
import org.catrobat.paintroid.test.utils.ScreenshotOnFailRule
import org.hamcrest.Matchers
Expand Down Expand Up @@ -101,7 +101,7 @@ class CatrobatImageIOIntegrationTest {
Espresso.onData(
AllOf.allOf(
Matchers.`is`(Matchers.instanceOf<Any>(String::class.java)),
Matchers.`is`<String>(FileIO.FileType.CATROBAT.value)
Matchers.`is`(FileIO.FileType.CATROBAT.value)
)
).inRoot(RootMatchers.isPlatformPopup()).perform(ViewActions.click())
onView(withId(R.id.pocketpaint_image_name_save_text))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ import org.catrobat.paintroid.colorpicker.PresetSelectorView
import org.catrobat.paintroid.colorpicker.RgbSelectorView
import org.catrobat.paintroid.test.espresso.util.UiMatcher.withBackground
import org.catrobat.paintroid.test.espresso.util.UiMatcher.withBackgroundColor
import org.catrobat.paintroid.test.espresso.util.wrappers.BottomNavigationViewInteraction.onBottomNavigationView
import org.catrobat.paintroid.test.espresso.util.wrappers.ColorPickerViewInteraction.onColorPickerView
import org.catrobat.paintroid.test.espresso.util.wrappers.OptionsMenuViewInteraction.onOptionsMenu
import org.catrobat.paintroid.test.espresso.util.wrappers.ToolBarViewInteraction.onToolBarView
import org.catrobat.paintroid.test.espresso.util.wrappers.TopBarViewInteraction.onTopBarView
import org.catrobat.paintroid.test.espresso.util.wrappers.BottomNavigationViewInteraction.Companion.onBottomNavigationView
import org.catrobat.paintroid.test.espresso.util.wrappers.ColorPickerViewInteraction.Companion.onColorPickerView
import org.catrobat.paintroid.test.espresso.util.wrappers.OptionsMenuViewInteraction.Companion.onOptionsMenu
import org.catrobat.paintroid.test.espresso.util.wrappers.ToolBarViewInteraction.Companion.onToolBarView
import org.catrobat.paintroid.test.espresso.util.wrappers.TopBarViewInteraction.Companion.onTopBarView
import org.catrobat.paintroid.test.utils.ScreenshotOnFailRule
import org.catrobat.paintroid.tools.Tool
import org.catrobat.paintroid.tools.ToolType
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,226 @@
package org.catrobat.paintroid.test.espresso

import android.content.res.Configuration
import android.graphics.drawable.Drawable
import androidx.test.rule.ActivityTestRule
import org.catrobat.paintroid.MainActivity
import org.catrobat.paintroid.contract.LayerContracts
import org.catrobat.paintroid.test.espresso.util.wrappers.LayerMenuViewInteraction
import org.catrobat.paintroid.ui.LayerAdapter.Companion.getBottomBackground
import org.catrobat.paintroid.ui.LayerAdapter.Companion.getCenterBackground
import org.catrobat.paintroid.ui.LayerAdapter.Companion.getSingleBackground
import org.catrobat.paintroid.ui.LayerAdapter.Companion.getTopBackground
import org.junit.Assert
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.Parameterized
import java.util.Locale

@RunWith(Parameterized::class)
class LayerBackgroundTest(private val language: String) {

private lateinit var mainActivity: MainActivity
private lateinit var layerAdapter: LayerContracts.Adapter

companion object {
private const val ENGLISH = "en"
private const val ARABIC = "ar"

@JvmStatic
@Parameterized.Parameters(name = "Language: {0}")
fun data() = arrayOf(
arrayOf(ARABIC),
arrayOf(ENGLISH)
)
}

@get:Rule
var launchActivityRule = ActivityTestRule(MainActivity::class.java)

@Before
fun setUp() {
mainActivity = launchActivityRule.activity
layerAdapter = mainActivity.layerAdapter
setLanguage(language)
}

@Test
fun testOneLayer() {
var actualBackground = getActualBackground(0)
Assert.assertEquals(actualBackground, getSingleBackground()?.constantState)
}

@Test
fun testTwoLayersTopSelected() {
LayerMenuViewInteraction.onLayerMenuView()
.performOpen()
.performAddLayer()

var backgroundTop = getActualBackground(0)
var backgroundBottom = getActualBackground(1)

Assert.assertEquals(backgroundTop, getTopBackground(true)?.constantState)
Assert.assertEquals(backgroundBottom, getBottomBackground(false)?.constantState)
}

@Test
fun testTwoLayersBottomSelected() {
LayerMenuViewInteraction.onLayerMenuView()
.performOpen()
.performAddLayer()
.performSelectLayer(1)

var backgroundTop = getActualBackground(0)
var backgroundBottom = getActualBackground(1)

Assert.assertEquals(backgroundTop, getTopBackground(false)?.constantState)
Assert.assertEquals(backgroundBottom, getBottomBackground(true)?.constantState)
}

@Test
fun testThreeLayersTopSelected() {
LayerMenuViewInteraction.onLayerMenuView()
.performOpen()
.performAddLayer()
.performAddLayer()

var backgroundTop = getActualBackground(0)
var backgroundCenter = getActualBackground(1)
var backgroundBottom = getActualBackground(2)

Assert.assertEquals(backgroundTop, getTopBackground(true)?.constantState)
Assert.assertEquals(backgroundCenter, getCenterBackground(false)?.constantState)
Assert.assertEquals(backgroundBottom, getBottomBackground(false)?.constantState)
}

@Test
fun testThreeLayersCenterSelected() {
LayerMenuViewInteraction.onLayerMenuView()
.performOpen()
.performAddLayer()
.performAddLayer()
.performSelectLayer(1)

var backgroundTop = getActualBackground(0)
var backgroundCenter = getActualBackground(1)
var backgroundBottom = getActualBackground(2)

Assert.assertEquals(backgroundTop, getTopBackground(false)?.constantState)
Assert.assertEquals(backgroundCenter, getCenterBackground(true)?.constantState)
Assert.assertEquals(backgroundBottom, getBottomBackground(false)?.constantState)
}

@Test
fun testThreeLayersBottomSelected() {
LayerMenuViewInteraction.onLayerMenuView()
.performOpen()
.performAddLayer()
.performAddLayer()
.performScrollToPositionInLayerNavigation(2)
.performSelectLayer(2)

var backgroundTop = getActualBackground(0)
var backgroundCenter = getActualBackground(1)
var backgroundBottom = getActualBackground(2)

Assert.assertEquals(backgroundTop, getTopBackground(false)?.constantState)
Assert.assertEquals(backgroundCenter, getCenterBackground(false)?.constantState)
Assert.assertEquals(backgroundBottom, getBottomBackground(true)?.constantState)
}

@Test
fun testFourLayersTopSelected() {
LayerMenuViewInteraction.onLayerMenuView()
.performOpen()
.performAddLayer()
.performAddLayer()
.performAddLayer()

val backgroundTop = getActualBackground(0)
val backgroundUpperCenter = getActualBackground(1)
val backgroundLowerCenter = getActualBackground(2)
val backgroundBottom = getActualBackground(3)

Assert.assertEquals(backgroundTop, getTopBackground(true)?.constantState)
Assert.assertEquals(backgroundUpperCenter, getCenterBackground(false)?.constantState)
Assert.assertEquals(backgroundLowerCenter, getCenterBackground(false)?.constantState)
Assert.assertEquals(backgroundBottom, getBottomBackground(false)?.constantState)
}

@Test
fun testFourLayersUpperCenterSelected() {
LayerMenuViewInteraction.onLayerMenuView()
.performOpen()
.performAddLayer()
.performAddLayer()
.performAddLayer()
.performSelectLayer(1)

val backgroundTop = getActualBackground(0)
val backgroundUpperCenter = getActualBackground(1)
val backgroundLowerCenter = getActualBackground(2)
val backgroundBottom = getActualBackground(3)

Assert.assertEquals(backgroundTop, getTopBackground(false)?.constantState)
Assert.assertEquals(backgroundUpperCenter, getCenterBackground(true)?.constantState)
Assert.assertEquals(backgroundLowerCenter, getCenterBackground(false)?.constantState)
Assert.assertEquals(backgroundBottom, getBottomBackground(false)?.constantState)
}

@Test
fun testFourLayersLowerCenterSelected() {
LayerMenuViewInteraction.onLayerMenuView()
.performOpen()
.performAddLayer()
.performAddLayer()
.performAddLayer()
.performScrollToPositionInLayerNavigation(2)
.performSelectLayer(2)

val backgroundTop = getActualBackground(0)
val backgroundUpperCenter = getActualBackground(1)
val backgroundLowerCenter = getActualBackground(2)
val backgroundBottom = getActualBackground(3)

Assert.assertEquals(backgroundTop, getTopBackground(false)?.constantState)
Assert.assertEquals(backgroundUpperCenter, getCenterBackground(false)?.constantState)
Assert.assertEquals(backgroundLowerCenter, getCenterBackground(true)?.constantState)
Assert.assertEquals(backgroundBottom, getBottomBackground(false)?.constantState)
}

@Test
fun testFourLayersBottomSelected() {
LayerMenuViewInteraction.onLayerMenuView()
.performOpen()
.performAddLayer()
.performAddLayer()
.performAddLayer()
.performScrollToPositionInLayerNavigation(3)
.performSelectLayer(3)

val backgroundTop = getActualBackground(0)
val backgroundUpperCenter = getActualBackground(1)
val backgroundLowerCenter = getActualBackground(2)
val backgroundBottom = getActualBackground(3)

Assert.assertEquals(backgroundTop, getTopBackground(false)?.constantState)
Assert.assertEquals(backgroundUpperCenter, getCenterBackground(false)?.constantState)
Assert.assertEquals(backgroundLowerCenter, getCenterBackground(false)?.constantState)
Assert.assertEquals(backgroundBottom, getBottomBackground(true)?.constantState)
}

private fun getActualBackground(position: Int): Drawable.ConstantState? {
val layout = layerAdapter?.getViewHolderAt(position)?.getViewLayout()
return layout?.background?.constantState
}

private fun setLanguage(language: String) {
val locale = Locale(language)
Locale.setDefault(locale)
val config: Configuration = mainActivity.resources.configuration
config.setLocale(locale)
mainActivity.resources.updateConfiguration(config, mainActivity.resources.displayMetrics)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ import org.catrobat.paintroid.test.espresso.util.UiMatcher
import org.catrobat.paintroid.test.espresso.util.wrappers.DrawingSurfaceInteraction
import org.catrobat.paintroid.test.espresso.util.wrappers.LayerMenuViewInteraction
import org.catrobat.paintroid.test.espresso.util.wrappers.ToolBarViewInteraction
import org.catrobat.paintroid.test.espresso.util.wrappers.ToolPropertiesInteraction
import org.catrobat.paintroid.test.espresso.util.wrappers.TopBarViewInteraction
import org.catrobat.paintroid.test.espresso.util.wrappers.ToolPropertiesInteraction
import org.catrobat.paintroid.test.espresso.util.wrappers.TransformToolOptionsViewInteraction
import org.catrobat.paintroid.test.utils.ScreenshotOnFailRule
import org.catrobat.paintroid.test.utils.ToastMatcher
Expand Down
Loading

0 comments on commit d451fa5

Please sign in to comment.