Skip to content

Commit

Permalink
added test for selecting an output
Browse files Browse the repository at this point in the history
  • Loading branch information
sezanzeb committed Oct 28, 2020
1 parent bdceea2 commit b7415d4
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions tests/testcases/integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
from importlib.util import spec_from_loader, module_from_spec
from importlib.machinery import SourceFileLoader

from alsacontrol.config import get_config
from alsacontrol.cards import input_exists, get_current_card, get_card

import alsaaudio
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk

from alsacontrol.config import get_config


def gtk_iteration():
"""Iterate while events are pending."""
Expand Down Expand Up @@ -98,6 +98,30 @@ def test_toggle_input(self):
self.assertEqual(get_config().get('pcm_input'), 'null')
self.assertIn('No card selected', input_card_name.get_label())

def test_select_output(self):
cards = alsaaudio.cards()
card_index = 0
config = get_config()

class FakeDropdown:
"""Acts like a Gtk.ComboBoxText object."""
def get_active_text(self):
return cards[card_index]

self.window.on_output_card_selected(FakeDropdown())
self.assertEqual(
config.get('pcm_output'),
f'hw:CARD={cards[card_index]}'
)

card_index = 1
config.set('output_plugin', 'ab')
self.window.on_output_card_selected(FakeDropdown())
self.assertEqual(
config.get('pcm_output'),
f'ab:CARD={cards[card_index]}'
)

def test_go_to_input_page(self):
# should start at the output page, no monitoring should be active now
self.assertNotIn(True, [
Expand Down

0 comments on commit b7415d4

Please sign in to comment.