From 77215d1eb26d7c6636b53471d106f89529750a58 Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Wed, 1 Nov 2023 18:31:57 +0000 Subject: [PATCH] Inhibit saving state when testing --- src/Application.vala | 2 ++ src/MainWindow.vala | 5 +++++ src/tests/Application.vala | 3 ++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Application.vala b/src/Application.vala index 311dc0a5b8..0f8ec0b900 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -14,6 +14,8 @@ public class Terminal.Application : Gtk.Application { public static GLib.Settings settings; public static GLib.Settings settings_sys; + public bool is_testing { get; set construct; } + private static Themes themes; public Application () { diff --git a/src/MainWindow.vala b/src/MainWindow.vala index fb1f5be808..1f8d51e48e 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -1357,6 +1357,11 @@ namespace Terminal { string[] opened_tabs = {}; int focused_tab = 0; + // Continuous saving of opened terminals interferes with current unit tests + if (app.is_testing) { + return; + } + if (save_zooms && current_terminal != null) { Application.saved_state.set_double ("zoom", current_terminal.font_scale); } diff --git a/src/tests/Application.vala b/src/tests/Application.vala index df88c9dd62..150f66b2d0 100644 --- a/src/tests/Application.vala +++ b/src/tests/Application.vala @@ -12,7 +12,8 @@ namespace Terminal.Test.Application { private void setup () { application = new Terminal.Application () { - application_id = "io.elementary.terminal.tests.application" + application_id = "io.elementary.terminal.tests.application", + is_testing = true }; application.shutdown.connect (() => application.get_windows ().foreach ((win) => win.destroy ()));