-
-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Use AssertJ-Swing for test framework - Add Sample project folder - Test Menus Signed-off-by: Hiroshi Miura <[email protected]>
- Loading branch information
Showing
21 changed files
with
1,332 additions
and
0 deletions.
There are no files selected for viewing
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
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,3 @@ | ||
project_stats.txt | ||
project_stats.json | ||
*.bak |
Empty file.
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,2 @@ | ||
# Glossary in tab-separated format -*- coding: utf-8 -*- | ||
Introduction 紹介 |
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,33 @@ | ||
<?xml version='1.0' encoding='UTF-8'?> | ||
<omegat> | ||
<project version="1.0"> | ||
<source_dir>__DEFAULT__</source_dir> | ||
<source_dir_excludes> | ||
<mask>**/.svn/**</mask> | ||
<mask>**/CVS/**</mask> | ||
<mask>**/.cvs/**</mask> | ||
<mask>**/.git/**</mask> | ||
<mask>**/.hg/**</mask> | ||
<mask>**/.repositories/**</mask> | ||
<mask>**/desktop.ini</mask> | ||
<mask>**/Thumbs.db</mask> | ||
<mask>**/.DS_Store</mask> | ||
<mask>**/~$*</mask> | ||
</source_dir_excludes> | ||
<target_dir>__DEFAULT__</target_dir> | ||
<tm_dir>__DEFAULT__</tm_dir> | ||
<glossary_dir>__DEFAULT__</glossary_dir> | ||
<glossary_file>__DEFAULT__</glossary_file> | ||
<dictionary_dir>__DEFAULT__</dictionary_dir> | ||
<export_tm_dir>__DEFAULT__</export_tm_dir> | ||
<export_tm_levels></export_tm_levels> | ||
<source_lang>en</source_lang> | ||
<target_lang>fr</target_lang> | ||
<source_tok>org.omegat.tokenizer.LuceneEnglishTokenizer</source_tok> | ||
<target_tok>org.omegat.tokenizer.LuceneFrenchTokenizer</target_tok> | ||
<sentence_seg>false</sentence_seg> | ||
<support_default_translations>true</support_default_translations> | ||
<remove_tags>true</remove_tags> | ||
<external_command></external_command> | ||
</project> | ||
</omegat> |
Empty file.
Empty file.
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,17 @@ | ||
<?xml version='1.0' encoding='UTF-8'?> | ||
<!DOCTYPE tmx SYSTEM "tmx11.dtd"> | ||
<tmx version="1.1"> | ||
<header creationtool="OmegaT" o-tmf="OmegaT TMX" adminlang="EN-US" datatype="plaintext" creationtoolversion="6.1.0_0_f59958c" segtype="paragraph" srclang="en"/> | ||
<body> | ||
<!-- Default translations --> | ||
<tu> | ||
<tuv lang="en"> | ||
<seg>Birds in Oregon</seg> | ||
</tuv> | ||
<tuv lang="fr" changeid="Hiroshi Miura" changedate="20240302T051308Z" creationid="Hiroshi Miura" creationdate="20240302T051308Z"> | ||
<seg>Birds in Oregon</seg> | ||
</tuv> | ||
</tu> | ||
<!-- Alternative translations --> | ||
</body> | ||
</tmx> |
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,36 @@ | ||
# | ||
# OmegaT - Computer Assisted Translation (CAT) tool | ||
# with fuzzy matching, translation memory, keyword search, | ||
# glossaries, and translation leveraging into updated projects. | ||
# | ||
# Copyright (C) 2023 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 <https://www.gnu.org/licenses/>. | ||
# | ||
MT_ENGINE_APERTIUM=Apertium | ||
|
||
MT_JSON_ERROR=Error while reading MT results | ||
|
||
APERTIUM_ERROR=Error {0}: {1} | ||
APERTIUM_CUSTOM_SERVER_LABEL=Connect to custom server instead of apertium.org | ||
APERTIUM_CUSTOM_SERVER_URL_LABEL=Custom server URL | ||
APERTIUM_CUSTOM_SERVER_KEY_LABEL=API key (optional) | ||
APERTIUM_CUSTOM_SERVER_NOTFOUND=Unable to connect to server. Ensure the server URL is correct. | ||
APERTIUM_CUSTOM_SERVER_INVALID=The server is not a valid Apertium server. Ensure the URL is correct. | ||
APERTIUM_MARKUNKNOWN_LABEL=Mark unknown words | ||
|
Empty file.
Empty file.
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,20 @@ | ||
package org.omegat; | ||
|
||
import javax.swing.UIManager; | ||
|
||
import org.omegat.filters2.master.PluginUtils; | ||
|
||
public final class TestMainInitializer { | ||
|
||
private TestMainInitializer() { | ||
} | ||
|
||
public static void initClassloader() { | ||
ClassLoader cl = ClassLoader.getSystemClassLoader(); | ||
MainClassLoader mainClassLoader = (cl instanceof MainClassLoader) ? (MainClassLoader) cl | ||
: new MainClassLoader(cl); | ||
PluginUtils.getThemePluginJars().forEach(mainClassLoader::add); | ||
UIManager.put("ClassLoader", mainClassLoader); | ||
} | ||
|
||
} |
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,80 @@ | ||
package org.omegat.gui; | ||
|
||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import java.awt.event.KeyEvent; | ||
import java.io.File; | ||
import java.nio.file.Files; | ||
|
||
import javax.swing.SwingUtilities; | ||
|
||
import org.apache.commons.io.FileUtils; | ||
import org.junit.Test; | ||
|
||
import org.omegat.gui.dialogs.CreateGlossaryEntry; | ||
import org.omegat.gui.glossary.GlossaryTextArea; | ||
import org.omegat.gui.main.BaseMainWindowMenu; | ||
import org.omegat.gui.main.ProjectUICommands; | ||
import org.omegat.gui.main.TestCoreGUI; | ||
import org.omegat.util.Preferences; | ||
|
||
public class GlossaryEntryTest extends TestCoreGUI { | ||
|
||
private File tmpDir; | ||
|
||
/** | ||
* Test case to create glossary entry and see a result. | ||
* @throws Exception | ||
*/ | ||
@Test | ||
public void testOpenGlossaryEntryDialog() throws Exception { | ||
// 0. Prepare project folder | ||
tmpDir = Files.createTempDirectory("omegat-sample-project-").toFile(); | ||
File projSrc = new File("test-acceptance/data/project/"); | ||
FileUtils.copyDirectory(projSrc, tmpDir); | ||
FileUtils.forceDeleteOnExit(tmpDir); | ||
// 1. Prepare preference for the test; | ||
// * OmegaT doesn't show a file list dialog on a project load event. | ||
// * Glossary sort order preference | ||
Preferences.setPreference(Preferences.PROJECT_FILES_SHOW_ON_LOAD, false); | ||
Preferences.setPreference(Preferences.GLOSSARY_SORT_BY_LENGTH, false); | ||
Preferences.setPreference(Preferences.GLOSSARY_SORT_BY_SRC_LENGTH, false); | ||
assertFalse(Preferences.isPreferenceDefault(Preferences.PROJECT_FILES_SHOW_ON_LOAD, true)); | ||
// 2. Open a sample project. | ||
SwingUtilities.invokeAndWait(() -> ProjectUICommands.projectOpen(tmpDir)); | ||
// 3. Operate Glossary preference from menu. | ||
Preferences.setPreference(Preferences.GLOSSARY_STEMMING, true); | ||
window.menuItem(BaseMainWindowMenu.OPTIONS_MENU).click(); | ||
window.menuItem(BaseMainWindowMenu.OPTIONS_GLOSSARY_SUBMENU).click(); | ||
assertTrue(window.menuItem(BaseMainWindowMenu.OPTIONS_GLOSSARY_FUZZY_MATCHING_CHECKBOX_MENUITEM).target() | ||
.getModel().isSelected()); | ||
window.menuItem(BaseMainWindowMenu.OPTIONS_GLOSSARY_FUZZY_MATCHING_CHECKBOX_MENUITEM).click(); | ||
// 4. toggle options > glossary menu | ||
window.menuItem(BaseMainWindowMenu.OPTIONS_MENU).click(); | ||
window.menuItem(BaseMainWindowMenu.OPTIONS_GLOSSARY_SUBMENU).click(); | ||
assertFalse(window.menuItem(BaseMainWindowMenu.OPTIONS_GLOSSARY_FUZZY_MATCHING_CHECKBOX_MENUITEM).target() | ||
.getModel().isSelected()); | ||
// 5. Click menu Edit > Create glossary menu items. | ||
window.menuItem(BaseMainWindowMenu.EDIT_MENU).click(); | ||
window.menuItem(BaseMainWindowMenu.EDIT_CREATE_GLOSSARY_MENUITEM).click(); | ||
// 6. Check Create glossary dialog visible | ||
window.dialog(CreateGlossaryEntry.DIALOG_NAME).requireVisible(); | ||
// 7. Enter glossary keyword and translation in the field | ||
window.dialog(CreateGlossaryEntry.DIALOG_NAME).textBox(CreateGlossaryEntry.SOURCE_TEXT_FIELD) | ||
.enterText("Apertium"); | ||
window.dialog(CreateGlossaryEntry.DIALOG_NAME).textBox(CreateGlossaryEntry.TARGET_TEXT_FIELD) | ||
.enterText("Translation Engine"); | ||
// 8. Click a OK button | ||
window.dialog(CreateGlossaryEntry.DIALOG_NAME).button(CreateGlossaryEntry.OK_BUTTON).click(); | ||
// 9. Enforce refresh glossary pane | ||
GlossaryTextArea glossaryTextArea = | ||
((GlossaryTextArea) (window.textBox(GlossaryTextArea.TEXTPANE_NAME).target())); | ||
glossaryTextArea.refresh(); | ||
// 10. Wait showing a search result during some operation | ||
window.textBox(GlossaryTextArea.TEXTPANE_NAME).rightClick(); | ||
window.pressKey(KeyEvent.VK_ESCAPE); | ||
// Check the glossary pane shown in the pane | ||
assertFalse(glossaryTextArea.getDisplayedEntries().isEmpty()); | ||
} | ||
} |
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,75 @@ | ||
/************************************************************************** | ||
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 <https://www.gnu.org/licenses/>. | ||
**************************************************************************/ | ||
package org.omegat.gui; | ||
|
||
import static org.junit.Assert.assertFalse; | ||
|
||
import java.io.File; | ||
import java.nio.file.Files; | ||
|
||
import org.junit.Test; | ||
|
||
import org.omegat.core.Core; | ||
import org.omegat.gui.dialogs.NewProjectFileChooser; | ||
import org.omegat.gui.main.BaseMainWindowMenu; | ||
import org.omegat.gui.main.TestCoreGUI; | ||
|
||
public class ProjectMenuTest extends TestCoreGUI { | ||
|
||
File tempDir; | ||
|
||
@Override | ||
protected void onSetUp() throws Exception { | ||
super.onSetUp(); | ||
tempDir = Files.createTempDirectory("omegat").toFile(); | ||
} | ||
|
||
/** | ||
* Test project menus. | ||
*/ | ||
@Test | ||
public void testNewProject() { | ||
window.requireTitle("OmegaT 6.1.0"); | ||
// 2. click menu Project > new project | ||
window.menuItem(BaseMainWindowMenu.PROJECT_MENU).click(); | ||
window.menuItem(BaseMainWindowMenu.PROJECT_NEW_MENUITEM).click(); | ||
window.fileChooser(NewProjectFileChooser.DIALOG_NAME).requireEnabled(); | ||
window.fileChooser().selectFile(tempDir); | ||
window.fileChooser().approve(); | ||
assertFalse(Core.getProject().isProjectLoaded()); | ||
/* | ||
window.dialog(Timeout.timeout(30000L)).requireVisible(); | ||
window.dialog(ProjectPropertiesDialog.DIALOG_NAME).requireModal(); | ||
window.dialog(ProjectPropertiesDialog.DIALOG_NAME).button(ProjectPropertiesDialog.OK_BUTTON_NAME).click(); | ||
assertTrue(Core.getProject().isProjectLoaded()); | ||
*/ | ||
// 3. select project > Exit menu. | ||
window.menuItem(BaseMainWindowMenu.PROJECT_MENU).click(); | ||
window.menuItem(BaseMainWindowMenu.PROJECT_EXIT_MENUITEM).click(); | ||
window.requireNotVisible(); | ||
window.requireDisabled(); | ||
} | ||
|
||
} |
Oops, something went wrong.