Skip to content

Commit

Permalink
Merge pull request #1042 from ThorstenBandel/Fixing_And_Refactoring_T…
Browse files Browse the repository at this point in the history
…ests

PAINTROID-394: Fixing and refactoring Tests
  • Loading branch information
ThorstenBandel authored Jun 23, 2022
2 parents 4a3c79b + 62966b4 commit e5c9308
Show file tree
Hide file tree
Showing 67 changed files with 737 additions and 269 deletions.
42 changes: 42 additions & 0 deletions .idea/codeStyles/Project.xml

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

2 changes: 2 additions & 0 deletions Paintroid/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ dependencies {
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.1.0'
androidTestImplementation "androidx.test.uiautomator:uiautomator:2.2.0"
testImplementation "androidx.test:core-ktx:1.4.0"
implementation 'com.android.support.test.espresso:espresso-idling-resource:3.1.0'
}

tasks.withType(Javadoc).all {
Expand Down
4 changes: 2 additions & 2 deletions Paintroid/config/detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ complexity:
active: false
ignoredLabels: ""
LargeClass:
active: true
threshold: 650
active: false
threshold: 1000
LongMethod:
active: true
threshold: 80
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ import androidx.test.espresso.Espresso
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.action.ViewActions
import androidx.test.espresso.action.ViewActions.replaceText
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.RootMatchers
import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.rule.ActivityTestRule
import androidx.test.rule.GrantPermissionRule
Expand Down Expand Up @@ -66,6 +68,7 @@ class CatrobatImageIOIntegrationTest {
companion object {
private const val IMAGE_NAME = "fileName"
}

@Before
fun setUp() {
activity = launchActivityRule.activity
Expand Down Expand Up @@ -98,9 +101,14 @@ class CatrobatImageIOIntegrationTest {
).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)).check(matches(isDisplayed()))
.perform(ViewActions.click())
onView(withText(R.string.overwrite_button_text)).check(matches(isDisplayed()))
.perform(ViewActions.click())
uriFile = activity.model.savedPictureUri!!
Assert.assertNotNull(uriFile)
Assert.assertNotNull(activity.workspace.getCommandSerializationHelper().readFromFile(uriFile))
Assert.assertNotNull(
activity.workspace.getCommandSerializationHelper().readFromFile(uriFile)
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class FileFromOtherSourceIntegrationTest {
public ScreenshotOnFailRule screenshotOnFailRule = new ScreenshotOnFailRule();

@ClassRule
public static GrantPermissionRule grantPermissionRule = EspressoUtils.grantPermissionRulesVersionCheck();
public static GrantPermissionRule grantPermissionRule = EspressoUtils.INSTANCE.grantPermissionRulesVersionCheck();

private ContentResolver resolver;
private MainActivity activity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,16 @@
import org.catrobat.paintroid.tools.Tool;
import org.catrobat.paintroid.tools.ToolType;
import org.catrobat.paintroid.tools.options.ToolOptionsViewController;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

import androidx.annotation.ArrayRes;
import androidx.annotation.ColorInt;
import androidx.test.espresso.IdlingRegistry;
import androidx.test.espresso.idling.CountingIdlingResource;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;

Expand Down Expand Up @@ -71,7 +74,7 @@
public class LandscapeIntegrationTest {

private MainActivity mainActivity;

private CountingIdlingResource idlingResource;
@Rule
public ActivityTestRule<MainActivity> activityTestRule = new ActivityTestRule<>(MainActivity.class);

Expand All @@ -89,6 +92,13 @@ private ToolOptionsViewController getToolOptionsViewController() {
@Before
public void setUp() {
mainActivity = activityTestRule.getActivity();
idlingResource = mainActivity.getIdlingResource();
IdlingRegistry.getInstance().register(idlingResource);
}

@After
public void tearDown() {
IdlingRegistry.getInstance().unregister(idlingResource);
}

@Test
Expand Down
Loading

0 comments on commit e5c9308

Please sign in to comment.