~aacid/unity8/useOwnDbusConnections

« back to all changes in this revision

Viewing changes to tests/autopilot/unity8/indicators/tests/test_action_latency.py

  • Committer: CI Train Bot
  • Author(s): Michał Sawicz
  • Date: 2015-04-22 14:46:07 UTC
  • mfrom: (1730.4.3 fix-flake8)
  • Revision ID: ci-train-bot@canonical.com-20150422144607-d9uileho9ijf68k1
Fix flake8 warnings Fixes: #1444170
Approved by: Leo Arias

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
from unity8 import (
22
22
    fixture_setup,
23
23
    indicators,
24
 
    process_helpers
25
24
)
26
 
from unity8.shell import tests
27
25
from unity8.indicators import tests
28
26
 
29
27
from autopilot.matchers import Eventually
30
28
from testtools.matchers import Equals, NotEquals
31
 
import time
32
29
 
33
30
 
34
31
class TestIndicatorBaseTestCase(tests.IndicatorTestCase):
35
32
 
36
 
    scenarios = [ tests.IndicatorTestCase.device_emulation_scenarios[0] ]
 
33
    scenarios = [tests.IndicatorTestCase.device_emulation_scenarios[0]]
37
34
 
38
35
    def setUp(self):
39
36
        super(TestIndicatorBaseTestCase, self).setUp()
49
46
        self.indicator_page = self.indicator.open()
50
47
 
51
48
    def launch_indicator_service(self):
52
 
        launch_service_fixture = fixture_setup.LaunchMockIndicatorService(self.action_delay)
 
49
        launch_service_fixture = \
 
50
            fixture_setup.LaunchMockIndicatorService(self.action_delay)
53
51
        self.useFixture(launch_service_fixture)
54
52
 
55
53
 
95
93
            Eventually(Equals(slider.value), timeout=20)
96
94
        )
97
95
 
 
96
 
98
97
class TestBuffering(TestIndicatorBaseTestCase):
99
98
 
100
99
    """Test that switching multiple times will buffer activations
107
106
 
108
107
        switch = self.indicator_page.get_switcher()
109
108
        switch.change_state()
110
 
        intermediate_value = switch.checked;
 
109
        intermediate_value = switch.checked
111
110
 
112
111
        # will buffer change until it receives the change from server
113
112
        switch.change_state()
114
 
        final_value = switch.checked;
 
113
        final_value = switch.checked
115
114
 
116
115
        # backend will respond to first switch.
117
116
        switch_menu = self.indicator_page.get_switch_menu()
121
120
        )
122
121
        # The buffered activation should have gone to server now.
123
122
 
124
 
        # front-end should not change as a result of server update while it is buffered
 
123
        # front-end should not change as a result of server update
 
124
        # while it is buffered
125
125
        self.assertThat(
126
126
            switch.checked,
127
127
            Equals(final_value)
142
142
    def test_slider_buffers_activations(self):
143
143
 
144
144
        slider = self.indicator_page.get_slider()
145
 
        original_value = slider.value;
 
145
        original_value = slider.value
146
146
        slider.slide_left()
147
147
 
148
148
        # will buffer change until it receives the change from server
149
149
        slider.slide_right()
150
 
        final_value = slider.value;
 
150
        final_value = slider.value
151
151
 
152
 
        # backend will respond to first slider. Since it's a live slider it'll probably
153
 
        # be a random value along the slide.
 
152
        # backend will respond to first slider. Since it's a live slider
 
153
        # it'll probably be a random value along the slide.
154
154
        slider_menu = self.indicator_page.get_slider_menu()
155
155
        self.assertThat(
156
156
            slider_menu.serverValue,
163
163
            NotEquals(final_value)
164
164
        )
165
165
 
166
 
        # front-end should not change as a result of server update while it is buffered
 
166
        # front-end should not change as a result of server update
 
167
        # while it is buffered
167
168
        self.assertThat(
168
169
            slider.value,
169
170
            Equals(final_value)
189
190
 
190
191
    See https://bugs.launchpad.net/ubuntu/+source/unity8/+bug/1390136 .
191
192
    """
192
 
    action_delay = -1 # never action.
 
193
    action_delay = -1  # never action.
193
194
 
194
195
    def test_switch_reverts_on_late_response(self):
195
196
 
196
197
        switch = self.indicator_page.get_switcher()
197
198
        switch_menu = self.indicator_page.get_switch_menu()
198
199
 
199
 
        original_value = switch.checked;
 
200
        original_value = switch.checked
200
201
        switch.change_state()
201
202
 
202
 
        # switch should revert to original value after 5 seconds (30 seconds in real usage)
 
203
        # switch should revert to original value after 5 seconds
 
204
        # (30 seconds in real usage)
203
205
        self.assertThat(
204
206
            switch.checked,
205
207
            Eventually(Equals(original_value), timeout=20)
216
218
        slider = self.indicator_page.get_slider()
217
219
        slider_menu = self.indicator_page.get_slider_menu()
218
220
 
219
 
        original_value = slider.value;
 
221
        original_value = slider.value
220
222
        slider.slide_left()
221
223
 
222
 
        # slider should revert to original value after 5 seconds (30 seconds in real usage)
 
224
        # slider should revert to original value after 5 seconds
 
225
        # (30 seconds in real usage)
223
226
        self.assertThat(
224
227
            slider.value,
225
228
            Eventually(Equals(original_value), timeout=20)