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
2 changes: 1 addition & 1 deletion .github/workflows/emulated_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ jobs:
- name: run tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 35
api-level: 36
force-avd-creation: true
emulator-boot-timeout: 900
emulator-options: >
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- "develop"
pull_request:
schedule:
- cron: "0 0 * * *" # Daily at midnight
workflow_dispatch:
Expand Down
6 changes: 4 additions & 2 deletions catroid/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def defaultVersionCode = 102
def defaultVersionName = "1.4.1"

android {
compileSdk = 35
compileSdk = 36

namespace = 'org.catrobat.catroid'

Expand All @@ -117,7 +117,7 @@ android {

defaultConfig {
minSdkVersion 28
targetSdkVersion 35
targetSdkVersion 36
applicationId appId
testInstrumentationRunner 'org.catrobat.catroid.runner.UiTestApplicationRunner'
versionCode defaultVersionCode
Expand Down Expand Up @@ -361,6 +361,7 @@ dependencies {
// WorkManager
implementation "androidx.work:work-runtime-ktx:$work_manager_version"
implementation "androidx.work:work-runtime:$work_manager_version"
testImplementation "androidx.work:work-testing:$work_manager_version"

// Kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
Expand All @@ -379,6 +380,7 @@ dependencies {
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.browser:browser:1.8.0'
implementation 'androidx.core:core-ktx:1.3.2'
implementation "androidx.activity:activity-ktx:1.6.0"

implementation "org.mockito:mockito-core:$mockitoVersion"
implementation "androidx.test.espresso:espresso-idling-resource:$espressoVersion"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,21 @@

import androidx.test.core.app.ApplicationProvider;
import androidx.test.espresso.intent.Intents;
import androidx.test.espresso.matcher.ViewMatchers;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.platform.app.InstrumentationRegistry;

import static org.catrobat.catroid.uiespresso.util.UiTestUtils.openActionBarMenu;
import static org.junit.Assert.assertEquals;

import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.Espresso.pressBack;
import static androidx.test.espresso.action.ViewActions.click;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.intent.Intents.intending;
import static androidx.test.espresso.intent.matcher.IntentMatchers.anyIntent;
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
import static androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static androidx.test.espresso.matcher.ViewMatchers.withText;

Expand Down Expand Up @@ -117,6 +120,22 @@ public void testProjectOptionsLaunchedWhenProjectOptionsButtonClicked() {
.check(matches(isDisplayed()));
}

@Category({Cat.AppUi.class, Level.Smoke.class})
@Test
public void testBottomBarVisibleAfterBackFromProjectOptions() {
baseActivityTestRule.launchActivity();
openActionBarMenu();
onView(withText(R.string.project_options)).perform(click());

onView(withId(R.id.bottom_bar))
.check(matches(withEffectiveVisibility(ViewMatchers.Visibility.GONE)));

pressBack();

onView(withId(R.id.bottom_bar))
.check(matches(isDisplayed()));
}

private SharedPreferences getDefaultSharedPreferences() {
return PreferenceManager.getDefaultSharedPreferences(ApplicationProvider.getApplicationContext());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,15 @@ import android.os.Looper
import android.preference.PreferenceManager
import androidx.test.core.app.ApplicationProvider.getApplicationContext
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.Espresso.pressBack
import androidx.test.espresso.Espresso.pressBackUnconditionally
import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.action.ViewActions.replaceText
import androidx.test.espresso.assertion.ViewAssertions.doesNotExist
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers.Visibility
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.ext.junit.runners.AndroidJUnit4
Expand All @@ -52,6 +56,7 @@ import org.catrobat.catroid.ui.ProjectUploadTestActivity
import org.catrobat.catroid.uiespresso.util.UiTestUtils
import org.catrobat.catroid.uiespresso.util.rules.BaseActivityTestRule
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Rule
import org.junit.Test
Expand Down Expand Up @@ -231,6 +236,35 @@ class ProjectUploadDialogTest {
assertFalse(isKeyboardVisible())
}

@Test
fun backOnNotesAndCreditsScreenReturnsToNameScreen() {
onView(withId(R.id.next))
.perform(click())

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

pressBack()

onView(withId(R.id.input_project_name))
.check(matches(isDisplayed()))
onView(withId(R.id.input_project_notes_and_credits))
.check(matches(withEffectiveVisibility(Visibility.GONE)))
}

@Test
fun backOnNameScreenFinishesActivity() {
onView(withId(R.id.input_project_name))
.check(matches(isDisplayed()))

val activity = activityTestRule.activity

pressBackUnconditionally()
getInstrumentation().waitForIdleSync()

assertTrue(activity.isFinishing)
}

private fun isKeyboardVisible(): Boolean {
val checkKeyboardCommand = "dumpsys input_method | grep mInputShown"
return UiDevice.getInstance(getInstrumentation()).executeShellCommand(checkKeyboardCommand).contains("mInputShown=true")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@

import static androidx.test.espresso.Espresso.onData;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.Espresso.pressBack;
import static androidx.test.espresso.action.ViewActions.click;
import static androidx.test.espresso.action.ViewActions.typeText;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
Expand All @@ -116,7 +117,7 @@ public class SettingsFragmentTest {
SETTINGS_SHOW_PHIRO_BRICKS_CHECKBOX_PREFERENCE, SETTINGS_SHOW_NFC_BRICKS, SETTINGS_SHOW_HINTS,
SETTINGS_CRASH_REPORTS, SETTINGS_MINDSTORMS_NXT_BRICKS_CHECKBOX_PREFERENCE,
SETTINGS_MINDSTORMS_NXT_SHOW_SENSOR_INFO_BOX_DISABLED,
SETTINGS_MINDSTORMS_EV3_BRICKS_CHECKBOX_PREFERENCE,
SETTINGS_MINDSTORMS_EV3_BRICKS_CHECKBOX_PREFERENCE, SETTINGS_SHOW_PLOT_BRICKS,
SETTINGS_MINDSTORMS_EV3_SHOW_SENSOR_INFO_BOX_DISABLED,
SETTINGS_SHOW_EMBROIDERY_BRICKS_CHECKBOX_PREFERENCE,
SETTINGS_SHOW_PARROT_AR_DRONE_BRICKS, SETTINGS_SHOW_JUMPING_SUMO_BRICKS,
Expand Down Expand Up @@ -210,6 +211,22 @@ public void noMultipleSelectAccessibilityProfilesTest() {
.perform(click());
}

@Category({Cat.AppUi.class, Level.Smoke.class})
@Test
public void backFromAccessibilitySettingsTest() {
onData(PreferenceMatchers.withTitle(R.string.preference_title_accessibility))
.perform(click());

onData(PreferenceMatchers.withTitle(
R.string.preference_title_accessibility_predefined_profile_headline))
.check(matches(isDisplayed()));

pressBack();

onData(PreferenceMatchers.withTitle(R.string.preference_title_accessibility))
.check(matches(isDisplayed()));
}

@Category({Cat.AppUi.class, Level.Smoke.class, Cat.Gadgets.class})
@Test
public void legoNxtSettingsTest() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
/*
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
* Catroid: An on-device visual programming system for Android devices
* Copyright (C) 2010-2026 The Catrobat Team
* (<http://developer.catrobat.org/credits>)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* An additional term exception under section 7 of the GNU Affero
* General Public License, version 3, is available at
* http://developer.catrobat.org/license_additional_term
*
* 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package org.catrobat.catroid.uiespresso.ui.activity

import android.Manifest
import android.app.Activity
import android.content.Intent
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.Espresso.pressBackUnconditionally
import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.withContentDescription
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.rule.GrantPermissionRule
import org.catrobat.catroid.R
import org.catrobat.catroid.soundrecorder.SoundRecorderActivity
import org.catrobat.catroid.testsuites.annotations.Cat.AppUi
import org.catrobat.catroid.testsuites.annotations.Level.Smoke
import org.catrobat.catroid.uiespresso.util.rules.BaseActivityTestRule
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.experimental.categories.Category
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
class SoundRecorderActivityTest {

@get:Rule
var baseActivityTestRule = BaseActivityTestRule(
SoundRecorderActivity::class.java, false, false
)

@get:Rule
var runtimePermissionRule: GrantPermissionRule =
GrantPermissionRule.grant(Manifest.permission.RECORD_AUDIO)

@Before
fun setUp() {
baseActivityTestRule.launchActivity(null)
}

@Category(AppUi::class, Smoke::class)
@Test
fun recordButtonStartsRecordingTest() {
onView(withId(R.id.soundrecorder_record_button))
.perform(click())

onView(withId(R.id.soundrecorder_chronometer_time_recorded))
.check(matches(isDisplayed()))
}

@Category(AppUi::class, Smoke::class)
@Test
fun recordThenStopReturnsRecordingTest() {
onView(withId(R.id.soundrecorder_record_button))
.perform(click())
onView(withId(R.id.soundrecorder_record_button))
.perform(click())

assertTrue(baseActivityTestRule.activity.isFinishing)
assertRecordingReturned()
}

@Category(AppUi::class, Smoke::class)
@Test
fun backWhileIdleFinishesWithoutRecordingTest() {
val activity = baseActivityTestRule.activity

pressBackUnconditionally()
InstrumentationRegistry.getInstrumentation().waitForIdleSync()

assertTrue(activity.isFinishing)
assertEquals(Activity.RESULT_CANCELED, baseActivityTestRule.activityResult.resultCode)
}

@Category(AppUi::class, Smoke::class)
@Test
fun backWhileRecordingReturnsRecordingTest() {
val activity = baseActivityTestRule.activity

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

pressBackUnconditionally()
InstrumentationRegistry.getInstrumentation().waitForIdleSync()

assertTrue(activity.isFinishing)
assertRecordingReturned()
}

@Category(AppUi::class, Smoke::class)
@Test
fun upButtonWhileRecordingReturnsRecordingTest() {
onView(withId(R.id.soundrecorder_record_button))
.perform(click())

onView(withContentDescription(R.string.abc_action_bar_up_description))
.perform(click())

assertTrue(baseActivityTestRule.activity.isFinishing)
assertRecordingReturned()
}

private fun assertRecordingReturned() {
assertEquals(Activity.RESULT_OK, baseActivityTestRule.activityResult.resultCode)
val resultIntent = baseActivityTestRule.activityResult.resultData
assertEquals(Intent.ACTION_PICK, resultIntent.action)
assertNotNull(resultIntent.data)
}
}
Loading
Loading