fixing test and ShareEpisodeDialog
This commit is contained in:
parent
b36078b8f1
commit
5363b09f00
@ -23,6 +23,8 @@ import org.junit.runner.RunWith;
|
|||||||
import static androidx.test.espresso.Espresso.onView;
|
import static androidx.test.espresso.Espresso.onView;
|
||||||
import static androidx.test.espresso.action.ViewActions.clearText;
|
import static androidx.test.espresso.action.ViewActions.clearText;
|
||||||
import static androidx.test.espresso.action.ViewActions.click;
|
import static androidx.test.espresso.action.ViewActions.click;
|
||||||
|
import static androidx.test.espresso.action.ViewActions.closeSoftKeyboard;
|
||||||
|
import static androidx.test.espresso.action.ViewActions.scrollTo;
|
||||||
import static androidx.test.espresso.action.ViewActions.typeText;
|
import static androidx.test.espresso.action.ViewActions.typeText;
|
||||||
import static androidx.test.espresso.assertion.ViewAssertions.matches;
|
import static androidx.test.espresso.assertion.ViewAssertions.matches;
|
||||||
import static androidx.test.espresso.matcher.RootMatchers.isDialog;
|
import static androidx.test.espresso.matcher.RootMatchers.isDialog;
|
||||||
@ -56,10 +58,12 @@ public class DialogsTest {
|
|||||||
|
|
||||||
String url = "https://omny.fm/shows/silence-is-not-an-option/why-not-being-racist-is-not-enough";
|
String url = "https://omny.fm/shows/silence-is-not-an-option/why-not-being-racist-is-not-enough";
|
||||||
|
|
||||||
onView(withId(R.id.btn_add_via_url)).perform(click());
|
onView(withId(R.id.btn_add_via_url)).perform(scrollTo()).perform(click());
|
||||||
onView(withId(R.id.text)).perform(clearText(), typeText(url));
|
onView(withId(R.id.text)).perform(clearText(), typeText(url));
|
||||||
onView(withText(R.string.confirm_label)).inRoot(isDialog())
|
onView(withText(R.string.confirm_label)).inRoot(isDialog())
|
||||||
.check(matches(isDisplayed()))
|
.check(matches(isDisplayed()))
|
||||||
|
.perform(closeSoftKeyboard())
|
||||||
|
.perform(scrollTo())
|
||||||
.perform(click());
|
.perform(click());
|
||||||
Thread.sleep(5000);
|
Thread.sleep(5000);
|
||||||
onView(withId(R.id.butSubscribe)).perform(click());
|
onView(withId(R.id.butSubscribe)).perform(click());
|
||||||
@ -72,21 +76,22 @@ public class DialogsTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testShareDialogDisplayed() {
|
public void testShareDialogDisplayed() {
|
||||||
onView(withText(R.string.share_label)).perform(click());
|
onView(withText(R.string.share_label)).perform(scrollTo()).perform(click());
|
||||||
onView(withText(R.string.share_episode_label)).check(matches(isDisplayed()));
|
onView(allOf(isDisplayed(), withText(R.string.share_episode_label)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testShareDialogShareButton() throws InterruptedException {
|
public void testShareDialogShareButton() throws InterruptedException {
|
||||||
onView(withText(R.string.share_label)).perform(click());
|
onView(withText(R.string.share_label)).perform(scrollTo()).perform(click());
|
||||||
onView(withText(R.string.share_label)).check(matches(isDisplayed()));
|
onView(allOf(isDisplayed(), withText(R.string.share_label)));
|
||||||
onView(withText(R.string.share_label)).perform(click());
|
Thread.sleep(1000);
|
||||||
Thread.sleep(3000);
|
onView(withText(R.string.share_episode_positive_label_button)).perform(scrollTo()).perform(click());
|
||||||
|
Thread.sleep(2000);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testShareDialogCancelButton() {
|
public void testShareDialogCancelButton() {
|
||||||
onView(withText(R.string.share_label)).perform(click());
|
onView(withText(R.string.share_label)).perform(scrollTo()).perform(click());
|
||||||
onView(withText(R.string.cancel_label)).check(matches(isDisplayed()));
|
onView(withText(R.string.cancel_label)).check(matches(isDisplayed()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ import android.view.View;
|
|||||||
import android.widget.RadioButton;
|
import android.widget.RadioButton;
|
||||||
import android.widget.RadioGroup;
|
import android.widget.RadioGroup;
|
||||||
import android.widget.Switch;
|
import android.widget.Switch;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
@ -54,7 +55,7 @@ public class ShareDialog extends DialogFragment {
|
|||||||
setupOptions();
|
setupOptions();
|
||||||
|
|
||||||
builder
|
builder
|
||||||
.setPositiveButton(R.string.share_label, new DialogInterface.OnClickListener() {
|
.setPositiveButton(R.string.share_episode_positive_label_button, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
if (radioEpisodeWebsite.isChecked()) {
|
if (radioEpisodeWebsite.isChecked()) {
|
||||||
@ -107,6 +108,11 @@ public class ShareDialog extends DialogFragment {
|
|||||||
|
|
||||||
boolean radioMediaIsChecked = prefs.getBoolean(UserPreferences.PREF_SHARE_EPISODE_MEDIA, false);
|
boolean radioMediaIsChecked = prefs.getBoolean(UserPreferences.PREF_SHARE_EPISODE_MEDIA, false);
|
||||||
radioMediaFile.setChecked(radioMediaIsChecked);
|
radioMediaFile.setChecked(radioMediaIsChecked);
|
||||||
|
|
||||||
|
if (!radioEpisodeWebsiteIsChecked && !radioMediaIsChecked) {
|
||||||
|
radioGroup.clearCheck();
|
||||||
|
radioEpisodeWebsite.setChecked(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean switchIsChecked = prefs.getBoolean(UserPreferences.PREF_SHARE_EPISODE_START_AT, false);
|
boolean switchIsChecked = prefs.getBoolean(UserPreferences.PREF_SHARE_EPISODE_START_AT, false);
|
||||||
|
@ -767,6 +767,7 @@
|
|||||||
|
|
||||||
<!-- Share episode dialog -->
|
<!-- Share episode dialog -->
|
||||||
<string name="share_episode_label">Share…</string>
|
<string name="share_episode_label">Share…</string>
|
||||||
|
<string name="share_episode_positive_label_button">Share</string>
|
||||||
<string name="share_dialog_include_label">Include:</string>
|
<string name="share_dialog_include_label">Include:</string>
|
||||||
<string name="share_start_at_timer_dialog_label">Start at (timer)</string>
|
<string name="share_start_at_timer_dialog_label">Start at (timer)</string>
|
||||||
<string name="share_dialog_media_file_label">Media file URL</string>
|
<string name="share_dialog_media_file_label">Media file URL</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user