~canonical-platform-qa/ubuntu-ui-toolkit/combobutton-tests

« back to all changes in this revision

Viewing changes to tests/autopilot/ubuntuuitoolkit/tests/gallery/test_combobuttons.py

  • Committer: Sergio Cazzolato
  • Date: 2015-05-14 17:20:44 UTC
  • Revision ID: sergio.cazzolato@canonical.com-20150514172044-z3ho1jehs781iogq
Test cases added to cover the ComboButton object

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2
2
#
3
 
# Copyright (C) 2012, 2013, 2014 Canonical Ltd.
 
3
# Copyright (C) 2012, 2013, 2014, 2015 Canonical Ltd.
4
4
#
5
5
# This program is free software; you can redistribute it and/or modify
6
6
# it under the terms of the GNU Lesser General Public License as published by
17
17
"""Tests for the Ubuntu UI Toolkit Gallery - ComboButton component"""
18
18
 
19
19
import testscenarios
20
 
from testtools.matchers import Equals
21
 
 
 
20
 
 
21
from fixtures import EnvironmentVariable
 
22
 
 
23
from ubuntuuitoolkit.tests import gallery
22
24
from ubuntuuitoolkit import ubuntu_scenarios
23
 
from ubuntuuitoolkit.tests import gallery
24
 
 
25
 
import os
26
25
 
27
26
 
28
27
class ComboButtonsTestCase(gallery.GalleryTestCase):
29
28
 
30
 
    combo_buttons_scenarios = [
31
 
        ('standard combo button', dict(
32
 
            combo_button_name="combobutton_collapsed", icon=None, text="Press me", expanded=False)),
33
 
        ('standard combo button', dict(
34
 
            combo_button_name="combobutton_collapsed_icon", icon="call.png", text=None, expanded=False)),
35
 
        ('standard combo button', dict(
36
 
            combo_button_name="combobutton_collapsed_icon_and_text", icon="call.png", text="Answer", expanded=False)),
37
 
        ('standard combo button', dict(
38
 
            combo_button_name="combobutton_expanded", icon=None, text="Press me", expanded=True))
39
 
    ]
40
 
 
41
 
    scenarios = testscenarios.multiply_scenarios(
42
 
        ubuntu_scenarios.get_device_simulation_scenarios(),
43
 
        combo_buttons_scenarios)
 
29
    scenarios = testscenarios.multiply_scenarios(ubuntu_scenarios.get_device_simulation_scenarios())
44
30
 
45
31
    def setUp(self):
46
 
        # Reset the locale to English
47
 
        os.environ['LANGUAGE'] = 'en'
 
32
        self.useFixture(EnvironmentVariable('LANGUAGE', 'en'))
48
33
        super().setUp()
49
34
 
50
 
    def test_combo_buttons(self):
51
 
        self.open_page('buttonsElement')
52
 
 
53
 
        combo_button = self.app.select_single(objectName=self.combo_button_name)
54
 
        self.assertIsNot(combo_button, None)
55
 
 
56
 
        if self.icon is not None:
57
 
            self.assertTrue(combo_button.iconSource.endswith(self.icon))
58
 
 
59
 
        if self.text is not None:
60
 
            self.assertEquals(self.text, combo_button.text)
61
 
 
62
 
        if self.expanded:
63
 
            self.assertTrue(combo_button.expanded)
64
 
            self.assertEquals(combo_button.expandedHeight, combo_button.height)
65
 
        else:
66
 
            self.assertFalse(combo_button.expanded)
 
35
    def test_collapsed_combo_button_has_text(self):
 
36
        self.open_page('buttonsElement')
 
37
 
 
38
        combo_button = self.app.select_single('ComboButton', objectName='collapsed')
 
39
 
 
40
        self.assertIsNot(combo_button, None)
 
41
        self.assertEquals('Press me', combo_button.text)
 
42
        self.assertFalse(combo_button.expanded)
 
43
 
 
44
    def test_collapsed_combo_button_has_icon(self):
 
45
        self.open_page('buttonsElement')
 
46
 
 
47
        combo_button = self.app.select_single('ComboButton', objectName='collapsed_icon')
 
48
 
 
49
        self.assertIsNot(combo_button, None)
 
50
        self.assertTrue(combo_button.iconSource.endswith('call.png'))
 
51
        self.assertFalse(combo_button.expanded)
 
52
 
 
53
    def test_collapsed_combo_button_has_icon_and_text(self):
 
54
        self.open_page('buttonsElement')
 
55
 
 
56
        combo_button = self.app.select_single('ComboButton', objectName='collapsed_icon_and_text')
 
57
 
 
58
        self.assertIsNot(combo_button, None)
 
59
        self.assertTrue(combo_button.iconSource.endswith('call.png'))
 
60
        self.assertEquals('Answer', combo_button.text)
 
61
        self.assertFalse(combo_button.expanded)
 
62
 
 
63
    def test_expanded_combo_button_has_text_and_correct_size(self):
 
64
        self.open_page('buttonsElement')
 
65
 
 
66
        combo_button = self.app.select_single('ComboButton', objectName='expanded')
 
67
        self.assertIsNot(combo_button, None)
 
68
        self.assertEquals('Press me', combo_button.text)
 
69
        self.assertTrue(combo_button.expanded)
 
70
        self.assertEquals(combo_button.expandedHeight, combo_button.height)
 
71
 
 
72
        combo_list = self.app.select_single(objectName='expanded_list')
 
73
        self.assertIsNot(combo_list, None)
 
74
        self.assertEquals(10, combo_list.count)