diff options
author | Bruno Jofret <bruno.jofret@scilab.org> | 2007-06-15 08:43:14 +0000 |
---|---|---|
committer | Bruno Jofret <bruno.jofret@scilab.org> | 2007-06-15 08:43:14 +0000 |
commit | 5788fc9929245d3bdbc7b2db9e62ab27a86efff6 (patch) | |
tree | 078ccdad280accf64e36b179a2146d7141cce259 /tests | |
parent | 8f0ad1312a6c13441120b0d8f04fb726fdcf413a (diff) | |
download | scilab-5788fc9929245d3bdbc7b2db9e62ab27a86efff6.zip scilab-5788fc9929245d3bdbc7b2db9e62ab27a86efff6.tar.gz |
Adding some GUI tests in trunk.
Must be improved...
Diffstat (limited to 'tests')
-rw-r--r-- | tests/GUI/Scilab.java | 140 | ||||
-rw-r--r-- | tests/GUI/ScilabConsoleTest.java | 100 | ||||
-rw-r--r-- | tests/GUI/addmember/AddMemberTest.java | 82 | ||||
-rw-r--r-- | tests/GUI/window/size/SizeTest.java | 86 |
4 files changed, 408 insertions, 0 deletions
diff --git a/tests/GUI/Scilab.java b/tests/GUI/Scilab.java new file mode 100644 index 0000000..26fc6a1 --- /dev/null +++ b/tests/GUI/Scilab.java | |||
@@ -0,0 +1,140 @@ | |||
1 | |||
2 | /* Copyright INRIA 2007 */ | ||
3 | |||
4 | package fr.scilab.test; | ||
5 | |||
6 | import java.awt.EventQueue; | ||
7 | |||
8 | import javax.swing.UIManager; | ||
9 | |||
10 | import org.flexdock.docking.DockingManager; | ||
11 | import org.flexdock.util.SwingUtility; | ||
12 | |||
13 | import fr.scilab.console.Console; | ||
14 | import fr.scilab.console.ScilabConsole; | ||
15 | import fr.scilab.ihm.canvas.Canvas; | ||
16 | import fr.scilab.ihm.canvas.ScilabCanvas; | ||
17 | import fr.scilab.ihm.tab.ScilabTab; | ||
18 | import fr.scilab.ihm.tab.Tab; | ||
19 | import fr.scilab.ihm.utils.Position; | ||
20 | import fr.scilab.ihm.utils.Size; | ||
21 | import fr.scilab.ihm.window.ScilabWindow; | ||
22 | import fr.scilab.ihm.window.Window; | ||
23 | |||
24 | /** | ||
25 | * Test class for Scilab 5.0 GUIs | ||
26 | * @author Vincent COUVERT | ||
27 | * @author Bruno JOFRET | ||
28 | */ | ||
29 | public class Scilab { | ||
30 | |||
31 | private static final int NEWWIDTH = 100; | ||
32 | private static final int NEWHEIGHT = 100; | ||
33 | |||
34 | private static final int NEWXPOSITION = 100; | ||
35 | private static final int NEWYPOSITION = 100; | ||
36 | |||
37 | private static final int DEFAULTWIDTH = 500; | ||
38 | private static final int DEFAULTHEIGHT = 500; | ||
39 | |||
40 | /** | ||
41 | * Constructor | ||
42 | */ | ||
43 | protected Scilab() { | ||
44 | throw new UnsupportedOperationException(); /* Prevents calls from subclass */ | ||
45 | } | ||
46 | |||
47 | /** | ||
48 | * Launch main Scilab | ||
49 | * @param args not used | ||
50 | */ | ||
51 | public static void main(String[] args) { | ||
52 | SwingUtility.setPlaf(UIManager.getSystemLookAndFeelClassName()); | ||
53 | |||
54 | DockingManager.setFloatingEnabled(true); | ||
55 | |||
56 | EventQueue.invokeLater(new Runnable() { | ||
57 | public void run() { | ||
58 | createAndShowGui(); | ||
59 | } | ||
60 | }); | ||
61 | } | ||
62 | |||
63 | /** | ||
64 | * Creates and show Scilab main GUI | ||
65 | */ | ||
66 | private static void createAndShowGui() { | ||
67 | System.out.println("-*- Starting Program -*-"); | ||
68 | |||
69 | Window mainView = ScilabWindow.createWindow(); | ||
70 | mainView.draw(); | ||
71 | |||
72 | /* DIMENSIONS */ | ||
73 | /* Defaut dimensions */ | ||
74 | Size windowSize = mainView.getDims(); | ||
75 | System.out.println("Window Size = " + windowSize.getWidth() + "x" + windowSize.getHeight()); | ||
76 | /* User defined dimensions */ | ||
77 | Size newWindowSize = new Size(NEWWIDTH, NEWHEIGHT); | ||
78 | mainView.setDims(newWindowSize); | ||
79 | windowSize = mainView.getDims(); | ||
80 | System.out.println("-*- Has size changed ??? -*-"); | ||
81 | System.out.println("Window Size: " + windowSize.getWidth() + "x" + windowSize.getHeight()); | ||
82 | |||
83 | /* POSITION */ | ||
84 | /* Default position */ | ||
85 | Position windowPosition = mainView.getPosition(); | ||
86 | System.out.println("Window Position: x=" + windowPosition.getX() + " and y=" + windowPosition.getY()); | ||
87 | /* User defined position */ | ||
88 | Position newWindowPosition = new Position(NEWXPOSITION, NEWYPOSITION); | ||
89 | mainView.setPosition(newWindowPosition); | ||
90 | windowPosition = mainView.getPosition(); | ||
91 | System.out.println("-*- Has position changed ??? -*-"); | ||
92 | System.out.println("New Window Position: x=" + windowPosition.getX() + " and y=" + windowPosition.getY()); | ||
93 | |||
94 | /* TITLE */ | ||
95 | System.out.println("Window Title: " + mainView.getTitle()); | ||
96 | mainView.setTitle("Scilab IHM in Java"); | ||
97 | System.out.println("-*- Has title changed ??? -*-"); | ||
98 | System.out.println("New Window Title: " + mainView.getTitle()); | ||
99 | |||
100 | /* VISIBILITY */ | ||
101 | System.out.println("Window is visible ? (YES=default value): " + mainView.isVisible()); | ||
102 | mainView.setVisible(false); | ||
103 | System.out.println("Window is visible ? (NO): " + mainView.isVisible()); | ||
104 | mainView.setVisible(true); | ||
105 | System.out.println("Window is visible ? (YES): " + mainView.isVisible()); | ||
106 | |||
107 | /* CONSOLE */ | ||
108 | mainView.setVisible(true); /* Added because the windows resize below does not work !! */ | ||
109 | newWindowSize = new Size(DEFAULTWIDTH, DEFAULTHEIGHT); | ||
110 | mainView.setDims(newWindowSize); | ||
111 | /* Create a tab to put console into */ | ||
112 | Tab consoleTab = ScilabTab.createTab("Console Scilab"); | ||
113 | //consoleTab.setName("Console"); | ||
114 | mainView.addTab(consoleTab); | ||
115 | /* Create the console */ | ||
116 | Console sciConsole = ScilabConsole.createConsole(); | ||
117 | consoleTab.addMember(sciConsole); | ||
118 | mainView.draw(); | ||
119 | |||
120 | /* FIGURE */ | ||
121 | /* Create the tab to put a canvas into */ | ||
122 | Tab figureTab = ScilabTab.createTab("Scilab Figure"); | ||
123 | //figureTab.setName("Scilab Figure"); | ||
124 | mainView.addTab(figureTab); | ||
125 | |||
126 | /* Create the Frame */ | ||
127 | //Frame canvasFrame = ScilabFrame.createFrame(); | ||
128 | /* Create the canvas */ | ||
129 | Canvas figureCanvas = ScilabCanvas.createCanvas(); | ||
130 | figureCanvas.setDims(new Size(DEFAULTWIDTH, DEFAULTHEIGHT)); | ||
131 | figureCanvas.draw(); | ||
132 | //canvasFrame.addMember(figureCanvas); | ||
133 | //canvasFrame.setDims(new Size(DEFAULTWIDTH, DEFAULTHEIGHT)); | ||
134 | //canvasFrame.draw(); | ||
135 | //figureTab.addMember(canvasFrame); | ||
136 | figureTab.addMember(figureCanvas); | ||
137 | figureTab.draw(); | ||
138 | mainView.draw(); | ||
139 | } | ||
140 | } | ||
diff --git a/tests/GUI/ScilabConsoleTest.java b/tests/GUI/ScilabConsoleTest.java new file mode 100644 index 0000000..223f0a6 --- /dev/null +++ b/tests/GUI/ScilabConsoleTest.java | |||
@@ -0,0 +1,100 @@ | |||
1 | |||
2 | /* Copyright INRIA 2007 */ | ||
3 | |||
4 | package fr.scilab.test; | ||
5 | |||
6 | import java.awt.EventQueue; | ||
7 | |||
8 | import javax.swing.JFrame; | ||
9 | import javax.swing.UIManager; | ||
10 | |||
11 | import org.flexdock.docking.DockingManager; | ||
12 | import org.flexdock.util.SwingUtility; | ||
13 | |||
14 | import fr.scilab.console.Console; | ||
15 | import fr.scilab.console.ScilabConsole; | ||
16 | import fr.scilab.ihm.bridge.swing.SwingScilabConsole; | ||
17 | import fr.scilab.ihm.frame.Frame; | ||
18 | import fr.scilab.ihm.frame.ScilabFrame; | ||
19 | import fr.scilab.ihm.tab.ScilabTab; | ||
20 | import fr.scilab.ihm.tab.Tab; | ||
21 | import fr.scilab.ihm.window.ScilabWindow; | ||
22 | import fr.scilab.ihm.window.Window; | ||
23 | |||
24 | /** | ||
25 | * Test class for Scilab 5.0 GUIs | ||
26 | * @author Vincent COUVERT | ||
27 | * @author Bruno JOFRET | ||
28 | */ | ||
29 | public class ScilabConsoleTest { | ||
30 | |||
31 | /** | ||
32 | * Launch main Scilab | ||
33 | * @param args not used | ||
34 | */ | ||
35 | public static void main(String[] args) { | ||
36 | SwingUtility.setPlaf(UIManager.getSystemLookAndFeelClassName()); | ||
37 | |||
38 | DockingManager.setFloatingEnabled(true); | ||
39 | |||
40 | EventQueue.invokeLater(new Runnable() { | ||
41 | public void run() { | ||
42 | createAndShowGui(); | ||
43 | } | ||
44 | }); | ||
45 | } | ||
46 | |||
47 | /** | ||
48 | * Creates and show Scilab main GUI | ||
49 | */ | ||
50 | private static void createAndShowGui() { | ||
51 | System.out.println("-*- Starting Program -*-"); | ||
52 | |||
53 | Window mainView = ScilabWindow.createWindow(); | ||
54 | mainView.draw(); | ||
55 | |||
56 | Tab consoleTab = ScilabTab.createTab("Console"); | ||
57 | mainView.addTab(consoleTab); | ||
58 | mainView.draw(); | ||
59 | System.out.println("Console Tab Title: " + consoleTab.getName()); | ||
60 | System.out.println("-*- Stoping Program -*-"); | ||
61 | |||
62 | /* Console creation */ | ||
63 | Frame consoleFrame = ScilabFrame.createFrame(); | ||
64 | |||
65 | Console sciConsole = ScilabConsole.createConsole(); | ||
66 | |||
67 | //JyConsole console2 = new JyConsole(); | ||
68 | |||
69 | consoleFrame.addMember(sciConsole); | ||
70 | //ScilabBridge.addMember(consoleFrame, sciConsole); | ||
71 | |||
72 | // Bruno | ||
73 | //((JPanel) consoleFrame).add(console2); | ||
74 | //((JPanel) consoleFrame).add(new JButton("Ca pue @")); | ||
75 | //Console sick = new SwingScilabConsole(); | ||
76 | //((JPanel) consoleFrame).add(new SwingScilabConsole()); | ||
77 | |||
78 | //ScilabBridge.addMember(consoleTab, consoleFrame); | ||
79 | consoleTab.addMember(consoleFrame); | ||
80 | |||
81 | consoleFrame.draw(); | ||
82 | consoleTab.draw(); | ||
83 | mainView.draw(); | ||
84 | |||
85 | JFrame f = new JFrame(); | ||
86 | f.setSize(200,200); | ||
87 | SwingScilabConsole content = new SwingScilabConsole(); | ||
88 | f.add(content); | ||
89 | f.setVisible(true); | ||
90 | |||
91 | // JyConsole console = new JyConsole(); | ||
92 | // JFrame f = new JFrame("JyConsole by Artenum"); | ||
93 | // //f.setIconImage(new ImageIcon(JyConsole.class.getResource("logo.gif")).getImage()); | ||
94 | // f.getContentPane().add(console, BorderLayout.CENTER); | ||
95 | // f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | ||
96 | // f.setSize(600, 400); | ||
97 | // f.setLocationRelativeTo(null); | ||
98 | // f.setVisible(true); | ||
99 | } | ||
100 | } | ||
diff --git a/tests/GUI/addmember/AddMemberTest.java b/tests/GUI/addmember/AddMemberTest.java new file mode 100644 index 0000000..edf5767 --- /dev/null +++ b/tests/GUI/addmember/AddMemberTest.java | |||
@@ -0,0 +1,82 @@ | |||
1 | |||
2 | /* Copyright INRIA 2007 */ | ||
3 | |||
4 | package fr.scilab.test.addmember; | ||
5 | |||
6 | import static org.junit.Assert.assertTrue; | ||
7 | |||
8 | import org.junit.Test; | ||
9 | |||
10 | import fr.scilab.console.Console; | ||
11 | import fr.scilab.console.ScilabConsole; | ||
12 | import fr.scilab.ihm.ScilabBridge; | ||
13 | import fr.scilab.ihm.frame.Frame; | ||
14 | import fr.scilab.ihm.frame.ScilabFrame; | ||
15 | import fr.scilab.ihm.tab.ScilabTab; | ||
16 | import fr.scilab.ihm.tab.Tab; | ||
17 | |||
18 | /** | ||
19 | * Test class for Scilab 5.0 GUIs | ||
20 | * @author Vincent COUVERT | ||
21 | * @author Bruno JOFRET | ||
22 | */ | ||
23 | public class AddMemberTest { | ||
24 | |||
25 | /** | ||
26 | * We want to be able to add a Frame in a Tab | ||
27 | */ | ||
28 | @Test | ||
29 | public void addFrameInTab() { | ||
30 | System.out.println("-*- Starting Program -*-"); | ||
31 | |||
32 | /* Tab Creation */ | ||
33 | Tab tab = ScilabTab.createTab("Tab"); | ||
34 | |||
35 | /* Frame creation */ | ||
36 | Frame frame = ScilabFrame.createFrame(); | ||
37 | |||
38 | // Try to add a Frame in a Tab | ||
39 | assertTrue("_MUST_ be able to add a Frame in a Tab", tab.addMember(frame) != -1); | ||
40 | assertTrue("_MUST_ be able to add a Frame in a Tab (Through the Bridge)", ScilabBridge.addMember(tab, frame) != -1); | ||
41 | System.out.println("-*- Stoping Program -*-"); | ||
42 | } | ||
43 | |||
44 | /** | ||
45 | * We DO NOT want to be able to add a Console in a Frame | ||
46 | */ | ||
47 | @Test | ||
48 | public void addConsoleInFrame() { | ||
49 | System.out.println("-*- Starting Program -*-"); | ||
50 | |||
51 | /* Frame creation */ | ||
52 | Frame frame = ScilabFrame.createFrame(); | ||
53 | |||
54 | /* Console creation */ | ||
55 | Console console = ScilabConsole.createConsole(); | ||
56 | |||
57 | // Try to add a Console in a Frame | ||
58 | assertTrue("_MUST_NOT_ be able to add a Console in a Frame", frame.addMember(console) == -1); | ||
59 | assertTrue("_MUST_ be able to add a Console in a Frame (Through the Bridge)", ScilabBridge.addMember(frame, console) != -1); | ||
60 | System.out.println("-*- Stoping Program -*-"); | ||
61 | } | ||
62 | |||
63 | /** | ||
64 | * We want to be able to add a Console in a Tab | ||
65 | */ | ||
66 | @Test | ||
67 | public void addConsoleInTab() { | ||
68 | System.out.println("-*- Starting Program -*-"); | ||
69 | |||
70 | /* Tab creation */ | ||
71 | Tab tab = ScilabTab.createTab("Tab"); | ||
72 | |||
73 | /* Console creation */ | ||
74 | Console console = ScilabConsole.createConsole(); | ||
75 | |||
76 | // Try to add a Console in a Tab | ||
77 | assertTrue("_MUST_ be able to add a Console in a Tab", tab.addMember(console) != -1); | ||
78 | assertTrue("_MUST_ be able to add a Console in a Tab(Through the Bridge)", ScilabBridge.addMember(tab, console) != -1); | ||
79 | System.out.println("-*- Stoping Program -*-"); | ||
80 | } | ||
81 | |||
82 | } | ||
diff --git a/tests/GUI/window/size/SizeTest.java b/tests/GUI/window/size/SizeTest.java new file mode 100644 index 0000000..cd8bb99 --- /dev/null +++ b/tests/GUI/window/size/SizeTest.java | |||
@@ -0,0 +1,86 @@ | |||
1 | |||
2 | /* Copyright INRIA 2007 */ | ||
3 | |||
4 | package fr.scilab.test.window.size; | ||
5 | |||
6 | import static org.junit.Assert.assertEquals; | ||
7 | |||
8 | import org.junit.Test; | ||
9 | |||
10 | import fr.scilab.ihm.utils.Size; | ||
11 | import fr.scilab.ihm.window.ScilabWindow; | ||
12 | import fr.scilab.ihm.window.Window; | ||
13 | |||
14 | /** | ||
15 | * Unitary test for window size modification in Scilab | ||
16 | * @author Bruno Jofret | ||
17 | */ | ||
18 | public class SizeTest { | ||
19 | |||
20 | private static final int DEFAULTWIDTH = 100; | ||
21 | private static final int DEFAULTHEIGHT = 100; | ||
22 | private static final int NEWWIDTH = 500; | ||
23 | private static final int NEWHEIGHT = 800; | ||
24 | |||
25 | /** | ||
26 | * Constructor for class SizeTest | ||
27 | */ | ||
28 | public SizeTest() { | ||
29 | throw new UnsupportedOperationException(); /* Prevents calls from subclass */ | ||
30 | }; | ||
31 | |||
32 | /** | ||
33 | * Default window size test | ||
34 | */ | ||
35 | @Test | ||
36 | public void windowDefaultSize() { | ||
37 | |||
38 | Window mainView = ScilabWindow.createWindow(); | ||
39 | Size windowSize = mainView.getDims(); | ||
40 | /* Checking Default Size */ | ||
41 | assertEquals(DEFAULTWIDTH, windowSize.getWidth()); | ||
42 | assertEquals(DEFAULTHEIGHT, windowSize.getHeight()); | ||
43 | } | ||
44 | |||
45 | |||
46 | /** | ||
47 | * Test the change of width | ||
48 | */ | ||
49 | @Test | ||
50 | public void windowChangeWidth() { | ||
51 | int newWidth = NEWWIDTH; | ||
52 | Window mainView = ScilabWindow.createWindow(); | ||
53 | Size windowSize = mainView.getDims(); | ||
54 | /* Checking Default Size */ | ||
55 | assertEquals(DEFAULTWIDTH, windowSize.getWidth()); | ||
56 | assertEquals(DEFAULTHEIGHT, windowSize.getHeight()); | ||
57 | |||
58 | /* Changing Width */ | ||
59 | Size newWindowSize = new Size(newWidth, windowSize.getHeight()); | ||
60 | mainView.setDims(newWindowSize); | ||
61 | /* Checking Updated Size */ | ||
62 | assertEquals(newWidth, mainView.getDims().getWidth()); | ||
63 | assertEquals(DEFAULTHEIGHT, mainView.getDims().getHeight()); | ||
64 | } | ||
65 | |||
66 | /** | ||
67 | * Test the change of height | ||
68 | */ | ||
69 | @Test | ||
70 | public void windowChangeHeight() { | ||
71 | int newHeight = NEWHEIGHT; | ||
72 | Window mainView = ScilabWindow.createWindow(); | ||
73 | Size windowSize = mainView.getDims(); | ||
74 | /* Checking Default Size */ | ||
75 | assertEquals(DEFAULTWIDTH, windowSize.getWidth()); | ||
76 | assertEquals(DEFAULTHEIGHT, windowSize.getHeight()); | ||
77 | |||
78 | /* Changing Width */ | ||
79 | Size newWindowSize = new Size(windowSize.getWidth(), newHeight); | ||
80 | mainView.setDims(newWindowSize); | ||
81 | /* Checking Updated Size */ | ||
82 | assertEquals(DEFAULTWIDTH, mainView.getDims().getWidth()); | ||
83 | assertEquals(newHeight, mainView.getDims().getHeight()); | ||
84 | } | ||
85 | |||
86 | } | ||