Skip to content

Commit 4554a24

Browse files
committed
add additional idling resource in tool switch and change assertion
1 parent 8b662ee commit 4554a24

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/LayerIntegrationTest.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ import org.junit.Rule
7171
import org.junit.Test
7272
import org.junit.runner.RunWith
7373
import java.io.File
74+
import java.lang.Thread.sleep
7475

7576
private const val FOUR_LAYERS = 4
7677

@@ -583,7 +584,9 @@ class LayerIntegrationTest {
583584
LayerMenuViewInteraction.onLayerMenuView()
584585
.performOpen()
585586
.performSetOpacityTo(50, 0)
586-
.performClose()
587+
588+
sleep(1000)
589+
LayerMenuViewInteraction.onLayerMenuView().performClose()
587590

588591
ToolBarViewInteraction.onToolBarView()
589592
.performSelectTool(ToolType.PIPETTE)

Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/util/wrappers/BottomNavigationViewInteraction.kt

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import org.catrobat.paintroid.tools.ToolType
3232
import org.hamcrest.Matchers.allOf
3333
import org.catrobat.paintroid.test.espresso.util.EspressoUtils
3434
import org.catrobat.paintroid.test.espresso.util.UiMatcher
35+
import org.hamcrest.Matchers
3536

3637
class BottomNavigationViewInteraction private constructor() :
3738
CustomViewInteraction(Espresso.onView(withId(R.id.pocketpaint_bottom_navigation))) {
@@ -59,13 +60,36 @@ class BottomNavigationViewInteraction private constructor() :
5960
var matcher = allOf(withId(R.id.icon),
6061
ViewMatchers.isDescendantOfA(withId(R.id.action_current_tool)),
6162
UiMatcher.withDrawable(R.drawable.ic_pocketpaint_tool_brush))
62-
var assertion = ViewAssertions.matches(isDisplayed())
63+
var assertion = ViewAssertions.matches(
64+
Matchers.allOf(
65+
isDisplayed(),
66+
UiMatcher.withDrawable(toolType.drawableResource)
67+
)
68+
)
6369
EspressoUtils.assertOnView(matcher, assertion)
6470

65-
matcher = allOf(withId(R.id.action_current_tool), ViewMatchers.hasDescendant(withText(toolType.nameResource)))
71+
matcher = allOf(withId(R.id.action_current_tool))
72+
assertion = ViewAssertions.matches(
73+
Matchers.allOf(
74+
isDisplayed(),
75+
ViewMatchers.hasDescendant(withText(toolType.nameResource))
76+
)
77+
)
6678
EspressoUtils.assertOnView(matcher, assertion)
6779
}
6880

81+
/*fun checkShowsCurrentTool(toolType: ToolType): ViewInteraction {
82+
Espresso.onView(
83+
allOf(
84+
withId(R.id.icon),
85+
ViewMatchers.isDescendantOfA(withId(R.id.action_current_tool))
86+
)
87+
)
88+
.check(ViewAssertions.matches(UiMatcher.withDrawable(toolType.drawableResource)))
89+
return Espresso.onView(withId(R.id.action_current_tool))
90+
.check(ViewAssertions.matches(ViewMatchers.hasDescendant(ViewMatchers.withText(toolType.nameResource))))
91+
}*/
92+
6993
fun onColorClicked(): ViewInteraction {
7094
return Espresso.onView(
7195
allOf(

Paintroid/src/main/java/org/catrobat/paintroid/controller/DefaultToolController.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@ class DefaultToolController(
103103
}
104104

105105
override fun switchTool(toolType: ToolType) {
106+
idlingResource.increment()
106107
switchTool(createAndSetupTool(toolType))
108+
idlingResource.decrement()
107109
}
108110

109111
override fun hideToolOptionsView() {

0 commit comments

Comments
 (0)