2020-12-09 12:42:01 +01:00
|
|
|
package org.schabi.newpipe.error;
|
2017-06-28 07:27:32 +02:00
|
|
|
|
|
|
|
import android.os.Parcel;
|
2020-03-31 19:20:15 +02:00
|
|
|
|
2020-08-27 22:56:12 +02:00
|
|
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
2019-10-04 14:59:08 +02:00
|
|
|
import androidx.test.filters.LargeTest;
|
2017-06-28 07:27:32 +02:00
|
|
|
|
|
|
|
import org.junit.Test;
|
|
|
|
import org.junit.runner.RunWith;
|
|
|
|
import org.schabi.newpipe.R;
|
|
|
|
|
|
|
|
import static org.junit.Assert.assertEquals;
|
|
|
|
|
|
|
|
/**
|
2020-03-31 19:20:15 +02:00
|
|
|
* Instrumented tests for {@link ErrorInfo}.
|
2017-06-28 07:27:32 +02:00
|
|
|
*/
|
|
|
|
@RunWith(AndroidJUnit4.class)
|
|
|
|
@LargeTest
|
|
|
|
public class ErrorInfoTest {
|
|
|
|
|
|
|
|
@Test
|
2020-03-31 19:20:15 +02:00
|
|
|
public void errorInfoTestParcelable() {
|
2020-08-16 10:24:58 +02:00
|
|
|
final ErrorInfo info = ErrorInfo.make(UserAction.USER_REPORT, "youtube", "request",
|
2020-03-31 19:20:15 +02:00
|
|
|
R.string.general_error);
|
2017-06-28 07:27:32 +02:00
|
|
|
// Obtain a Parcel object and write the parcelable object to it:
|
2020-08-16 10:24:58 +02:00
|
|
|
final Parcel parcel = Parcel.obtain();
|
2017-06-28 07:27:32 +02:00
|
|
|
info.writeToParcel(parcel, 0);
|
|
|
|
parcel.setDataPosition(0);
|
2020-08-16 10:24:58 +02:00
|
|
|
final ErrorInfo infoFromParcel = ErrorInfo.CREATOR.createFromParcel(parcel);
|
2017-06-28 07:27:32 +02:00
|
|
|
|
2020-10-04 03:50:28 +02:00
|
|
|
assertEquals(UserAction.USER_REPORT, infoFromParcel.getUserAction());
|
|
|
|
assertEquals("youtube", infoFromParcel.getServiceName());
|
|
|
|
assertEquals("request", infoFromParcel.getRequest());
|
2020-12-11 14:55:47 +01:00
|
|
|
assertEquals(R.string.general_error, infoFromParcel.getMessageStringId());
|
2017-06-28 07:27:32 +02:00
|
|
|
|
|
|
|
parcel.recycle();
|
|
|
|
}
|
2020-03-31 19:20:15 +02:00
|
|
|
}
|