Skip to content

Commit 79da539

Browse files
committed
Merge pull request #84 from ProgrammingLife3/tests/moretests
Tests/moretests
2 parents 87ed79c + d0fb571 commit 79da539

31 files changed

+886
-49
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ hs_err_pid*
5858
/local/*
5959
!/data/testdata/
6060
!/data/testdata/*.graph
61-
61+
!/data/testdata/*/*.nwk
6262
!resources/pictures/*
6363

64+
.save-helix2.txt
6465
lastOpenedSave.txt

.save-helix2.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/Users/tombrouws/Downloads/100_strains_graph
2+
/Users/tombrouws/context/ProgrammingLife3/data/10_strains_graph
3+
/Users/tombrouws/Downloads/38_strains_graph
4+
/Users/tombrouws/context/ProgrammingLife3/data/10_strains_graph/metadata.txt
5+
/Users/tombrouws/Downloads/38_strains_graph/simple_graph.node.graph

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ notifications:
88
- http://octopull.rmhartog.me/api/travis/webhook
99
before_install:
1010
- "[ \"$BUILD_PR_BRANCH\" = \"true\" ] && git checkout $TRAVIS_BRANCH && echo \"OCTOPULL_SHA=$(git rev-parse HEAD)\"; true"
11+
- "export DISPLAY=:99.0"
12+
- "sh -e /etc/init.d/xvfb start"
1113
env:
1214
- BUILD_PR_BRANCH=true
1315
- BUILD_PR_BRANCH=false

data/testdata/LastOpenedTest/test.edge.graph

Whitespace-only changes.

data/testdata/LastOpenedTest/test.node.graph

Whitespace-only changes.

data/testdata/LastOpenedTest/test.nwk

Whitespace-only changes.

data/testdata/savetest

Whitespace-only changes.

pom.xml

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,32 @@
99
<url>http://maven.apache.org</url>
1010
<properties>
1111
<checkstyle.config.location>checkstyle.xml</checkstyle.config.location>
12+
<powermock.version>1.6.1</powermock.version>
1213
</properties>
1314
<dependencies>
15+
<dependency>
16+
<groupId>org.powermock</groupId>
17+
<artifactId>powermock-module-junit4</artifactId>
18+
<version>${powermock.version}</version>
19+
<scope>test</scope>
20+
</dependency>
21+
<dependency>
22+
<groupId>org.powermock</groupId>
23+
<artifactId>powermock-api-mockito</artifactId>
24+
<version>${powermock.version}</version>
25+
<scope>test</scope>
26+
</dependency>
1427
<dependency>
1528
<groupId>junit</groupId>
1629
<artifactId>junit</artifactId>
1730
<version>4.12</version>
1831
<scope>test</scope>
1932
</dependency>
33+
<dependency>
34+
<groupId>com.github.stefanbirkner</groupId>
35+
<artifactId>system-rules</artifactId>
36+
<version>1.3.0</version>
37+
</dependency>
2038
<dependency>
2139
<groupId>org.graphstream</groupId>
2240
<artifactId>gs-core</artifactId>
@@ -37,11 +55,11 @@
3755
<artifactId>findbugs</artifactId>
3856
<version>3.0.1</version>
3957
</dependency>
40-
<dependency>
41-
<groupId>org.mockito</groupId>
42-
<artifactId>mockito-all</artifactId>
43-
<version>1.9.5</version>
44-
</dependency>
58+
<!--<dependency>-->
59+
<!--<groupId>org.mockito</groupId>-->
60+
<!--<artifactId>mockito-all</artifactId>-->
61+
<!--<version>1.9.5</version>-->
62+
<!--</dependency>-->
4563
<dependency>
4664
<groupId>org.swinglabs</groupId>
4765
<artifactId>swingx</artifactId>

src/main/java/tudelft/ti2806/pl3/Application.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,15 +162,10 @@ public void makeGraphFromFiles() {
162162
*/
163163
public void makeGraph(File nodeFile, File edgeFile, File treeFile) {
164164
try {
165-
final long startTime = System.currentTimeMillis();
166-
167165
graphController.parseGraph(nodeFile, edgeFile);
168166
if (treeFile != null) {
169167
makePhyloTree(treeFile);
170168
}
171-
172-
long loadTime = System.currentTimeMillis() - startTime;
173-
System.out.println("Loadtime: " + loadTime);
174169
} catch (FileNotFoundException exception) {
175170
if (DialogUtil.confirm("Error!", "Your file was not found. Want to try again?")) {
176171
makeGraph(nodeFile, edgeFile, treeFile);
@@ -305,7 +300,7 @@ public Rectangle getBounds() {
305300
return new Rectangle(main.getWidth(), main.getHeight());
306301
}
307302

308-
public void repaint(){
303+
public void repaint() {
309304
main.repaint();
310305
}
311306

src/main/java/tudelft/ti2806/pl3/ScreenSize.java

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
*/
1010
public class ScreenSize {
1111

12-
private static int minimumWidth = 800;
13-
private static int minimumHeight = 600;
12+
public static int minimumWidth = 800;
13+
public static int minimumHeight = 600;
1414
private static ScreenSize size;
15-
private static int menubarHeight = 25;
15+
public static int menubarHeight = 25;
1616
private int width;
1717
private int height;
1818
private int zoombarHeight;
@@ -93,12 +93,4 @@ public void calculate() {
9393
public int calculate(double percentage, int integer) {
9494
return (int) (percentage * integer);
9595
}
96-
97-
public int calculateHeight(double percentage) {
98-
return calculate(percentage, height);
99-
}
100-
101-
public int calculateWidth(double percentage) {
102-
return calculate(percentage, width);
103-
}
10496
}

src/main/java/tudelft/ti2806/pl3/controls/ResizeAdapter.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
/**
1111
* Creates an adapter that updates screen sizes for the components in the view.
12-
*
12+
* <p>
1313
* Created by Kasper on 16-6-2015.
1414
*/
1515
public class ResizeAdapter extends ComponentAdapter {
@@ -22,7 +22,6 @@ public ResizeAdapter(Application application) {
2222
}
2323

2424

25-
2625
@Override
2726
public void componentResized(ComponentEvent e) {
2827
Rectangle bounds = application.getBounds();
@@ -44,7 +43,7 @@ public void componentResized(ComponentEvent e) {
4443
application.repaint();
4544
}
4645

47-
public ComponentAdapter getResizer(){
46+
public ComponentAdapter getResizer() {
4847
return this;
4948
}
5049
}

src/main/java/tudelft/ti2806/pl3/findgenes/FindgenesController.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
import tudelft.ti2806.pl3.ui.util.DialogUtil;
1010
import tudelft.ti2806.pl3.visualization.GraphController;
1111

12-
import javax.swing.JOptionPane;
13-
1412
/**
1513
* This controller controls the view that lets you select a gene from a list, and will navigate you to it in the graph.
1614
* Created by Boris Mattijssen on 30-05-15.
@@ -52,9 +50,7 @@ public void openDialog() {
5250
Gene selected = (Gene) findgenesView.getSelectedItem();
5351
DataNode node = graphData.getGeneToStartNodeMap().get(selected);
5452
if (node == null) {
55-
JOptionPane.showMessageDialog(null,
56-
"Couldn't find the selected gene. Try again");
57-
tryAgain = true;
53+
tryAgain = DialogUtil.confirm("Error!", "Couldn't find the selected gene. Please try again");
5854
} else {
5955
cc.getGraphController().centerOnNode(node);
6056
}

src/main/java/tudelft/ti2806/pl3/menubar/LastOpenedController.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ public void actionPerformed(ActionEvent e) {
4646

4747
if (chosenfile.endsWith(".nwk")) {
4848
// tree file
49-
System.out.println("phylo tree");
5049
FileSelector.lastopened.add(file);
5150
application.makePhyloTree(file);
5251
} else if (chosenfile.endsWith(".node.graph")) {

src/main/java/tudelft/ti2806/pl3/menubar/MenuBarController.java

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ public class MenuBarController implements ActionListener, Controller {
4242
/**
4343
* Text that is displayed in the About Me option in the Help menu.
4444
*/
45-
final String about = "Helix² is an interactive DNA sequence viewer. "
45+
static final String about = "Helix\u00B2 is an interactive DNA sequence viewer. "
4646
+ "It uses semantic zooming to only display relative information. \n"
4747
+ "This application was created as part of an assignment"
4848
+ "for the Context Project at TU Delft.\n"
4949
+ "\n"
50-
+ "Helix was created by: \n"
50+
+ "Helix\u00B2 was created by: \n"
5151
+ "- Tom Brouws\n"
5252
+ "- Boris Mattijssen\n"
5353
+ "- Mathieu Post\n"
@@ -59,7 +59,7 @@ public class MenuBarController implements ActionListener, Controller {
5959
/**
6060
* Text that is displayed in the Controls option in the Help menu.
6161
*/
62-
final String controls = "Helix² uses key shortcuts to make life easier. "
62+
static final String controls = "Helix\u00B2 uses key shortcuts to make life easier. "
6363
+ "All the controls that can be used are listed below. \n"
6464
+ "\n"
6565
+ "Zooming in \t+ \n"
@@ -132,10 +132,19 @@ private void showFindGenes() {
132132
public void setLastOpenedMenu(Component lastOpenedMenu) {
133133
menuBarView.setLastOpenedMenu(lastOpenedMenu);
134134
}
135+
136+
/**
137+
* Displays the controls text in a {@link DialogUtil}.
138+
*/
139+
private void displayControls() {
140+
DialogUtil.displayMessageWithView(new JScrollPane(makeControls()), "Controls");
141+
}
142+
135143
/**
136-
* Displays the controls text in a {@link JTextPane}.
144+
* Make a {@link JTextPane} with controls text.
145+
* @return JTextpane with control text.
137146
*/
138-
public void displayControls() {
147+
public JTextPane makeControls() {
139148
JTextPane textPane = new JTextPane();
140149
TabStop[] tabs = new TabStop[1];
141150
tabs[0] = new TabStop(300, TabStop.ALIGN_LEFT, TabStop.LEAD_NONE);
@@ -150,13 +159,21 @@ public void displayControls() {
150159
textPane.setBackground(new Color(240, 240, 240));
151160
textPane.setPreferredSize(new Dimension(500, 200));
152161

153-
DialogUtil.displayMessageWithView(new JScrollPane(textPane), "Controls");
162+
return textPane;
154163
}
155164

156165
/**
157-
* Displays the about me text in a {@link JTextPane}.
166+
* Displays the about me text in {@link DialogUtil}.
158167
*/
159168
private void displayAbout() {
169+
DialogUtil.displayMessageWithView(new JScrollPane(makeAbout()), "About me");
170+
}
171+
172+
/**
173+
* Make a {@link JTextPane} with about me text.
174+
* @return JTextpane with about me text.
175+
*/
176+
public JTextPane makeAbout() {
160177
StyleContext styleContext = new StyleContext();
161178
DefaultStyledDocument doc = new DefaultStyledDocument(styleContext);
162179
JTextPane textPane = new JTextPane(doc);
@@ -174,7 +191,7 @@ private void displayAbout() {
174191
textPane.setBackground(new Color(240, 240, 240));
175192
textPane.setPreferredSize(new Dimension(500, 200));
176193

177-
DialogUtil.displayMessageWithView(new JScrollPane(textPane), "About me");
194+
return textPane;
178195
}
179196

180197
/**
@@ -184,7 +201,7 @@ private void displayAbout() {
184201
*
185202
* @return clickable JLabel with URL
186203
*/
187-
private JLabel website() {
204+
public JLabel website() {
188205
JLabel website = new JLabel("https://github.com/ProgrammingLife3/ProgrammingLife3");
189206
website.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
190207
website.addMouseListener(new MouseAdapter() {
@@ -195,8 +212,8 @@ public void mouseClicked(MouseEvent e) {
195212
Desktop.getDesktop().browse(github);
196213
} catch (IOException | URISyntaxException exception) {
197214
String message = "An error has occurred!"
198-
+ " We are unable to display the GitHub link in your browser.";
199-
DialogUtil.displayError(message,"Error!");
215+
+ " We are unable to display the GitHub link in your browser.";
216+
DialogUtil.displayError(message, "Error!");
200217
}
201218
}
202219
});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package tudelft.ti2806.pl3.ui.util;
2+
3+
/**
4+
* Interface for the ConfirmOptionPane
5+
* Created by Kasper on 17-6-2015.
6+
*/
7+
public interface ConfirmOptionPane {
8+
9+
/**
10+
* @see {@link javax.swing.JOptionPane}
11+
*/
12+
boolean showConfirmDialog(Object message, String title);
13+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package tudelft.ti2806.pl3.ui.util;
2+
3+
import javax.swing.JOptionPane;
4+
5+
/**
6+
* Default implementation of the {@link ConfirmOptionPane}.
7+
* Created by Kasper on 17-6-2015.
8+
*/
9+
public class DefaultConfirmOptionPane implements ConfirmOptionPane {
10+
@Override
11+
public boolean showConfirmDialog(Object message, String title) {
12+
int answer = JOptionPane
13+
.showConfirmDialog(null, message, title,
14+
JOptionPane.YES_NO_OPTION,
15+
JOptionPane.QUESTION_MESSAGE);
16+
return answer == JOptionPane.YES_OPTION;
17+
}
18+
}

src/main/java/tudelft/ti2806/pl3/ui/util/DialogUtil.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* Created by Boris Mattijssen on 14-06-15.
99
*/
1010
public class DialogUtil {
11+
static ConfirmOptionPane confirmOptionPane = new DefaultConfirmOptionPane();
1112

1213
private DialogUtil() {
1314
}
@@ -22,11 +23,7 @@ private DialogUtil() {
2223
* @return the dialog
2324
*/
2425
public static boolean confirm(String title, String message) {
25-
int answer = JOptionPane
26-
.showConfirmDialog(null, message, title,
27-
JOptionPane.YES_NO_OPTION,
28-
JOptionPane.QUESTION_MESSAGE);
29-
return answer == JOptionPane.YES_OPTION;
26+
return confirmOptionPane.showConfirmDialog(message, title);
3027
}
3128

3229
/**
@@ -75,4 +72,8 @@ public static void displayError(String message, String title) {
7572
JOptionPane.showMessageDialog(null, message, title, JOptionPane.ERROR_MESSAGE);
7673
}
7774

75+
public static void setConfirmOptionPane(ConfirmOptionPane pane) {
76+
confirmOptionPane = pane;
77+
}
78+
7879
}

src/main/java/tudelft/ti2806/pl3/visualization/GraphController.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public class GraphController implements Controller {
2828
private GraphDataRepository graphDataRepository;
2929
private Map<String, Filter<DataNode>> filters = new HashMap<>();
3030
private static final int DEFAULT_VIEW = 1;
31+
private GeneData geneData;
3132

3233
/**
3334
* Percentage of the screen that is moved.
@@ -76,7 +77,7 @@ public void addLoadingObservers(ArrayList<LoadingObserver> loadingObservers) {
7677
*/
7778
public void parseGraph(File nodeFile, File edgeFile) throws FileNotFoundException {
7879
try {
79-
GeneData geneData = GeneData.parseGenes("geneAnnotationsRef");
80+
geneData = GeneData.parseGenes("geneAnnotationsRef");
8081
graphDataRepository.parseGraph(nodeFile, edgeFile, geneData);
8182
graphView.getPanel().setVisible(false);
8283
graphView.getPanel().setVisible(true);
@@ -245,4 +246,8 @@ public float getOffsetToCenter() {
245246
public void removeDetailView() {
246247
graphView.removeDetailView();
247248
}
249+
250+
public GeneData getGeneData() {
251+
return geneData;
252+
}
248253
}

0 commit comments

Comments
 (0)