Search in sources :

Example 1 with DiffStyler

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());
}
Also used : DiffStyler(com.github.pockethub.android.ui.commit.DiffStyler) BufferedReader(java.io.BufferedReader) StringReader(java.io.StringReader) GitHubFile(com.meisolsson.githubsdk.model.GitHubFile)

Example 2 with DiffStyler

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());
}
Also used : DiffStyler(com.github.pockethub.android.ui.commit.DiffStyler) GitHubFile(com.meisolsson.githubsdk.model.GitHubFile)

Example 3 with DiffStyler

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());
}
Also used : DiffStyler(com.github.pockethub.android.ui.commit.DiffStyler)

Aggregations

DiffStyler (com.github.pockethub.android.ui.commit.DiffStyler)3 GitHubFile (com.meisolsson.githubsdk.model.GitHubFile)2 BufferedReader (java.io.BufferedReader)1 StringReader (java.io.StringReader)1