Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add acceptance test of Fuzzy matches pane #1219

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/org/omegat/gui/main/DockableScrollPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ public void setName(String name) {
dockKey.setName(name);
}

@Override
public String getName() {
if (dockKey == null) {
return null;
}
return dockKey.getName();
}

/** Creates a new instance of DockableScrollBox */
public DockableScrollPane(String key, String name, Component view, boolean detouchable) {
super(view);
Expand Down
1 change: 1 addition & 0 deletions src/org/omegat/gui/matches/MatchesTextArea.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ public class MatchesTextArea extends EntryInfoThreadPane<List<NearString>> imple
/** Creates new form MatchGlossaryPane */
public MatchesTextArea(IMainWindow mw) {
super(true);
setName("matches_pane");

String title = OStrings.getString("GUI_MATCHWINDOW_SUBWINDOWTITLE_Fuzzy_Matches");
scrollPane = new DockableScrollPane("MATCHES", title, this, true);
Expand Down
4 changes: 4 additions & 0 deletions test-acceptance/data/project/omegat/last_entry.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#Wed Nov 27 12:53:42 JST 2024
LAST_ENTRY_NUMBER=3
LAST_ENTRY_SRC=Error {0}\: {1}
LAST_ENTRY_FILE=Bundle.properties
26 changes: 25 additions & 1 deletion test-acceptance/data/project/omegat/project_save.tmx
Original file line number Diff line number Diff line change
@@ -1,9 +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"/>
<header creationtool="OmegaT" o-tmf="OmegaT TMX" adminlang="EN-US" datatype="plaintext" creationtoolversion="6.1.0_0_8a8099715" segtype="paragraph" srclang="en"/>
<body>
<!-- Default translations -->
<tu>
<tuv lang="en">
<seg>Apertium</seg>
</tuv>
<tuv lang="fr" changeid="Hiroshi Miura" changedate="20241127T035017Z" creationid="Hiroshi Miura" creationdate="20241127T035017Z">
<seg>Apertium</seg>
</tuv>
</tu>
<tu>
<tuv lang="en">
<seg>Birds in Oregon</seg>
Expand All @@ -12,6 +20,22 @@
<seg>Birds in Oregon</seg>
</tuv>
</tu>
<tu>
<tuv lang="en">
<seg>Error while reading MT results</seg>
</tuv>
<tuv lang="fr" changeid="Hiroshi Miura" changedate="20241127T035157Z" creationid="Hiroshi Miura" creationdate="20241127T035031Z">
<seg>Erreur lors de la lecture des résultats de TA</seg>
</tuv>
</tu>
<tu>
<tuv lang="en">
<seg>Error {0}: {1}</seg>
</tuv>
<tuv lang="fr" changeid="Hiroshi Miura" changedate="20241127T035216Z" creationid="Hiroshi Miura" creationdate="20241127T035216Z">
<seg>Error {0}: {1}</seg>
</tuv>
</tu>
<!-- Alternative translations -->
</body>
</tmx>
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ public void testAligner() throws Exception {
//
aligner.menuItem("align_menu_file").click();
aligner.menuItem("align_menu_close_item").click();
//
closeProject();
}

}
20 changes: 20 additions & 0 deletions test-acceptance/src/org/omegat/gui/main/TestCoreGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,21 @@ public abstract class TestCoreGUI extends AssertJSwingJUnitTestCase {

protected File tmpDir;

protected void closeProject() throws Exception {
CountDownLatch latch = new CountDownLatch(1);
Core.getProject().closeProject();
CoreEvents.registerProjectChangeListener(event -> {
if (!Core.getProject().isProjectLoaded()) {
latch.countDown();
}
});
try {
latch.await(5, TimeUnit.SECONDS);
} catch (InterruptedException ignored) {
}
assertFalse("Project should not be loaded.", Core.getProject().isProjectLoaded());
}

protected void openSampleProject(String projectPath) throws Exception {
// 0. Prepare project folder
tmpDir = Files.createTempDirectory("omegat-sample-project-").toFile();
Expand Down Expand Up @@ -88,6 +103,11 @@ protected void openSampleProject(String projectPath) throws Exception {
assertTrue("Sample project should be loaded.", Core.getProject().isProjectLoaded());
}

@Override
protected void onTearDown() throws Exception {
window.cleanUp();
}

@Override
protected void onSetUp() throws Exception {
Path tmp = Files.createTempDirectory("omegat");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**************************************************************************
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.matches;

import java.util.Locale;
import java.util.regex.Pattern;

import org.junit.Rule;
import org.junit.Test;

import org.omegat.gui.main.TestCoreGUI;
import org.omegat.util.LocaleRule;
import org.omegat.util.OStrings;

public class MatchesTextAreaTest extends TestCoreGUI {

private static final String PROJECT_PATH = "test-acceptance/data/project/";

@Rule
public final LocaleRule localeRule = new LocaleRule(new Locale("en"));

@Test
public void testFuzzyMatches() throws Exception {
// load project
openSampleProject(PROJECT_PATH);
robot().waitForIdle();
// check a fuzzy match pane
window.scrollPane(OStrings.getString("GUI_MATCHWINDOW_SUBWINDOWTITLE_Fuzzy_Matches")).requireVisible();
window.textBox("matches_pane").requireVisible();
window.textBox("matches_pane").requireNotEditable();
Pattern pattern = Pattern.compile("1. Error while reading MT results\\n"
+ "Erreur lors de la lecture des résultats de TA\\n"
+ "<\\d+/\\d+/\\d+%\\s*>");
window.textBox("matches_pane").requireText(pattern);
closeProject();
}
}
Loading