1
# Copyright (C) 2014 Canonical Ltd
3
# This file is part of Ubuntu Clock App
5
# Ubuntu Clock App is free software: you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License version 3 as
7
# published by the Free Software Foundation.
9
# Ubuntu Clock App is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public License
15
# along with this program. If not, see <http://www.gnu.org/licenses/>.
17
"""Tests for the Clock App - Alarm"""
19
from __future__ import absolute_import
24
from autopilot.matchers import Eventually
25
from testtools.matchers import Equals
26
from ubuntu_clock_app.tests import ClockAppTestCase
27
from autopilot.platform import model
30
class TestAlarm(ClockAppTestCase):
32
"""Tests the alarm page features"""
35
""" This is needed to wait for the application to start.
37
In the testfarm, the application may take some time to show up.
40
super(TestAlarm, self).setUp()
42
self.main_view.visible, Eventually(Equals(True)))
44
self.page = self.main_view.open_alarm()
47
# Due to bug https://bugs.launchpad.net/ubuntu-calendar-app/+bug/1328600
48
# this test cannot be run on device, so until the bug is not fixed we are
49
# skipping the test if model not Desktop.
50
@unittest.skipIf(model() != 'Desktop',
51
"datepicker does not work correctly on device")
52
def test_add_recurring_type_alarm_must_add_to_alarm_list(self):
53
"""Test to check if a single type alarm is saved properly
55
This test saves a single type alarm and verifies if it is added to the
56
alarm list in the alarm page.
59
tomorrow = datetime.datetime.now() + datetime.timedelta(days=1)
60
time_to_set = datetime.time(6, 10, 0)
61
test_alarm_name = 'Single Test'
62
# TODO this will be affected by the locale. --elopio - 2014-02-27
63
expected_alarm_name = test_alarm_name
64
expected_recurrence = tomorrow.strftime('%A')
65
expected_enabled_value = True
66
expected_time = "06:10:00"
67
test_sound_name = "Bliss"
68
expected_alarm_info = (
69
expected_alarm_name, expected_recurrence, expected_enabled_value,
72
tomorrow_day = tomorrow.strftime('%A')
73
self.page.add_single_alarm(
74
test_alarm_name, tomorrow_day, time_to_set, test_sound_name)
76
alarmlistPage = self.main_view.get_AlarmList()
77
saved_alarms = alarmlistPage.get_saved_alarms()
78
self.assertIn(expected_alarm_info, saved_alarms)
80
# TODO: Remove this statement once proper support for cleaning the
81
# test alarm environment is added. Until then remove the alarm
82
# created during the test at the end of the test.
83
# -- nik90 - 2014-03-03
84
alarmlistPage.delete_alarm(index=0)