source: gs3-extensions/testing/trunk/src/src/org/greenstone/gsdl3/testing/GSGUITestingUtil.java@ 32694

Last change on this file since 32694 was 32694, checked in by ak19, 5 years ago

Started implementing GSGUITestingUtil.java and simultaneously testing it out. To compile it now needs GLI.jar in classpath which also needs GS3 env script run, so update to build.xml as well.

File size: 5.9 KB
Line 
1package org.greenstone.gsdl3.testing;
2
3import java.util.Map;
4import java.awt.Component;
5
6// only JUnit and JAssert-Swing, no Selenium in this class
7import org.junit.Assert;
8import org.assertj.swing.fixture.*;
9
10// GLI imports
11import org.greenstone.gatherer.Gatherer;
12import org.greenstone.gatherer.GathererProg; // main GLI class we'll be testing
13import org.greenstone.gatherer.Dictionary; // access to display strings
14
15/*
16 * Utility class containing helper functions for GLI GUI testing using AsssertJ Swing
17*/
18
19public class GSGUITestingUtil
20{
21 public static final String DOWNLOAD_PANE = "GUI.Download";
22 public static final String GATHER_PANE = "GUI.Gather";
23 public static final String ENRICH_PANE = "GUI.Enrich";
24 public static final String DESIGN_PANE = "GUI.Design";
25 public static final String CREATE_PANE = "GUI.Create";
26 public static final String FORMAT_PANE = "GUI.Format";
27
28 /************** NEEDED FOR TESTING *************/
29 // There's now a new method in GLI: GUIManager.setNamesRecursively()
30 // that attempts to recursively call setName() on visible GUI components so that we
31 // can have easier access to those GUI components when testing here through their names
32
33 /************************ GENERAL *******************************/
34 //https://joel-costigliola.github.io/assertj/swing/api/org/assertj/swing/fixture/FrameFixture.html
35 public static void switchToPane(FrameFixture window, String pane) {
36 String paneLabel = Dictionary.get(pane); // e.g. GUI.Enrich
37 //JPanelFixture tab = window.panel(pane); // this just gets us the JPanel of controls within
38 JTabbedPaneFixture tab = window.tabbedPane("GUIManager.tab_pane");
39 tab.selectTab(paneLabel); // select tab by its title
40 }
41 public static void getMenu(String menu, String subMenu) {}
42
43 // e.g. pane = Enrich,view=collection; pane = Gather, view = workspace (or collection)
44 public static void getFolderPath(String pane, String view, String folderPath) {}
45 public static void getFilePath(String pane, String view, String filePath) {}
46
47 /**********************FILE MENU*******************************/
48 public static void setPrefs(String tab, Map params) {}
49 // mode e.g. librarian, expert
50 public static void changeUserMode(String mode) {}
51
52 public static void deleteCollection(){}
53 public static void saveCollection(){}
54 public static void closeCollection(){}
55 public static void createCollection(String basedOn) {}
56 public static void loadCollection(String colName) {}
57
58 // only for GS2?
59 public static void exportCollection() {}
60
61 /*************** DESIGN ******************************/
62 public static void changeIndexer(String toIndexer) {}
63 public static void changeDB(String toDB) {}
64
65 public static void configurePartitionIndex(String tab, Map params) {}
66
67 public static void configurePlugin(String pluginName, Map params) {
68 }
69
70 public static void configureClassifier(String classifierName, Map params) {}
71
72 public static void configurePlugout(String plugoutName, Map params) {}
73
74 // https://www.journaldev.com/1257/java-varargs
75 // https://www.geeksforgeeks.org/variable-arguments-varargs-in-java/
76 public static void keepOnlyPlugins(String ... plug_n) {}
77
78 public static void removePlugs(String ... plug_n) {}
79
80 /********************** CREATE PANEL ********************/
81 public static void buildOpenCollection() {}
82 public static void buildOpenCollection(boolean minimalRebuild) {}
83 public static void configureImportOptions(Map params) {}
84 public static void configureBuildOptions(Map params) {}
85
86 public static void buildOutputContains(String ... n) {}
87
88 /******************** GATHER PANE ********************/
89 public static void createWorkspaceShortcut(){}
90
91 // in current open collection
92 public static void createCollectionSubfolder() {}
93
94 public static void dragNDrop(String workspacePath, String collPath) {}
95
96 /********************* ENRICH PANE ******************/
97 // docPath can be just docName or collectionSubfolder/Subfolder2/docName
98 public static void addMeta(String docPath, Map metanamesToValues) {}
99 public static void addFolderLevelMeta(String folderPath, Map metanamesToValues) {}
100
101 /********************* DOWNLOAD PANE ******************/
102 // TODO: more functions needed here: e.g. serverInfo?
103 public static void download(String downloader, Map params) {}
104 public static void clearCache() {}
105 public static String serverInfo() {
106 return "";
107 }
108
109 /********************* DOWNLOAD PANE ******************/
110 public static void formatGeneral(){}
111 public static void formatSearch() {}
112 public static void formatFeature(String featureName, String filename) {}
113 public static boolean isFormatFeatureXMLValid() {
114 return true;
115 }
116
117 // Moving these working bits of code here, in case I can use them to right
118 // general get methods that make use of the GenericTypeMatcher method of accessing components
119 // See https://joel-costigliola.github.io/assertj/assertj-swing-lookup.html
120
121 /*window = findFrame(new GenericTypeMatcher<JFrame>(JFrame.class) {
122 protected boolean isMatching(JFrame window) {
123 return window.getTitle().trim().startsWith(expectedWindowTitle)
124 && window.isShowing();
125 }
126 }).using(robot());
127 */
128 /*
129 JTabbedPaneFixture tab = window.tabbedPane(new GenericTypeMatcher<JTabbedPane>(JTabbedPane.class) {
130 @Override protected boolean isMatching(JTabbedPane tabPane) {
131 System.err.println("### trying for match");
132 //int index = GuiActionRunner.execute(() -> tabPane.getSelectedIndex());
133 int index = tabPane.getSelectedIndex();
134 String selectedTabTitle = tabPane.getTitleAt(index); //GuiActionRunner.execute(() -> tabPane.getTitleAt(index));
135 System.err.println("### GOT TITLE: " + selectedTabTitle);
136 return gatherPaneLabel.equals(selectedTabTitle);
137 }
138 });
139 */
140}
Note: See TracBrowser for help on using the repository browser.