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
4 changes: 4 additions & 0 deletions .github/workflows/build-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,10 @@ jobs:
container:
image: ghcr.io/flathub-infra/flatpak-github-actions:gnome-51
options: --privileged
# Docker copies the image's runtimes into the volume. On AWS-hosted runners, updating a runtime that sits in
# an image layer fails with "Invalid cross-device link" (run 43615225881).
volumes:
- flatpak-system:/var/lib/flatpak
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
Expand Down
7 changes: 6 additions & 1 deletion core/crates/test-fixtures/src/clickhouse_fixture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,11 @@ mod tests {
};
assert_eq!(reason, "no answer within 8 seconds");
assert!(state.starts_with("status running, "), "{state}");
assert!(logs.contains("Listening for http://0.0.0.0:8124"), "{logs}");
// 26.8.36 and 26.3 bind 0.0.0.0 and 26.8.37 binds `::`: the image picks the address, the config the port.
assert!(
logs.lines()
.any(|line| line.contains("Listening for http://") && line.trim_end().ends_with(":8124")),
"{logs}"
);
}
}
2 changes: 1 addition & 1 deletion windows/docs/decisions/0002-sql-editor-control.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
- A SwapChainPanel holds a composition swap chain (flip sequential, three buffers, at most two frames waiting). A frame starts only when the swap chain can take it, through its frame latency object, so Present never blocks the UI thread. Direct3D 11 runs on the GPU, or WARP when there is none or software rendering is asked for. Direct2D draws on it, DirectWrite lays out each visible line.
- Every editor on a UI thread draws on one Direct3D and Direct2D device, as the grid's rows do (0003), and the first editor to find it lost replaces it for the rest. Each editor has its own device context and swap chain. TabView unloads a tab's content on every switch, so a hidden editor gives back its swap chain (`SetSwapChain(null)`) and keeps its layouts and brushes; showing it again makes one swap chain.
- Line layouts are cached by text and colors, so lines that shift after an edit keep theirs; only the edited line is laid out again. A line over 4,096 characters is laid out in a slice around the visible columns.
- A frame is drawn on the UI thread when something changed, and many changes before it give one frame. It holds the gutter, current line band, find matches, selections, text and IME marks. The carets are a composition visual of their own over the swap chain, one sprite per visible caret, as WinUI's TextBox keeps its caret in an element of its own (`TextBoxView.cpp`, `EnsureCaretElement`). SwapChainPanel draws its swap chain first (`SwapChainPanel.cpp`, `GetChildrenInRenderOrder`), so the panel's child visual lies above it. A frame places the sprites at the positions it laid out, snapped to pixels; a blink, focus or the window's activation only shows or hides the visual, with no frame. On `windows-2025` (run 43277097648) focus and a 5 second blink of 10 toggles presented 11 frames when the frame held the caret, and 0 with the visual. The caret blinks at the system rate, with the system caret width, and stops after the system caret timeout (`SPI_GETCARETTIMEOUT`, 5 seconds when the call fails) with no input, shown, as a Win32 edit control's does. In an inactive window (`InputActivationListener`) it is hidden and nothing blinks, as Win32's About Carets asks.
- A frame is drawn on the UI thread when something changed, and many changes before it give one frame. It holds the gutter, current line band, find matches, selections, text and IME marks. The carets are a composition visual of their own over the swap chain, one sprite per visible caret, as WinUI's TextBox keeps its caret in an element of its own (`TextBoxView.cpp`, `EnsureCaretElement`). SwapChainPanel draws its swap chain first (`SwapChainPanel.cpp`, `GetChildrenInRenderOrder`), so the panel's child visual lies above it. A frame places the sprites at the positions it laid out, snapped to pixels; a blink, focus or the window's activation only shows or hides the visual, with no frame. On `windows-2025` (run 43277097648) focus and a 5 second blink of 10 toggles presented 11 frames when the frame held the caret, and 0 with the visual. WinUI raises LostFocus on the focused editor when another window takes the activation, and GotFocus when it comes back (run 43614838421), so focus leaving clears the composition and draws only when one was shown. The caret blinks at the system rate, with the system caret width, and stops after the system caret timeout (`SPI_GETCARETTIMEOUT`, 5 seconds when the call fails) with no input, shown, as a Win32 edit control's does. In an inactive window (`InputActivationListener`) it is hidden and nothing blinks, as Win32's About Carets asks.
- Why a SwapChainPanel and not Composition drawing surfaces: one surface, presented when something changed, and a frame time measured from input to present; the same model as Windows Terminal. Surfaces per line would add their own management for scrolling that this cost does not need.
- Colors: theme resources for the chrome. In high contrast the system colors, selected text in the highlight text color, and no syntax colors.
- DPI: the buffer is in pixels and the panel's composition scale shrinks it back. Ctrl+wheel, Ctrl+= and Ctrl+- zoom.
Expand Down
5 changes: 5 additions & 0 deletions windows/src/TablePro.Editor/SqlEditor.Ime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ public void Commit(string text)

public void ShowComposition(string text, int caret, IReadOnlyList<CompositionRun> runs)
{
// Every focus loss clears the composition; with none shown, the swap chain has nothing new to draw.
if (text.Length == 0 && editor._composition.Length == 0)
{
return;
}
editor._composition = text;
editor._compositionCaret = caret;
editor._compositionRuns = runs;
Expand Down
24 changes: 23 additions & 1 deletion windows/tests/Shared/WinUiApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ namespace TablePro.Testing;
internal static class WinUiApp
{
private static readonly Lazy<Task<DispatcherQueue>> s_queue = new(StartAsync);
private static readonly TaskCompletionSource s_desktopTaken = new(TaskCreationOptions.RunContinuationsAsynchronously);
private static Mutex? s_desktop;

public static Window Window { get; private set; } = null!;

Expand All @@ -20,7 +22,10 @@ internal static class WinUiApp

public static async Task RunAsync(Func<Task> body)
{
var queue = await s_queue.Value.WaitAsync(TimeSpan.FromSeconds(90));
var started = s_queue.Value;
// Waiting for the other WinUI test process to end is not a WinUI start that hung.
await s_desktopTaken.Task.WaitAsync(TimeSpan.FromMinutes(5));
var queue = await started.WaitAsync(TimeSpan.FromSeconds(90));
var done = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
queue.TryEnqueue(async () =>
{
Expand Down Expand Up @@ -62,6 +67,8 @@ private static Task<DispatcherQueue> StartAsync()
{
try
{
TakeDesktop();
s_desktopTaken.TrySetResult();
WinRT.ComWrappersSupport.InitializeComWrappers();
Application.Start(callback =>
{
Expand All @@ -76,6 +83,7 @@ private static Task<DispatcherQueue> StartAsync()
}
catch (Exception ex)
{
s_desktopTaken.TrySetResult();
ready.TrySetException(ex);
}
})
Expand All @@ -87,6 +95,20 @@ private static Task<DispatcherQueue> StartAsync()
thread.Start();
return ready.Task;
}

// dotnet test runs the editor and grid test processes at once, and each window took the other's activation.
private static void TakeDesktop()
{
s_desktop = new Mutex(false, @"Local\TablePro.WinUiTests");
try
{
s_desktop.WaitOne();
}
catch (AbandonedMutexException)
{
// The process that held it ended, which hands it to this one.
}
}
}

// An app with no XAML files, so the WinUI controls' types come from their own metadata provider.
Expand Down
6 changes: 4 additions & 2 deletions windows/tests/TablePro.App.UITests/AppSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -472,14 +472,16 @@ private InvalidOperationException Failure(string message, bool screen = false)
return new InvalidOperationException(message + exited + log);
}

// A status has no UIA Name while its text is empty, and FlaUI's Name throws for it then.
public static string TextOf(AutomationElement element) => element.Properties.Name.ValueOrDefault ?? string.Empty;

public static string WaitForText(AutomationElement element, Func<string, bool> done)
{
var text = string.Empty;
Retry.WhileFalse(
() =>
{
// A status may have no UIA Name until its asynchronous result arrives.
text = element.Properties.Name.ValueOrDefault ?? string.Empty;
text = TextOf(element);
return done(text);
},
Wait,
Expand Down
4 changes: 2 additions & 2 deletions windows/tests/TablePro.App.UITests/BrowseObjectsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public void ATriggerOpensItsDefinitionReadOnlyAndInAnEditor(string theme)
app.FindByName("Track", tree);
app.TypeInto("Query 1", CreateTrigger);
app.Chord(
() => app.Find("QueryStatus").Name.StartsWith("Done", StringComparison.Ordinal),
() => AppSession.TextOf(app.Find("QueryStatus")).StartsWith("Done", StringComparison.Ordinal),
VirtualKeyShort.CONTROL,
VirtualKeyShort.ENTER);

Expand Down Expand Up @@ -61,7 +61,7 @@ public void ARunIsKeptInHistoryAndOpensAgainAndOffersExport(string theme)
app.FindByName("Track", app.Find("ObjectTree"));
app.TypeInto("Query 1", CountTracks);
app.Chord(
() => app.Find("QueryStatus").Name.StartsWith("Rows: 1", StringComparison.Ordinal),
() => AppSession.TextOf(app.Find("QueryStatus")).StartsWith("Rows: 1", StringComparison.Ordinal),
VirtualKeyShort.CONTROL,
VirtualKeyShort.ENTER);
Assert.Equal("3503", app.WaitForCell(app.Find("ResultsGrid"), 0, 0, value => value == "3503"));
Expand Down
5 changes: 3 additions & 2 deletions windows/tests/TablePro.App.UITests/RunStatementTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public void RunStatementRunsOnlyTheStatementAtTheCursorAndSelectsIt(string theme
app.FindByName("Track", app.Find("ObjectTree"));
app.TypeInto("Query 1", TwoSelects);
app.Chord(
() => app.Find("QueryStatus").Name.StartsWith("Rows: 1", StringComparison.Ordinal),
() => AppSession.TextOf(app.Find("QueryStatus")).StartsWith("Rows: 1", StringComparison.Ordinal),
VirtualKeyShort.CONTROL,
VirtualKeyShort.SHIFT,
VirtualKeyShort.ENTER);
Expand Down Expand Up @@ -66,7 +66,8 @@ public void ARunPastTheResultLimitKeepsTheNewestAndSaysHowManyWent(string theme)
app.FindByName("Track", app.Find("ObjectTree"));
app.TypeInto("Query 1", "SELECT 1 AS a; SELECT 2 AS b; SELECT 3 AS c; SELECT 4 AS d");
app.Chord(
() => app.Find("QueryStatus").Name.EndsWith("2 earlier results were dropped.", StringComparison.Ordinal),
() => AppSession.TextOf(app.Find("QueryStatus"))
.EndsWith("2 earlier results were dropped.", StringComparison.Ordinal),
VirtualKeyShort.CONTROL,
VirtualKeyShort.ENTER);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public void EmptyingATableAsksFirstAndCancelRunsNothing(string theme)
app.Screenshot("39-run-asked");
app.CloseDialog();
app.TypeInto("Query 1", "SELECT COUNT(*) = 3503 FROM Track;");
app.Chord(() => app.Find("QueryStatus").Name.StartsWith("Rows: 1", StringComparison.Ordinal),
app.Chord(() => AppSession.TextOf(app.Find("QueryStatus")).StartsWith("Rows: 1", StringComparison.Ordinal),
VirtualKeyShort.CONTROL, VirtualKeyShort.ENTER);
Assert.Equal("1", app.WaitForCell(app.Find("ResultsGrid"), 0, 0, value => value == "1"));
}
Expand Down Expand Up @@ -54,7 +54,7 @@ public void ReconnectAsksBeforeRollingBackAndBringsTheTabsBack(string theme)
Assert.True(rolledBack);
Assert.Equal(Update, AppSession.EditorText(app.FindEditor("Query 1")).TrimEnd('\r', '\n'));
app.TypeInto("Query 1", "SELECT COUNT(*) FROM Track WHERE TrackId = 1 AND Name = 'Pending';");
app.Chord(() => app.Find("QueryStatus").Name.StartsWith("Rows: 1", StringComparison.Ordinal),
app.Chord(() => AppSession.TextOf(app.Find("QueryStatus")).StartsWith("Rows: 1", StringComparison.Ordinal),
VirtualKeyShort.CONTROL, VirtualKeyShort.ENTER);
Assert.Equal("0", app.WaitForCell(app.Find("ResultsGrid"), 0, 0, value => value == "0"));
}
Expand Down Expand Up @@ -101,7 +101,7 @@ public void ReconnectingWhileAQueryRunsBringsItsTabBack(string theme)
private static void AnswerRuns(AppSession app)
{
app.TypeInto("Query 1", "SELECT 42 AS answer;");
app.Chord(() => app.Find("QueryStatus").Name.StartsWith("Rows: 1", StringComparison.Ordinal),
app.Chord(() => AppSession.TextOf(app.Find("QueryStatus")).StartsWith("Rows: 1", StringComparison.Ordinal),
VirtualKeyShort.CONTROL, VirtualKeyShort.ENTER);
Assert.Equal("42", app.WaitForCell(app.Find("ResultsGrid"), 0, 0, value => value == "42"));
}
Expand Down
2 changes: 1 addition & 1 deletion windows/tests/TablePro.App.UITests/ShareTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public void AResultAndAQueryOpenTheShareSheetWhichAsksToSignIn(string theme)
app.FindByName("Track", app.Find("ObjectTree"));
app.TypeInto("Query 1", "SELECT TrackId, Name FROM Track");
app.Chord(
() => app.Find("QueryStatus").Name.StartsWith("Rows: ", StringComparison.Ordinal),
() => AppSession.TextOf(app.Find("QueryStatus")).StartsWith("Rows: ", StringComparison.Ordinal),
VirtualKeyShort.CONTROL,
VirtualKeyShort.ENTER);
var grid = app.Find("ResultsGrid");
Expand Down
4 changes: 3 additions & 1 deletion windows/tests/TablePro.App.UITests/ShellPolishTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,9 @@ public void ATableKeepsItsPageSizeAndGoesToAPageInsideItsCount(string theme)

app.Click(app.Find("PageSizeButton"), () => app.TryFindMenuItem("100 rows") is not null);
app.Screenshot("29-page-size-menu");
app.Click(app.FindMenuItem("100 rows"), () => status.Name.StartsWith("1-100 ", StringComparison.Ordinal));
app.Click(
app.FindMenuItem("100 rows"),
() => AppSession.TextOf(status).StartsWith("1-100 ", StringComparison.Ordinal));
Assert.Matches(PagedStatus("1-100"), status.Name);
Assert.Equal("100 rows", app.Find("PageSizeButton").Name);
var goTo = app.Find("GoToPageButton");
Expand Down
2 changes: 1 addition & 1 deletion windows/tests/TablePro.App.UITests/TabWindowTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public void ClosingATabWindowOrExitingAsksBeforeRollingBack(string theme)
app.Find("PrimaryButton", torn).AsButton().Invoke();
app.WaitForClose(SampleWindow);
app.TypeInto("Query 1", "SELECT COUNT(*) FROM Track WHERE TrackId = 1 AND Name = 'Pending';");
app.Chord(() => app.Find("QueryStatus").Name.StartsWith("Rows: 1", StringComparison.Ordinal),
app.Chord(() => AppSession.TextOf(app.Find("QueryStatus")).StartsWith("Rows: 1", StringComparison.Ordinal),
VirtualKeyShort.CONTROL, VirtualKeyShort.ENTER);
Assert.Equal("0", app.WaitForCell(app.Find("ResultsGrid"), 0, 0, value => value == "0"));
}
Expand Down
2 changes: 1 addition & 1 deletion windows/tests/TablePro.App.UITests/TableEditingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void ATableTabKeepsEditsPendingPreviewsTheirSqlAndSavesThem(string theme)
app.Chord(() => app.TryFind("SqlEditor") is { IsOffscreen: false }, VirtualKeyShort.CONTROL, VirtualKeyShort.KEY_1);
var names = string.Join(", ", new[] { Renamed, Added, deleted }.Select(name => "'" + name.Replace("'", "''", StringComparison.Ordinal) + "'"));
app.TypeInto("Query 1", $"SELECT COUNT(*) FROM Artist WHERE Name IN ({names});");
app.Chord(() => app.Find("QueryStatus").Name.StartsWith("Rows: 1", StringComparison.Ordinal),
app.Chord(() => AppSession.TextOf(app.Find("QueryStatus")).StartsWith("Rows: 1", StringComparison.Ordinal),
VirtualKeyShort.CONTROL, VirtualKeyShort.ENTER);
Assert.Equal("2", app.WaitForCell(app.Find("ResultsGrid"), 0, 0, value => value == "2"));
}
Expand Down
Loading
Loading