Search in sources :

Example 1 with EditorBot

use of code.satyagraha.gfm.viewer.bots.EditorBot in project gfm_viewer by satyagraha.

the class MarkdownViewTest method shouldGenerateHTMLonEditorSave.

@Test
public void shouldGenerateHTMLonEditorSave() throws Exception {
    LOGGER.info("");
    assertThat(MarkdownViewBot.isPresent(), is(false));
    MarkdownViewBot markdownViewBot = MarkdownViewBot.open();
    assertThat(MarkdownViewBot.isPresent(), is(true));
    ProjectBot project = ProjectBot.createSimpleProject();
    ProjectFileBot fileBot = project.newFile("file1.md");
    EditorBot editorBot = EditorBot.findByName("file1.md");
    String textMd = "sample text, timestamp: " + System.currentTimeMillis() + ".";
    editorBot.typeText(textMd + "\r");
    editorBot.save();
    SWTUtils.sleep(2000);
    assertThat(markdownViewBot.getTitle(), is("file1"));
    File fileMd = fileBot.toFile();
    File fileHt = new File(fileMd.getParentFile(), ".file1.md.html");
    assertThat("not found: " + fileHt, fileHt.exists(), is(true));
    String textHt = IOUtils.toString(new FileInputStream(fileHt));
    assertThat(textHt, containsString(textMd));
    editorBot.close();
    markdownViewBot.close();
    SWTUtils.sleep(2000);
    project.delete();
}
Also used : EditorBot(code.satyagraha.gfm.viewer.bots.EditorBot) MarkdownViewBot(code.satyagraha.gfm.viewer.bots.MarkdownViewBot) ProjectBot(code.satyagraha.gfm.viewer.bots.ProjectBot) ProjectFileBot(code.satyagraha.gfm.viewer.bots.ProjectBot.ProjectFileBot) Matchers.containsString(org.hamcrest.Matchers.containsString) File(java.io.File) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 2 with EditorBot

use of code.satyagraha.gfm.viewer.bots.EditorBot in project gfm_viewer by satyagraha.

the class MarkdownViewTest method shouldNotGenerateHTMLonEditorSaveIfOffline.

@Test
public void shouldNotGenerateHTMLonEditorSaveIfOffline() throws Exception {
    LOGGER.info("");
    assertThat(MarkdownViewBot.isPresent(), is(false));
    MarkdownViewBot markdownViewBot = MarkdownViewBot.open();
    assertThat(MarkdownViewBot.isPresent(), is(true));
    SWTBotToolbarButton onlineButton = markdownViewBot.getOnlineButton();
    SWTBotToolbarButton reloadButton = markdownViewBot.getReloadButton();
    ProjectBot project = ProjectBot.createSimpleProject();
    ProjectFileBot fileBot = project.newFile("file1.md");
    EditorBot editorBot = EditorBot.findByName("file1.md");
    String textMd1 = "sample text 1, timestamp: " + System.currentTimeMillis() + ".";
    editorBot.typeText(textMd1 + "\r");
    editorBot.save();
    // set offline
    onlineButton.click();
    String textMd2 = "sample text 2, timestamp: " + System.currentTimeMillis() + ".";
    editorBot.typeText(textMd2 + "\r");
    editorBot.save();
    SWTUtils.sleep(2000);
    File fileMd = fileBot.toFile();
    File fileHt = new File(fileMd.getParentFile(), ".file1.md.html");
    assertThat("not found: " + fileHt, fileHt.exists(), is(true));
    assertThat(markdownViewBot.getTitle(), is("*file1"));
    String textHt1 = IOUtils.toString(new FileInputStream(fileHt));
    assertThat(textHt1, containsString(textMd1));
    assertThat(textHt1, not(containsString(textMd2)));
    reloadButton.click();
    SWTUtils.sleep(2000);
    assertThat(markdownViewBot.getTitle(), is("*file1"));
    String textHt2 = IOUtils.toString(new FileInputStream(fileHt));
    assertThat(textHt2, containsString(textMd1));
    assertThat(textHt2, not(containsString(textMd2)));
    // set online
    onlineButton.click();
    reloadButton.click();
    SWTUtils.sleep(2000);
    assertThat(markdownViewBot.getTitle(), is("file1"));
    String textHt3 = IOUtils.toString(new FileInputStream(fileHt));
    assertThat(textHt3, containsString(textMd1));
    assertThat(textHt3, containsString(textMd2));
    editorBot.close();
    markdownViewBot.close();
    project.delete();
}
Also used : EditorBot(code.satyagraha.gfm.viewer.bots.EditorBot) MarkdownViewBot(code.satyagraha.gfm.viewer.bots.MarkdownViewBot) ProjectBot(code.satyagraha.gfm.viewer.bots.ProjectBot) ProjectFileBot(code.satyagraha.gfm.viewer.bots.ProjectBot.ProjectFileBot) Matchers.containsString(org.hamcrest.Matchers.containsString) File(java.io.File) SWTBotToolbarButton(org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 3 with EditorBot

use of code.satyagraha.gfm.viewer.bots.EditorBot in project gfm_viewer by satyagraha.

the class MarkdownViewTest method shouldFollowEditorSelectedWhenLinked.

@Test
public void shouldFollowEditorSelectedWhenLinked() throws Exception {
    LOGGER.info("");
    assertThat(MarkdownViewBot.isPresent(), is(false));
    ProjectBot project = ProjectBot.createSimpleProject();
    project.newFile("file1.md");
    project.newFile("file2.md");
    MarkdownViewBot markdownViewBot = MarkdownViewBot.open();
    assertThat(MarkdownViewBot.isPresent(), is(true));
    EditorBot editorBot1 = EditorBot.findByName("file1.md").show();
    SWTUtils.sleep(2000);
    assertThat(markdownViewBot.getTitle(), is("file1"));
    EditorBot editorBot2 = EditorBot.findByName("file2.md").show();
    SWTUtils.sleep(2000);
    assertThat(markdownViewBot.getTitle(), is("file2"));
    editorBot2.close();
    SWTUtils.sleep(2000);
    assertThat(markdownViewBot.getTitle(), is("file1"));
    editorBot1.close();
    SWTUtils.sleep(2000);
    assertThat(markdownViewBot.getTitle(), is("file1"));
    markdownViewBot.close();
    project.delete();
}
Also used : EditorBot(code.satyagraha.gfm.viewer.bots.EditorBot) ProjectBot(code.satyagraha.gfm.viewer.bots.ProjectBot) MarkdownViewBot(code.satyagraha.gfm.viewer.bots.MarkdownViewBot) Test(org.junit.Test)

Example 4 with EditorBot

use of code.satyagraha.gfm.viewer.bots.EditorBot in project gfm_viewer by satyagraha.

the class MarkdownViewTest method shouldGenerateHTMLviaContextMenu.

@Test
public void shouldGenerateHTMLviaContextMenu() throws Exception {
    LOGGER.info("");
    assertThat(MarkdownViewBot.isPresent(), is(false));
    ProjectBot project = ProjectBot.createSimpleProject();
    ProjectFileBot fileBot = project.newFile("file1.md");
    EditorBot editorBot = EditorBot.findByName("file1.md");
    String textMd = "sample text, timestamp: " + System.currentTimeMillis() + ".";
    editorBot.typeText(textMd + "\r");
    editorBot.save();
    editorBot.close();
    File fileMd = fileBot.toFile();
    File fileHt = new File(fileMd.getParentFile(), ".file1.md.html");
    assertThat(fileHt.exists(), is(false));
    fileBot.generateMarkdownPreview();
    SWTUtils.sleep(2000);
    assertThat("not found: " + fileHt, fileHt.exists(), is(true));
    String textHt = IOUtils.toString(new FileInputStream(fileHt));
    assertThat(textHt, containsString(textMd));
    EditorBot.closeAll();
    project.delete();
}
Also used : EditorBot(code.satyagraha.gfm.viewer.bots.EditorBot) ProjectBot(code.satyagraha.gfm.viewer.bots.ProjectBot) ProjectFileBot(code.satyagraha.gfm.viewer.bots.ProjectBot.ProjectFileBot) Matchers.containsString(org.hamcrest.Matchers.containsString) File(java.io.File) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 5 with EditorBot

use of code.satyagraha.gfm.viewer.bots.EditorBot in project gfm_viewer by satyagraha.

the class MarkdownViewTest method shouldNotFollowEditorSelectedWhenNotLinked.

@Test
public void shouldNotFollowEditorSelectedWhenNotLinked() throws Exception {
    LOGGER.info("");
    assertThat(MarkdownViewBot.isPresent(), is(false));
    ProjectBot project = ProjectBot.createSimpleProject();
    project.newFile("file1.md");
    project.newFile("file2.md");
    MarkdownViewBot markdownViewBot = MarkdownViewBot.open();
    assertThat(MarkdownViewBot.isPresent(), is(true));
    SWTBotToolbarButton linkedButton = markdownViewBot.getLinkedButton();
    EditorBot editorBot1 = EditorBot.findByName("file1.md").show();
    SWTUtils.sleep(2000);
    assertThat(markdownViewBot.getTitle(), is("file1"));
    EditorBot editorBot2 = EditorBot.findByName("file2.md").show();
    SWTUtils.sleep(2000);
    assertThat(markdownViewBot.getTitle(), is("file2"));
    // set unlinked
    linkedButton.click();
    editorBot2.close();
    SWTUtils.sleep(2000);
    assertThat(markdownViewBot.getTitle(), is("file2"));
    editorBot1.close();
    SWTUtils.sleep(2000);
    assertThat(markdownViewBot.getTitle(), is("file2"));
    linkedButton.click();
    markdownViewBot.close();
    project.delete();
}
Also used : EditorBot(code.satyagraha.gfm.viewer.bots.EditorBot) ProjectBot(code.satyagraha.gfm.viewer.bots.ProjectBot) MarkdownViewBot(code.satyagraha.gfm.viewer.bots.MarkdownViewBot) SWTBotToolbarButton(org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton) Test(org.junit.Test)

Aggregations

EditorBot (code.satyagraha.gfm.viewer.bots.EditorBot)5 ProjectBot (code.satyagraha.gfm.viewer.bots.ProjectBot)5 Test (org.junit.Test)5 MarkdownViewBot (code.satyagraha.gfm.viewer.bots.MarkdownViewBot)4 ProjectFileBot (code.satyagraha.gfm.viewer.bots.ProjectBot.ProjectFileBot)3 File (java.io.File)3 FileInputStream (java.io.FileInputStream)3 Matchers.containsString (org.hamcrest.Matchers.containsString)3 SWTBotToolbarButton (org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton)2