24
from retrying import retry
23
from datetime import datetime
24
from threading import Event
26
26
from autopilot.exceptions import StateNotFoundError
27
27
from autopilot.matchers import Eventually
28
from datetime import datetime
28
from retrying import retry
29
29
from testtools import skipUnless
30
30
from testtools.matchers import Equals
31
from threading import Event
33
32
from ubuntu_system_tests.helpers import addressbook
33
from ubuntu_system_tests.helpers import dialer_app as dialer
34
from ubuntu_system_tests.helpers import display
35
from ubuntu_system_tests.helpers import media
36
from ubuntu_system_tests.helpers import mediaplayer
37
from ubuntu_system_tests.helpers import network
38
from ubuntu_system_tests.helpers import ofono
39
from ubuntu_system_tests.helpers import scopes
40
from ubuntu_system_tests.helpers import sensors
41
from ubuntu_system_tests.helpers import webbrowser
34
42
from ubuntu_system_tests.helpers.addressbook import(
36
44
fixture_setup as address_book_fixture
38
from ubuntu_system_tests.helpers import dialer_app as dialer
46
from ubuntu_system_tests.helpers.data import load_test_metadata
39
47
from ubuntu_system_tests.helpers.dialer_app import fixture_setup as dialer_fixture_setup # NOQA
40
from ubuntu_system_tests.helpers import display
41
48
from ubuntu_system_tests.helpers import indicators
42
from ubuntu_system_tests.helpers import media
43
from ubuntu_system_tests.helpers import mediaplayer
49
from ubuntu_system_tests.helpers.indicators import(
50
network as network_indicator
44
52
from ubuntu_system_tests.helpers.messaging.fixture_setup import (
45
53
MessagingTestEnvironment)
46
from ubuntu_system_tests.helpers import network
47
from ubuntu_system_tests.helpers import ofono
54
from ubuntu_system_tests.helpers.music import launch_music_app
55
from ubuntu_system_tests.helpers.music.fixture_setup import (
56
MusicAppWelcomeWizard)
48
57
from ubuntu_system_tests.helpers.ofono import fixture_setup as ofono_fixture_setup # NOQA
49
58
from ubuntu_system_tests.helpers.power.fixture_setup import (
50
59
EnablePowerdFakeSensors)
51
from ubuntu_system_tests.helpers.indicators import(
52
network as network_indicator
54
from ubuntu_system_tests.helpers import scopes
55
from ubuntu_system_tests.helpers import sensors
56
60
from ubuntu_system_tests.helpers.system_settings.fixture_setup import SilentMode # NOQA
57
61
from ubuntu_system_tests.helpers.timedate import get_current_utc_time
58
62
from ubuntu_system_tests.helpers.vibration import start_vibration_observer
59
from ubuntu_system_tests.helpers import webbrowser
61
63
from ubuntu_system_tests.tests.base import wait_until
62
64
from ubuntu_system_tests.tests.base_telephony import BaseTelephonyTestCase
63
from ubuntu_system_tests.tests.scopes.data import (
64
LOCAL_VIDEO_FILE_3, SRC_VIDEO_FILE_3)
65
from ubuntu_system_tests.tests.data import (
66
LOCAL_AUDIO_FILE_5, LOCAL_VIDEO_FILE_3, SRC_AUDIO_FILE_5, SRC_VIDEO_FILE_3)
67
68
CONTACT_NAME_1 = 'Fulano de Tal'
376
379
self._assert_proximity_near()
377
380
self._assert_proximity_far()
382
def _assert_proximity_sensor_inactive(self):
383
"""Set proximity sensor to near and check that the display does not
386
self.assertTrue(display.is_display_on())
387
sensors.set_proximity_near()
388
self.addCleanup(sensors.set_proximity_far)
389
self.assertFalse(wait_until(
390
display.is_display_off, timeout=5),
391
'Display turned off with near proximity when not expected.')
379
393
def test_receive_incoming_call_from_contact(self):
381
395
Test to recive an incoming call from a contact.
583
597
self._create_observers()
584
indicator = indicators.Indicator(
585
self.shell, indicators.SOUND_INDICATOR,
586
indicators.SOUND_INDICATOR_PAGE)
587
indicator_page = indicator.open()
588
self.addCleanup(indicator.ensure_closed)
598
indicator, indicator_page = indicators.open_network_indicator(
590
601
self.assertFalse(indicator_page.get_silent_mode_switcher().checked)
591
602
indicator_page.enable_silent_mode()
868
879
self.assertTrue(player.playing)
870
sensors.set_proximity_near()
871
self.addCleanup(sensors.set_proximity_far)
872
self.assertFalse(wait_until(
873
display.is_display_off, timeout=5),
874
'Display turned off with near proximity during video playback.')
881
self._assert_proximity_sensor_inactive()
883
def test_receive_call_during_music_playback(self):
885
Receive an incoming call during music playback.
886
1. Copy music to the device.
887
2. Launch the Music app and switch to songs view.
888
3. Select the song to start playing.
889
4. Receive incoming call.
890
5. Ensure the music is paused as soon as the notification appears.
891
6. Accept the call and ensure proximity sensor is functional.
892
7. Terminate the call from remote end.
893
8. Ensure music playback resumes when the call is terminated.
895
self.useFixture(media.BackupRestoreLocalMediaFixture())
896
self.useFixture(MusicAppWelcomeWizard(show_wizard=False))
897
shutil.copy2(SRC_AUDIO_FILE_5, LOCAL_AUDIO_FILE_5)
899
music_app = launch_music_app()
900
songs = music_app.get_songs_page()
901
now_playing = songs.play_track(0)
903
now_playing.get_artist(), test_data.audio.noise60.artist)
905
now_playing.get_title(), test_data.audio.noise60.title)
906
player = now_playing.player
907
self.assertTrue(player.isPlaying)
909
call = self.telephony.make_phonecall(
910
to=self.get_device_phone_number(),
911
from_=self.contact_1.number,
913
call_url=CALL_URL_30_SEC)
914
call_notifier = self._get_incoming_call_notification()
915
self.assertFalse(player.isPlaying)
916
stop_time = player.position
918
call_notifier.start_call()
919
call_page = dialer.get_dialer_app_proxy().live_call_page
920
self._validate_call_started(call_page, self.contact_1.name)
921
self.assertTrue(display.is_display_on())
922
self._assert_proximity_sensor()
924
self.telephony.hangup_call(call['sid'])
925
self._validate_call_ended(call_page)
926
self.assertTrue(player.isPlaying)
927
self.assertGreaterEqual(player.position, stop_time)
929
self._assert_proximity_sensor_inactive()