Skip to content

Commit

Permalink
Release v2.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
wslany authored May 22, 2022
2 parents 4a4bee5 + a75a804 commit e0df628
Show file tree
Hide file tree
Showing 247 changed files with 4,463 additions and 1,455 deletions.
16 changes: 0 additions & 16 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.action.ViewActions
import androidx.test.espresso.action.ViewActions.replaceText
import androidx.test.espresso.matcher.RootMatchers
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.rule.ActivityTestRule
import androidx.test.rule.GrantPermissionRule
import org.catrobat.paintroid.FileIO
import org.catrobat.paintroid.MainActivity
import org.catrobat.paintroid.R
import org.catrobat.paintroid.common.CATROBAT_IMAGE_ENDING
import org.catrobat.paintroid.test.espresso.util.DrawingSurfaceLocationProvider
import org.catrobat.paintroid.test.espresso.util.EspressoUtils
import org.catrobat.paintroid.test.espresso.util.UiInteractions
Expand Down Expand Up @@ -93,13 +93,12 @@ class CatrobatImageIOIntegrationTest {
Espresso.onData(
AllOf.allOf(
Matchers.`is`(Matchers.instanceOf<Any>(String::class.java)),
Matchers.`is`<String>(CATROBAT_IMAGE_ENDING)
Matchers.`is`<String>(FileIO.FileType.CATROBAT.value)
)
).inRoot(RootMatchers.isPlatformPopup()).perform(ViewActions.click())
onView(withId(R.id.pocketpaint_image_name_save_text))
.perform(replaceText(IMAGE_NAME))
onView(withText(R.string.save_button_text))
.perform(ViewActions.click())
onView(withText(R.string.save_button_text)).perform(ViewActions.click())
uriFile = activity.model.savedPictureUri!!
Assert.assertNotNull(uriFile)
Assert.assertNotNull(activity.workspace.getCommandSerializationHelper().readFromFile(uriFile))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import androidx.test.espresso.intent.Intents
import androidx.test.espresso.intent.matcher.IntentMatchers
import androidx.test.espresso.matcher.RootMatchers
import androidx.test.espresso.matcher.ViewMatchers
import androidx.test.espresso.matcher.ViewMatchers.isRoot
import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.rule.ActivityTestRule
Expand All @@ -44,6 +45,7 @@ import org.catrobat.paintroid.test.espresso.util.BitmapLocationProvider
import org.catrobat.paintroid.test.espresso.util.DrawingSurfaceLocationProvider
import org.catrobat.paintroid.test.espresso.util.EspressoUtils
import org.catrobat.paintroid.test.espresso.util.UiInteractions
import org.catrobat.paintroid.test.espresso.util.UiInteractions.waitFor
import org.catrobat.paintroid.test.espresso.util.UiMatcher
import org.catrobat.paintroid.test.espresso.util.wrappers.DrawingSurfaceInteraction
import org.catrobat.paintroid.test.espresso.util.wrappers.LayerMenuViewInteraction
Expand Down Expand Up @@ -351,6 +353,7 @@ class LayerIntegrationTest {
.perform(click())
onView(withText(R.string.save_button_text))
.perform(click())
onView(isRoot()).perform(waitFor(100))
ToolBarViewInteraction.onToolBarView()
.performSelectTool(ToolType.PIPETTE)
DrawingSurfaceInteraction.onDrawingSurfaceView()
Expand Down Expand Up @@ -642,8 +645,10 @@ class LayerIntegrationTest {
.performAddLayer()
.checkLayerCount(2)
.performToggleLayerVisibility(0)
.performLongClickLayer(0)
onView(withText(R.string.no_longclick_on_hidden_layer)).inRoot(RootMatchers.withDecorView(Matchers.not(launchActivityRule.activity.window.decorView))).check(ViewAssertions.matches(ViewMatchers.isDisplayed()))
.performStartDragging(0)
onView(withText(R.string.no_longclick_on_hidden_layer))
.inRoot(RootMatchers.withDecorView(Matchers.not(launchActivityRule.activity.window.decorView)))
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
/*
* Paintroid: An image manipulation application for Android.
* Copyright (C) 2010-2021 The Catrobat Team
* Copyright (C) 2010-2022 The Catrobat Team
* (<http://developer.catrobat.org/credits>)
*
* This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -40,6 +40,8 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;

import java.io.File;

import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.rule.ActivityTestRule;
Expand Down Expand Up @@ -89,6 +91,8 @@ public class MainActivityIntegrationTest {
private UserPreferences sharedPreferences;
@Mock
private Context context;
@Mock
private File internalMemoryPath;

@InjectMocks
private MainActivityPresenter presenter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,25 @@ import androidx.test.espresso.intent.Intents
import androidx.test.espresso.intent.matcher.IntentMatchers.hasAction
import androidx.test.espresso.intent.rule.IntentsTestRule
import androidx.test.espresso.matcher.RootMatchers
import androidx.test.espresso.matcher.ViewMatchers.isClickable
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.espresso.matcher.ViewMatchers.isRoot
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.withSpinnerText
import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.espresso.matcher.ViewMatchers.isClickable
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.rule.GrantPermissionRule
import kotlinx.coroutines.delay
import kotlinx.coroutines.runBlocking
import org.catrobat.paintroid.FileIO
import org.catrobat.paintroid.MainActivity
import org.catrobat.paintroid.R
import org.catrobat.paintroid.common.TEMP_PICTURE_NAME
import org.catrobat.paintroid.presenter.MainActivityPresenter
import org.catrobat.paintroid.test.espresso.util.BitmapLocationProvider
import org.catrobat.paintroid.test.espresso.util.DrawingSurfaceLocationProvider.HALFWAY_BOTTOM_MIDDLE
import org.catrobat.paintroid.test.espresso.util.DrawingSurfaceLocationProvider.HALFWAY_RIGHT_MIDDLE
import org.catrobat.paintroid.test.espresso.util.DrawingSurfaceLocationProvider.MIDDLE
import org.catrobat.paintroid.test.espresso.util.EspressoUtils.grantPermissionRulesVersionCheck
import org.catrobat.paintroid.test.espresso.util.UiInteractions.touchAt
import org.catrobat.paintroid.test.espresso.util.UiInteractions.waitFor
import org.catrobat.paintroid.test.espresso.util.wrappers.DrawingSurfaceInteraction.onDrawingSurfaceView
import org.catrobat.paintroid.test.espresso.util.wrappers.ToolBarViewInteraction
import org.catrobat.paintroid.test.espresso.util.wrappers.TopBarViewInteraction.onTopBarView
Expand Down Expand Up @@ -95,6 +94,7 @@ class MenuFileActivityIntegrationTest {
var screenshotOnFailRule = ScreenshotOnFailRule()

private lateinit var activity: MainActivity
private var defaultFileName = "menuTestDefaultFile"

companion object {
private lateinit var deletionFileList: ArrayList<File?>
Expand Down Expand Up @@ -125,17 +125,12 @@ class MenuFileActivityIntegrationTest {
onDrawingSurfaceView().checkPixelColor(Color.BLACK, BitmapLocationProvider.MIDDLE)
onTopBarView().performOpenMoreOptions()
onView(withText(R.string.menu_new_image)).perform(click())
runBlocking {
onView(withText(R.string.save_button_text))
.perform(click())
delay(100)
}
onView(withText(R.string.save_button_text)).perform(click())
onView(isRoot()).perform(waitFor(100))
onView(withId(R.id.pocketpaint_image_name_save_text))
.perform(replaceText("test987654"))
runBlocking {
onView(withText(R.string.save_button_text)).perform(click())
delay(100)
}
onView(withText(R.string.save_button_text)).perform(click())
onView(isRoot()).perform(waitFor(100))
onDrawingSurfaceView().checkPixelColor(Color.TRANSPARENT, BitmapLocationProvider.MIDDLE)
}

Expand Down Expand Up @@ -236,10 +231,8 @@ class MenuFileActivityIntegrationTest {
onView(withText(R.string.menu_save_image)).perform(click())
onView(withId(R.id.pocketpaint_image_name_save_text))
.perform(replaceText("test98765"))
runBlocking {
onView(withText(R.string.save_button_text)).perform(click())
delay(100)
}
onView(withText(R.string.save_button_text)).perform(click())
onView(isRoot()).perform(waitFor(100))
assertNotNull(activity.model.savedPictureUri)
addUriToDeletionFileList(activity.model.savedPictureUri)
assertTrue(activity.model.isSaved)
Expand All @@ -250,10 +243,8 @@ class MenuFileActivityIntegrationTest {
onDrawingSurfaceView().perform(touchAt(MIDDLE))
onTopBarView().performOpenMoreOptions()
onView(withText(R.string.menu_save_image)).perform(click())
runBlocking {
onView(withText(R.string.save_button_text)).perform(click())
delay(100)
}
onView(withText(R.string.save_button_text)).perform(click())
onView(isRoot()).perform(waitFor(100))
assertNotNull(activity.model.savedPictureUri)
if (!activity.model.isOpenedFromCatroid) {
assertNotSame(
Expand All @@ -275,10 +266,8 @@ class MenuFileActivityIntegrationTest {
onView(withText(R.string.menu_save_image)).perform(click())
onView(withId(R.id.pocketpaint_image_name_save_text))
.perform(replaceText("save1"))
runBlocking {
onView(withText(R.string.save_button_text)).perform(click())
delay(100)
}
onView(withText(R.string.save_button_text)).perform(click())
onView(isRoot()).perform(waitFor(100))
assertNotNull(activity.model.savedPictureUri)
if (!activity.model.isOpenedFromCatroid) {
assertNotSame(
Expand All @@ -295,10 +284,8 @@ class MenuFileActivityIntegrationTest {
onView(withText(R.string.menu_save_copy)).perform(click())
onView(withId(R.id.pocketpaint_image_name_save_text))
.perform(replaceText("copy1"))
runBlocking {
onView(withText(R.string.save_button_text)).perform(click())
delay(100)
}
onView(withText(R.string.save_button_text)).perform(click())
onView(isRoot()).perform(waitFor(100))
val newFile = File(activity.model.savedPictureUri.toString())
assertNotSame("Changes to saved", oldFile, newFile)
assertNotNull(activity.model.savedPictureUri)
Expand All @@ -318,10 +305,8 @@ class MenuFileActivityIntegrationTest {
onView(withText(R.string.menu_save_image)).perform(click())
onView(withId(R.id.pocketpaint_image_name_save_text))
.perform(replaceText("AskForSaveAfterSavedOnce"))
runBlocking {
onView(withText(R.string.save_button_text)).perform(click())
delay(100)
}
onView(withText(R.string.save_button_text)).perform(click())
onView(isRoot()).perform(waitFor(100))
assertNotNull(activity.model.savedPictureUri)
addUriToDeletionFileList(activity.model.savedPictureUri)
onDrawingSurfaceView().perform(touchAt(MIDDLE))
Expand All @@ -336,18 +321,14 @@ class MenuFileActivityIntegrationTest {
onView(withText(R.string.menu_save_image)).perform(click())
onView(withId(R.id.pocketpaint_image_name_save_text))
.perform(replaceText("12345test12345"))
runBlocking {
onView(withText(R.string.save_button_text)).perform(click())
delay(100)
}
onView(withText(R.string.save_button_text)).perform(click())
onView(isRoot()).perform(waitFor(100))
assertNotNull(activity.model.savedPictureUri)
addUriToDeletionFileList(activity.model.savedPictureUri)
onTopBarView().performOpenMoreOptions()
onView(withText(R.string.menu_save_image)).perform(click())
runBlocking {
onView(withText(R.string.save_button_text)).perform(click())
delay(100)
}
onView(withText(R.string.save_button_text)).perform(click())
onView(isRoot()).perform(waitFor(100))
onView(withText(R.string.overwrite_button_text)).check(matches(isDisplayed()))
}

Expand All @@ -357,15 +338,14 @@ class MenuFileActivityIntegrationTest {
val imageNumber = launchActivityRule.activity.presenter.imageNumber
onTopBarView().performOpenMoreOptions()
onView(withText(R.string.menu_save_image)).perform(click())
runBlocking {
onView(withText(R.string.save_button_text)).perform(click())
delay(100)
}
onView(withText(R.string.save_button_text)).perform(click())
onView(isRoot()).perform(waitFor(200))
assertNotNull(activity.model.savedPictureUri)
addUriToDeletionFileList(activity.model.savedPictureUri)
onDrawingSurfaceView().perform(touchAt(MIDDLE))
onTopBarView().performOpenMoreOptions()
onView(withText(R.string.menu_save_image)).perform(click())
onView(isRoot()).perform(waitFor(200))
val newImageNumber = launchActivityRule.activity.presenter.imageNumber
assertEquals((imageNumber + 1).toLong(), newImageNumber.toLong())
}
Expand All @@ -378,10 +358,8 @@ class MenuFileActivityIntegrationTest {
val imageNumber = launchActivityRule.activity.presenter.imageNumber
onView(withId(R.id.pocketpaint_image_name_save_text))
.perform(replaceText("test9876"))
runBlocking {
onView(withText(R.string.save_button_text)).perform(click())
delay(100)
}
onView(withText(R.string.save_button_text)).perform(click())
onView(isRoot()).perform(waitFor(100))
assertNotNull(activity.model.savedPictureUri)
addUriToDeletionFileList(activity.model.savedPictureUri)
val newImageNumber = launchActivityRule.activity.presenter.imageNumber
Expand All @@ -400,11 +378,9 @@ class MenuFileActivityIntegrationTest {
onData(allOf(`is`(instanceOf<Any>(String::class.java)), `is`<String>("png")))
.inRoot(RootMatchers.isPlatformPopup()).perform(click())
onView(withId(R.id.pocketpaint_image_name_save_text))
.perform(replaceText(TEMP_PICTURE_NAME))
runBlocking {
onView(withText(R.string.save_button_text)).perform(click())
delay(100)
}
.perform(replaceText(defaultFileName))
onView(withText(R.string.save_button_text)).perform(click())
onView(isRoot()).perform(waitFor(100))
assertNotNull(activity.model.savedPictureUri)
addUriToDeletionFileList(activity.model.savedPictureUri)
val oldFile = File(activity.model.savedPictureUri.toString())
Expand All @@ -414,11 +390,9 @@ class MenuFileActivityIntegrationTest {
onData(allOf(`is`(instanceOf<Any>(String::class.java)), `is`<String>("jpg")))
.inRoot(RootMatchers.isPlatformPopup()).perform(click())
onView(withId(R.id.pocketpaint_image_name_save_text))
.perform(replaceText(TEMP_PICTURE_NAME))
runBlocking {
onView(withText(R.string.save_button_text)).perform(click())
delay(100)
}
.perform(replaceText(defaultFileName))
onView(withText(R.string.save_button_text)).perform(click())
onView(isRoot()).perform(waitFor(100))
assertNotNull(activity.model.savedPictureUri)
addUriToDeletionFileList(activity.model.savedPictureUri)
val newFile = File(activity.model.savedPictureUri.toString())
Expand Down Expand Up @@ -468,10 +442,8 @@ class MenuFileActivityIntegrationTest {
onView(withId(R.id.pocketpaint_save_dialog_spinner)).perform(click())
onData(allOf(`is`(instanceOf<Any>(String::class.java)), `is`<String>("png")))
.inRoot(RootMatchers.isPlatformPopup()).perform(click())
runBlocking {
onView(withText(R.string.save_button_text)).perform(click())
delay(100)
}
onView(withText(R.string.save_button_text)).perform(click())
onView(isRoot()).perform(waitFor(100))
assertNotNull(activity.model.savedPictureUri)
addUriToDeletionFileList(activity.model.savedPictureUri)
onTopBarView().performOpenMoreOptions()
Expand All @@ -491,10 +463,8 @@ class MenuFileActivityIntegrationTest {
onView(withId(R.id.pocketpaint_save_dialog_spinner)).perform(click())
onData(allOf(`is`(instanceOf<Any>(String::class.java)), `is`<String>("png")))
.inRoot(RootMatchers.isPlatformPopup()).perform(click())
runBlocking {
onView(withText(R.string.save_button_text)).perform(click())
delay(100)
}
onView(withText(R.string.save_button_text)).perform(click())
onView(isRoot()).perform(waitFor(100))
onTopBarView().performOpenMoreOptions()
onView(withText(R.string.menu_save_copy)).perform(click())
imageNumber = launchActivityRule.activity.presenter.imageNumber
Expand Down
Loading

0 comments on commit e0df628

Please sign in to comment.