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

CATROID-1359 Fix testActivityRecreateRenameSpriteDialog #4444

Merged
merged 1 commit into from
Feb 13, 2022
Merged
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
@@ -1,6 +1,6 @@
/*
* Catroid: An on-device visual programming system for Android devices
* Copyright (C) 2010-2020 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 @@ -43,8 +43,6 @@
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.platform.app.InstrumentationRegistry;

import static org.catrobat.catroid.uiespresso.ui.fragment.rvutils.RecyclerViewInteractionWrapper.onRecyclerView;

import static androidx.test.InstrumentationRegistry.getInstrumentation;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu;
Expand Down Expand Up @@ -82,13 +80,7 @@ public void testActivityRecreateNewSpriteDialog() {
onView(withText(R.string.new_sprite_dialog_title)).inRoot(isDialog())
.check(matches(isDisplayed()));

InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() {
@Override
public void run() {
baseActivityTestRule.getActivity().recreate();
}
});

InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> baseActivityTestRule.getActivity().recreate());
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
}

Expand All @@ -97,23 +89,14 @@ public void run() {
@Test
public void testActivityRecreateRenameSpriteDialog() {
openActionBarOverflowOrOptionsMenu(getInstrumentation().getTargetContext());
onView(withText(R.string.rename)).perform(click());

onRecyclerView().atPosition(1)
.performCheckItem();

onView(withId(R.id.confirm)).perform(click());
onView(withText(R.string.rename))
.perform(click());

onView(withText(R.string.rename_sprite_dialog)).inRoot(isDialog())
.check(matches(isDisplayed()));

InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() {
@Override
public void run() {
baseActivityTestRule.getActivity().recreate();
}
});

InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> baseActivityTestRule.getActivity().recreate());
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
}

Expand All @@ -122,18 +105,14 @@ public void run() {
@Test
public void testActivityRecreateNewGroupDialog() {
openActionBarOverflowOrOptionsMenu(getInstrumentation().getTargetContext());
onView(withText(R.string.new_group)).perform(click());

onView(withText(R.string.new_group))
.perform(click());

onView(withText(R.string.new_group)).inRoot(isDialog())
.check(matches(isDisplayed()));

InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() {
@Override
public void run() {
baseActivityTestRule.getActivity().recreate();
}
});

InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> baseActivityTestRule.getActivity().recreate());
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
}

Expand All @@ -142,17 +121,14 @@ public void run() {
@Test
public void testActivityRecreateNewSceneDialog() {
openActionBarOverflowOrOptionsMenu(getInstrumentation().getTargetContext());
onView(withText(R.string.new_scene)).perform(click());

onView(withText(R.string.new_scene))
.perform(click());

onView(withText(R.string.new_scene_dialog)).inRoot(isDialog())
.check(matches(isDisplayed()));

InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() {
@Override
public void run() {
baseActivityTestRule.getActivity().recreate();
}
});
InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> baseActivityTestRule.getActivity().recreate());
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
}

Expand Down