Support some lbry hosts to deep links. Add unit tests #1008

Merged
kekkyojin merged 3 commits from more-deeplinks into master 2020-10-02 13:34:39 +02:00
Showing only changes of commit 2893b5dce9 - Show all commits

View file

@ -1,5 +1,6 @@
package io.lbry.browser.utils;
import org.jetbrains.annotations.NotNull;
import org.junit.Before;
import org.junit.Test;
@ -84,16 +85,7 @@ public class LbryUriTest {
@Test
public void parseLbryProtocolOnlyChannel() {
LbryUri expectedForChannel = new LbryUri();
expectedForChannel.setChannelName("@UCBerkeley");
expectedForChannel.setChannel(true);
try {
LbryUri.UriModifier primaryMod = LbryUri.UriModifier.parse("#", "d");
expectedForChannel.setChannelClaimId(primaryMod.getClaimId());
} catch (LbryUriException e) {
e.printStackTrace();
}
LbryUri expectedForChannel = sinthesizeExpected();
LbryUri obtained = new LbryUri();
@ -105,4 +97,34 @@ public class LbryUriTest {
assertEquals(expectedForChannel, obtained);
}
@Test
public void parseLbryTvProtocolOnlyChannel() {
LbryUri expectedForChannel = sinthesizeExpected();
LbryUri obtained = new LbryUri();
try {
obtained = LbryUri.parse("https://lbry.tv/@UCBerkeley:d",false);
} catch (LbryUriException e) {
e.printStackTrace();
}
assertEquals(expectedForChannel, obtained);
}
@NotNull
private LbryUri sinthesizeExpected() {
LbryUri expectedForChannel = new LbryUri();
expectedForChannel.setChannelName("@UCBerkeley");
expectedForChannel.setChannel(true);
try {
LbryUri.UriModifier primaryMod = LbryUri.UriModifier.parse("#", "d");
expectedForChannel.setChannelClaimId(primaryMod.getClaimId());
} catch (LbryUriException e) {
e.printStackTrace();
}
return expectedForChannel;
}
}