Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CATROID-1593 Fix error 'Could not launch activity' in Espresso tests #5033

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
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
1 change: 1 addition & 0 deletions catroid/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ dependencies {
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.browser:browser:1.2.0'

implementation "org.mockito:mockito-core:$mockitoVersion"
implementation "androidx.test.espresso:espresso-idling-resource:$espressoVersion"
implementation 'androidx.multidex:multidex:2.0.1'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Catroid: An on-device visual programming system for Android devices
* Copyright (C) 2010-2022 The Catrobat Team
* Copyright (C) 2010-2024 The Catrobat Team
* (<http://developer.catrobat.org/credits>)
*
* This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -33,8 +33,8 @@ import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.ext.junit.runners.AndroidJUnit4
import org.catrobat.catroid.ui.ConnectBluetoothDeviceTestActivity
import org.catrobat.catroid.R
import org.catrobat.catroid.bluetooth.ConnectBluetoothDeviceActivity
import org.catrobat.catroid.bluetooth.ConnectBluetoothDeviceActivity.DEVICE_TO_CONNECT
import org.catrobat.catroid.bluetooth.base.BluetoothDevice.MULTIPLAYER
import org.catrobat.catroid.common.SharedPreferenceKeys.SHOW_MULTIPLAYER_BLUETOOTH_DIALOG_KEY
Expand Down Expand Up @@ -119,9 +119,4 @@ class ConnectBluetoothDeviceActivityTest {
.perform(click())
.check(matches(withDrawable(R.drawable.ic_close)))
}

class ConnectBluetoothDeviceTestActivity : ConnectBluetoothDeviceActivity() {
override fun initBluetooth() = Unit
override fun doDiscovery() = Unit
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Catroid: An on-device visual programming system for Android devices
* Copyright (C) 2010-2023 The Catrobat Team
* Copyright (C) 2010-2024 The Catrobat Team
* (<http://developer.catrobat.org/credits>)
*
* This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -48,8 +48,7 @@ import org.catrobat.catroid.content.Scene
import org.catrobat.catroid.io.asynctask.saveProjectSerial
import org.catrobat.catroid.ui.NUMBER_OF_UPLOADED_PROJECTS
import org.catrobat.catroid.ui.PROJECT_DIR
import org.catrobat.catroid.ui.ProjectUploadActivity
import org.catrobat.catroid.ui.controller.ProjectUploadController
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
Expand All @@ -58,7 +57,6 @@ import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mockito
import org.mockito.Mockito.spy
import org.mockito.Mockito.verify

@RunWith(AndroidJUnit4::class)
Expand Down Expand Up @@ -237,17 +235,4 @@ class ProjectUploadDialogTest {
val checkKeyboardCommand = "dumpsys input_method | grep mInputShown"
return UiDevice.getInstance(getInstrumentation()).executeShellCommand(checkKeyboardCommand).contains("mInputShown=true")
}

class ProjectUploadTestActivity : ProjectUploadActivity() {
override fun createProjectUploadController(): ProjectUploadController? {
projectUploadController = spy(ProjectUploadController(this))
return projectUploadController
}

override fun verifyUserIdentity() {
onTokenCheckComplete(true, false)
}

fun projectUploadController(): ProjectUploadController? = projectUploadController
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Catroid: An on-device visual programming system for Android devices
* Copyright (C) 2010-2022 The Catrobat Team
* Copyright (C) 2010-2024 The Catrobat Team
* (<http://developer.catrobat.org/credits>)
*
* This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -40,7 +40,7 @@
import org.catrobat.catroid.content.Sprite;
import org.catrobat.catroid.content.StartScript;
import org.catrobat.catroid.content.bricks.BackgroundRequestBrick;
import org.catrobat.catroid.uiespresso.ui.activity.ProjectUploadDialogTest;
import org.catrobat.catroid.ui.ProjectUploadTestActivity;
import org.catrobat.catroid.uiespresso.util.rules.BaseActivityTestRule;
import org.junit.After;
import org.junit.Before;
Expand Down Expand Up @@ -68,8 +68,8 @@ public class ReplaceApiKeyDialogTest {
private static final String TAG = ReplaceApiKeyDialogTest.class.getSimpleName();

@Rule
public BaseActivityTestRule<ProjectUploadDialogTest.ProjectUploadTestActivity> activityTestRule =
new BaseActivityTestRule<>(ProjectUploadDialogTest.ProjectUploadTestActivity.class, false, false);
public BaseActivityTestRule<ProjectUploadTestActivity> activityTestRule =
new BaseActivityTestRule<>(ProjectUploadTestActivity.class, false, false);

private int bufferedPrivacyPolicyPreferenceSetting;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Catroid: An on-device visual programming system for Android devices
* Copyright (C) 2010-2022 The Catrobat Team
* Copyright (C) 2010-2024 The Catrobat Team
* (<http://developer.catrobat.org/credits>)
*
* This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -39,7 +39,7 @@ import org.catrobat.catroid.formulaeditor.UserVariable
import org.catrobat.catroid.io.XstreamSerializer
import org.catrobat.catroid.io.asynctask.saveProjectSerial
import org.catrobat.catroid.ui.PROJECT_DIR
import org.catrobat.catroid.uiespresso.ui.activity.ProjectUploadDialogTest.ProjectUploadTestActivity
import org.catrobat.catroid.ui.ProjectUploadTestActivity
import org.catrobat.catroid.uiespresso.util.rules.BaseActivityTestRule
import org.junit.After
import org.junit.Rule
Expand Down
5 changes: 5 additions & 0 deletions catroid/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@
tools:replace="android:label,android:allowBackup,android:name"
android:usesCleartextTraffic="true">

<activity
android:name=".ui.ConnectBluetoothDeviceTestActivity" />

<activity
android:name=".ui.ProjectUploadTestActivity" />
<!--
<activity
android:name=".ui.SettingsActivity"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Catroid: An on-device visual programming system for Android devices
* Copyright (C) 2010-2024 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.ui

import org.catrobat.catroid.bluetooth.ConnectBluetoothDeviceActivity

class ConnectBluetoothDeviceTestActivity : ConnectBluetoothDeviceActivity() {
override fun initBluetooth() = Unit
override fun doDiscovery() = Unit
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Catroid: An on-device visual programming system for Android devices
* Copyright (C) 2010-2024 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.ui

import org.catrobat.catroid.ui.controller.ProjectUploadController
import org.mockito.Mockito.spy

class ProjectUploadTestActivity : ProjectUploadActivity() {
override fun createProjectUploadController(): ProjectUploadController? {
projectUploadController = spy(ProjectUploadController(this))
return projectUploadController
}

override fun verifyUserIdentity() {
onTokenCheckComplete(true, false)
}

fun projectUploadController(): ProjectUploadController? = projectUploadController
}
7 changes: 4 additions & 3 deletions catroid/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,10 @@

<uses-feature
android:glEsVersion="0x00020000"
android:required="true" /><uses-feature
android:name="android.hardware.camera"
android:required="false" />
android:required="true" />
<uses-feature
android:name="android.hardware.camera"
android:required="false" />

<application
android:name=".CatroidApplication"
Expand Down