~opencompute-developers/opencompute/checkbox

« back to all changes in this revision

Viewing changes to checkbox/scripts/tests/test_audio_settings.py

Updated OCP Checkbox to the final release version of Checkbox which is now in Legacy mode.

Also fixed some unittest failures found during the update.

Incremented release version to match the last release version of Checkbox.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
# This file is part of Checkbox.
 
3
#
 
4
# Copyright 2013 Canonical Ltd.
 
5
#
 
6
# Checkbox is free software: you can redistribute it and/or modify
 
7
# it under the terms of the GNU General Public License version 3,
 
8
# as published by the Free Software Foundation.
 
9
 
 
10
#
 
11
# Checkbox is distributed in the hope that it will be useful,
 
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
# GNU General Public License for more details.
 
15
#
 
16
# You should have received a copy of the GNU General Public License
 
17
# along with Checkbox.  If not, see <http://www.gnu.org/licenses/>.
 
18
#
 
19
import os
 
20
import unittest
 
21
 
 
22
from checkbox.scripts.audio_settings import _guess_hdmi_profile
 
23
from checkbox.parsers.tests.test_pactl import PactlDataMixIn
 
24
 
 
25
 
 
26
class SetProfileTest(unittest.TestCase, PactlDataMixIn):
 
27
 
 
28
    def test_desktop_precise_xps1340(self):
 
29
        """
 
30
        Precise system with a Nvidia chipset.
 
31
        HDMI is present in the card ports list but not shown in the sinks list.
 
32
        The port availability cannot be determined, in that case the expected
 
33
        value is the first stereo profile listed in the identified port.
 
34
        Meaningful lines:
 
35
 
 
36
        Card #0
 
37
        [...]
 
38
            Ports:
 
39
        [...]
 
40
                hdmi-output-0: HDMI / DisplayPort (priority 5900)
 
41
                    Part of profile(s): output:hdmi-stereo, output:hdmi-stereo+input:analog-stereo, output:hdmi-surround, output:hdmi-surround+input:analog-stereo
 
42
        """
 
43
        self.assertEqual(
 
44
            _guess_hdmi_profile(self.get_text("desktop-precise-xps1340")),
 
45
            ('0', 'output:hdmi-stereo'))
 
46
 
 
47
    def test_desktop_precise_radeon_not_available(self):
 
48
        """
 
49
        Home-made system running Precise with a Radeon card.
 
50
        HDMI is present in the card ports list and shown in the sinks list.
 
51
        But the port is "not available", both card and profile should be set
 
52
        to None.
 
53
        Meaningful lines:
 
54
 
 
55
        Sink #0
 
56
        [...]
 
57
            Ports:
 
58
                hdmi-output-0: HDMI / DisplayPort (priority: 5900, not available)
 
59
        [...]
 
60
        Card #0
 
61
        [...]
 
62
            Ports:
 
63
                hdmi-output-0: HDMI / DisplayPort (priority 5900)
 
64
                    Part of profile(s): output:hdmi-stereo
 
65
        """
 
66
        self.assertEqual(
 
67
            _guess_hdmi_profile(self.get_text("desktop-precise-radeon")),
 
68
            (None, None))
 
69
 
 
70
    def test_desktop_precise_radeon_available(self):
 
71
        """
 
72
        Home-made system running Precise with a Radeon card.
 
73
        HDMI is present in the card ports list, shown in the sinks list and
 
74
        marked as "available", in that case the expected value is the first
 
75
        stereo profile listed in the identified port.
 
76
        Meaningful lines:
 
77
 
 
78
        Sink #0
 
79
        [...]
 
80
            Ports:
 
81
                hdmi-output-0: HDMI / DisplayPort (priority: 5900, available)
 
82
        [...]
 
83
        Card #0
 
84
        [...]
 
85
            Ports:
 
86
                hdmi-output-0: HDMI / DisplayPort (priority 5900)
 
87
                    Part of profile(s): output:hdmi-stereo
 
88
        """
 
89
        self.assertEqual(
 
90
            _guess_hdmi_profile(self.get_text(
 
91
                "desktop-precise-radeon-hdmi-available")),
 
92
            ('0', 'output:hdmi-stereo'))
 
93
 
 
94
    def test_desktop_raring_t430s_not_available(self):
 
95
        """
 
96
        Raring system with a Mini-DisplayPort.
 
97
        DisplayPort is present in the card ports list but marked as
 
98
        "not available". Thus both card and profile should be set
 
99
        to None.
 
100
        Meaningful lines:
 
101
 
 
102
        Card #2
 
103
        [...]
 
104
            Ports:
 
105
        [...]
 
106
                hdmi-output-0: HDMI / DisplayPort (priority: 5900, latency offset: 0 usec, not available)
 
107
                    Properties:
 
108
                        device.icon_name = "video-display"
 
109
                    Part of profile(s): output:hdmi-stereo, output:hdmi-stereo+input:analog-stereo
 
110
                hdmi-output-1: HDMI / DisplayPort 2 (priority: 5800, latency offset: 0 usec, not available)
 
111
                    Properties:
 
112
                        device.icon_name = "video-display"
 
113
                    Part of profile(s): output:hdmi-stereo-extra1, output:hdmi-stereo-extra1+input:analog-stereo, output:hdmi-surround-extra1, output:hdmi-surround-extra1+input:analog-stereo
 
114
                hdmi-output-2: HDMI / DisplayPort 3 (priority: 5700, latency offset: 0 usec, not available)
 
115
                    Properties:
 
116
                        device.icon_name = "video-display"
 
117
                    Part of profile(s): output:hdmi-stereo-extra2, output:hdmi-stereo-extra2+input:analog-stereo, output:hdmi-surround-extra2, output:hdmi-surround-extra2+input:analog-stereo
 
118
        """
 
119
        self.assertEqual(
 
120
            _guess_hdmi_profile(self.get_text("desktop-raring-t430s")),
 
121
            (None, None))
 
122
 
 
123
    def test_desktop_raring_t430s_available(self):
 
124
        """
 
125
        Raring system with a Mini-DisplayPort.
 
126
        DisplayPort is present in the card ports list and marked as
 
127
        "available", in that case the expected value is the first stereo
 
128
        profile listed in the identified port.
 
129
        Meaningful lines:
 
130
 
 
131
        Card #2
 
132
        [...]
 
133
            Ports:
 
134
        [...]
 
135
                hdmi-output-0: HDMI / DisplayPort (priority: 5900, latency offset: 0 usec, available)
 
136
                    Properties:
 
137
                        device.icon_name = "video-display"
 
138
                    Part of profile(s): output:hdmi-stereo, output:hdmi-stereo+input:analog-stereo
 
139
                hdmi-output-1: HDMI / DisplayPort 2 (priority: 5800, latency offset: 0 usec, not available)
 
140
                    Properties:
 
141
                        device.icon_name = "video-display"
 
142
                    Part of profile(s): output:hdmi-stereo-extra1, output:hdmi-stereo-extra1+input:analog-stereo, output:hdmi-surround-extra1, output:hdmi-surround-extra1+input:analog-stereo
 
143
                hdmi-output-2: HDMI / DisplayPort 3 (priority: 5700, latency offset: 0 usec, not available)
 
144
                    Properties:
 
145
                        device.icon_name = "video-display"
 
146
                    Part of profile(s): output:hdmi-stereo-extra2, output:hdmi-stereo-extra2+input:analog-stereo, output:hdmi-surround-extra2, output:hdmi-surround-extra2+input:analog-stereo
 
147
        """
 
148
        self.assertEqual(
 
149
            _guess_hdmi_profile(self.get_text(
 
150
                "desktop-raring-t430s-dp-available")),
 
151
            ('2', 'output:hdmi-stereo'))