PageRenderTime 40ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/bundles/plugins-trunk/XML/test/xml/translate/TrangGUITest.java

#
Java | 180 lines | 115 code | 45 blank | 20 comment | 0 complexity | 7af59783de4d67f78886f8651824c5d2 MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0
  1. /*
  2. * TrangGUITest.java
  3. * :folding=explicit:collapseFolds=1:
  4. *
  5. * Copyright (C) 2010 Eric Le Lay
  6. *
  7. * The XML plugin is licensed under the GNU General Public License, with
  8. * the following exception:
  9. *
  10. * "Permission is granted to link this code with software released under
  11. * the Apache license version 1.1, for example used by the Xerces XML
  12. * parser package."
  13. */
  14. package xml.translate;
  15. // {{{ jUnit imports
  16. import java.util.concurrent.TimeUnit;
  17. import org.junit.*;
  18. import static org.junit.Assert.*;
  19. import static org.junit.Assume.*;
  20. import org.fest.swing.fixture.*;
  21. import org.fest.swing.core.*;
  22. import org.fest.swing.data.TableCell;
  23. import org.fest.swing.finder.*;
  24. import org.fest.swing.edt.*;
  25. import org.fest.swing.timing.*;
  26. import org.fest.swing.core.matcher.JButtonMatcher;
  27. import static org.fest.assertions.Assertions.*;
  28. import org.gjt.sp.jedit.testframework.Log;
  29. import static org.gjt.sp.jedit.testframework.TestUtils.*;
  30. import static org.gjt.sp.jedit.testframework.EBFixture.*;
  31. import org.gjt.sp.jedit.testframework.PluginOptionsFixture;
  32. import org.gjt.sp.jedit.testframework.TestUtils;
  33. // }}}
  34. import org.gjt.sp.jedit.jEdit;
  35. import org.gjt.sp.jedit.Buffer;
  36. import java.io.*;
  37. import java.util.*;
  38. import javax.swing.text.JTextComponent;
  39. /**
  40. * unit tests for TrangTranslator
  41. * $Id: TrangGUITest.java 21325 2012-03-11 11:03:44Z kerik-sf $
  42. */
  43. public class TrangGUITest{
  44. private static File testData;
  45. @BeforeClass
  46. public static void setUpjEdit() throws IOException{
  47. TestUtils.beforeClass();
  48. testData = new File(System.getProperty("test_data")).getCanonicalFile();
  49. assertTrue(testData.exists());
  50. }
  51. @AfterClass
  52. public static void tearDownjEdit() {
  53. TestUtils.afterClass();
  54. }
  55. @Test
  56. public void testDTDToXSD() throws IOException{
  57. final File in = new File(testData,"../xml/dtds/oasis-catalog.dtd");
  58. final File out = new File(testData,"../xml/dtds/oasis-catalog.xsd");
  59. final File out2 = new File(testData,"../xml/dtds/xml.xsd");
  60. Buffer b = openFile(in.getPath());
  61. GuiActionRunner.execute(new GuiTask(){
  62. protected void executeInEDT(){
  63. action("xml-trang-translate");
  64. }
  65. });
  66. DialogFixture f = findDialogByTitle("Trang GUI");
  67. f.textBox("xml.translate.input.prompt").requireText(in.getPath());
  68. f.comboBox("input-type").requireSelection("dtd");
  69. f.checkBox("inline-attlist").requireVisible().requireNotSelected();
  70. f.textBox("xml.translate.output.prompt").requireText(in.getPath());
  71. f.comboBox("output-type").requireSelection("dtd");
  72. f.comboBox("output-type").selectItem("xsd");
  73. f.checkBox("disable-abstract-elements").requireVisible().requireNotSelected();
  74. f.checkBox("inline-attlist").requireVisible().requireSelected();
  75. f.textBox("xml.translate.output.prompt").requireText(out.getPath());
  76. ClickT clickT = new ClickT(Option.OK);
  77. clickT.start();
  78. f.button(JButtonMatcher.withText("OK")).click();
  79. clickT.waitForClick();
  80. Buffer outB = jEdit.getBuffer(out.getPath());
  81. assertNotNull(outB);
  82. //inline-attlist
  83. assertFalse(outB.getText(0,outB.getLength())
  84. .contains("<xs:attributeGroup ref=\"ns1:attlist.rewriteURI\"/>"));
  85. GuiActionRunner.execute(new GuiTask(){
  86. protected void executeInEDT(){
  87. action("xml-trang-translate");
  88. }
  89. });
  90. Pause.pause(1000);
  91. f = new DialogFixture(robot(),robot().finder().findByType(TrangGUI.class));
  92. f.comboBox("output-type").selectItem("xsd");
  93. f.checkBox("inline-attlist").uncheck();
  94. clickT = new ClickT(Option.OK);
  95. clickT.start();
  96. f.button(JButtonMatcher.withText("OK")).click();
  97. clickT.waitForClick();
  98. assertTrue(outB.getText(0,outB.getLength())
  99. .contains("<xs:attributeGroup ref=\"ns1:attlist.rewriteURI\"/>"));
  100. close(view(),outB);
  101. outB = jEdit.getBuffer(out2.getPath());
  102. assertNotNull(outB);
  103. close(view(),outB);
  104. close(view(),b);
  105. }
  106. @Test
  107. public void testInputFormatChange() throws IOException{
  108. final File in1 = new File(testData,"rnc/actions.xml").getCanonicalFile();
  109. final File in2 = new File(testData,"rnc/actions.rnc").getCanonicalFile();
  110. Buffer b = openFile(in1.getPath());
  111. GuiActionRunner.execute(new GuiTask(){
  112. protected void executeInEDT(){
  113. action("xml-trang-translate");
  114. }
  115. });
  116. final DialogFixture f = findDialogByTitle("Trang GUI");
  117. f.textBox("xml.translate.input.prompt").requireText(in1.getPath());
  118. f.comboBox("input-type").requireSelection("xml");
  119. f.button("xml.translate.input.select").click();
  120. DialogFixture browseDialog = findDialogByTitle("File Browser - Open");
  121. Pause.pause(1000);
  122. browseDialog.button("up").click();
  123. Pause.pause(1000);
  124. browseDialog.table("file").cell(
  125. browseDialog.table("file").cell(in1.getParentFile().getName())).doubleClick();
  126. Pause.pause(1000);
  127. browseDialog.table("file").selectCell(
  128. browseDialog.table("file").cell(in2.getName()));
  129. browseDialog.button("ok").click();
  130. Pause.pause(500);
  131. f.comboBox("input-type").requireSelection("rnc");
  132. f.close();
  133. close(view(),b);
  134. }
  135. }