From 0263125e11fe251f04e5ccb5b53a28bac10cdd57 Mon Sep 17 00:00:00 2001 From: Stypox Date: Tue, 29 Dec 2020 23:57:16 +0100 Subject: [PATCH] Fix tests --- .../schabi/newpipe/error/ErrorInfoTest.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/app/src/androidTest/java/org/schabi/newpipe/error/ErrorInfoTest.java b/app/src/androidTest/java/org/schabi/newpipe/error/ErrorInfoTest.java index d491059e5..891824a55 100644 --- a/app/src/androidTest/java/org/schabi/newpipe/error/ErrorInfoTest.java +++ b/app/src/androidTest/java/org/schabi/newpipe/error/ErrorInfoTest.java @@ -8,8 +8,13 @@ import androidx.test.filters.LargeTest; import org.junit.Test; import org.junit.runner.RunWith; import org.schabi.newpipe.R; +import org.schabi.newpipe.extractor.ServiceList; +import org.schabi.newpipe.extractor.exceptions.ParsingException; + +import java.util.Arrays; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; /** * Instrumented tests for {@link ErrorInfo}. @@ -20,18 +25,21 @@ public class ErrorInfoTest { @Test public void errorInfoTestParcelable() { - final ErrorInfo info = ErrorInfo.make(UserAction.USER_REPORT, "youtube", "request", - R.string.general_error); + final ErrorInfo info = new ErrorInfo(new ParsingException("Hello"), + UserAction.USER_REPORT, "request", ServiceList.YouTube.getServiceId()); // Obtain a Parcel object and write the parcelable object to it: final Parcel parcel = Parcel.obtain(); info.writeToParcel(parcel, 0); parcel.setDataPosition(0); - final ErrorInfo infoFromParcel = ErrorInfo.CREATOR.createFromParcel(parcel); + final ErrorInfo infoFromParcel = (ErrorInfo) ErrorInfo.CREATOR.createFromParcel(parcel); + assertTrue(Arrays.toString(infoFromParcel.getStackTraces()) + .contains(ErrorInfoTest.class.getSimpleName())); assertEquals(UserAction.USER_REPORT, infoFromParcel.getUserAction()); - assertEquals("youtube", infoFromParcel.getServiceName()); + assertEquals(ServiceList.YouTube.getServiceInfo().getName(), + infoFromParcel.getServiceName()); assertEquals("request", infoFromParcel.getRequest()); - assertEquals(R.string.general_error, infoFromParcel.getMessageStringId()); + assertEquals(R.string.parsing_error, infoFromParcel.getMessageStringId()); parcel.recycle(); }