Skip to content

Commit

Permalink
Merge pull request #1176 from omegat-org/topic/miurahr/test/gui/impro…
Browse files Browse the repository at this point in the history
…ve-acceptance-test202411

chore: improve acceptance test
  • Loading branch information
miurahr authored Nov 7, 2024
2 parents e992738 + ede7ded commit 12fd6a6
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/acceptance-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
name: Setup Gradle
id: setup-gradle
- name: Run acceptance test
run: ./gradlew -PenvIsCi=true --scan testAcceptance
run: ./gradlew -PenvIsCi=true -PtestDisplay=99 --scan testAcceptance
id: gradle
- name: "Add Build Scan URL as PR comment"
uses: actions/github-script@v7
Expand Down
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -1666,11 +1666,11 @@ def isCommandAvailable(command) {

tasks.register('testAcceptance', Test) {
onlyIf {
isCommandAvailable('Xvfb')
isCommandAvailable('Xvfb') || project.hasProperty("acceptanceTestLive")
}
def display = 99
def display = project.hasProperty("testDisplay") ? project.getProperty("testDisplay") : ""
doFirst {
if (display != null) {
if (!display.isEmpty()) {
def lockFile = new File("/tmp/.X${display}-lock")
if (!lockFile.exists()) {
ext.xvfbPid = startX(display)
Expand All @@ -1679,7 +1679,7 @@ tasks.register('testAcceptance', Test) {
}
}
doLast {
if (display != null) {
if (!display.isEmpty()) {
def pid = ext.has('xvfbPid') ? ext.xvfbPid : null
if (pid != null) {
stopX(pid)
Expand Down
2 changes: 1 addition & 1 deletion src/org/omegat/gui/editor/EditorController.java
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ public void componentResized(ComponentEvent e) {
scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
scrollPane.getVerticalScrollBar().addAdjustmentListener(scrollListener);

scrollPane.setName("EditorScrollPane");
pane.setLayout(new BorderLayout());
pane.add(scrollPane, BorderLayout.CENTER);

Expand Down
8 changes: 8 additions & 0 deletions src/org/omegat/gui/main/DockablePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,12 @@ public void setToolTipText(String text) {
public void setName(String name) {
dockKey.setName(name);
}

@Override
public String getName() {
if (dockKey ==null) {
return null;
}
return dockKey.getName();
}
}
14 changes: 7 additions & 7 deletions src/org/omegat/gui/main/MainWindowUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ private File getPerProjectLayout() {
/**
* Initialize the size of OmegaT window, then load the layout prefs.
*/
public static void initializeScreenLayout(MainWindow mainWindow) {
public static void initializeScreenLayout(IMainWindow mainWindow) {
/**
* (23dec22) Set a reasonable default window size assuming a
* standard"pro" laptop resolution of 1920x1080. Smaller screens do not
Expand Down Expand Up @@ -182,14 +182,14 @@ public static void initializeScreenLayout(MainWindow mainWindow) {
// Ensure any "closed" Dockables are visible. These can be newly added
// panes not included in an older layout file, or e.g. panes installed
// by plugins.
UIDesignManager.ensureDockablesVisible(mainWindow.desktop);
UIDesignManager.ensureDockablesVisible(mainWindow.getDesktop());
}

/**
* Load the main window layout from the global preferences file. Will reset
* to defaults if global preferences are not present or if an error occurs.
*/
private static void loadScreenLayoutFromPreferences(MainWindow mainWindow) {
private static void loadScreenLayoutFromPreferences(IMainWindow mainWindow) {
File uiLayoutFile = new File(StaticUtils.getConfigDir(), MainWindowUI.UI_LAYOUT_FILE);
if (uiLayoutFile.exists()) {
loadScreenLayout(mainWindow, uiLayoutFile);
Expand All @@ -202,9 +202,9 @@ private static void loadScreenLayoutFromPreferences(MainWindow mainWindow) {
* Load the main window layout from the specified file. Will reset to
* defaults if an error occurs.
*/
private static void loadScreenLayout(MainWindow mainWindow, File uiLayoutFile) {
private static void loadScreenLayout(IMainWindow mainWindow, File uiLayoutFile) {
try (InputStream in = new FileInputStream(uiLayoutFile)) {
mainWindow.desktop.readXML(in);
mainWindow.getDesktop().readXML(in);
} catch (Exception ex) {
Log.log(ex);
resetDesktopLayout(mainWindow);
Expand Down Expand Up @@ -234,9 +234,9 @@ private static void saveScreenLayout(MainWindow mainWindow, File uiLayoutFile) {
* Restores main window layout to the default values (distinct from global
* preferences).
*/
public static void resetDesktopLayout(MainWindow mainWindow) {
public static void resetDesktopLayout(IMainWindow mainWindow) {
try (InputStream in = MainWindowUI.class.getResourceAsStream("DockingDefaults.xml")) {
mainWindow.desktop.readXML(in);
mainWindow.getDesktop().readXML(in);
} catch (Exception e) {
Log.log(e);
}
Expand Down
20 changes: 20 additions & 0 deletions test-acceptance/src/org/omegat/gui/editor/EditorTextAreaTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.omegat.gui.editor;

import org.junit.Test;

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

public class EditorTextAreaTest extends TestCoreGUI {

@Test
public void testIntroPaneExist() {
window.panel(OStrings.getString("DOCKING_FIRST_STEPS_TITLE")).requireEnabled();
window.panel(OStrings.getString("DOCKING_FIRST_STEPS_TITLE")).scrollPane("EditorScrollPane").requireEnabled();
window.panel(OStrings.getString("DOCKING_FIRST_STEPS_TITLE")).scrollPane("EditorScrollPane")
.verticalScrollBar().requireVisible();
window.panel(OStrings.getString("DOCKING_FIRST_STEPS_TITLE")).scrollPane("EditorScrollPane")
.horizontalScrollBar().requireNotVisible();
}

}
2 changes: 2 additions & 0 deletions test-acceptance/src/org/omegat/gui/main/TestMainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ public void initializeScreenLayout() {

Rectangle defaultWindowSize = new Rectangle(omegatLeftPosition, 0, omegatWidth, omegatHeight);
applicationFrame.setBounds(defaultWindowSize);

MainWindowUI.initializeScreenLayout(TestMainWindow.this);
}

@Override
Expand Down

0 comments on commit 12fd6a6

Please sign in to comment.