Skip to content

Commit

Permalink
Inhibit saving state when testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Wootten committed Nov 1, 2023
1 parent 2e059a2 commit 77215d1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
5 changes: 5 additions & 0 deletions src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
3 changes: 2 additions & 1 deletion src/tests/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()));
Expand Down

0 comments on commit 77215d1

Please sign in to comment.