From 8b662ee46dcbd145ec0101a5d8b2a7261fa35cca Mon Sep 17 00:00:00 2001 From: foenabua Date: Mon, 7 Jul 2025 17:00:20 +0200 Subject: [PATCH 01/15] some ideas --- .../test/espresso/LandscapeIntegrationTest.kt | 10 +- .../test/espresso/util/EspressoUtils.kt | 95 ++++++++++++++++++- .../paintroid/test/espresso/util/ViewRobot.kt | 57 +++++++++++ .../BottomNavigationViewInteraction.kt | 25 ++--- 4 files changed, 168 insertions(+), 19 deletions(-) create mode 100644 Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/util/ViewRobot.kt diff --git a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/LandscapeIntegrationTest.kt b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/LandscapeIntegrationTest.kt index 11c0738fda..5064b86a3b 100644 --- a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/LandscapeIntegrationTest.kt +++ b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/LandscapeIntegrationTest.kt @@ -44,6 +44,7 @@ import org.catrobat.paintroid.R import org.catrobat.paintroid.colorpicker.HSVColorPickerView import org.catrobat.paintroid.colorpicker.PresetSelectorView import org.catrobat.paintroid.colorpicker.RgbSelectorView +import org.catrobat.paintroid.test.espresso.util.EspressoUtils 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.Companion.onBottomNavigationView @@ -57,7 +58,6 @@ import org.catrobat.paintroid.tools.ToolType import org.catrobat.paintroid.tools.options.ToolOptionsViewController import org.hamcrest.Matchers.allOf import org.hamcrest.Matchers.`is` -import org.hamcrest.Matchers.not import org.junit.After import org.junit.Assert.assertEquals import org.junit.Before @@ -109,14 +109,16 @@ class LandscapeIntegrationTest { if (tool) { continue } onToolBarView() .performSelectTool(toolType) - if (toolOptionsViewController?.isVisible?.not() == true) { + if (toolOptionsViewController?.isVisible == false) { onToolBarView() .performClickSelectedToolButton() } onBottomNavigationView() .onCurrentClicked() - onView(withId(R.id.pocketpaint_layout_tool_specific_options)) - .check(matches(not(isDisplayed()))) + EspressoUtils.waitForViewToDisappear(withId(R.id.pocketpaint_layout_tool_specific_options)) + // BaseRobot().waitForViewToDisappear(withId(R.id.pocketpaint_layout_tool_specific_options)).check(matches(not(isDisplayed()))) +// onView(withId(R.id.pocketpaint_layout_tool_specific_options)) +// .check(matches(not(isDisplayed()))) } } diff --git a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/util/EspressoUtils.kt b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/util/EspressoUtils.kt index f40903af83..2307354018 100644 --- a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/util/EspressoUtils.kt +++ b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/util/EspressoUtils.kt @@ -24,12 +24,18 @@ import android.app.Activity import android.content.res.Configuration import android.graphics.PointF import android.os.Build +import android.os.SystemClock import android.util.TypedValue import android.view.View +import androidx.core.view.isVisible import androidx.test.espresso.Espresso +import androidx.test.espresso.Espresso.onView import androidx.test.espresso.NoMatchingViewException +import androidx.test.espresso.UiController +import androidx.test.espresso.ViewAction +import androidx.test.espresso.ViewAssertion import androidx.test.espresso.assertion.ViewAssertions -import androidx.test.espresso.matcher.ViewMatchers +import androidx.test.espresso.assertion.ViewAssertions.matches import androidx.test.platform.app.InstrumentationRegistry import androidx.test.rule.GrantPermissionRule import androidx.test.runner.lifecycle.ActivityLifecycleMonitorRegistry @@ -37,6 +43,10 @@ import androidx.test.runner.lifecycle.Stage import org.catrobat.paintroid.MainActivity import org.hamcrest.Matcher import org.junit.Assert +import androidx.test.espresso.matcher.ViewMatchers.isDisplayed +import androidx.test.espresso.matcher.ViewMatchers.isRoot +import androidx.test.espresso.util.TreeIterables +import org.hamcrest.Matchers.not object EspressoUtils { const val DEFAULT_STROKE_WIDTH = 25 @@ -87,19 +97,55 @@ object EspressoUtils { val viewInteraction = Espresso.onView(viewMatcher).inRoot(UiMatcher.isToast) while (System.currentTimeMillis() < waitTime) { try { - viewInteraction.check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + viewInteraction.check(ViewAssertions.matches(isDisplayed())) return } catch (e: NoMatchingViewException) { - Espresso.onView(ViewMatchers.isRoot()).perform(UiInteractions.waitFor(250)) + Espresso.onView(isRoot()).perform(UiInteractions.waitFor(250)) + } + } + viewInteraction.check(ViewAssertions.matches(isDisplayed())) + } + + @SuppressWarnings("SwallowedException") + fun waitForViewToDisappear( + viewMatcher: org.hamcrest.Matcher, + timeoutMillis: Long = 10_000, // Default timeout 10 seconds + pollIntervalMillis: Long = 100 // Default poll interval 100 ms + ) { + val endTime = System.currentTimeMillis() + timeoutMillis + var viewFound = true // Assume view is initially present + + while (System.currentTimeMillis() < endTime && viewFound) { + try { + // Check if the view is still displayed + onView(viewMatcher).check(matches(isDisplayed())) + // If the check passes, the view is still displayed. + // Wait for a short interval before trying again. + onView(isRoot()).perform(UiInteractions.waitFor(pollIntervalMillis)) + } catch (e: NoMatchingViewException) { + // View is not found in the hierarchy, so it has "disappeared" in this sense. + viewFound = false + } catch (e: AssertionError) { + // View is in the hierarchy but not displayed (e.g., GONE, INVISIBLE). + // This also means it has "disappeared" for the user. + viewFound = false + } + } + + if (viewFound) { + try { + onView(viewMatcher).check(matches(not(isDisplayed()))) + } catch (e: NoMatchingViewException) { + // This is acceptable, means it's not in hierarchy } } - viewInteraction.check(ViewAssertions.matches(ViewMatchers.isDisplayed())) } val configuration: Configuration get() = InstrumentationRegistry.getInstrumentation().targetContext.resources.configuration fun grantPermissionRulesVersionCheck(): GrantPermissionRule { + return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { GrantPermissionRule.grant(Manifest.permission.READ_EXTERNAL_STORAGE) } else { @@ -109,4 +155,45 @@ object EspressoUtils { ) } } + fun searchFor(matcher: Matcher): ViewAction { + return object : ViewAction { + + override fun getConstraints(): Matcher { + return isRoot() + } + + override fun getDescription(): String { + return "searching for view $matcher in the root view" + } + + override fun perform(uiController: UiController, view: View) { + val childViews: Iterable = TreeIterables.breadthFirstViewTraversal(view) + childViews.forEach { + if (matcher.matches(it).and(it.isVisible)) { + return + } + } + throw NoMatchingViewException.Builder() + .withRootView(view) + .withViewMatcher(matcher) + .build() + } + } + } + + @SuppressWarnings("SwallowedException") + fun assertOnView(viewMatcher: Matcher?, assertion: ViewAssertion, waitMillis: Int = 10_000, waitMillisPerTry: Long = 50) { + val endTime = System.currentTimeMillis() + waitMillis + while (System.currentTimeMillis() < endTime) { + try { + onView(viewMatcher).check(assertion) + return + } catch (e: NoMatchingViewException) { + SystemClock.sleep(waitMillisPerTry) + } catch (e: AssertionError) { + SystemClock.sleep(waitMillisPerTry) + } + } + onView(viewMatcher).check(assertion) + } } diff --git a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/util/ViewRobot.kt b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/util/ViewRobot.kt new file mode 100644 index 0000000000..49d9542d3f --- /dev/null +++ b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/util/ViewRobot.kt @@ -0,0 +1,57 @@ +package org.catrobat.paintroid.test.espresso.util + +import android.os.SystemClock.sleep +import android.util.Log +import android.view.View +import androidx.test.espresso.Espresso.onView +import androidx.test.espresso.ViewAction +import androidx.test.espresso.ViewAssertion +import androidx.test.espresso.ViewInteraction +import androidx.test.espresso.matcher.ViewMatchers.isRoot +import org.catrobat.paintroid.test.espresso.util.EspressoUtils.searchFor +import org.hamcrest.Matcher + +open class ViewRobot { + + fun doOnView(matcher: Matcher, vararg actions: ViewAction) { + actions.forEach { + waitForView(matcher).perform(it) + } + } + + fun assertOnView(matcher: Matcher, vararg assertions: ViewAssertion) { + assertions.forEach { + waitForView(matcher).check(it) + } + } + + @SuppressWarnings("SwallowedException", "TooGenericExceptionThrown") + private fun waitForView(viewMatcher: Matcher, waitMillis: Int = 5000, waitMillisPerTry: Long = 50): ViewInteraction { + val endTime = System.currentTimeMillis() + waitMillis + while (System.currentTimeMillis() < endTime) { + try { + onView(isRoot()).perform(searchFor(viewMatcher)) + return onView(viewMatcher) + } catch (e: Exception) { + Log.d("asdf", "sleeping...") + sleep(waitMillisPerTry) + } + } + throw Exception("Error finding a view matching $viewMatcher after ${waitMillis}ms milliseconds") + } + + @SuppressWarnings("SwallowedException", "TooGenericExceptionThrown") + fun waitForViewToDisappear(viewMatcher: Matcher, waitMillis: Int = 5000, waitMillisPerTry: Long = 50): ViewInteraction { + val endTime = System.currentTimeMillis() + waitMillis + while (System.currentTimeMillis() < endTime) { + try { + onView(isRoot()).perform(searchFor(viewMatcher)) + sleep(waitMillisPerTry) + } catch (e: Exception) { + return onView(viewMatcher) + } + } + onView(isRoot()).perform(searchFor(viewMatcher)) + throw Exception("View $viewMatcher did not disappear after ${waitMillis}ms") + } +} diff --git a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/util/wrappers/BottomNavigationViewInteraction.kt b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/util/wrappers/BottomNavigationViewInteraction.kt index 182d6a5570..038c7d6536 100644 --- a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/util/wrappers/BottomNavigationViewInteraction.kt +++ b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/util/wrappers/BottomNavigationViewInteraction.kt @@ -19,15 +19,19 @@ package org.catrobat.paintroid.test.espresso.util.wrappers import androidx.test.espresso.Espresso +import androidx.test.espresso.Espresso.onView import androidx.test.espresso.ViewInteraction import androidx.test.espresso.action.ViewActions import androidx.test.espresso.assertion.ViewAssertions import androidx.test.espresso.matcher.ViewMatchers +import androidx.test.espresso.matcher.ViewMatchers.isDisplayed import androidx.test.espresso.matcher.ViewMatchers.withId +import androidx.test.espresso.matcher.ViewMatchers.withText import org.catrobat.paintroid.R -import org.catrobat.paintroid.test.espresso.util.UiMatcher import org.catrobat.paintroid.tools.ToolType import org.hamcrest.Matchers.allOf +import org.catrobat.paintroid.test.espresso.util.EspressoUtils +import org.catrobat.paintroid.test.espresso.util.UiMatcher class BottomNavigationViewInteraction private constructor() : CustomViewInteraction(Espresso.onView(withId(R.id.pocketpaint_bottom_navigation))) { @@ -51,16 +55,15 @@ class BottomNavigationViewInteraction private constructor() : .perform(ViewActions.click()) } - fun checkShowsCurrentTool(toolType: ToolType): ViewInteraction { - Espresso.onView( - allOf( - withId(R.id.icon), - ViewMatchers.isDescendantOfA(withId(R.id.action_current_tool)) - ) - ) - .check(ViewAssertions.matches(UiMatcher.withDrawable(toolType.drawableResource))) - return Espresso.onView(withId(R.id.action_current_tool)) - .check(ViewAssertions.matches(ViewMatchers.hasDescendant(ViewMatchers.withText(toolType.nameResource)))) + fun checkShowsCurrentTool(toolType: ToolType) { + var matcher = allOf(withId(R.id.icon), + ViewMatchers.isDescendantOfA(withId(R.id.action_current_tool)), + UiMatcher.withDrawable(R.drawable.ic_pocketpaint_tool_brush)) + var assertion = ViewAssertions.matches(isDisplayed()) + EspressoUtils.assertOnView(matcher, assertion) + + matcher = allOf(withId(R.id.action_current_tool), ViewMatchers.hasDescendant(withText(toolType.nameResource))) + EspressoUtils.assertOnView(matcher, assertion) } fun onColorClicked(): ViewInteraction { From 4554a24fed2b0404e356a386bd67195700444e25 Mon Sep 17 00:00:00 2001 From: foenabua Date: Tue, 8 Jul 2025 18:40:48 +0200 Subject: [PATCH 02/15] add additional idling resource in tool switch and change assertion --- .../test/espresso/LayerIntegrationTest.kt | 5 +++- .../BottomNavigationViewInteraction.kt | 28 +++++++++++++++++-- .../controller/DefaultToolController.kt | 2 ++ 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/LayerIntegrationTest.kt b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/LayerIntegrationTest.kt index da096f3772..905c2bfc5c 100644 --- a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/LayerIntegrationTest.kt +++ b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/LayerIntegrationTest.kt @@ -71,6 +71,7 @@ import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import java.io.File +import java.lang.Thread.sleep private const val FOUR_LAYERS = 4 @@ -583,7 +584,9 @@ class LayerIntegrationTest { LayerMenuViewInteraction.onLayerMenuView() .performOpen() .performSetOpacityTo(50, 0) - .performClose() + + sleep(1000) + LayerMenuViewInteraction.onLayerMenuView().performClose() ToolBarViewInteraction.onToolBarView() .performSelectTool(ToolType.PIPETTE) diff --git a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/util/wrappers/BottomNavigationViewInteraction.kt b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/util/wrappers/BottomNavigationViewInteraction.kt index 038c7d6536..8d10681440 100644 --- a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/util/wrappers/BottomNavigationViewInteraction.kt +++ b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/util/wrappers/BottomNavigationViewInteraction.kt @@ -32,6 +32,7 @@ import org.catrobat.paintroid.tools.ToolType import org.hamcrest.Matchers.allOf import org.catrobat.paintroid.test.espresso.util.EspressoUtils import org.catrobat.paintroid.test.espresso.util.UiMatcher +import org.hamcrest.Matchers class BottomNavigationViewInteraction private constructor() : CustomViewInteraction(Espresso.onView(withId(R.id.pocketpaint_bottom_navigation))) { @@ -59,13 +60,36 @@ class BottomNavigationViewInteraction private constructor() : var matcher = allOf(withId(R.id.icon), ViewMatchers.isDescendantOfA(withId(R.id.action_current_tool)), UiMatcher.withDrawable(R.drawable.ic_pocketpaint_tool_brush)) - var assertion = ViewAssertions.matches(isDisplayed()) + var assertion = ViewAssertions.matches( + Matchers.allOf( + isDisplayed(), + UiMatcher.withDrawable(toolType.drawableResource) + ) + ) EspressoUtils.assertOnView(matcher, assertion) - matcher = allOf(withId(R.id.action_current_tool), ViewMatchers.hasDescendant(withText(toolType.nameResource))) + matcher = allOf(withId(R.id.action_current_tool)) + assertion = ViewAssertions.matches( + Matchers.allOf( + isDisplayed(), + ViewMatchers.hasDescendant(withText(toolType.nameResource)) + ) + ) EspressoUtils.assertOnView(matcher, assertion) } + /*fun checkShowsCurrentTool(toolType: ToolType): ViewInteraction { + Espresso.onView( + allOf( + withId(R.id.icon), + ViewMatchers.isDescendantOfA(withId(R.id.action_current_tool)) + ) + ) + .check(ViewAssertions.matches(UiMatcher.withDrawable(toolType.drawableResource))) + return Espresso.onView(withId(R.id.action_current_tool)) + .check(ViewAssertions.matches(ViewMatchers.hasDescendant(ViewMatchers.withText(toolType.nameResource)))) + }*/ + fun onColorClicked(): ViewInteraction { return Espresso.onView( allOf( diff --git a/Paintroid/src/main/java/org/catrobat/paintroid/controller/DefaultToolController.kt b/Paintroid/src/main/java/org/catrobat/paintroid/controller/DefaultToolController.kt index 5f49fc9bc2..a2b87dfeb4 100644 --- a/Paintroid/src/main/java/org/catrobat/paintroid/controller/DefaultToolController.kt +++ b/Paintroid/src/main/java/org/catrobat/paintroid/controller/DefaultToolController.kt @@ -103,7 +103,9 @@ class DefaultToolController( } override fun switchTool(toolType: ToolType) { + idlingResource.increment() switchTool(createAndSetupTool(toolType)) + idlingResource.decrement() } override fun hideToolOptionsView() { From 838ab15c37d7a6283535d6f3f96edbc256ab3c3f Mon Sep 17 00:00:00 2001 From: foenabua Date: Tue, 8 Jul 2025 20:56:16 +0200 Subject: [PATCH 03/15] put checksShowsCurrentTool in LandscapeIntegrationTest.kt --- .../test/espresso/LandscapeIntegrationTest.kt | 29 +++++++++++++++++-- .../BottomNavigationViewInteraction.kt | 6 ++-- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/LandscapeIntegrationTest.kt b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/LandscapeIntegrationTest.kt index 5064b86a3b..effc570d3b 100644 --- a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/LandscapeIntegrationTest.kt +++ b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/LandscapeIntegrationTest.kt @@ -31,8 +31,10 @@ import androidx.test.espresso.Espresso.pressBack import androidx.test.espresso.IdlingRegistry import androidx.test.espresso.action.ViewActions.click import androidx.test.espresso.action.ViewActions.scrollTo +import androidx.test.espresso.assertion.ViewAssertions import androidx.test.espresso.assertion.ViewAssertions.matches import androidx.test.espresso.idling.CountingIdlingResource +import androidx.test.espresso.matcher.ViewMatchers import androidx.test.espresso.matcher.ViewMatchers.isDisplayed import androidx.test.espresso.matcher.ViewMatchers.withClassName import androidx.test.espresso.matcher.ViewMatchers.withId @@ -45,6 +47,7 @@ import org.catrobat.paintroid.colorpicker.HSVColorPickerView import org.catrobat.paintroid.colorpicker.PresetSelectorView import org.catrobat.paintroid.colorpicker.RgbSelectorView import org.catrobat.paintroid.test.espresso.util.EspressoUtils +import org.catrobat.paintroid.test.espresso.util.UiMatcher 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.Companion.onBottomNavigationView @@ -56,6 +59,7 @@ import org.catrobat.paintroid.test.utils.ScreenshotOnFailRule import org.catrobat.paintroid.tools.Tool import org.catrobat.paintroid.tools.ToolType import org.catrobat.paintroid.tools.options.ToolOptionsViewController +import org.hamcrest.Matchers import org.hamcrest.Matchers.allOf import org.hamcrest.Matchers.`is` import org.junit.After @@ -420,13 +424,34 @@ class LandscapeIntegrationTest { if (tools) { continue } onToolBarView() .performSelectTool(toolType) - onBottomNavigationView() - .checkShowsCurrentTool(toolType) + checkShowsCurrentTool(toolType) } } private fun setOrientation(orientation: Int) { activityTestRule.activity.requestedOrientation = orientation } + private fun checkShowsCurrentTool(toolType: ToolType) { + var matcher = allOf(withId(R.id.icon), + ViewMatchers.isDescendantOfA(withId(R.id.action_current_tool)) + ) + var assertion = ViewAssertions.matches( + Matchers.allOf( + isDisplayed(), + UiMatcher.withDrawable(toolType.drawableResource) + ) + ) + EspressoUtils.assertOnView(matcher, assertion) + + matcher = withId(R.id.action_current_tool) + assertion = ViewAssertions.matches( + Matchers.allOf( + isDisplayed(), + ViewMatchers.hasDescendant(withText(toolType.nameResource)) + ) + ) + EspressoUtils.assertOnView(matcher, assertion) + } + companion object { @ColorInt private fun getColorArrayFromResource(context: Context, @ArrayRes id: Int): IntArray { diff --git a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/util/wrappers/BottomNavigationViewInteraction.kt b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/util/wrappers/BottomNavigationViewInteraction.kt index 8d10681440..ed4a1389cb 100644 --- a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/util/wrappers/BottomNavigationViewInteraction.kt +++ b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/util/wrappers/BottomNavigationViewInteraction.kt @@ -58,8 +58,8 @@ class BottomNavigationViewInteraction private constructor() : fun checkShowsCurrentTool(toolType: ToolType) { var matcher = allOf(withId(R.id.icon), - ViewMatchers.isDescendantOfA(withId(R.id.action_current_tool)), - UiMatcher.withDrawable(R.drawable.ic_pocketpaint_tool_brush)) + ViewMatchers.isDescendantOfA(withId(R.id.action_current_tool)) + ) var assertion = ViewAssertions.matches( Matchers.allOf( isDisplayed(), @@ -68,7 +68,7 @@ class BottomNavigationViewInteraction private constructor() : ) EspressoUtils.assertOnView(matcher, assertion) - matcher = allOf(withId(R.id.action_current_tool)) + matcher = withId(R.id.action_current_tool) assertion = ViewAssertions.matches( Matchers.allOf( isDisplayed(), From 82dc1a551449132b38fa477d52a4bd0dc176e201 Mon Sep 17 00:00:00 2001 From: foenabua Date: Wed, 9 Jul 2025 17:55:05 +0200 Subject: [PATCH 04/15] try with viewrobot --- .../test/espresso/LandscapeIntegrationTest.kt | 10 +++---- .../test/espresso/util/EspressoUtils.kt | 3 +-- .../paintroid/test/espresso/util/ViewRobot.kt | 2 -- .../BottomNavigationViewInteraction.kt | 26 +++++++------------ 4 files changed, 13 insertions(+), 28 deletions(-) diff --git a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/LandscapeIntegrationTest.kt b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/LandscapeIntegrationTest.kt index effc570d3b..d838cf574d 100644 --- a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/LandscapeIntegrationTest.kt +++ b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/LandscapeIntegrationTest.kt @@ -31,10 +31,8 @@ import androidx.test.espresso.Espresso.pressBack import androidx.test.espresso.IdlingRegistry import androidx.test.espresso.action.ViewActions.click import androidx.test.espresso.action.ViewActions.scrollTo -import androidx.test.espresso.assertion.ViewAssertions import androidx.test.espresso.assertion.ViewAssertions.matches import androidx.test.espresso.idling.CountingIdlingResource -import androidx.test.espresso.matcher.ViewMatchers import androidx.test.espresso.matcher.ViewMatchers.isDisplayed import androidx.test.espresso.matcher.ViewMatchers.withClassName import androidx.test.espresso.matcher.ViewMatchers.withId @@ -47,7 +45,6 @@ import org.catrobat.paintroid.colorpicker.HSVColorPickerView import org.catrobat.paintroid.colorpicker.PresetSelectorView import org.catrobat.paintroid.colorpicker.RgbSelectorView import org.catrobat.paintroid.test.espresso.util.EspressoUtils -import org.catrobat.paintroid.test.espresso.util.UiMatcher 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.Companion.onBottomNavigationView @@ -59,7 +56,6 @@ import org.catrobat.paintroid.test.utils.ScreenshotOnFailRule import org.catrobat.paintroid.tools.Tool import org.catrobat.paintroid.tools.ToolType import org.catrobat.paintroid.tools.options.ToolOptionsViewController -import org.hamcrest.Matchers import org.hamcrest.Matchers.allOf import org.hamcrest.Matchers.`is` import org.junit.After @@ -424,13 +420,13 @@ class LandscapeIntegrationTest { if (tools) { continue } onToolBarView() .performSelectTool(toolType) - checkShowsCurrentTool(toolType) + onBottomNavigationView().checkShowsCurrentTool(toolType) } } private fun setOrientation(orientation: Int) { activityTestRule.activity.requestedOrientation = orientation } - private fun checkShowsCurrentTool(toolType: ToolType) { + /*private fun checkShowsCurrentTool(toolType: ToolType) { var matcher = allOf(withId(R.id.icon), ViewMatchers.isDescendantOfA(withId(R.id.action_current_tool)) ) @@ -450,7 +446,7 @@ class LandscapeIntegrationTest { ) ) EspressoUtils.assertOnView(matcher, assertion) - } + }*/ companion object { @ColorInt diff --git a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/util/EspressoUtils.kt b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/util/EspressoUtils.kt index 2307354018..cd5adb7d2d 100644 --- a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/util/EspressoUtils.kt +++ b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/util/EspressoUtils.kt @@ -27,7 +27,6 @@ import android.os.Build import android.os.SystemClock import android.util.TypedValue import android.view.View -import androidx.core.view.isVisible import androidx.test.espresso.Espresso import androidx.test.espresso.Espresso.onView import androidx.test.espresso.NoMatchingViewException @@ -169,7 +168,7 @@ object EspressoUtils { override fun perform(uiController: UiController, view: View) { val childViews: Iterable = TreeIterables.breadthFirstViewTraversal(view) childViews.forEach { - if (matcher.matches(it).and(it.isVisible)) { + if (matcher.matches(it)) { return } } diff --git a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/util/ViewRobot.kt b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/util/ViewRobot.kt index 49d9542d3f..c1e1aa1e47 100644 --- a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/util/ViewRobot.kt +++ b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/util/ViewRobot.kt @@ -1,7 +1,6 @@ package org.catrobat.paintroid.test.espresso.util import android.os.SystemClock.sleep -import android.util.Log import android.view.View import androidx.test.espresso.Espresso.onView import androidx.test.espresso.ViewAction @@ -33,7 +32,6 @@ open class ViewRobot { onView(isRoot()).perform(searchFor(viewMatcher)) return onView(viewMatcher) } catch (e: Exception) { - Log.d("asdf", "sleeping...") sleep(waitMillisPerTry) } } diff --git a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/util/wrappers/BottomNavigationViewInteraction.kt b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/util/wrappers/BottomNavigationViewInteraction.kt index ed4a1389cb..8a929f2fe4 100644 --- a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/util/wrappers/BottomNavigationViewInteraction.kt +++ b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/util/wrappers/BottomNavigationViewInteraction.kt @@ -19,7 +19,6 @@ package org.catrobat.paintroid.test.espresso.util.wrappers import androidx.test.espresso.Espresso -import androidx.test.espresso.Espresso.onView import androidx.test.espresso.ViewInteraction import androidx.test.espresso.action.ViewActions import androidx.test.espresso.assertion.ViewAssertions @@ -30,9 +29,8 @@ import androidx.test.espresso.matcher.ViewMatchers.withText import org.catrobat.paintroid.R import org.catrobat.paintroid.tools.ToolType import org.hamcrest.Matchers.allOf -import org.catrobat.paintroid.test.espresso.util.EspressoUtils import org.catrobat.paintroid.test.espresso.util.UiMatcher -import org.hamcrest.Matchers +import org.catrobat.paintroid.test.espresso.util.ViewRobot class BottomNavigationViewInteraction private constructor() : CustomViewInteraction(Espresso.onView(withId(R.id.pocketpaint_bottom_navigation))) { @@ -57,25 +55,19 @@ class BottomNavigationViewInteraction private constructor() : } fun checkShowsCurrentTool(toolType: ToolType) { + val viewRobot = ViewRobot() var matcher = allOf(withId(R.id.icon), - ViewMatchers.isDescendantOfA(withId(R.id.action_current_tool)) - ) - var assertion = ViewAssertions.matches( - Matchers.allOf( - isDisplayed(), + ViewMatchers.isDescendantOfA(withId(R.id.action_current_tool)), UiMatcher.withDrawable(toolType.drawableResource) - ) ) - EspressoUtils.assertOnView(matcher, assertion) + var assertion = ViewAssertions.matches(isDisplayed()) + viewRobot.assertOnView(matcher, assertion) - matcher = withId(R.id.action_current_tool) - assertion = ViewAssertions.matches( - Matchers.allOf( - isDisplayed(), - ViewMatchers.hasDescendant(withText(toolType.nameResource)) - ) + matcher = allOf(withId(R.id.action_current_tool), + ViewMatchers.hasDescendant(withText(toolType.nameResource)) ) - EspressoUtils.assertOnView(matcher, assertion) + assertion = ViewAssertions.matches(isDisplayed()) + viewRobot.assertOnView(matcher, assertion) } /*fun checkShowsCurrentTool(toolType: ToolType): ViewInteraction { From 6f0f544a656d2173249f93af430593d7c4ddb2fc Mon Sep 17 00:00:00 2001 From: foenabua Date: Wed, 9 Jul 2025 18:44:21 +0200 Subject: [PATCH 05/15] make wait longer --- .../org/catrobat/paintroid/test/espresso/util/ViewRobot.kt | 2 +- .../src/main/java/org/catrobat/paintroid/ui/LayerAdapter.kt | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/util/ViewRobot.kt b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/util/ViewRobot.kt index c1e1aa1e47..d3c3a91cce 100644 --- a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/util/ViewRobot.kt +++ b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/util/ViewRobot.kt @@ -25,7 +25,7 @@ open class ViewRobot { } @SuppressWarnings("SwallowedException", "TooGenericExceptionThrown") - private fun waitForView(viewMatcher: Matcher, waitMillis: Int = 5000, waitMillisPerTry: Long = 50): ViewInteraction { + private fun waitForView(viewMatcher: Matcher, waitMillis: Int = 10_000, waitMillisPerTry: Long = 100): ViewInteraction { val endTime = System.currentTimeMillis() + waitMillis while (System.currentTimeMillis() < endTime) { try { diff --git a/Paintroid/src/main/java/org/catrobat/paintroid/ui/LayerAdapter.kt b/Paintroid/src/main/java/org/catrobat/paintroid/ui/LayerAdapter.kt index 753d002bc0..a7d1e90644 100644 --- a/Paintroid/src/main/java/org/catrobat/paintroid/ui/LayerAdapter.kt +++ b/Paintroid/src/main/java/org/catrobat/paintroid/ui/LayerAdapter.kt @@ -139,10 +139,12 @@ class LayerAdapter( MAX_VAL } - if (opacityPercentage != opacitySeekBar.progress) { + /* if (opacityPercentage != opacitySeekBar.progress) { opacitySeekBar.progress = opacityPercentage layerPresenter.changeLayerOpacity(position, opacityPercentage) - } + }*/ + opacitySeekBar.progress = opacityPercentage + layerPresenter.changeLayerOpacity(position, opacityPercentage) layerPresenter.refreshDrawingSurface() } }) From df51d00a766d504413bf4ed723adda1eb02e8e40 Mon Sep 17 00:00:00 2001 From: foenabua Date: Wed, 9 Jul 2025 19:30:48 +0200 Subject: [PATCH 06/15] wait after setting to landscape mode --- .../paintroid/test/espresso/LandscapeIntegrationTest.kt | 4 ++++ .../src/main/java/org/catrobat/paintroid/ui/LayerAdapter.kt | 6 ++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/LandscapeIntegrationTest.kt b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/LandscapeIntegrationTest.kt index d838cf574d..a5b3a54fac 100644 --- a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/LandscapeIntegrationTest.kt +++ b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/LandscapeIntegrationTest.kt @@ -34,6 +34,7 @@ import androidx.test.espresso.action.ViewActions.scrollTo import androidx.test.espresso.assertion.ViewAssertions.matches import androidx.test.espresso.idling.CountingIdlingResource import androidx.test.espresso.matcher.ViewMatchers.isDisplayed +import androidx.test.espresso.matcher.ViewMatchers.isRoot import androidx.test.espresso.matcher.ViewMatchers.withClassName import androidx.test.espresso.matcher.ViewMatchers.withId import androidx.test.espresso.matcher.ViewMatchers.withText @@ -45,6 +46,7 @@ import org.catrobat.paintroid.colorpicker.HSVColorPickerView import org.catrobat.paintroid.colorpicker.PresetSelectorView import org.catrobat.paintroid.colorpicker.RgbSelectorView import org.catrobat.paintroid.test.espresso.util.EspressoUtils +import org.catrobat.paintroid.test.espresso.util.UiInteractions.waitFor 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.Companion.onBottomNavigationView @@ -410,6 +412,7 @@ class LandscapeIntegrationTest { @Test fun testIfCurrentToolIsShownInBottomNavigation() { setOrientation(SCREEN_ORIENTATION_LANDSCAPE) + onView(isRoot()).perform(waitFor(2000)) for (toolType in ToolType.values()) { val tools = toolType == ToolType.IMPORTPNG || toolType == ToolType.COLORCHOOSER || @@ -420,6 +423,7 @@ class LandscapeIntegrationTest { if (tools) { continue } onToolBarView() .performSelectTool(toolType) + onView(isRoot()).perform(waitFor(2000)) onBottomNavigationView().checkShowsCurrentTool(toolType) } } diff --git a/Paintroid/src/main/java/org/catrobat/paintroid/ui/LayerAdapter.kt b/Paintroid/src/main/java/org/catrobat/paintroid/ui/LayerAdapter.kt index a7d1e90644..753d002bc0 100644 --- a/Paintroid/src/main/java/org/catrobat/paintroid/ui/LayerAdapter.kt +++ b/Paintroid/src/main/java/org/catrobat/paintroid/ui/LayerAdapter.kt @@ -139,12 +139,10 @@ class LayerAdapter( MAX_VAL } - /* if (opacityPercentage != opacitySeekBar.progress) { + if (opacityPercentage != opacitySeekBar.progress) { opacitySeekBar.progress = opacityPercentage layerPresenter.changeLayerOpacity(position, opacityPercentage) - }*/ - opacitySeekBar.progress = opacityPercentage - layerPresenter.changeLayerOpacity(position, opacityPercentage) + } layerPresenter.refreshDrawingSurface() } }) From 994c5f5c3814ec6c42e0e78f1e6730e1e30d57bf Mon Sep 17 00:00:00 2001 From: foenabua Date: Wed, 16 Jul 2025 15:10:04 +0200 Subject: [PATCH 07/15] i am out of ideas --- .../paintroid/test/espresso/LandscapeIntegrationTest.kt | 4 ---- .../util/wrappers/BottomNavigationViewInteraction.kt | 9 ++++----- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/LandscapeIntegrationTest.kt b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/LandscapeIntegrationTest.kt index a5b3a54fac..d838cf574d 100644 --- a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/LandscapeIntegrationTest.kt +++ b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/LandscapeIntegrationTest.kt @@ -34,7 +34,6 @@ import androidx.test.espresso.action.ViewActions.scrollTo import androidx.test.espresso.assertion.ViewAssertions.matches import androidx.test.espresso.idling.CountingIdlingResource import androidx.test.espresso.matcher.ViewMatchers.isDisplayed -import androidx.test.espresso.matcher.ViewMatchers.isRoot import androidx.test.espresso.matcher.ViewMatchers.withClassName import androidx.test.espresso.matcher.ViewMatchers.withId import androidx.test.espresso.matcher.ViewMatchers.withText @@ -46,7 +45,6 @@ import org.catrobat.paintroid.colorpicker.HSVColorPickerView import org.catrobat.paintroid.colorpicker.PresetSelectorView import org.catrobat.paintroid.colorpicker.RgbSelectorView import org.catrobat.paintroid.test.espresso.util.EspressoUtils -import org.catrobat.paintroid.test.espresso.util.UiInteractions.waitFor 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.Companion.onBottomNavigationView @@ -412,7 +410,6 @@ class LandscapeIntegrationTest { @Test fun testIfCurrentToolIsShownInBottomNavigation() { setOrientation(SCREEN_ORIENTATION_LANDSCAPE) - onView(isRoot()).perform(waitFor(2000)) for (toolType in ToolType.values()) { val tools = toolType == ToolType.IMPORTPNG || toolType == ToolType.COLORCHOOSER || @@ -423,7 +420,6 @@ class LandscapeIntegrationTest { if (tools) { continue } onToolBarView() .performSelectTool(toolType) - onView(isRoot()).perform(waitFor(2000)) onBottomNavigationView().checkShowsCurrentTool(toolType) } } diff --git a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/util/wrappers/BottomNavigationViewInteraction.kt b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/util/wrappers/BottomNavigationViewInteraction.kt index 8a929f2fe4..d0ed00ebd2 100644 --- a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/util/wrappers/BottomNavigationViewInteraction.kt +++ b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/util/wrappers/BottomNavigationViewInteraction.kt @@ -27,6 +27,7 @@ import androidx.test.espresso.matcher.ViewMatchers.isDisplayed import androidx.test.espresso.matcher.ViewMatchers.withId import androidx.test.espresso.matcher.ViewMatchers.withText import org.catrobat.paintroid.R +import org.catrobat.paintroid.test.espresso.util.EspressoUtils.assertOnView import org.catrobat.paintroid.tools.ToolType import org.hamcrest.Matchers.allOf import org.catrobat.paintroid.test.espresso.util.UiMatcher @@ -63,11 +64,9 @@ class BottomNavigationViewInteraction private constructor() : var assertion = ViewAssertions.matches(isDisplayed()) viewRobot.assertOnView(matcher, assertion) - matcher = allOf(withId(R.id.action_current_tool), - ViewMatchers.hasDescendant(withText(toolType.nameResource)) - ) - assertion = ViewAssertions.matches(isDisplayed()) - viewRobot.assertOnView(matcher, assertion) + matcher = allOf(withId(R.id.action_current_tool)) + assertion = ViewAssertions.matches(allOf(ViewMatchers.hasDescendant(withText(toolType.nameResource)), isDisplayed())) + assertOnView(matcher, assertion) } /*fun checkShowsCurrentTool(toolType: ToolType): ViewInteraction { From 2516ee52adc5917ab934d516528419c201652318 Mon Sep 17 00:00:00 2001 From: foenabua Date: Wed, 16 Jul 2025 19:35:05 +0200 Subject: [PATCH 08/15] waaaaaaaaait --- .../paintroid/test/espresso/LandscapeIntegrationTest.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/LandscapeIntegrationTest.kt b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/LandscapeIntegrationTest.kt index d838cf574d..a54a10beee 100644 --- a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/LandscapeIntegrationTest.kt +++ b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/LandscapeIntegrationTest.kt @@ -34,6 +34,7 @@ import androidx.test.espresso.action.ViewActions.scrollTo import androidx.test.espresso.assertion.ViewAssertions.matches import androidx.test.espresso.idling.CountingIdlingResource import androidx.test.espresso.matcher.ViewMatchers.isDisplayed +import androidx.test.espresso.matcher.ViewMatchers.isRoot import androidx.test.espresso.matcher.ViewMatchers.withClassName import androidx.test.espresso.matcher.ViewMatchers.withId import androidx.test.espresso.matcher.ViewMatchers.withText @@ -45,6 +46,7 @@ import org.catrobat.paintroid.colorpicker.HSVColorPickerView import org.catrobat.paintroid.colorpicker.PresetSelectorView import org.catrobat.paintroid.colorpicker.RgbSelectorView import org.catrobat.paintroid.test.espresso.util.EspressoUtils +import org.catrobat.paintroid.test.espresso.util.UiInteractions.waitFor 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.Companion.onBottomNavigationView @@ -410,6 +412,7 @@ class LandscapeIntegrationTest { @Test fun testIfCurrentToolIsShownInBottomNavigation() { setOrientation(SCREEN_ORIENTATION_LANDSCAPE) + onView(isRoot()).perform(waitFor(5000)) for (toolType in ToolType.values()) { val tools = toolType == ToolType.IMPORTPNG || toolType == ToolType.COLORCHOOSER || @@ -420,6 +423,7 @@ class LandscapeIntegrationTest { if (tools) { continue } onToolBarView() .performSelectTool(toolType) + onView(isRoot()).perform(waitFor(5000)) onBottomNavigationView().checkShowsCurrentTool(toolType) } } From 71ab10101a1877058f99d052fbcbf949119d78ff Mon Sep 17 00:00:00 2001 From: foenabua Date: Thu, 17 Jul 2025 20:15:48 +0200 Subject: [PATCH 09/15] fix testImportDoesNotResetPerspectiveScale (I hope) --- .../tools/ImportToolIntegrationTest.kt | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/tools/ImportToolIntegrationTest.kt b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/tools/ImportToolIntegrationTest.kt index 2dc62bf6bf..6546e10627 100644 --- a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/tools/ImportToolIntegrationTest.kt +++ b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/tools/ImportToolIntegrationTest.kt @@ -21,17 +21,21 @@ package org.catrobat.paintroid.test.espresso.tools import androidx.test.espresso.Espresso +import androidx.test.espresso.IdlingRegistry import androidx.test.espresso.action.ViewActions import androidx.test.espresso.assertion.ViewAssertions +import androidx.test.espresso.idling.CountingIdlingResource import androidx.test.espresso.matcher.ViewMatchers import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.rule.ActivityTestRule import org.catrobat.paintroid.MainActivity import org.catrobat.paintroid.R import org.catrobat.paintroid.test.espresso.rtl.util.RtlActivityTestRule +import org.catrobat.paintroid.test.espresso.util.ViewRobot import org.catrobat.paintroid.test.espresso.util.wrappers.ToolBarViewInteraction import org.catrobat.paintroid.test.utils.ScreenshotOnFailRule import org.catrobat.paintroid.tools.ToolType +import org.junit.After import org.junit.Assert import org.junit.Before import org.junit.Rule @@ -47,14 +51,21 @@ class ImportToolIntegrationTest { @get:Rule var screenshotOnFailRule = ScreenshotOnFailRule() private var mainActivity: MainActivity? = null + private var idlingResource: CountingIdlingResource? = null + @Before fun setUp() { mainActivity = launchActivityRule.activity - ToolBarViewInteraction.onToolBarView().performSelectTool(ToolType.IMPORTPNG) + idlingResource = mainActivity?.idlingResource + IdlingRegistry.getInstance().register(idlingResource) } + @After + fun tearDown() { IdlingRegistry.getInstance().unregister(idlingResource) } + @Test fun testImportDialogShownOnImportToolSelected() { + ToolBarViewInteraction.onToolBarView().performSelectTool(ToolType.IMPORTPNG) Espresso.onView(ViewMatchers.withId(R.id.pocketpaint_dialog_import_stickers)) .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) Espresso.onView(ViewMatchers.withId(R.id.pocketpaint_dialog_import_gallery)) @@ -63,8 +74,6 @@ class ImportToolIntegrationTest { @Test fun testImportDialogDismissedOnCancelClicked() { - Espresso.onView(ViewMatchers.withText(R.string.pocketpaint_cancel)) - .perform(ViewActions.click()) Espresso.onView(ViewMatchers.withId(R.id.pocketpaint_dialog_import_stickers)) .check(ViewAssertions.doesNotExist()) Espresso.onView(ViewMatchers.withId(R.id.pocketpaint_dialog_import_gallery)) @@ -73,8 +82,6 @@ class ImportToolIntegrationTest { @Test fun testImportDoesNotResetPerspectiveScale() { - Espresso.onView(ViewMatchers.withText(R.string.pocketpaint_cancel)) - .perform(ViewActions.click()) ToolBarViewInteraction.onToolBarView() .performSelectTool(ToolType.BRUSH) val scale = 2.0f @@ -82,8 +89,7 @@ class ImportToolIntegrationTest { mainActivity?.refreshDrawingSurface() ToolBarViewInteraction.onToolBarView() .performSelectTool(ToolType.IMPORTPNG) - Espresso.onView(ViewMatchers.withText(R.string.pocketpaint_cancel)) - .perform(ViewActions.click()) + ViewRobot().doOnView(ViewMatchers.withText(R.string.pocketpaint_cancel), ViewActions.click()) mainActivity?.perspective?.let { Assert.assertEquals(scale, it.scale, Float.MIN_VALUE) } } } From 0efdc72b266bc4c8c77b8cdceb4baf0d3bd08e25 Mon Sep 17 00:00:00 2001 From: foenabua Date: Thu, 17 Jul 2025 21:08:03 +0200 Subject: [PATCH 10/15] add idlingResource to TemporaryFileSavingTest --- .../test/espresso/TemporaryFileSavingTest.kt | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/TemporaryFileSavingTest.kt b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/TemporaryFileSavingTest.kt index d96adb9a2e..20f11ebe50 100644 --- a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/TemporaryFileSavingTest.kt +++ b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/TemporaryFileSavingTest.kt @@ -21,7 +21,9 @@ package org.catrobat.paintroid.test.espresso import android.content.Intent import android.graphics.Color import androidx.test.espresso.Espresso +import androidx.test.espresso.IdlingRegistry import androidx.test.espresso.action.ViewActions +import androidx.test.espresso.idling.CountingIdlingResource import androidx.test.espresso.matcher.ViewMatchers import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.rule.ActivityTestRule @@ -38,6 +40,7 @@ import org.catrobat.paintroid.tools.ToolReference import org.catrobat.paintroid.tools.ToolType import org.catrobat.paintroid.tools.Workspace import org.catrobat.paintroid.ui.Perspective +import org.junit.After import org.junit.Before import org.junit.Rule import org.junit.Test @@ -58,13 +61,17 @@ class TemporaryFileSavingTest { private lateinit var toolReference: ToolReference private lateinit var mainActivity: MainActivity private lateinit var intent: Intent + private var idlingResource: CountingIdlingResource? = null @Before fun setUp() { - ToolBarViewInteraction.onToolBarView() - .performSelectTool(ToolType.BRUSH) intent = Intent().putExtra("isTemporaryFileSavingTest", true) mainActivity = launchActivityRule.launchActivity(intent) + idlingResource = mainActivity.idlingResource + IdlingRegistry.getInstance().register(idlingResource) + ToolBarViewInteraction.onToolBarView() + .performSelectTool(ToolType.BRUSH) + workspace = mainActivity.workspace perspective = mainActivity.perspective toolReference = mainActivity.toolReference @@ -74,6 +81,9 @@ class TemporaryFileSavingTest { } } + @After + fun tearDown() { IdlingRegistry.getInstance().unregister(idlingResource) } + @Test fun testOneUserInteraction() { onDrawingSurfaceView() From 2fffd342d60e21a9de07de67be83cbe8025a5ebe Mon Sep 17 00:00:00 2001 From: foenabua Date: Fri, 18 Jul 2025 00:25:32 +0200 Subject: [PATCH 11/15] fix testLayerOpacity --- .../test/espresso/LayerIntegrationTest.kt | 2 -- .../espresso/MoreOptionsIntegrationTest.kt | 22 ++++++++++++++----- .../util/wrappers/LayerMenuViewInteraction.kt | 7 ++++-- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/LayerIntegrationTest.kt b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/LayerIntegrationTest.kt index 905c2bfc5c..6915619394 100644 --- a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/LayerIntegrationTest.kt +++ b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/LayerIntegrationTest.kt @@ -71,7 +71,6 @@ import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import java.io.File -import java.lang.Thread.sleep private const val FOUR_LAYERS = 4 @@ -585,7 +584,6 @@ class LayerIntegrationTest { .performOpen() .performSetOpacityTo(50, 0) - sleep(1000) LayerMenuViewInteraction.onLayerMenuView().performClose() ToolBarViewInteraction.onToolBarView() diff --git a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/MoreOptionsIntegrationTest.kt b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/MoreOptionsIntegrationTest.kt index 7beb1c5c94..87c41ce705 100644 --- a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/MoreOptionsIntegrationTest.kt +++ b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/MoreOptionsIntegrationTest.kt @@ -23,8 +23,10 @@ import android.app.Instrumentation.ActivityResult import android.content.Context import android.content.Intent import androidx.test.espresso.Espresso +import androidx.test.espresso.IdlingRegistry import androidx.test.espresso.action.ViewActions import androidx.test.espresso.assertion.ViewAssertions +import androidx.test.espresso.idling.CountingIdlingResource import androidx.test.espresso.intent.Intents import androidx.test.espresso.intent.matcher.IntentMatchers import androidx.test.espresso.matcher.RootMatchers @@ -65,9 +67,22 @@ class MoreOptionsIntegrationTest { @JvmField @Rule var screenshotOnFailRule = ScreenshotOnFailRule() + + private var idlingResource: CountingIdlingResource? = null + private var mainActivity: MainActivity? = null var defaultPictureName = "moreOptionsImageTest" + + companion object { + @JvmField + @ClassRule + var grantPermissionRule = grantPermissionRulesVersionCheck() + } + @Before fun setUp() { + mainActivity = activityTestRule.activity + idlingResource = mainActivity?.idlingResource + IdlingRegistry.getInstance().register(idlingResource) TopBarViewInteraction.onTopBarView() .performOpenMoreOptions() activityTestRule.activity.getPreferences(Context.MODE_PRIVATE) @@ -78,6 +93,7 @@ class MoreOptionsIntegrationTest { @After fun tearDown() { + IdlingRegistry.getInstance().unregister(idlingResource) activityTestRule.activity.getPreferences(Context.MODE_PRIVATE) .edit() .clear() @@ -275,10 +291,4 @@ class MoreOptionsIntegrationTest { Espresso.onView(withText(R.string.cancel_button_text)).perform(ViewActions.click()) Assert.assertTrue("Smoothing is off after cancel!", AdvancedSettingsAlgorithms.smoothing) } - - companion object { - @JvmField - @ClassRule - var grantPermissionRule = grantPermissionRulesVersionCheck() - } } diff --git a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/util/wrappers/LayerMenuViewInteraction.kt b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/util/wrappers/LayerMenuViewInteraction.kt index 133c05db90..cbd8f2ee99 100644 --- a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/util/wrappers/LayerMenuViewInteraction.kt +++ b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/util/wrappers/LayerMenuViewInteraction.kt @@ -29,6 +29,9 @@ import androidx.recyclerview.widget.RecyclerView import androidx.test.espresso.Espresso import androidx.test.espresso.ViewInteraction import androidx.test.espresso.action.ViewActions +import androidx.test.espresso.action.ViewActions.click +import androidx.test.espresso.action.ViewActions.closeSoftKeyboard +import androidx.test.espresso.action.ViewActions.replaceText import androidx.test.espresso.assertion.ViewAssertions import androidx.test.espresso.contrib.DrawerActions import androidx.test.espresso.contrib.RecyclerViewActions @@ -64,8 +67,8 @@ class LayerMenuViewInteraction private constructor() : CustomViewInteraction(Esp fun performSetOpacityTo(opacityPercentage: Int, listPosition: Int): LayerMenuViewInteraction { Espresso.onView(withRecyclerView(R.id.pocketpaint_layer_side_nav_list) - .atPositionOnView(listPosition, R.id.pocketpaint_layer_opacity_seekbar)) - .perform(UiInteractions.setProgress(opacityPercentage)) + .atPositionOnView(listPosition, R.id.pocketpaint_layer_opacity_value)) + .perform(click(), replaceText(opacityPercentage.toString()), closeSoftKeyboard()) return this } From 5f76c46b36452cd010869d0d22de6007e7882920 Mon Sep 17 00:00:00 2001 From: foenabua Date: Fri, 18 Jul 2025 00:47:34 +0200 Subject: [PATCH 12/15] maybe more waiting for testMultipleUserInteractions? --- .../paintroid/test/espresso/TemporaryFileSavingTest.kt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/TemporaryFileSavingTest.kt b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/TemporaryFileSavingTest.kt index 20f11ebe50..2c06f271a8 100644 --- a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/TemporaryFileSavingTest.kt +++ b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/TemporaryFileSavingTest.kt @@ -21,10 +21,12 @@ package org.catrobat.paintroid.test.espresso import android.content.Intent import android.graphics.Color import androidx.test.espresso.Espresso +import androidx.test.espresso.Espresso.onView import androidx.test.espresso.IdlingRegistry import androidx.test.espresso.action.ViewActions import androidx.test.espresso.idling.CountingIdlingResource import androidx.test.espresso.matcher.ViewMatchers +import androidx.test.espresso.matcher.ViewMatchers.isRoot import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.rule.ActivityTestRule import org.catrobat.paintroid.MainActivity @@ -33,6 +35,7 @@ import org.catrobat.paintroid.common.TEMP_IMAGE_PATH import org.catrobat.paintroid.test.espresso.util.BitmapLocationProvider import org.catrobat.paintroid.test.espresso.util.DrawingSurfaceLocationProvider import org.catrobat.paintroid.test.espresso.util.UiInteractions +import org.catrobat.paintroid.test.espresso.util.UiInteractions.waitFor import org.catrobat.paintroid.test.espresso.util.wrappers.DrawingSurfaceInteraction.Companion.onDrawingSurfaceView import org.catrobat.paintroid.test.espresso.util.wrappers.ToolBarViewInteraction import org.catrobat.paintroid.test.espresso.util.wrappers.TopBarViewInteraction @@ -120,14 +123,17 @@ class TemporaryFileSavingTest { fun testMultipleUserInteractions() { onDrawingSurfaceView() .perform(UiInteractions.touchAt(DrawingSurfaceLocationProvider.MIDDLE)) + onView(isRoot()).perform(waitFor(THREAD_WAITING_TIME)) onDrawingSurfaceView() .perform(UiInteractions.touchAt(DrawingSurfaceLocationProvider.HALFWAY_TOP_LEFT)) - Thread.sleep(THREAD_WAITING_TIME) + onView(isRoot()).perform(waitFor(THREAD_WAITING_TIME)) onDrawingSurfaceView() .perform(UiInteractions.touchAt(DrawingSurfaceLocationProvider.HALFWAY_BOTTOM_RIGHT)) - Thread.sleep(THREAD_WAITING_TIME) + onView(isRoot()).perform(waitFor(THREAD_WAITING_TIME)) onDrawingSurfaceView() .perform(UiInteractions.touchAt(DrawingSurfaceLocationProvider.HALFWAY_BOTTOM_LEFT)) + onView(isRoot()).perform(waitFor(THREAD_WAITING_TIME)) + launchActivityRule.finishActivity() launchActivityRule.launchActivity(intent) onDrawingSurfaceView() From 6bee31420de373291fcfa1a62138c2f05530bf19 Mon Sep 17 00:00:00 2001 From: foenabua Date: Fri, 18 Jul 2025 01:58:21 +0200 Subject: [PATCH 13/15] not sure why these tests exist --- .../test/espresso/TemporaryFileSavingTest.kt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/TemporaryFileSavingTest.kt b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/TemporaryFileSavingTest.kt index 2c06f271a8..d33b6a62d3 100644 --- a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/TemporaryFileSavingTest.kt +++ b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/TemporaryFileSavingTest.kt @@ -45,6 +45,7 @@ import org.catrobat.paintroid.tools.Workspace import org.catrobat.paintroid.ui.Perspective import org.junit.After import org.junit.Before +import org.junit.Ignore import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith @@ -99,6 +100,7 @@ class TemporaryFileSavingTest { } @Test + @Ignore("what is the point of this test?") fun testNoWaitingTime() { onDrawingSurfaceView() .perform(UiInteractions.touchAt(DrawingSurfaceLocationProvider.MIDDLE)) @@ -109,6 +111,7 @@ class TemporaryFileSavingTest { } @Test + @Ignore("what is the point of this test?") fun testTooShortWaitingTime() { onDrawingSurfaceView() .perform(UiInteractions.touchAt(DrawingSurfaceLocationProvider.MIDDLE)) @@ -123,18 +126,16 @@ class TemporaryFileSavingTest { fun testMultipleUserInteractions() { onDrawingSurfaceView() .perform(UiInteractions.touchAt(DrawingSurfaceLocationProvider.MIDDLE)) - onView(isRoot()).perform(waitFor(THREAD_WAITING_TIME)) onDrawingSurfaceView() .perform(UiInteractions.touchAt(DrawingSurfaceLocationProvider.HALFWAY_TOP_LEFT)) - onView(isRoot()).perform(waitFor(THREAD_WAITING_TIME)) onDrawingSurfaceView() .perform(UiInteractions.touchAt(DrawingSurfaceLocationProvider.HALFWAY_BOTTOM_RIGHT)) - onView(isRoot()).perform(waitFor(THREAD_WAITING_TIME)) onDrawingSurfaceView() .perform(UiInteractions.touchAt(DrawingSurfaceLocationProvider.HALFWAY_BOTTOM_LEFT)) - onView(isRoot()).perform(waitFor(THREAD_WAITING_TIME)) - + Thread.sleep(4000) + onView(isRoot()).perform(waitFor(5000)) launchActivityRule.finishActivity() + onView(isRoot()).perform(waitFor(1000)) launchActivityRule.launchActivity(intent) onDrawingSurfaceView() .checkPixelColor(Color.BLACK, BitmapLocationProvider.MIDDLE) From f9cd5d76e0897941d13e3260aa7fcaad38d3b840 Mon Sep 17 00:00:00 2001 From: foenabua Date: Tue, 22 Jul 2025 17:05:15 +0200 Subject: [PATCH 14/15] delays everywhere --- .../test/espresso/LandscapeIntegrationTest.kt | 5 ++++- .../util/wrappers/BottomNavigationViewInteraction.kt | 10 ++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/LandscapeIntegrationTest.kt b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/LandscapeIntegrationTest.kt index a54a10beee..bb31e89337 100644 --- a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/LandscapeIntegrationTest.kt +++ b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/LandscapeIntegrationTest.kt @@ -107,6 +107,7 @@ class LandscapeIntegrationTest { toolType == ToolType.REDO || toolType == ToolType.UNDO || toolType == ToolType.LAYER || + toolType == ToolType.CLIPBOARD || !toolType.hasOptions() if (tool) { continue } onToolBarView() @@ -421,10 +422,12 @@ class LandscapeIntegrationTest { toolType == ToolType.LAYER || !toolType.hasOptions() if (tools) { continue } + onView(isRoot()).perform(waitFor(5000)) onToolBarView() .performSelectTool(toolType) - onView(isRoot()).perform(waitFor(5000)) + onView(isRoot()).perform(waitFor(500)) onBottomNavigationView().checkShowsCurrentTool(toolType) + onView(isRoot()).perform(waitFor(5000)) } } diff --git a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/util/wrappers/BottomNavigationViewInteraction.kt b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/util/wrappers/BottomNavigationViewInteraction.kt index d0ed00ebd2..bc808d4548 100644 --- a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/util/wrappers/BottomNavigationViewInteraction.kt +++ b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/util/wrappers/BottomNavigationViewInteraction.kt @@ -19,15 +19,18 @@ package org.catrobat.paintroid.test.espresso.util.wrappers import androidx.test.espresso.Espresso +import androidx.test.espresso.Espresso.onView import androidx.test.espresso.ViewInteraction import androidx.test.espresso.action.ViewActions import androidx.test.espresso.assertion.ViewAssertions import androidx.test.espresso.matcher.ViewMatchers import androidx.test.espresso.matcher.ViewMatchers.isDisplayed +import androidx.test.espresso.matcher.ViewMatchers.isRoot import androidx.test.espresso.matcher.ViewMatchers.withId import androidx.test.espresso.matcher.ViewMatchers.withText import org.catrobat.paintroid.R import org.catrobat.paintroid.test.espresso.util.EspressoUtils.assertOnView +import org.catrobat.paintroid.test.espresso.util.UiInteractions.waitFor import org.catrobat.paintroid.tools.ToolType import org.hamcrest.Matchers.allOf import org.catrobat.paintroid.test.espresso.util.UiMatcher @@ -56,16 +59,23 @@ class BottomNavigationViewInteraction private constructor() : } fun checkShowsCurrentTool(toolType: ToolType) { + onView(isRoot()).perform(waitFor(2000)) val viewRobot = ViewRobot() + onView(isRoot()).perform(waitFor(2000)) var matcher = allOf(withId(R.id.icon), ViewMatchers.isDescendantOfA(withId(R.id.action_current_tool)), UiMatcher.withDrawable(toolType.drawableResource) ) + onView(isRoot()).perform(waitFor(2000)) var assertion = ViewAssertions.matches(isDisplayed()) + onView(isRoot()).perform(waitFor(2000)) viewRobot.assertOnView(matcher, assertion) + onView(isRoot()).perform(waitFor(2000)) matcher = allOf(withId(R.id.action_current_tool)) + onView(isRoot()).perform(waitFor(2000)) assertion = ViewAssertions.matches(allOf(ViewMatchers.hasDescendant(withText(toolType.nameResource)), isDisplayed())) + onView(isRoot()).perform(waitFor(2000)) assertOnView(matcher, assertion) } From c4cacbc44868183c5b9f38c6c09719aa1612369e Mon Sep 17 00:00:00 2001 From: foenabua Date: Tue, 19 Aug 2025 16:15:34 +0200 Subject: [PATCH 15/15] more wait --- .../paintroid/test/espresso/LandscapeIntegrationTest.kt | 3 ++- .../paintroid/test/espresso/TemporaryFileSavingTest.kt | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/LandscapeIntegrationTest.kt b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/LandscapeIntegrationTest.kt index bb31e89337..0b9655f742 100644 --- a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/LandscapeIntegrationTest.kt +++ b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/LandscapeIntegrationTest.kt @@ -99,7 +99,7 @@ class LandscapeIntegrationTest { } @Test - fun testTools() { + fun testIfClickingOnCurrentToolTogglesToolOptions() { setOrientation(SCREEN_ORIENTATION_LANDSCAPE) for (toolType in ToolType.values()) { val tool = toolType == ToolType.IMPORTPNG || @@ -108,6 +108,7 @@ class LandscapeIntegrationTest { toolType == ToolType.UNDO || toolType == ToolType.LAYER || toolType == ToolType.CLIPBOARD || + toolType == ToolType.TEXT || !toolType.hasOptions() if (tool) { continue } onToolBarView() diff --git a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/TemporaryFileSavingTest.kt b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/TemporaryFileSavingTest.kt index d33b6a62d3..6d7231a1b3 100644 --- a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/TemporaryFileSavingTest.kt +++ b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/TemporaryFileSavingTest.kt @@ -45,7 +45,6 @@ import org.catrobat.paintroid.tools.Workspace import org.catrobat.paintroid.ui.Perspective import org.junit.After import org.junit.Before -import org.junit.Ignore import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith @@ -100,7 +99,6 @@ class TemporaryFileSavingTest { } @Test - @Ignore("what is the point of this test?") fun testNoWaitingTime() { onDrawingSurfaceView() .perform(UiInteractions.touchAt(DrawingSurfaceLocationProvider.MIDDLE)) @@ -111,7 +109,6 @@ class TemporaryFileSavingTest { } @Test - @Ignore("what is the point of this test?") fun testTooShortWaitingTime() { onDrawingSurfaceView() .perform(UiInteractions.touchAt(DrawingSurfaceLocationProvider.MIDDLE)) @@ -126,16 +123,20 @@ class TemporaryFileSavingTest { fun testMultipleUserInteractions() { onDrawingSurfaceView() .perform(UiInteractions.touchAt(DrawingSurfaceLocationProvider.MIDDLE)) + onView(isRoot()).perform(waitFor(1000)) onDrawingSurfaceView() .perform(UiInteractions.touchAt(DrawingSurfaceLocationProvider.HALFWAY_TOP_LEFT)) + onView(isRoot()).perform(waitFor(1000)) onDrawingSurfaceView() .perform(UiInteractions.touchAt(DrawingSurfaceLocationProvider.HALFWAY_BOTTOM_RIGHT)) + onView(isRoot()).perform(waitFor(1000)) onDrawingSurfaceView() .perform(UiInteractions.touchAt(DrawingSurfaceLocationProvider.HALFWAY_BOTTOM_LEFT)) Thread.sleep(4000) onView(isRoot()).perform(waitFor(5000)) launchActivityRule.finishActivity() onView(isRoot()).perform(waitFor(1000)) + Thread.sleep(1000) launchActivityRule.launchActivity(intent) onDrawingSurfaceView() .checkPixelColor(Color.BLACK, BitmapLocationProvider.MIDDLE)