diff options
-rw-r--r-- | src/arctica-greeter.vala | 30 | ||||
-rw-r--r-- | src/background.vala | 3 | ||||
-rw-r--r-- | src/dash-box.vala | 3 | ||||
-rw-r--r-- | src/dash-entry.vala | 5 | ||||
-rw-r--r-- | src/greeter-list.vala | 37 | ||||
-rw-r--r-- | src/main-window.vala | 8 | ||||
-rw-r--r-- | src/menubar.vala | 12 | ||||
-rw-r--r-- | src/session-list.vala | 3 | ||||
-rw-r--r-- | src/user-list.vala | 89 | ||||
-rw-r--r-- | tests/arctica-greeter.vala | 10 | ||||
-rw-r--r-- | tests/test.vala | 70 |
11 files changed, 171 insertions, 99 deletions
diff --git a/src/arctica-greeter.vala b/src/arctica-greeter.vala index 09c1feb..013739c 100644 --- a/src/arctica-greeter.vala +++ b/src/arctica-greeter.vala @@ -21,16 +21,15 @@ public const int grid_size = 40; -public class ArcticaGreeter +[SingleInstance] +public class ArcticaGreeter : Object { - public static ArcticaGreeter singleton; - public signal void show_message (string text, LightDM.MessageType type); public signal void show_prompt (string text, LightDM.PromptType type); public signal void authentication_complete (); public signal void starting_session (); - public bool test_mode = false; + public bool test_mode { get; construct; default = false; } private string state_file; private KeyFile state; @@ -53,11 +52,8 @@ public class ArcticaGreeter public signal void xsettings_ready (); public signal void greeter_ready (); - private ArcticaGreeter (bool test_mode_) + construct { - singleton = this; - test_mode = test_mode_; - greeter = new LightDM.Greeter (); greeter.show_message.connect ((text, type) => { show_message (text, type); }); greeter.show_prompt.connect ((text, type) => { show_prompt (text, type); }); @@ -140,6 +136,22 @@ public class ArcticaGreeter xsettings_ready_cb (); } + /* + * Note that we need a way to specify a parameter for the initial instance + * creation of the singleton, but also a constructor that takes no + * parameters for later usage. + * + * Making the parameter optional is a good compromise. + * + * This this parameter is construct-only, initializing it by passing it to + * the GObject constructor is both the correct way to do it, and it will + * additionally avoid changing it in later calls of our constructor. + */ + public ArcticaGreeter (bool test_mode_ = false) + { + Object (test_mode: test_mode_); + } + public string? get_state (string key) { try @@ -340,7 +352,7 @@ public class ArcticaGreeter { try { - ArcticaGreeter.singleton.greeter.authenticate_remote (session, userid); + greeter.authenticate_remote (session, userid); } catch (Error e) { diff --git a/src/background.vala b/src/background.vala index 9a77047..18bf169 100644 --- a/src/background.vala +++ b/src/background.vala @@ -778,7 +778,8 @@ public class Background : Gtk.Fixed { notify_property ("average-color"); - if (!ArcticaGreeter.singleton.test_mode) + var greeter = new ArcticaGreeter (); + if (!greeter.test_mode) { var rgba = current.average_color.to_string (); var root = get_screen ().get_root_window (); diff --git a/src/dash-box.vala b/src/dash-box.vala index cc1d715..d8fe6fd 100644 --- a/src/dash-box.vala +++ b/src/dash-box.vala @@ -54,7 +54,8 @@ public class DashBox : Gtk.Box /* Does not actually add w to this widget, as doing so would potentially mess with w's placement. */ public void set_base (Gtk.Widget? w) { - if (!ArcticaGreeter.singleton.test_mode) { + var greeter = new ArcticaGreeter (); + if (!greeter.test_mode) { return_if_fail (pushed == null); return_if_fail (mode == Mode.NORMAL); } diff --git a/src/dash-entry.vala b/src/dash-entry.vala index 526b631..4d1146d 100644 --- a/src/dash-entry.vala +++ b/src/dash-entry.vala @@ -301,10 +301,11 @@ public class DashEntry : Gtk.Entry, Fadable // This is a workaround for bug https://launchpad.net/bugs/944159 // The problem is that orca seems to not notice that it's in a password // field on startup. We just need to kick orca in the pants. - if (ArcticaGreeter.singleton.orca_needs_kick) + var greeter = new ArcticaGreeter (); + if (greeter.orca_needs_kick) { Signal.emit_by_name (get_accessible (), "focus-event", true); - ArcticaGreeter.singleton.orca_needs_kick = false; + greeter.orca_needs_kick = false; } return base.key_press_event (event); diff --git a/src/greeter-list.vala b/src/greeter-list.vala index 0cc3a1f..98c8b48 100644 --- a/src/greeter-list.vala +++ b/src/greeter-list.vala @@ -229,7 +229,8 @@ public abstract class GreeterList : FadableBox public void cancel_authentication () { - ArcticaGreeter.singleton.cancel_authentication (); + var greeter = new ArcticaGreeter (); + greeter.cancel_authentication (); entry_selected (selected_entry.id); } @@ -483,7 +484,8 @@ public abstract class GreeterList : FadableBox entry.destroy (); /* Show a manual login if no users and no remote login entry */ - if (!have_entries () && !ArcticaGreeter.singleton.show_remote_login_hint ()) + var greeter = new ArcticaGreeter (); + if (!have_entries () && !greeter.show_remote_login_hint ()) add_manual_entry (); queue_draw (); @@ -793,9 +795,10 @@ public abstract class GreeterList : FadableBox protected void connect_to_lightdm () { - ArcticaGreeter.singleton.show_message.connect (show_message_cb); - ArcticaGreeter.singleton.show_prompt.connect (show_prompt_cb); - ArcticaGreeter.singleton.authentication_complete.connect (authentication_complete_cb); + var greeter = new ArcticaGreeter (); + greeter.show_message.connect (show_message_cb); + greeter.show_prompt.connect (show_prompt_cb); + greeter.authentication_complete.connect (authentication_complete_cb); } protected void show_message_cb (string text, LightDM.MessageType type) @@ -809,10 +812,11 @@ public abstract class GreeterList : FadableBox /* Notify the greeter on what user has been logged */ if (get_selected_id () == "*other" && manual_name == null) { - if (ArcticaGreeter.singleton.test_mode) + var greeter = new ArcticaGreeter (); + if (greeter.test_mode) manual_name = test_username; else - manual_name = ArcticaGreeter.singleton.authentication_user(); + manual_name = greeter.authentication_user(); } prompted = true; @@ -841,10 +845,11 @@ public abstract class GreeterList : FadableBox return; bool is_authenticated; - if (ArcticaGreeter.singleton.test_mode) + var greeter = new ArcticaGreeter (); + if (greeter.test_mode) is_authenticated = test_is_authenticated; else - is_authenticated = ArcticaGreeter.singleton.is_authenticated(); + is_authenticated = greeter.is_authenticated(); if (is_authenticated) { @@ -852,7 +857,7 @@ public abstract class GreeterList : FadableBox if (prompted && !unacknowledged_messages) { login_complete (); - if (ArcticaGreeter.singleton.test_mode) + if (greeter.test_mode) start_session (); else { @@ -905,16 +910,17 @@ public abstract class GreeterList : FadableBox greeter_authenticating_user = get_selected_id (); - if (ArcticaGreeter.singleton.test_mode) + var greeter = new ArcticaGreeter (); + if (greeter.test_mode) test_start_authentication (); else { if (get_selected_id () == "*other") - ArcticaGreeter.singleton.authenticate (); + greeter.authenticate (); else if (get_selected_id () == "*guest") - ArcticaGreeter.singleton.authenticate_as_guest (); + greeter.authenticate_as_guest (); else - ArcticaGreeter.singleton.authenticate (get_selected_id ()); + greeter.authenticate (get_selected_id ()); } } @@ -929,7 +935,8 @@ public abstract class GreeterList : FadableBox private void start_session () { - if (!ArcticaGreeter.singleton.start_session (get_lightdm_session (), background)) + var greeter = new ArcticaGreeter (); + if (!greeter.start_session (get_lightdm_session (), background)) { show_message (_("Failed to start session"), true); start_authentication (); diff --git a/src/main-window.vala b/src/main-window.vala index 993e43e..172c6f4 100644 --- a/src/main-window.vala +++ b/src/main-window.vala @@ -159,7 +159,8 @@ public class MainWindow : Gtk.Window only_on_monitor = AGSettings.get_string(AGSettings.KEY_ONLY_ON_MONITOR); monitor_setting_ok = only_on_monitor == "auto"; - if (ArcticaGreeter.singleton.test_mode) + var greeter = new ArcticaGreeter (); + if (greeter.test_mode) { /* Simulate an 800x600 monitor to the left of a 640x480 monitor */ monitors = new List<Monitor> (); @@ -375,6 +376,7 @@ public class MainWindow : Gtk.Window } } + var greeter = new ArcticaGreeter (); switch (event.keyval) { case Gdk.Key.Escape: @@ -434,14 +436,14 @@ public class MainWindow : Gtk.Window } return true; case Gdk.Key.z: - if (ArcticaGreeter.singleton.test_mode && (event.state & Gdk.ModifierType.MOD1_MASK) != 0) + if (greeter.test_mode && (event.state & Gdk.ModifierType.MOD1_MASK) != 0) { show_shutdown_dialog (ShutdownDialogType.SHUTDOWN); return true; } break; case Gdk.Key.Z: - if (ArcticaGreeter.singleton.test_mode && (event.state & Gdk.ModifierType.MOD1_MASK) != 0) + if (greeter.test_mode && (event.state & Gdk.ModifierType.MOD1_MASK) != 0) { show_shutdown_dialog (ShutdownDialogType.RESTART); return true; diff --git a/src/menubar.vala b/src/menubar.vala index a2b6b99..3f9f72c 100644 --- a/src/menubar.vala +++ b/src/menubar.vala @@ -108,7 +108,8 @@ public class MenuBar : Gtk.MenuBar */ public void set_keyboard_state () { - if (!ArcticaGreeter.singleton.test_mode) + var greeter = new ArcticaGreeter (); + if (!greeter.test_mode) onscreen_keyboard_item.set_active (AGSettings.get_boolean (AGSettings.KEY_ONSCREEN_KEYBOARD)); } @@ -155,7 +156,8 @@ public class MenuBar : Gtk.MenuBar setup_indicators (); - ArcticaGreeter.singleton.starting_session.connect (cleanup); + var greeter = new ArcticaGreeter (); + greeter.starting_session.connect (cleanup); } private void close_pid (ref Pid pid) @@ -293,7 +295,8 @@ public class MenuBar : Gtk.MenuBar private void load_indicator (string indicator_name) { - if (!ArcticaGreeter.singleton.test_mode) + var greeter = new ArcticaGreeter (); + if (!greeter.test_mode) { if (indicator_name == "ug-accessibility") { @@ -484,7 +487,8 @@ public class MenuBar : Gtk.MenuBar // this is not racy with orca startup, it is racy with whether // orca will read the first character or not out loud. Hence // why we do both. Ideally this would be fixed in orca itself. - ArcticaGreeter.singleton.orca_needs_kick = true; + var greeter = new ArcticaGreeter (); + greeter.orca_needs_kick = true; Timeout.add_seconds (1, () => { Signal.emit_by_name ((get_toplevel () as Gtk.Window).get_focus ().get_accessible (), "focus-event", true); return false; diff --git a/src/session-list.vala b/src/session-list.vala index 820b4c6..290a7af 100644 --- a/src/session-list.vala +++ b/src/session-list.vala @@ -44,7 +44,8 @@ public class SessionPrompt : PromptBox box = new ToggleBox (default_session, session); - if (ArcticaGreeter.singleton.test_mode) + var greeter = new ArcticaGreeter (); + if (greeter.test_mode) { box.add_item ("gnome", "GNOME", SessionList.get_badge ("gnome")); box.add_item ("kde", "KDE", SessionList.get_badge ("kde")); diff --git a/src/user-list.vala b/src/user-list.vala index 0991703..3012c7d 100644 --- a/src/user-list.vala +++ b/src/user-list.vala @@ -73,7 +73,8 @@ public class UserList : GreeterList { show_hidden_users_ = value; - if (ArcticaGreeter.singleton.test_mode) + var greeter = new ArcticaGreeter (); + if (greeter.test_mode) { if (value) add_user ("hidden", "Hidden User", null, false, false, null); @@ -166,8 +167,9 @@ public class UserList : GreeterList connect_to_lightdm (); - if (!ArcticaGreeter.singleton.test_mode && - ArcticaGreeter.singleton.show_remote_login_hint ()) + var greeter = new ArcticaGreeter (); + if (!greeter.test_mode && + greeter.show_remote_login_hint ()) remote_logon_service_watch = Bus.watch_name (BusType.SESSION, "org.ArcticaProject.RemoteLogon", BusNameWatcherFlags.AUTO_START, @@ -390,7 +392,8 @@ public class UserList : GreeterList remote_logon_service = null; /* provide a fallback manual login option */ - if (ArcticaGreeter.singleton.hide_users_hint ()) { + var greeter = new ArcticaGreeter (); + if (greeter.hide_users_hint ()) { add_manual_entry(); set_active_entry ("*other"); } @@ -443,10 +446,11 @@ public class UserList : GreeterList else { var login_success = false; + var greeter = new ArcticaGreeter (); try { var url = url_from_remote_loding_server_list_name (selected_entry.id); - if (ArcticaGreeter.singleton.test_mode) + if (greeter.test_mode) { if (password_field.text == "password") { @@ -528,7 +532,8 @@ public class UserList : GreeterList sensitive = false; will_clear = true; greeter_authenticating_user = selected_entry.id; - if (ArcticaGreeter.singleton.test_mode) + var greeter = new ArcticaGreeter (); + if (greeter.test_mode) { Gtk.Entry field = current_remote_fields.get ("password") as Gtk.Entry; test_is_authenticated = field.text == "password"; @@ -539,7 +544,7 @@ public class UserList : GreeterList } else { - ArcticaGreeter.singleton.authenticate_remote (get_lightdm_session (), null); + greeter.authenticate_remote (get_lightdm_session (), null); remote_logon_service.set_last_used_server.begin (currently_browsing_server_url, url_from_remote_loding_server_list_name (selected_entry.id)); } } @@ -576,7 +581,8 @@ public class UserList : GreeterList if (is_supported_remote_session (config_session)) { greeter_authenticating_user = selected_entry.id; - ArcticaGreeter.singleton.authenticate_remote (config_session, null); + var greeter = new ArcticaGreeter (); + greeter.authenticate_remote (config_session, null); } } dialog.destroy (); @@ -635,7 +641,8 @@ public class UserList : GreeterList private void entry_selected_cb (string? username) { - ArcticaGreeter.singleton.set_state ("last-user", username); + var greeter = new ArcticaGreeter (); + greeter.set_state ("last-user", username); if (selected_entry is UserPromptBox) session = (selected_entry as UserPromptBox).session; else @@ -777,9 +784,10 @@ public class UserList : GreeterList else if (field.type == "email") { string[] email_domains; + var greeter = new ArcticaGreeter (); try { - if (ArcticaGreeter.singleton.test_mode) + if (greeter.test_mode) email_domains = { "canonical.com", "ubuntu.org", "candy.com", "urban.net" }; else yield remote_logon_service.get_cached_domains_for_server (url, out email_domains); @@ -889,12 +897,13 @@ public class UserList : GreeterList will_clear = true; unacknowledged_messages = false; + var greeter = new ArcticaGreeter (); foreach (var response in responses) { - if (ArcticaGreeter.singleton.test_mode) + if (greeter.test_mode) test_respond (response); else - ArcticaGreeter.singleton.respond (response); + greeter.respond (response); } } @@ -904,10 +913,11 @@ public class UserList : GreeterList unacknowledged_messages = false; var is_authenticated = false; - if (ArcticaGreeter.singleton.test_mode) + var greeter = new ArcticaGreeter (); + if (greeter.test_mode) is_authenticated = test_is_authenticated; else - is_authenticated = ArcticaGreeter.singleton.is_authenticated(); + is_authenticated = greeter.is_authenticated(); /* Finish authentication (again) or restart it */ if (is_authenticated) @@ -923,18 +933,21 @@ public class UserList : GreeterList { var session_chooser = new SessionList (background, menubar, session, default_session); session_chooser.session_clicked.connect (session_clicked_cb); - ArcticaGreeter.singleton.push_list (session_chooser); + var greeter = new ArcticaGreeter (); + greeter.push_list (session_chooser); } private void session_clicked_cb (string session) { this.session = session; - ArcticaGreeter.singleton.pop_list (); + var greeter = new ArcticaGreeter (); + greeter.pop_list (); } private bool should_show_session_badge () { - if (ArcticaGreeter.singleton.test_mode) + var greeter = new ArcticaGreeter (); + if (greeter.test_mode) return get_selected_id () != "no-badge"; else return LightDM.get_sessions ().length () > 1; @@ -962,7 +975,8 @@ public class UserList : GreeterList private bool is_supported_remote_session (string session_internal_name) { - if (ArcticaGreeter.singleton.test_mode) + var greeter = new ArcticaGreeter (); + if (greeter.test_mode) return session_internal_name == "rdp"; var found = false; @@ -1004,13 +1018,14 @@ public class UserList : GreeterList private void fill_list () { - if (ArcticaGreeter.singleton.test_mode) + var greeter = new ArcticaGreeter (); + if (greeter.test_mode) test_fill_list (); else { - default_session = ArcticaGreeter.singleton.default_session_hint (); - always_show_manual = ArcticaGreeter.singleton.show_manual_login_hint (); - if (!ArcticaGreeter.singleton.hide_users_hint ()) + default_session = greeter.default_session_hint (); + always_show_manual = greeter.show_manual_login_hint (); + if (!greeter.hide_users_hint ()) { var users = LightDM.UserList.get_instance (); users.user_added.connect (user_added_cb); @@ -1020,7 +1035,7 @@ public class UserList : GreeterList user_added_cb (user); } - if (ArcticaGreeter.singleton.has_guest_account_hint ()) + if (greeter.has_guest_account_hint ()) { debug ("Adding guest account entry"); offer_guest = true; @@ -1030,9 +1045,9 @@ public class UserList : GreeterList if (!have_entries ()) add_manual_entry (); - var last_user = ArcticaGreeter.singleton.get_state ("last-user"); - if (ArcticaGreeter.singleton.select_user_hint () != null) - set_active_entry (ArcticaGreeter.singleton.select_user_hint ()); + var last_user = greeter.get_state ("last-user"); + if (greeter.select_user_hint () != null) + set_active_entry (greeter.select_user_hint ()); else if (last_user != null) set_active_entry (last_user); } @@ -1098,39 +1113,40 @@ public class UserList : GreeterList { if (selected_entry.id.has_prefix ("*remote_login")) { + var greeter = new ArcticaGreeter (); if ((text == pam_x2go.PROMPT_USER) || (text == pam_freerdp2.PROMPT_USER)) { Gtk.Entry field = current_remote_fields.get ("username") as Gtk.Entry; var answer = field != null ? field.text : ""; debug ("remote_login prompt parsing: username -> %s", answer); - ArcticaGreeter.singleton.respond (answer); + greeter.respond (answer); } else if ((text == pam_x2go.PROMPT_PASSWORD) || (text == pam_freerdp2.PROMPT_PASSWORD)) { Gtk.Entry field = current_remote_fields.get ("password") as Gtk.Entry; var answer = field != null ? field.text : ""; debug ("remote_login prompt parsing: password -> <hidden>"); - ArcticaGreeter.singleton.respond (answer); + greeter.respond (answer); } else if ((text == pam_x2go.PROMPT_HOST) || (text == pam_freerdp2.PROMPT_HOST)) { var answer = url_from_remote_loding_server_list_name (selected_entry.id); debug ("remote_login prompt parsing: host -> %s", answer); - ArcticaGreeter.singleton.respond (answer); + greeter.respond (answer); } else if (text == pam_freerdp2.PROMPT_DOMAIN) { Gtk.Entry field = current_remote_fields.get ("domain") as Gtk.Entry; var answer = field != null ? field.text : ""; debug ("remote_login prompt parsing: domain -> %s", answer); - ArcticaGreeter.singleton.respond (answer); + greeter.respond (answer); } else if (text == pam_x2go.PROMPT_COMMAND) { Gtk.Entry field = current_remote_fields.get ("command") as Gtk.Entry; var answer = field != null ? field.text : ""; debug ("remote_login prompt parsing: command -> %s", answer); - ArcticaGreeter.singleton.respond (answer); + greeter.respond (answer); } } else @@ -1210,7 +1226,8 @@ public class UserList : GreeterList { } - if (!ArcticaGreeter.singleton.hide_users_hint()) + var greeter = new ArcticaGreeter (); + if (!greeter.hide_users_hint()) while (add_test_entry ()); /* add a manual entry if the list of entries is empty initially */ @@ -1221,12 +1238,12 @@ public class UserList : GreeterList n_test_entries++; } - offer_guest = ArcticaGreeter.singleton.has_guest_account_hint(); - always_show_manual = ArcticaGreeter.singleton.show_manual_login_hint(); + offer_guest = greeter.has_guest_account_hint(); + always_show_manual = greeter.show_manual_login_hint(); key_press_event.connect (test_key_press_cb); - if (ArcticaGreeter.singleton.show_remote_login_hint()) + if (greeter.show_remote_login_hint()) Timeout.add (1000, () => { RemoteServer[] test_server_list = {}; @@ -1248,7 +1265,7 @@ public class UserList : GreeterList return false; }); - var last_user = ArcticaGreeter.singleton.get_state ("last-user"); + var last_user = greeter.get_state ("last-user"); if (last_user != null) set_active_entry (last_user); diff --git a/tests/arctica-greeter.vala b/tests/arctica-greeter.vala index 2a6581b..3bcfeb8 100644 --- a/tests/arctica-greeter.vala +++ b/tests/arctica-greeter.vala @@ -19,7 +19,8 @@ public const int grid_size = 40; -public class ArcticaGreeter +[SingleInstance] +public class ArcticaGreeter : Object { public static ArcticaGreeter singleton; @@ -27,11 +28,16 @@ public class ArcticaGreeter public signal void show_prompt (string text, LightDM.PromptType type); public signal void authentication_complete (); - public bool test_mode = false; + public bool test_mode { get; construct; default = false; } public bool session_started = false; public string last_respond_response; public bool orca_needs_kick; + public ArcticaGreeter (bool test_mode_ = false) + { + Object (test_mode: test_mode_); + } + public bool is_authenticated () { return false; diff --git a/tests/test.vala b/tests/test.vala index b129bfd..9348b82 100644 --- a/tests/test.vala +++ b/tests/test.vala @@ -137,6 +137,21 @@ public class Test } } + public static void greeter_test_mode () + { + var greeter = new ArcticaGreeter (); + + /* + * Test that fetching the greeter singleton worked, even though we use + * the default value for test mode (false). + */ + GLib.assert (true == greeter.test_mode); + + // And explicitly try to override it, too. + greeter = new ArcticaGreeter (false); + GLib.assert (true == greeter.test_mode); + } + public static void simple_navigation () { MainWindow mw = setup (); @@ -486,11 +501,12 @@ public class Test GLib.assert (list.selected_entry.id == "*remote_login*http://rdpdefaultusername2.com*lwola"); wait_for_scrolling_end (list); - ArcticaGreeter.singleton.session_started = false; + var greeter = new ArcticaGreeter (); + greeter.session_started = false; pwd = remote_login_entry_password_field (list); pwd.text = "password"; list.selected_entry.respond ({}); - GLib.assert (ArcticaGreeter.singleton.session_started); + GLib.assert (greeter.session_started); mw.hide (); } @@ -516,7 +532,8 @@ public class Test GLib.assert (list.selected_entry.id == "*remote_login*http://rdpdefaultusername2.com*lwola"); wait_for_scrolling_end (list); - ArcticaGreeter.singleton.session_started = false; + var greeter = new ArcticaGreeter (); + greeter.session_started = false; pwd = remote_login_entry_password_field (list); pwd.text = "delay"; pwd.activate (); @@ -650,14 +667,15 @@ public class Test username.text = "bar"; pwd.text = "foobar"; - ArcticaGreeter.singleton.show_prompt("remote login:", LightDM.PromptType.QUESTION); - GLib.assert (ArcticaGreeter.singleton.last_respond_response == username.text); - ArcticaGreeter.singleton.show_prompt("remote host:", LightDM.PromptType.QUESTION); - GLib.assert (ArcticaGreeter.singleton.last_respond_response == "http://coolrdpserver.com"); - ArcticaGreeter.singleton.show_prompt("domain:", LightDM.PromptType.QUESTION); - GLib.assert (ArcticaGreeter.singleton.last_respond_response == domain.text); - ArcticaGreeter.singleton.show_prompt("password:", LightDM.PromptType.SECRET); - GLib.assert (ArcticaGreeter.singleton.last_respond_response == pwd.text); + var greeter = new ArcticaGreeter (); + greeter.show_prompt("remote login:", LightDM.PromptType.QUESTION); + GLib.assert (greeter.last_respond_response == username.text); + greeter.show_prompt("remote host:", LightDM.PromptType.QUESTION); + GLib.assert (greeter.last_respond_response == "http://coolrdpserver.com"); + greeter.show_prompt("domain:", LightDM.PromptType.QUESTION); + GLib.assert (greeter.last_respond_response == domain.text); + greeter.show_prompt("password:", LightDM.PromptType.SECRET); + GLib.assert (greeter.last_respond_response == pwd.text); mw.hide (); } @@ -690,15 +708,16 @@ public class Test public static void remote_login_only () { - ArcticaGreeter.singleton.test_mode = true; - ArcticaGreeter.singleton.session_started = false; + var greeter = new ArcticaGreeter (); + greeter.test_mode = true; + greeter.session_started = false; /* this configuration should result in the list containing only the remote login entry, without any fallback manual entry */ - ArcticaGreeter.singleton._hide_users_hint = true; - ArcticaGreeter.singleton._show_remote_login_hint = true; - ArcticaGreeter.singleton._has_guest_account_hint = false; - ArcticaGreeter.singleton._show_manual_login_hint = false; + greeter._hide_users_hint = true; + greeter._show_remote_login_hint = true; + greeter._has_guest_account_hint = false; + greeter._show_manual_login_hint = false; MainWindow mw = setup (); TestList list = mw.stack.top () as TestList; @@ -725,14 +744,15 @@ public class Test public static void manual_login_fallback () { - ArcticaGreeter.singleton.test_mode = true; - ArcticaGreeter.singleton.session_started = false; + var greeter = new ArcticaGreeter (); + greeter.test_mode = true; + greeter.session_started = false; /* this configuration should result in the list containing at least a manual entry */ - ArcticaGreeter.singleton._hide_users_hint = true; - ArcticaGreeter.singleton._show_remote_login_hint = false; - ArcticaGreeter.singleton._has_guest_account_hint = false; - ArcticaGreeter.singleton._show_manual_login_hint = true; + greeter._hide_users_hint = true; + greeter._show_remote_login_hint = false; + greeter._has_guest_account_hint = false; + greeter._show_manual_login_hint = true; MainWindow mw = setup (); TestList list = mw.stack.top () as TestList; @@ -782,9 +802,9 @@ public class Test setup_gsettings (); - ArcticaGreeter.singleton = new ArcticaGreeter(); - ArcticaGreeter.singleton.test_mode = true; + var greeter = new ArcticaGreeter (true); + GLib.Test.add_func ("/Greeter Test Mode", greeter_test_mode); GLib.Test.add_func ("/Simple Navigation", simple_navigation); GLib.Test.add_func ("/Remote Login", remote_login); GLib.Test.add_func ("/Remote Login duplicate entries", remote_login_duplicate_entries); |