mirror of
https://github.com/readrops/Readrops.git
synced 2025-02-11 01:10:38 +01:00
Add some tests for HtmlParser class
This commit is contained in:
parent
7946b2a62d
commit
9af213c26b
@ -13,6 +13,9 @@ android {
|
||||
versionName "1.0.2.2"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
testOptions {
|
||||
unitTests.returnDefaultValues = true
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false // proguard makes some functionalities fail so It's disabled until I find the problem source
|
||||
|
@ -116,7 +116,18 @@ public class ParsingResult extends AbstractItem<ParsingResult, ParsingResult.Par
|
||||
public void unbindView(@NotNull ParsingResult item) {
|
||||
// not useful
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o == null)
|
||||
return false;
|
||||
else if (!(o instanceof ParsingResult))
|
||||
return false;
|
||||
else {
|
||||
ParsingResult parsingResult = (ParsingResult) o;
|
||||
|
||||
return parsingResult.getUrl().equals(this.getUrl());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
36
app/src/test/java/com/readrops/app/HtmlParserTest.java
Normal file
36
app/src/test/java/com/readrops/app/HtmlParserTest.java
Normal file
@ -0,0 +1,36 @@
|
||||
package com.readrops.app;
|
||||
|
||||
import com.readrops.app.utils.HtmlParser;
|
||||
import com.readrops.app.utils.ParsingResult;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static junit.framework.TestCase.assertEquals;
|
||||
|
||||
public class HtmlParserTest {
|
||||
|
||||
@Test
|
||||
public void getFeedLinkTest() throws Exception {
|
||||
String url = "https://github.com/readrops/Readrops";
|
||||
|
||||
ParsingResult parsingResult = new ParsingResult("https://github.com/readrops/Readrops/commits/master.atom", "Recent Commits to Readrops:master");
|
||||
List<ParsingResult> parsingResultList = new ArrayList<>();
|
||||
parsingResultList.add(parsingResult);
|
||||
|
||||
List<ParsingResult> parsingResultList1 = HtmlParser.getFeedLink(url);
|
||||
|
||||
Assert.assertEquals(parsingResultList, parsingResultList1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getFaviconLinkTest() throws IOException {
|
||||
String url = "https://github.com/readrops/Readrops";
|
||||
|
||||
assertEquals("https://github.com/fluidicon.png", HtmlParser.getFaviconLink(url));
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user