503
503
bool confirm_disabled = g_settings_get_boolean (indicator_settings, confirm_disabled_key);
504
504
bool confirm = confirm_supported && !confirm_disabled;
506
// Add users so switch options are shown
507
IndicatorSessionUser * u = g_new0 (IndicatorSessionUser, 1);
509
u->user_name = g_strdup ("thing1");
510
u->real_name = g_strdup (" ");
511
indicator_session_users_mock_add_user (INDICATOR_SESSION_USERS_MOCK(mock_users), u);
512
u = g_new0 (IndicatorSessionUser, 1);
514
u->user_name = g_strdup ("thing2");
515
u->real_name = g_strdup (" ");
516
indicator_session_users_mock_add_user (INDICATOR_SESSION_USERS_MOCK(mock_users), u);
517
wait_for_menu_resync ();
506
519
// confirm that the ellipsis are correct
507
520
ASSERT_EQ (confirm, action_menuitem_label_is_ellipsized ("indicator.switch-to-screensaver"));
508
521
ASSERT_EQ (confirm, action_menuitem_label_is_ellipsized ("indicator.logout"));
537
550
bool confirm_disabled = g_settings_get_boolean (indicator_settings, confirm_disabled_key);
538
551
bool confirm = confirm_supported && !confirm_disabled;
553
// Add users so switch options are shown
554
IndicatorSessionUser * u = g_new0 (IndicatorSessionUser, 1);
556
u->user_name = g_strdup ("thing1");
557
u->real_name = g_strdup (" ");
558
indicator_session_users_mock_add_user (INDICATOR_SESSION_USERS_MOCK(mock_users), u);
559
u = g_new0 (IndicatorSessionUser, 1);
561
u->user_name = g_strdup ("thing2");
562
u->real_name = g_strdup (" ");
563
indicator_session_users_mock_add_user (INDICATOR_SESSION_USERS_MOCK(mock_users), u);
564
wait_for_menu_resync ();
540
566
// confirm that the ellipsis are correct
541
567
ASSERT_EQ (confirm, action_menuitem_label_is_ellipsized ("indicator.switch-to-screensaver"));
542
568
ASSERT_EQ (confirm, action_menuitem_label_is_ellipsized ("indicator.logout"));
562
588
g_settings_reset (indicator_settings, confirm_disabled_key);
591
TEST_F (ServiceTest, LockdownUserSwitching)
593
const char * const can_switch_key = "can-switch-sessions";
595
// Add users so switch options are shown
596
IndicatorSessionUser * u = g_new0 (IndicatorSessionUser, 1);
598
u->user_name = g_strdup ("thing1");
599
u->real_name = g_strdup (" ");
600
indicator_session_users_mock_add_user (INDICATOR_SESSION_USERS_MOCK(mock_users), u);
601
u = g_new0 (IndicatorSessionUser, 1);
603
u->user_name = g_strdup ("thing2");
604
u->real_name = g_strdup (" ");
605
indicator_session_users_mock_add_user (INDICATOR_SESSION_USERS_MOCK(mock_users), u);
606
wait_for_menu_resync ();
608
// Check can enable screensaver lock
609
ASSERT_TRUE (action_menuitem_exists ("indicator.switch-to-screensaver"));
610
ASSERT_FALSE (action_menuitem_exists ("indicator.switch-to-greeter"));
612
g_settings_set_boolean (mock_settings, can_switch_key, FALSE);
613
wait_for_menu_resync ();
615
// Check can still enable screensaver (though it can't switch)
616
ASSERT_TRUE (action_menuitem_exists ("indicator.switch-to-screensaver"));
617
ASSERT_FALSE (action_menuitem_exists ("indicator.switch-to-greeter"));
620
g_settings_reset (mock_settings, can_switch_key);
623
TEST_F (ServiceTest, LockdownLockScreen)
625
const char * const can_lock_key = "can-lock";
627
// Add users so switch options are shown
628
IndicatorSessionUser * u = g_new0 (IndicatorSessionUser, 1);
630
u->user_name = g_strdup ("thing1");
631
u->real_name = g_strdup (" ");
632
indicator_session_users_mock_add_user (INDICATOR_SESSION_USERS_MOCK(mock_users), u);
633
u = g_new0 (IndicatorSessionUser, 1);
635
u->user_name = g_strdup ("thing2");
636
u->real_name = g_strdup (" ");
637
indicator_session_users_mock_add_user (INDICATOR_SESSION_USERS_MOCK(mock_users), u);
638
wait_for_menu_resync ();
640
// Check can enable screensaver lock
641
ASSERT_TRUE (action_menuitem_exists ("indicator.switch-to-screensaver"));
642
ASSERT_FALSE (action_menuitem_exists ("indicator.switch-to-greeter"));
644
g_settings_set_boolean (mock_settings, can_lock_key, FALSE);
645
wait_for_menu_resync ();
647
// Check can't enable screensaver - just go to greeter
648
ASSERT_FALSE (action_menuitem_exists ("indicator.switch-to-screensaver"));
649
ASSERT_TRUE (action_menuitem_exists ("indicator.switch-to-greeter"));
652
g_settings_reset (mock_settings, can_lock_key);
655
TEST_F (ServiceTest, LockdownUserSwitchingAndLockScreen)
657
const char * const can_switch_key = "can-switch-sessions";
658
const char * const can_lock_key = "can-lock";
660
// Add users so switch options are shown
661
IndicatorSessionUser * u = g_new0 (IndicatorSessionUser, 1);
663
u->user_name = g_strdup ("thing1");
664
u->real_name = g_strdup (" ");
665
indicator_session_users_mock_add_user (INDICATOR_SESSION_USERS_MOCK(mock_users), u);
666
u = g_new0 (IndicatorSessionUser, 1);
668
u->user_name = g_strdup ("thing2");
669
u->real_name = g_strdup (" ");
670
indicator_session_users_mock_add_user (INDICATOR_SESSION_USERS_MOCK(mock_users), u);
671
wait_for_menu_resync ();
673
// Check can enable screensaver lock
674
ASSERT_TRUE (action_menuitem_exists ("indicator.switch-to-screensaver"));
675
ASSERT_FALSE (action_menuitem_exists ("indicator.switch-to-greeter"));
677
g_settings_set_boolean (mock_settings, can_switch_key, FALSE);
678
g_settings_set_boolean (mock_settings, can_lock_key, FALSE);
679
wait_for_menu_resync ();
681
// Check can't enable screensaver or go to greeter
682
ASSERT_FALSE (action_menuitem_exists ("indicator.switch-to-screensaver"));
683
ASSERT_FALSE (action_menuitem_exists ("indicator.switch-to-greeter"));
686
g_settings_reset (mock_settings, can_switch_key);
687
g_settings_reset (mock_settings, can_lock_key);
566
691
* Check that the default menu has items for each of these actions