diff --git a/test-acceptance/src/org/omegat/gui/main/TestCoreGUI.java b/test-acceptance/src/org/omegat/gui/main/TestCoreGUI.java
index 049113e64b..38e20836df 100644
--- a/test-acceptance/src/org/omegat/gui/main/TestCoreGUI.java
+++ b/test-acceptance/src/org/omegat/gui/main/TestCoreGUI.java
@@ -29,36 +29,22 @@
import java.io.File;
import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.Collections;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
-import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import org.apache.commons.io.FileUtils;
-import org.assertj.swing.edt.GuiActionRunner;
import org.assertj.swing.fixture.FrameFixture;
import org.assertj.swing.junit.testcase.AssertJSwingJUnitTestCase;
-import org.omegat.TestMainInitializer;
import org.omegat.core.Core;
import org.omegat.core.CoreEvents;
-import org.omegat.core.TestCoreInitializer;
-import org.omegat.core.data.NotLoadedProject;
-import org.omegat.core.threads.IAutoSave;
-import org.omegat.filters2.master.FilterMaster;
-import org.omegat.filters2.master.PluginUtils;
import org.omegat.util.Preferences;
-import org.omegat.util.RuntimePreferences;
-import org.omegat.util.gui.UIDesignManager;
public abstract class TestCoreGUI extends AssertJSwingJUnitTestCase {
protected FrameFixture window;
- protected JFrame frame;
-
protected File tmpDir;
protected void closeProject() throws Exception {
@@ -93,7 +79,7 @@ protected void openSampleProject(String projectPath) throws Exception {
latch.countDown();
}
});
- ProjectUICommands.projectOpen(tmpDir);
+ ProjectUICommands.projectOpen(tmpDir, true);
try {
latch.await(5, TimeUnit.SECONDS);
} catch (InterruptedException ignored) {
@@ -105,66 +91,11 @@ protected void openSampleProject(String projectPath) throws Exception {
@Override
protected void onTearDown() throws Exception {
- window.cleanUp();
+ // window.cleanUp();
}
@Override
protected void onSetUp() throws Exception {
- Path tmp = Files.createTempDirectory("omegat");
- FileUtils.forceDeleteOnExit(tmp.toFile());
- RuntimePreferences.setConfigDir(tmp.toString());
- TestMainInitializer.initClassloader();
- // same order as Main.main
- Preferences.init();
- PluginUtils.loadPlugins(Collections.emptyMap());
- FilterMaster.setFilterClasses(PluginUtils.getFilterClasses());
- Preferences.initFilters();
- Preferences.initSegmentation();
- //
- frame = GuiActionRunner.execute(() -> {
- Core.setProject(new NotLoadedProject());
- UIDesignManager.initialize();
- TestMainWindow mw = new TestMainWindow(TestMainWindowMenuHandler.class);
- TestCoreInitializer.initMainWindow(mw);
- TestCoreInitializer.initAutoSave(autoSave);
-
- CoreEvents.fireApplicationStartup();
- SwingUtilities.invokeLater(() -> {
- // setVisible can't be executed directly, because we need to
- // call all application startup listeners for initialize UI
- Core.getMainWindow().getApplicationFrame().setVisible(true);
- });
- return mw.getApplicationFrame();
- });
-
- window = new FrameFixture(robot(), frame);
- window.show();
- }
-
- static IAutoSave autoSave = new IAutoSave() {
- public void enable() {
- }
-
- public void disable() {
- }
- };
-
- static class TestMainWindowMenu extends BaseMainWindowMenu {
-
- TestMainWindowMenu(IMainWindow mainWindow, BaseMainWindowMenuHandler mainWindowMenuHandler) {
- super(mainWindow, mainWindowMenuHandler);
- initComponents();
- }
-
- @Override
- void createMenuBar() {
- mainMenu.add(projectMenu);
- mainMenu.add(editMenu);
- mainMenu.add(gotoMenu);
- mainMenu.add(viewMenu);
- mainMenu.add(toolsMenu);
- mainMenu.add(optionsMenu);
- mainMenu.add(helpMenu);
- }
+ window = TestCoreGUIInitializer.getInstance().initialize(robot());
}
}
diff --git a/test-acceptance/src/org/omegat/gui/main/TestCoreGUIInitializer.java b/test-acceptance/src/org/omegat/gui/main/TestCoreGUIInitializer.java
new file mode 100644
index 0000000000..5a62daf2f4
--- /dev/null
+++ b/test-acceptance/src/org/omegat/gui/main/TestCoreGUIInitializer.java
@@ -0,0 +1,108 @@
+/**************************************************************************
+ OmegaT - Computer Assisted Translation (CAT) tool
+ with fuzzy matching, translation memory, keyword search,
+ glossaries, and translation leveraging into updated projects.
+
+ Copyright (C) 2024 Hiroshi Miura
+ Home page: https://www.omegat.org/
+ Support center: https://omegat.org/support
+
+ This file is part of OmegaT.
+
+ OmegaT 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.
+
+ OmegaT 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 .
+ **************************************************************************/
+package org.omegat.gui.main;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Collections;
+
+import javax.swing.JFrame;
+import javax.swing.SwingUtilities;
+
+import org.apache.commons.io.FileUtils;
+import org.assertj.swing.core.Robot;
+import org.assertj.swing.edt.GuiActionRunner;
+import org.assertj.swing.fixture.FrameFixture;
+
+import org.omegat.TestMainInitializer;
+import org.omegat.core.Core;
+import org.omegat.core.CoreEvents;
+import org.omegat.core.TestCoreInitializer;
+import org.omegat.core.data.NotLoadedProject;
+import org.omegat.core.threads.IAutoSave;
+import org.omegat.filters2.master.FilterMaster;
+import org.omegat.filters2.master.PluginUtils;
+import org.omegat.util.Preferences;
+import org.omegat.util.RuntimePreferences;
+import org.omegat.util.gui.UIDesignManager;
+
+public final class TestCoreGUIInitializer {
+ private static TestCoreGUIInitializer initializer;
+ private volatile JFrame frame;
+ private FrameFixture mainWindow;
+
+ private TestCoreGUIInitializer() {
+ }
+
+ public static TestCoreGUIInitializer getInstance() {
+ if (initializer == null) {
+ initializer = new TestCoreGUIInitializer();
+ }
+ return initializer;
+ }
+
+ public synchronized FrameFixture initialize(Robot robot) throws IOException {
+ if (frame == null) {
+ Path tmp = Files.createTempDirectory("omegat");
+ FileUtils.forceDeleteOnExit(tmp.toFile());
+ RuntimePreferences.setConfigDir(tmp.toString());
+ TestMainInitializer.initClassloader();
+ // same order as Main.main
+ Preferences.init();
+ PluginUtils.loadPlugins(Collections.emptyMap());
+ FilterMaster.setFilterClasses(PluginUtils.getFilterClasses());
+ Preferences.initFilters();
+ Preferences.initSegmentation();
+ //
+ frame = GuiActionRunner.execute(() -> {
+ Core.setProject(new NotLoadedProject());
+ UIDesignManager.initialize();
+ TestMainWindow mw = new TestMainWindow(TestMainWindowMenuHandler.class);
+ TestCoreInitializer.initMainWindow(mw);
+ TestCoreInitializer.initAutoSave(autoSave);
+
+ CoreEvents.fireApplicationStartup();
+ SwingUtilities.invokeLater(() -> {
+ // setVisible can't be executed directly, because we need to
+ // call all application startup listeners for initialize UI
+ Core.getMainWindow().getApplicationFrame().setVisible(true);
+ });
+ return mw.getApplicationFrame();
+ });
+ mainWindow = new FrameFixture(robot, frame);
+ mainWindow.show();
+ }
+ return mainWindow;
+ }
+
+ static IAutoSave autoSave = new IAutoSave() {
+ public void enable() {
+ }
+
+ public void disable() {
+ }
+ };
+}
diff --git a/test-acceptance/src/org/omegat/gui/main/TestMainWindow.java b/test-acceptance/src/org/omegat/gui/main/TestMainWindow.java
index ca3c4b3558..0150e5f68a 100644
--- a/test-acceptance/src/org/omegat/gui/main/TestMainWindow.java
+++ b/test-acceptance/src/org/omegat/gui/main/TestMainWindow.java
@@ -80,7 +80,7 @@ class TestMainWindow implements IMainWindow {
try {
BaseMainWindowMenuHandler handler = mainWindowMenuHandler
.getDeclaredConstructor(IMainWindow.class).newInstance(this);
- menu = new TestCoreGUI.TestMainWindowMenu(this, handler);
+ menu = new TestMainWindowMenu(this, handler);
} catch (Exception e) {
throw new RuntimeException();
}
diff --git a/test-acceptance/src/org/omegat/gui/main/TestMainWindowMenu.java b/test-acceptance/src/org/omegat/gui/main/TestMainWindowMenu.java
new file mode 100644
index 0000000000..3b50d5b0dd
--- /dev/null
+++ b/test-acceptance/src/org/omegat/gui/main/TestMainWindowMenu.java
@@ -0,0 +1,44 @@
+/**************************************************************************
+ OmegaT - Computer Assisted Translation (CAT) tool
+ with fuzzy matching, translation memory, keyword search,
+ glossaries, and translation leveraging into updated projects.
+
+ Copyright (C) 2024 Hiroshi Miura
+ Home page: https://www.omegat.org/
+ Support center: https://omegat.org/support
+
+ This file is part of OmegaT.
+
+ OmegaT 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.
+
+ OmegaT 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 .
+ **************************************************************************/
+package org.omegat.gui.main;
+
+class TestMainWindowMenu extends BaseMainWindowMenu {
+
+ TestMainWindowMenu(IMainWindow mainWindow, BaseMainWindowMenuHandler mainWindowMenuHandler) {
+ super(mainWindow, mainWindowMenuHandler);
+ initComponents();
+ }
+
+ @Override
+ void createMenuBar() {
+ mainMenu.add(projectMenu);
+ mainMenu.add(editMenu);
+ mainMenu.add(gotoMenu);
+ mainMenu.add(viewMenu);
+ mainMenu.add(toolsMenu);
+ mainMenu.add(optionsMenu);
+ mainMenu.add(helpMenu);
+ }
+}