Skip to content

Commit

Permalink
PAINTROID-631 ToolSelectionIntegrationTest & LandscapeIntegrationTest
Browse files Browse the repository at this point in the history
  • Loading branch information
khalid-nasralla committed Aug 27, 2023
1 parent bd080c0 commit 39be59f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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())))
}
Expand Down Expand Up @@ -418,6 +421,7 @@ class LandscapeIntegrationTest {
if (tools) { continue }
onToolBarView()
.performSelectTool(toolType)
onView(ViewMatchers.isRoot()).perform(UiInteractions.waitFor(9999))
onBottomNavigationView()
.checkShowsCurrentTool(toolType)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -65,15 +65,15 @@ class ToolBarViewInteraction :

fun performOpenToolOptionsView(): ToolBarViewInteraction {
onToolOptionsView()
.check(ViewAssertions.matches(Matchers.not(ViewMatchers.isDisplayed())))
.check(ViewAssertions.matches(Matchers.not(isDisplayed())))
onBottomNavigationView()
.onCurrentClicked()
return this
}

fun performCloseToolOptionsView(): ToolBarViewInteraction {
onToolOptionsView()
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))
.check(ViewAssertions.matches(isDisplayed()))
onBottomNavigationView()
.onCurrentClicked()
return this
Expand Down

0 comments on commit 39be59f

Please sign in to comment.