From 39be59f14f055724f962d5be20c7e0f45342c8d5 Mon Sep 17 00:00:00 2001 From: Khalid Nasralla Date: Sun, 27 Aug 2023 23:50:14 +0200 Subject: [PATCH] PAINTROID-631 ToolSelectionIntegrationTest & LandscapeIntegrationTest --- .../test/espresso/LandscapeIntegrationTest.kt | 8 ++++++-- .../test/espresso/ToolSelectionIntegrationTest.kt | 4 ++++ .../util/wrappers/BottomNavigationViewInteraction.kt | 11 ++--------- .../espresso/util/wrappers/ToolBarViewInteraction.kt | 6 +++--- 4 files changed, 15 insertions(+), 14 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 11c0738fda..69fcf74971 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 @@ -33,6 +33,7 @@ import androidx.test.espresso.action.ViewActions.click 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 import androidx.test.espresso.matcher.ViewMatchers.isDisplayed import androidx.test.espresso.matcher.ViewMatchers.withClassName import androidx.test.espresso.matcher.ViewMatchers.withId @@ -44,6 +45,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.UiInteractions 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 @@ -113,8 +115,9 @@ class LandscapeIntegrationTest { onToolBarView() .performClickSelectedToolButton() } - onBottomNavigationView() - .onCurrentClicked() + onView(ViewMatchers.isRoot()).perform(UiInteractions.waitFor(5000)) + onBottomNavigationView().onCurrentClicked() + onView(ViewMatchers.isRoot()).perform(UiInteractions.waitFor(5000)) onView(withId(R.id.pocketpaint_layout_tool_specific_options)) .check(matches(not(isDisplayed()))) } @@ -418,6 +421,7 @@ class LandscapeIntegrationTest { if (tools) { continue } onToolBarView() .performSelectTool(toolType) + onView(ViewMatchers.isRoot()).perform(UiInteractions.waitFor(9999)) onBottomNavigationView() .checkShowsCurrentTool(toolType) } diff --git a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/ToolSelectionIntegrationTest.kt b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/ToolSelectionIntegrationTest.kt index e60a785fdb..74543e0f82 100644 --- a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/ToolSelectionIntegrationTest.kt +++ b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/ToolSelectionIntegrationTest.kt @@ -21,9 +21,12 @@ package org.catrobat.paintroid.test.espresso +import androidx.test.espresso.Espresso +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.test.espresso.util.UiInteractions import org.catrobat.paintroid.test.espresso.util.wrappers.BottomNavigationViewInteraction.Companion.onBottomNavigationView import org.catrobat.paintroid.test.espresso.util.wrappers.ToolBarViewInteraction.Companion.onToolBarView import org.catrobat.paintroid.test.utils.ScreenshotOnFailRule @@ -62,6 +65,7 @@ class ToolSelectionIntegrationTest { toolType === ToolType.LAYER if (tool) { continue } onToolBarView().performSelectTool(toolType) + Espresso.onView(ViewMatchers.isRoot()).perform(UiInteractions.waitFor(5000)) 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 182d6a5570..e8965c4a0c 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 @@ -51,16 +51,9 @@ 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)) - ) - ) + fun checkShowsCurrentTool(toolType: ToolType) { + 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 { diff --git a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/util/wrappers/ToolBarViewInteraction.kt b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/util/wrappers/ToolBarViewInteraction.kt index 21cbcf7523..0e0d4b639c 100644 --- a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/util/wrappers/ToolBarViewInteraction.kt +++ b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/util/wrappers/ToolBarViewInteraction.kt @@ -22,7 +22,7 @@ import androidx.test.espresso.Espresso 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 org.catrobat.paintroid.R import org.catrobat.paintroid.test.espresso.util.EspressoUtils @@ -65,7 +65,7 @@ class ToolBarViewInteraction : fun performOpenToolOptionsView(): ToolBarViewInteraction { onToolOptionsView() - .check(ViewAssertions.matches(Matchers.not(ViewMatchers.isDisplayed()))) + .check(ViewAssertions.matches(Matchers.not(isDisplayed()))) onBottomNavigationView() .onCurrentClicked() return this @@ -73,7 +73,7 @@ class ToolBarViewInteraction : fun performCloseToolOptionsView(): ToolBarViewInteraction { onToolOptionsView() - .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + .check(ViewAssertions.matches(isDisplayed())) onBottomNavigationView() .onCurrentClicked() return this