Skip to content
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
24 changes: 23 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,17 @@ jobs:
java-version: '17'
cache: maven

# Maven Central drops connections at times: the dependencies and plugins of the build are downloaded first
# and again after a failure, not when the tests ran already
- name: Download the dependencies and plugins
shell: bash
run: |
for attempt in 1 2 3; do
./mvnw -B -ntp dependency:go-offline dependency:unpack@unpack-javafx && exit 0
sleep 30
done
exit 1

# The databases start while SqlJam is compiled
- name: Build and test against the main databases (UI tests run headless)
run: |
Expand Down Expand Up @@ -75,6 +86,17 @@ jobs:
java-version: '17'
cache: maven

# Maven Central drops connections at times: the dependencies and plugins of the build are downloaded first
# and again after a failure, not when the tests ran already
- name: Download the dependencies and plugins
shell: bash
run: |
for attempt in 1 2 3; do
./mvnw -B -ntp dependency:go-offline dependency:unpack@unpack-javafx && exit 0
sleep 30
done
exit 1

- name: Build and test (UI tests run headless)
shell: bash
run: ./mvnw -B -ntp verify -Dit.env=ci -Djacoco.haltOnFailure=false
Expand Down Expand Up @@ -122,7 +144,7 @@ jobs:
run: |
$wix = Join-Path $env:RUNNER_TEMP "wix"
Invoke-WebRequest -Uri "https://github.com/wixtoolset/wix3/releases/download/wix3141rtm/wix314-binaries.zip" `
-OutFile "$wix.zip"
-OutFile "$wix.zip" -MaximumRetryCount 5 -RetryIntervalSec 15
Expand-Archive -Path "$wix.zip" -DestinationPath $wix
$wix | Out-File -FilePath $env:GITHUB_PATH -Append -Encoding utf8

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/github/sqljam/face/view/SqlCompletion.java
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,11 @@ private void showMenu(Context context, List<String> names) {
if (caret.isPresent()) {
menu.show(area, caret.get().getMinX(), caret.get().getMaxY());
} else {
// No place on the screen while the editor is not shown, e.g. its tab is closed meanwhile
Bounds bounds = area.localToScreen(area.getBoundsInLocal());
if (bounds == null) {
return;
}
menu.show(area, bounds.getMinX(), bounds.getMinY());
}
// The first suggestion is chosen by Enter
Expand Down
27 changes: 27 additions & 0 deletions src/test/java/com/github/sqljam/face/view/SqlCompletionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package com.github.sqljam.face.view;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

Expand Down Expand Up @@ -136,4 +137,30 @@ public List<String> columns(String table) {
});
assertEquals("SELECT", FxTestSupport.call(editor::getText));
}

/**
* An editor which is not shown, e.g. its tab is closed while the names are read, opens no menu
*/
@Test
void showsNothingForEditorNotShown() {
AtomicInteger tableReads = new AtomicInteger();
SqlEditor hidden = FxTestSupport.call(SqlEditor::new);
SqlCompletion completion = FxTestSupport.call(() -> SqlCompletion.attach(hidden, new SqlCompletion.Source() {
@Override
public List<String> tables() {
tableReads.incrementAndGet();
return List.of("orders");
}

@Override
public List<String> columns(String table) {
return List.of();
}
}));
FxTestSupport.run(completion::show);
FxTestSupport.waitUntil(() -> tableReads.get() == 1);
// After the names are handed to the FX thread
org.testfx.util.WaitForAsyncUtils.waitForFxEvents();
assertFalse(FxTestSupport.call(completion.getMenu()::isShowing));
}
}
3 changes: 3 additions & 0 deletions src/test/java/com/github/sqljam/face/view/SqlTabTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,9 @@ void switchesBeforeFirstStatement() throws Exception {
@Test
void completesTablesAndColumns() {
open(schemaNode());
// The editor is in the window after the tab pane lays out its new tab, slow machines take a while
FxTestSupport.waitUntil(() -> FxTestSupport.call(() -> tab.getEditor().getCodeArea().localToScreen(0, 0)
!= null));
type("SELECT * FROM T_O", 17);
FxTestSupport.run(() -> tab.getEditor().getCodeArea().requestFocus());
FxTestSupport.run(() -> javafx.event.Event.fireEvent(tab.getEditor().getCodeArea(), new javafx.scene.input
Expand Down
Loading