@@ -83,6 +83,9 @@ class ImportToolIntentTest {
8383 private var initialWidth = 0
8484 private var initialHeight = 0
8585 private var maxBitmapSize = 0
86+ private var initialBitmapHeight = 0
87+ private var initialBitmapWidth = 0
88+ private var maxWidth = 0
8689 private lateinit var idlingResource: CountingIdlingResource
8790 private lateinit var mainActivity: MainActivity
8891 private lateinit var activityHelper: MainActivityHelper
@@ -106,7 +109,15 @@ class ImportToolIntentTest {
106109 initialHeight = workingBitmap.height
107110 perspective = mainActivity.perspective
108111 workspace = mainActivity.workspace
112+ maxWidth = maxBitmapSize / initialHeight
113+ initialBitmapWidth = workspace.width
114+ initialBitmapHeight = workspace.height
115+ perspective.multiplyScale(.25f )
109116 saveTestImage()
117+ val imgGalleryResult = createImageGallerySetResultStub(mainActivity)
118+ intending(hasAction(Intent .ACTION_GET_CONTENT )).respondWith(imgGalleryResult)
119+ onView(withId(R .id.pocketpaint_dialog_import_gallery))
120+ .perform(click())
110121 }
111122
112123 @After
@@ -117,20 +128,11 @@ class ImportToolIntentTest {
117128
118129 @Test
119130 fun testEnlargeCanvas () {
120- val maxWidth = maxBitmapSize / initialHeight
121- var initialBitmapWidth = workspace.width
122- var initialBitmapHeight = workspace.height
123- perspective.multiplyScale(.25f )
124131 var dragFrom = perspective.getSurfacePointFromCanvasPoint(
125132 PointF (initialBitmapWidth.toFloat(), initialBitmapHeight.toFloat()))
126133 var dragTo = perspective.getSurfacePointFromCanvasPoint(
127134 PointF (maxWidth + 10f , initialHeight.toFloat()))
128135
129- val imgGalleryResult = createImageGallerySetResultStub(mainActivity)
130- intending(hasAction(Intent .ACTION_GET_CONTENT )).respondWith(imgGalleryResult)
131- onView(withId(R .id.pocketpaint_dialog_import_gallery))
132- .perform(click())
133-
134136 DrawingSurfaceInteraction .onDrawingSurfaceView()
135137 .perform(UiInteractions .swipe(dragFrom, dragTo))
136138 TopBarViewInteraction .onTopBarView().performClickCheckmark()
@@ -164,6 +166,24 @@ class ImportToolIntentTest {
164166 initialBitmapHeight * initialBitmapWidth, workspace.height * workspace.width)
165167 }
166168
169+ @Test
170+ fun testEnlargeWhenSwitchingTool () {
171+ val dragFrom = perspective.getSurfacePointFromCanvasPoint(
172+ PointF (initialBitmapWidth.toFloat(), initialBitmapHeight.toFloat()))
173+ val dragTo = perspective.getSurfacePointFromCanvasPoint(
174+ PointF (maxWidth + 10f , initialHeight.toFloat()))
175+
176+ DrawingSurfaceInteraction .onDrawingSurfaceView()
177+ .perform(UiInteractions .swipe(dragFrom, dragTo))
178+ ToolBarViewInteraction .onToolBarView()
179+ .performSelectTool(ToolType .BRUSH )
180+
181+ onView(withText(R .string.dialog_import_image_enlarge_image)).check(
182+ ViewAssertions .matches(ViewMatchers .isDisplayed()))
183+ onView(withText(R .string.pocketpaint_enlarge)).perform(click())
184+ Assert .assertTrue(initialBitmapHeight * initialBitmapWidth < workspace.height * workspace.width)
185+ }
186+
167187 private fun saveTestImage () {
168188 val bm = BitmapFactory .decodeResource(intentsTestRule.activity.resources, R .drawable.pocketpaint_logo)
169189 val dir = intentsTestRule.activity.externalCacheDir
0 commit comments