-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #73 from pvlaraia/fix-window-crash
Fix Colocalisation_Test window crash on multiple runs
- Loading branch information
Showing
5 changed files
with
79 additions
and
28 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,9 @@ on: | |
- master | ||
tags: | ||
- "*-[0-9]+.*" | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
build: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
src/test/java/sc/fiji/coloc/tests/ColocalisationGUITest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/*- | ||
* #%L | ||
* Fiji's plugin for colocalization analysis. | ||
* %% | ||
* Copyright (C) 2009 - 2024 Fiji developers. | ||
* %% | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public | ||
* License along with this program. If not, see | ||
* <http://www.gnu.org/licenses/gpl-3.0.html>. | ||
* #L% | ||
*/ | ||
package sc.fiji.coloc.tests; | ||
|
||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertTrue; | ||
import static org.junit.Assume.assumeFalse; | ||
|
||
import java.awt.Window; | ||
import java.awt.event.WindowEvent; | ||
|
||
import org.junit.Test; | ||
|
||
import ij.IJ; | ||
import ij.ImagePlus; | ||
import ij.WindowManager; | ||
import ij.plugin.ChannelSplitter; | ||
import sc.fiji.coloc.Colocalisation_Test; | ||
|
||
public class ColocalisationGUITest extends ColocalisationTest { | ||
@Test | ||
public void testThatWindowRefIsCleanedUpIfClosed() { | ||
assumeFalse(java.awt.GraphicsEnvironment.isHeadless()); | ||
|
||
ImagePlus img = IJ.openImage("http://imagej.net/images/FluorescentCells.zip"); | ||
ImagePlus[] splitImg = ChannelSplitter.split(img); | ||
Colocalisation_Test colocalisationTest = new Colocalisation_Test(); | ||
|
||
// run module once, it'll open results textWindow | ||
colocalisationTest.correlate(splitImg[0], splitImg[1], splitImg[2]); | ||
|
||
// check textWindow is open, and close it | ||
Window resultsWindow = WindowManager.getWindow("Results"); | ||
assertTrue(resultsWindow.isVisible()); | ||
resultsWindow.dispatchEvent(new WindowEvent(resultsWindow, WindowEvent.WINDOW_CLOSING)); | ||
assertFalse(resultsWindow.isVisible()); | ||
|
||
// run module again | ||
colocalisationTest.correlate(splitImg[0], splitImg[1], splitImg[2]); | ||
|
||
// check textWindow is open, .correlate didnt crash! | ||
resultsWindow = WindowManager.getWindow("Results"); | ||
assertTrue(resultsWindow.isVisible()); | ||
|
||
} | ||
} |