aboutsummaryrefslogtreecommitdiffstats
path: root/test/uitests.sikuli/test_conversions.py
blob: c186c620fcdd389674ad6a82f02db7a66aec14cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
#!/usr/bin/python

import sys
import os
import tempfile
import shutil
import unittest
from lvcgui import MVCGui
import datafiles
import devices

data = datafiles.TestData()


class Test_Conversions(unittest.TestCase):
    """For any completed conversion
    I want to be able to locate and play the file
    And it should be formatted as I have specified
    """

    def setUp(self):
        """
        Each tests assumes that I there are files in the
        list ready to be converted to some format.

        """
        self.lvc = MVCGui()
        self.lvc.lvc_focus()
        print "starting test: ", self.shortDescription()
        datadir, testfiles = data.test_data(many=True)
        self.lvc.browse_for_files(datadir, testfiles)
        self.output_dir = tempfile.mkdtemp()
        self.lvc.choose_save_location(self.output_dir)

    def test_send_file_to_itunes(self):
        """Scenario: Send to iTunes.

        Given I have "Send to iTunes" checked
        When  I convert the an apple format
        Then the file is added to my iTunes library
        """
        item = "mp4-0.mp4"
        lvc = MVCGui()
        lvc.choose_device_conversion("iPad")
        lvc.choose_itunes()
        lvc.start_conversions()
        lvc.verify_completed(item, 30)
        assert lvc.verify_itunes(item)

    def test_verify_custom_output_directory(self):
        """Scenario: File in specific output location.

        Given I have set the output directory to "directory"
        When I convert a file
        Then the output file is in the specified directory
        """

        custom_output_dir = os.path.join(os.getenv("HOME"), "Desktop")
        item = "mp4-0.mp4"
        lvc.lvcGui()
        lvc.choose_device_conversion("KindleFire")
        lvc.choose_save_location(custom_output_dir)
        lvc.start_conversions()
        lvc.verify_completed(item, 30)
        assert lvc.verify_output_dir(self, item, custom_output_dir)

    def test_file_in_default_location(self):
        """Scenario: File in default output location.

        Given I have set the output directory to "default"
        When I convert a file
        Then the output file is in the default directory
        """

        datadir, testfile = data.test_data()
        item = testfile[0]
        lvc.lvcGui()
        lvc.choose_device_conversion("Galaxy Tab")
        lvc.choose_save_location('default')
        lvc.start_conversions()
        lvc.verify_completed(item, 30)
        assert lvc.verify_output_dir(self, item, datadir)

    def test_output_file_name_in_default_dir(self):
        """Scenario: Output file name when saved in default (same) directory.

        When I convert a file
        Then it is named with the file name (or even better item title)
        as the base and the output container is the extension
        """
        self.fail('I do not know the planned naming convention yet')

    def test_output_file_name_in_custom_dir(self):
        """Scenario: Output file name when saved in default (same) directory.

        When I convert a file
        Then it is named with the file name (or even better item title)
        as the base and the output container is the extension
        """
        self.fail('I do not know the planned naminig convention yet')

    def test_output_video_no_upsize(self):
        datadir, testfile = data.test_data()
        item = testfile[0]
        # mp4-0.mp4 is smaller than the Apple Universal Setting
        lvc.lvcGui()
        lvc.choose_device_conversion("Apple Universal")
        lvc.choose_dont_upsize('on')
        lvc.start_conversion()
        assert lvc.verify_size(os.path.join(datadir, item), width, height)

        """Scenario: Output file video size.

        When I convert a file to "format"
        And Don't Upsize is selected
        Then the output file dimensions are not changed if the
        input file is smaller than the device
        """

        # This test is best covered more completely in unittests to verify
        # that we resize according to device sizes
        item = "mp4-0.mp4"
        # mp4-0.mp4 is smaller than the Apple Universal Setting
        lvc.lvcGui()
        lvc.choose_device_conversion("Apple Universal")
        lvc.choose_dont_upsize('on')
        lvc.start_conversion()
        assert lvc.verify_size(os.path.join(self.output_dir, item),
                               width, height)

    def test_output_video_upsize(self):
        """Scenario: Output file video size.

        When I convert a file to "format"
        And Don't Upsize is NOT selected
        The the output file dimensions are changed to match the device spec.
        """
        # This test is best covered more completely in unittests to verify
        # that we resize according to device sizes

        item = "mp4-0.mp4"
        # mp4-0.mp4 is smaller than the Apple Universal Setting
        lvc.lvcGui()
        lvc.choose_device_conversion("Apple Universal")
        lvc.choose_dont_upsize('off')
        lvc.start_conversion()
        assert lvc.verify_size(os.path.join(self.output_dir, item),
                               width, height)

    def test_completed_conversions_display(self):
        """Scenario: File displays as completed.

        When I convert a file
        Then the file displays as completed
        """
        item = "mp4-0.mp4"
        lvc.lvcGui()
        lvc.choose_device_conversion("Xoom")
        lvc.choose_save_location(custom_output_dir)
        lvc.start_conversions()
        assert lvc.verify_completed(item, 30)

    def test_failed_conversion_display(self):
        """Scenario: File fails conversion.
        When I convert a "file" to "format"
            And the file conversion fails
        Then the file displays as failed.
        """
        item = 'fake_video.mp4'
        item_dir = data.testfile_attr(item, 'testdir')
        lvc.lvcGui()
        lvc.browse_for_files(item_dir, item)
        lvc.choose_device_conversion("iPhone")
        lvc.start_conversion()
        assert lvc.verify_failed(item)

    def test_ffmpeg_log_output_on_failure(self):
        """Scenario: Show ffmpeg output.

        Given I convert a file
        When I view the ffmpeg output
        Then the ffmpeg output is displayed in a text window
        """
        item = 'fake_video.mp4'
        item_dir = data.testfile_attr(item, 'testdir')
        lvc.lvcGui()
        lvc.browse_for_files(item_dir, item)
        lvc.choose_device_conversion("iPhone")
        lvc.start_conversion()
        lvc.verify_failed(item)
        assert lvc.show_ffmpeg_output(item)

    def tearDown(self):
        shutil.rmtree(self.output_dir)
        self.lvc_quit()