예제 #1
0
  public void testPreviewDiffBug() throws Exception {
    // https://bugs.corefiling.com/show_bug.cgi?id=13510
    // Old versions of the diff_match_patch package have a bug in the diff_cleanupSemantic method
    // The two comparison strings need to be well crafted to trigger the bug.
    String name = uniqueWikiPageName("PreviewPageTest");
    String content =
        "="
            + NEWLINE_TEXTAREA
            + "This is a lis of things that someone be doing if"
            + NEWLINE_TEXTAREA
            + "===Wiki"
            + NEWLINE_TEXTAREA;
    String newContent = "||" + NEWLINE_TEXTAREA + "==";

    HtmlPage edited = editWikiPage(name, content, "", "", true);
    HtmlPage editPage = clickEditLink(edited);
    HtmlForm form = editPage.getFormByName(ID_EDIT_FORM);
    HtmlTextArea contentArea = form.getTextAreaByName("content");
    contentArea.setText(newContent);
    editPage = (HtmlPage) form.getInputByValue("Preview").click();

    form = editPage.getFormByName(ID_EDIT_FORM);
    contentArea = form.getTextAreaByName("content");
    assertEquals(newContent + NEWLINE_TEXTAREA, contentArea.getText());
  }
예제 #2
0
  public void testPreview() throws Exception {
    String name = uniqueWikiPageName("PreviewPageTest");
    HtmlPage editPage = clickEditLink(getWikiPage(name));
    HtmlForm form = editPage.getFormByName(ID_EDIT_FORM);
    HtmlInput minorEdit = form.getInputByName("minorEdit");
    assertFalse(minorEdit.isChecked());
    minorEdit.setChecked(true);
    HtmlInput description = form.getInputByName("description");
    String expectedDescription = "My test change";
    description.setValueAttribute(expectedDescription);
    HtmlTextArea content = form.getTextAreaByName("content");
    String expectedContent = "http://www.example.com";
    content.setText(expectedContent);

    // Now if we preview we should get the previewed text rendered, and in
    // the edit area.  The other options should be preserved too.
    editPage = (HtmlPage) form.getInputByValue("Preview").click();
    form = editPage.getFormByName(ID_EDIT_FORM);
    minorEdit = form.getInputByName("minorEdit");
    description = form.getInputByName("description");
    content = form.getTextAreaByName("content");
    assertEquals(expectedDescription, description.getValueAttribute());
    assertTrue(minorEdit.isChecked());
    assertEquals(expectedContent + NEWLINE_TEXTAREA, content.getText());
    // This checks for the rendering...
    assertNotNull(editPage.getAnchorByHref(expectedContent));
  }
 private static List<String> getSimulatedProperties(final BrowserVersion browserVersion)
     throws Exception {
   final URL url = PropertiesTest.class.getClassLoader().getResource("objects/properties.html");
   final WebClient webClient = new WebClient(browserVersion);
   final HtmlPage page = webClient.getPage(url);
   final HtmlTextArea textarea = page.getHtmlElementById("myTextarea");
   return Arrays.asList(textarea.getText().split("\r\n|\n"));
 }
예제 #4
0
  public void testPreviewWithChangedAttributes() throws Exception {
    String name = uniqueWikiPageName("PreviewPageTest");
    HtmlPage editPage = clickEditLink(getWikiPage(name));
    HtmlForm form = editPage.getFormByName(ID_EDIT_FORM);
    HtmlTextArea attributes = form.getTextAreaByName("attributes");
    String expectedContent = "SomeContent";
    String expectedAttributes = "\"text\" = \"" + expectedContent + "\"";
    attributes.setText(expectedAttributes);
    HtmlTextArea content = form.getTextAreaByName("content");
    String expectedContentSource = "<<attr:text>>";
    content.setText(expectedContentSource);

    // Now if we preview we should get the previewed text rendered, and in
    // the edit area.
    editPage = (HtmlPage) form.getInputByValue("Preview").click();
    editPage.asText().contains(expectedContent);
    form = editPage.getFormByName(ID_EDIT_FORM);
    attributes = form.getTextAreaByName("attributes");
    assertEquals(expectedAttributes + NEWLINE_TEXTAREA, attributes.getText());
    content = form.getTextAreaByName("content");
    assertEquals(expectedContentSource + NEWLINE_TEXTAREA, content.getText());
  }