Skip to content

Commit

Permalink
Add new-tab tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremypw committed Nov 24, 2024
1 parent 3d6443b commit fc5260b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 27 deletions.
10 changes: 6 additions & 4 deletions src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

public class Terminal.Application : Gtk.Application {
public static string SEND_PROCESS_FINISHED_BASH;
public static string send_process_finished_bash;
public int minimum_width;
public int minimum_height;

Expand All @@ -15,7 +15,7 @@ public class Terminal.Application : Gtk.Application {
public static GLib.Settings settings;
public static GLib.Settings settings_sys;

public bool is_testing { get; set construct; }
public bool is_testing { get; construct; }

private static Themes themes;

Expand All @@ -31,9 +31,11 @@ stdout.printf ("# Application new \n");

construct {
if (is_testing) {
SEND_PROCESS_FINISHED_BASH = "";
stdout.printf ("# App construct - is testing\n");
send_process_finished_bash = "";
} else {
SEND_PROCESS_FINISHED_BASH= "dbus-send --type=method_call " +
stdout.printf ("# App construct - NOT testing\n");
send_process_finished_bash = "dbus-send --type=method_call " +
"--session --dest=io.elementary.terminal " +
"/io/elementary/terminal " +
"io.elementary.terminal.ProcessFinished " +
Expand Down
46 changes: 23 additions & 23 deletions src/tests/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -166,31 +166,31 @@ stdout.printf ("# Callback cli 1\n");
// });

// primary command line: first instance from terminal. any instance from dbus.
// GLib.Test.add_func ("/application/command-line/new-tab", () => {
// stdout.printf ("# Starting command-line/new-tab\n");
// int default_tabs = 0;
// option (null, "@a{sv} {}", () => {
// stdout.printf ("# null option callback\n");
// unowned var window = (MainWindow) application.active_window;
// assert_nonnull (window);
// default_tabs = (int) window.notebook.n_pages;
// });
GLib.Test.add_func ("/application/command-line/new-tab", () => {
stdout.printf ("# Starting command-line/new-tab\n");
int default_tabs = 0;
option (null, "@a{sv} {}", () => {
stdout.printf ("# null option callback\n");
unowned var window = (MainWindow) application.active_window;
assert_nonnull (window);
default_tabs = (int) window.notebook.n_pages;
});

// option ("{'new-tab':<true>}", "@a{sv} {}", () => {
// stdout.printf ("# new tab true callback\n");
// unowned var window = (MainWindow) application.active_window;
// assert_nonnull (window);
// var n_tabs = (int) window.notebook.n_pages;
// assert_cmpint (n_tabs - default_tabs, CompareOperator.EQ, 1);
// });
option ("{'new-tab':<true>}", "@a{sv} {}", () => {
stdout.printf ("# new tab true callback\n");
unowned var window = (MainWindow) application.active_window;
assert_nonnull (window);
var n_tabs = (int) window.notebook.n_pages;
assert_cmpint (n_tabs - default_tabs, CompareOperator.EQ, 1);
});

// option ("{'new-tab':<false>}", "@a{sv} {}", () => {
// unowned var window = (MainWindow) application.active_window;
// assert_nonnull (window);
// var n_tabs = (int) window.notebook.n_pages;
// assert_cmpint (n_tabs, CompareOperator.EQ, default_tabs);
// });
// });
option ("{'new-tab':<false>}", "@a{sv} {}", () => {
unowned var window = (MainWindow) application.active_window;
assert_nonnull (window);
var n_tabs = (int) window.notebook.n_pages;
assert_cmpint (n_tabs, CompareOperator.EQ, default_tabs);
});
});

// GLib.Test.add_func ("/application/command-line/new-window", () => {
// option ("{'new-window':<true>}", "@a{sv} {}", () => {
Expand Down

0 comments on commit fc5260b

Please sign in to comment.