~fginther/ubuntu-test-cases/document-rtm-mp-testing

« back to all changes in this revision

Viewing changes to tests/memevent/ubuntu_test_cases/memory_usage_measurement/apps/media_player.py

  • Committer: Leo Arias
  • Date: 2014-11-10 19:28:56 UTC
  • mfrom: (345 touch)
  • mto: This revision was merged to the branch mainline in revision 352.
  • Revision ID: leo.arias@canonical.com-20141110192856-rgpksx9n9j0b39yl
Merged with the touch branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
"""Media player application to write autopilot test cases easily."""
 
2
 
 
3
import os
 
4
 
 
5
from testtools.matchers import Equals, GreaterThan
 
6
 
 
7
from mediaplayer_app.emulators.main_window import (
 
8
    MainWindow as MediaPlayerWindow)
 
9
 
 
10
from ubuntu_test_cases.memory_usage_measurement.apps import App
 
11
from ubuntu_test_cases.memory_usage_measurement.matchers import Eventually
 
12
 
 
13
 
 
14
class MediaPlayerApp(App):
 
15
 
 
16
    """Media player application."""
 
17
 
 
18
    # Default content
 
19
    VIDEOS_DIR = 'file:///usr/share/mediaplayer-app/videos/'
 
20
 
 
21
    def assert_playback_finished(self):
 
22
        """Media player memory usage after playing a file."""
 
23
        time_line = self.window.get_slider()
 
24
 
 
25
        # Time line value isn't set to maximum value after playback is finished
 
26
        # (LP: #1190555)
 
27
        maximum_value = time_line.maximumValue - 2.0
 
28
        self.tc.assertThat(time_line.value,
 
29
                           Eventually(GreaterThan(maximum_value)))
 
30
 
 
31
    def launch(self, movie_file=None):
 
32
        """Launch application.
 
33
 
 
34
        :param movie_file:
 
35
            Relative path to movie file (uses default content directory as
 
36
            root).
 
37
        :type movie_file: str
 
38
 
 
39
        """
 
40
        binary = 'mediaplayer-app'
 
41
        args = [
 
42
            binary,
 
43
            '--fullscreen',
 
44
            ('--desktop_file_hint='
 
45
             '/usr/share/applications/mediaplayer-app.desktop'),
 
46
        ]
 
47
        if movie_file:
 
48
            args.insert(1, os.path.join(self.VIDEOS_DIR, movie_file))
 
49
 
 
50
        self.app = self.tc.launch_test_application(*args, app_type='qt')
 
51
        self.window = MediaPlayerWindow(self.app)
 
52
        self.tc.assertThat(self.window.get_qml_view().visible,
 
53
                           Eventually(Equals(True)))