~ubuntu-branches/ubuntu/utopic/indicator-session/utopic

« back to all changes in this revision

Viewing changes to tests/test-service.cc

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release, Robert Ancell
  • Date: 2014-07-18 21:36:22 UTC
  • mfrom: (1.1.84)
  • Revision ID: package-import@ubuntu.com-20140718213622-0w6358ejfzxd0x8m
Tags: 12.10.5+14.10.20140718-0ubuntu1
[ Robert Ancell ]
Hide relevant items from session indicator when
org.gnome.desktop.lockdown disable-lock-screen or disable-user-
switching are set to match 12.04 LTS behaviour (LP: #1325353)

Show diffs side-by-side

added added

removed removed

Lines of Context:
503
503
  bool confirm_disabled = g_settings_get_boolean (indicator_settings, confirm_disabled_key);
504
504
  bool confirm = confirm_supported && !confirm_disabled;
505
505
 
 
506
  // Add users so switch options are shown
 
507
  IndicatorSessionUser * u = g_new0 (IndicatorSessionUser, 1);
 
508
  u->uid = 100;
 
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);
 
513
  u->uid = 101;
 
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 ();
 
518
 
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;
539
552
 
 
553
  // Add users so switch options are shown
 
554
  IndicatorSessionUser * u = g_new0 (IndicatorSessionUser, 1);
 
555
  u->uid = 100;
 
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);
 
560
  u->uid = 101;
 
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 ();
 
565
 
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);
563
589
}
564
590
 
 
591
TEST_F (ServiceTest, LockdownUserSwitching)
 
592
{
 
593
  const char * const can_switch_key = "can-switch-sessions";
 
594
 
 
595
  // Add users so switch options are shown
 
596
  IndicatorSessionUser * u = g_new0 (IndicatorSessionUser, 1);
 
597
  u->uid = 100;
 
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);
 
602
  u->uid = 101;
 
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 ();
 
607
 
 
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"));
 
611
 
 
612
  g_settings_set_boolean (mock_settings, can_switch_key, FALSE);
 
613
  wait_for_menu_resync ();
 
614
 
 
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"));
 
618
 
 
619
  // cleanup
 
620
  g_settings_reset (mock_settings, can_switch_key);
 
621
}
 
622
 
 
623
TEST_F (ServiceTest, LockdownLockScreen)
 
624
{
 
625
  const char * const can_lock_key = "can-lock";
 
626
 
 
627
  // Add users so switch options are shown
 
628
  IndicatorSessionUser * u = g_new0 (IndicatorSessionUser, 1);
 
629
  u->uid = 100;
 
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);
 
634
  u->uid = 101;
 
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 ();
 
639
 
 
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"));
 
643
 
 
644
  g_settings_set_boolean (mock_settings, can_lock_key, FALSE);
 
645
  wait_for_menu_resync ();
 
646
 
 
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"));
 
650
 
 
651
  // cleanup
 
652
  g_settings_reset (mock_settings, can_lock_key);
 
653
}
 
654
 
 
655
TEST_F (ServiceTest, LockdownUserSwitchingAndLockScreen)
 
656
{
 
657
  const char * const can_switch_key = "can-switch-sessions";
 
658
  const char * const can_lock_key = "can-lock";
 
659
 
 
660
  // Add users so switch options are shown
 
661
  IndicatorSessionUser * u = g_new0 (IndicatorSessionUser, 1);
 
662
  u->uid = 100;
 
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);
 
667
  u->uid = 101;
 
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 ();
 
672
 
 
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"));
 
676
 
 
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 ();
 
680
 
 
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"));
 
684
 
 
685
  // cleanup
 
686
  g_settings_reset (mock_settings, can_switch_key);
 
687
  g_settings_reset (mock_settings, can_lock_key);
 
688
}
 
689
 
565
690
/**
566
691
 * Check that the default menu has items for each of these actions
567
692
 */