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

PAINTROID-631 ToolSelectionIntegrationTest & LandscapeIntegrationTest #1304

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
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