~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/gallery.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
"""Gallery application to write autopilot test cases easily."""
 
2
 
 
3
import os
 
4
import shutil
 
5
import tempfile
 
6
 
 
7
from ubuntu_test_cases.memory_usage_measurement.apps import App
 
8
 
 
9
 
 
10
class GalleryApp(App):
 
11
 
 
12
    """Gallery application."""
 
13
 
 
14
    SAMPLE_DIR = '/usr/lib/python2.7/dist-packages/gallery_app/data/default'
 
15
 
 
16
    def __init__(self, tc):
 
17
        super(GalleryApp, self).__init__(tc)
 
18
        self.temp_sample_dir = None
 
19
        self._copy_sample_dir()
 
20
 
 
21
    def _copy_sample_dir(self):
 
22
        """Copy sample directory to a temporary location.
 
23
 
 
24
        This is useful to provide some default content.
 
25
 
 
26
        """
 
27
        self.temp_sample_dir = tempfile.mkdtemp(prefix='gallery-app-test-')
 
28
        self.tc.addCleanup(shutil.rmtree, self.temp_sample_dir)
 
29
        self.temp_sample_dir = os.path.join(self.temp_sample_dir, 'data')
 
30
        shutil.copytree(self.SAMPLE_DIR, self.temp_sample_dir)
 
31
 
 
32
    def launch(self):
 
33
        """Launch the application."""
 
34
        args = [
 
35
            'gallery-app',
 
36
            ('--desktop_file_hint='
 
37
             '/usr/share/applications/gallery-app.desktop'),
 
38
            self.temp_sample_dir,
 
39
        ]
 
40
        self.app = self.tc.launch_test_application(*args,
 
41
                                                   app_type='qt')