on xenial help sign in
Merge Mircos changes
8e38d4dChristopher Lee
tests/autopilot/unity8/shell/emulators/create_interactive_notification.py+19
@@ -1,5 +1,24 @@
1#!/usr/bin/env python
1#!/usr/bin/env python
2
2
3+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
4+#
5+# Unity Autopilot Test Suite
6+# Copyright (C) 2012-2013 Canonical
7+#
8+# This program is free software: you can redistribute it and/or modify
9+# it under the terms of the GNU General Public License as published by
10+# the Free Software Foundation, either version 3 of the License, or
11+# (at your option) any later version.
12+#
13+# This program is distributed in the hope that it will be useful,
14+# but WITHOUT ANY WARRANTY; without even the implied warranty of
15+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+# GNU General Public License for more details.
17+#
18+# You should have received a copy of the GNU General Public License
19+# along with this program. If not, see <http://www.gnu.org/licenses/>.
20+#
21+
3import argparse
22import argparse
4from gi.repository import GLib, Notify
23from gi.repository import GLib, Notify
5import signal
24import signal
tests/autopilot/unity8/shell/tests/test_notifications.py+21−12
@@ -111,6 +111,7 @@ class InteractiveNotificationBase(NotificationsBase):
111 self._notify_proc = None
111 self._notify_proc = None
112
112
113 def test_interactive(self):
113 def test_interactive(self):
114+ """Interactive notification must react upon click on itself."""
114 self.launch_unity()
115 self.launch_unity()
115 greeter = self.main_window.get_greeter()
116 greeter = self.main_window.get_greeter()
116 greeter.unlock()
117 greeter.unlock()
@@ -255,7 +256,6 @@ class InteractiveNotificationBase(NotificationsBase):
255 stdout=subprocess.PIPE,
256 stdout=subprocess.PIPE,
256 stderr=subprocess.PIPE,
257 stderr=subprocess.PIPE,
257 close_fds=True,
258 close_fds=True,
258− preexec_fn=os.setsid
259 )
259 )
260
260
261 self.addCleanup(self._tidy_up_script_process)
261 self.addCleanup(self._tidy_up_script_process)
@@ -359,6 +359,7 @@ class EphemeralNotificationsTests(NotificationsBase):
359 self._assert_notification(notification, summary, body, True, True, 1.0)
359 self._assert_notification(notification, summary, body, True, True, 1.0)
360
360
361 def test_icon_summary(self):
361 def test_icon_summary(self):
362+ """Notification must display the expected summary and secondary icon."""
362 self.launch_unity()
363 self.launch_unity()
363 greeter = self.main_window.get_greeter()
364 greeter = self.main_window.get_greeter()
364 greeter.unlock()
365 greeter.unlock()
@@ -396,6 +397,7 @@ class EphemeralNotificationsTests(NotificationsBase):
396 )
397 )
397
398
398 def test_urgency_order(self):
399 def test_urgency_order(self):
400+ """Notifications must be displayed in order according to their urgency."""
399 self.launch_unity()
401 self.launch_unity()
400 greeter = self.main_window.get_greeter()
402 greeter = self.main_window.get_greeter()
401 greeter.unlock()
403 greeter.unlock()
@@ -486,6 +488,7 @@ class EphemeralNotificationsTests(NotificationsBase):
486 )
488 )
487
489
488 def test_summary_and_body(self):
490 def test_summary_and_body(self):
491+ """Notification must display the expected summary- and body-text."""
489 self.launch_unity()
492 self.launch_unity()
490 greeter = self.main_window.get_greeter()
493 greeter = self.main_window.get_greeter()
491 greeter.unlock()
494 greeter.unlock()
@@ -511,6 +514,7 @@ class EphemeralNotificationsTests(NotificationsBase):
511 )
514 )
512
515
513 def test_summary_only(self):
516 def test_summary_only(self):
517+ """Notification must display only the expected summary-text."""
514 self.launch_unity()
518 self.launch_unity()
515 greeter = self.main_window.get_greeter()
519 greeter = self.main_window.get_greeter()
516 greeter.unlock()
520 greeter.unlock()
@@ -528,19 +532,15 @@ class EphemeralNotificationsTests(NotificationsBase):
528
532
529 self._assert_notification(notification, summary, '', False, False, 1.0)
533 self._assert_notification(notification, summary, '', False, False, 1.0)
530
534
531− def test_update_notification(self):
535+ def test_update_notification_same_layout(self):
532− # Mirco, this should probably be split up into 2 tests, one for each
536+ """Notification must allow updating its contents while being displayed."""
533− # layout type.
534− # Also, the sleeps should be changed to something similar to what is in
535− # the test "test_urgency_order" i.e. using the eventually matcher to
536− # ensure that the required notification etc. is displayed.
537 self.launch_unity()
537 self.launch_unity()
538 greeter = self.main_window.get_greeter()
538 greeter = self.main_window.get_greeter()
539 greeter.unlock()
539 greeter.unlock()
540
540
541 notify_list = self._get_notifications_list()
541 notify_list = self._get_notifications_list()
542
542
543− summary = 'Inital notification (1. notification)'
543+ summary = 'Initial notification'
544 body = 'This is the original content of this notification-bubble.'
544 body = 'This is the original content of this notification-bubble.'
545 icon_path = self._get_icon_path('avatars/funky@12.png')
545 icon_path = self._get_icon_path('avatars/funky@12.png')
546
546
@@ -563,7 +563,7 @@ class EphemeralNotificationsTests(NotificationsBase):
563 )
563 )
564
564
565 time.sleep(3)
565 time.sleep(3)
566− summary = 'Updated notification (1. notification)'
566+ summary = 'Updated notification'
567 body = 'Here the same bubble with new title- and body-text, even ' \
567 body = 'Here the same bubble with new title- and body-text, even ' \
568 'the icon can be changed on the update.'
568 'the icon can be changed on the update.'
569 icon_path = self._get_icon_path('avatars/amanda@12.png')
569 icon_path = self._get_icon_path('avatars/amanda@12.png')
@@ -572,8 +572,15 @@ class EphemeralNotificationsTests(NotificationsBase):
572 self.assertThat(get_notification, Eventually(NotEquals(None)))
572 self.assertThat(get_notification, Eventually(NotEquals(None)))
573 self._assert_notification(get_notification(), summary, body)
573 self._assert_notification(get_notification(), summary, body)
574
574
575− time.sleep(6)
575+ def test_update_notification_layout_change(self):
576+ """Notification must allow updating its contents and layout while being displayed."""
577+ self.launch_unity()
578+ greeter = self.main_window.get_greeter()
579+ greeter.unlock()
580+
581+ notify_list = self._get_notifications_list()
582+
576− summary = 'Initial layout (2. notification)'
583+ summary = 'Initial layout'
577 body = 'This bubble uses the icon-title-body layout with a ' \
584 body = 'This bubble uses the icon-title-body layout with a ' \
578 'secondary icon.'
585 'secondary icon.'
579 icon_path = self._get_icon_path('avatars/anna_olsson@12.png')
586 icon_path = self._get_icon_path('avatars/anna_olsson@12.png')
@@ -590,6 +597,7 @@ class EphemeralNotificationsTests(NotificationsBase):
590 )
597 )
591 notification.show()
598 notification.show()
592
599
600+ get_notification = lambda: notify_list.select_single('Notification')
593 self.assertThat(get_notification, Eventually(NotEquals(None)))
601 self.assertThat(get_notification, Eventually(NotEquals(None)))
594 self._assert_notification(
602 self._assert_notification(
595 get_notification(),
603 get_notification(),
@@ -602,7 +610,7 @@ class EphemeralNotificationsTests(NotificationsBase):
602
610
603 time.sleep(3)
611 time.sleep(3)
604 notification.clear_hints()
612 notification.clear_hints()
605− summary = 'Updated layout (2. notification)'
613+ summary = 'Updated layout'
606 body = 'After the update we now have a bubble using the title-body ' \
614 body = 'After the update we now have a bubble using the title-body ' \
607 'layout.'
615 'layout.'
608 notification.update(summary, body, None)
616 notification.update(summary, body, None)
@@ -612,6 +620,7 @@ class EphemeralNotificationsTests(NotificationsBase):
612 self._assert_notification(get_notification(), summary, body, False)
620 self._assert_notification(get_notification(), summary, body, False)
613
621
614 def test_append_hint(self):
622 def test_append_hint(self):
623+ """Notification has to accumulate body-text using append-hint."""
615 self.launch_unity()
624 self.launch_unity()
616 greeter = self.main_window.get_greeter()
625 greeter = self.main_window.get_greeter()
617 greeter.unlock()
626 greeter.unlock()