use of com.github.pockethub.android.ui.commit.DiffStyler in project PocketHub by pockethub.
the class DiffStylerTest method compareStyled.
private void compareStyled(String patch) throws IOException {
assertNotNull(patch);
String fileName = "file.txt";
DiffStyler styler = new DiffStyler(getContext().getResources());
GitHubFile file = GitHubFile.builder().filename(fileName).patch(patch).build();
styler.setFiles(Collections.singletonList(file));
List<CharSequence> styled = styler.get(fileName);
assertNotNull(styled);
BufferedReader reader = new BufferedReader(new StringReader(patch));
String line = reader.readLine();
int processed = 0;
while (line != null) {
assertEquals(line, styled.get(processed).toString());
line = reader.readLine();
processed++;
}
assertEquals(processed, styled.size());
}
use of com.github.pockethub.android.ui.commit.DiffStyler in project PocketHub by pockethub.
the class DiffStylerTest method testEmptyPatch.
/**
* Test styler with empty patch
*/
public void testEmptyPatch() {
DiffStyler styler = new DiffStyler(getContext().getResources());
GitHubFile file = GitHubFile.builder().filename("file.txt").build();
styler.setFiles(Collections.singletonList(file));
assertTrue(styler.get("file.txt").isEmpty());
file = file.toBuilder().filename("").build();
styler.setFiles(Collections.singletonList(file));
assertTrue(styler.get("file.txt").isEmpty());
}
use of com.github.pockethub.android.ui.commit.DiffStyler in project PocketHub by pockethub.
the class DiffStylerTest method testEmptyFiles.
/**
* Test styler with empty files
*/
public void testEmptyFiles() {
DiffStyler styler = new DiffStyler(getContext().getResources());
styler.setFiles(null);
assertTrue(styler.get("navigation_drawer_header_background").isEmpty());
styler.setFiles(Collections.<GitHubFile>emptyList());
assertTrue(styler.get("navigation_drawer_header_background").isEmpty());
}
Aggregations