summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Berg <bberg@redhat.com>2018-01-11 16:20:35 +0100
committerBenjamin Berg <bberg@redhat.com>2018-01-15 17:14:49 +0100
commit9ad0468bba7743d9b5cd6c41b0bca7d2101af06a (patch)
treedef6b1ebbacb82a5abd726c7cc47752d1be4ca3f
parent975d901a5f97e6c73e41938d9bc5fb78e873236e (diff)
downloadgnome-settings-daemon-9ad0468bba7743d9b5cd6c41b0bca7d2101af06a.tar.gz
power: Simplify test code by using the check_plugin_log helper
Use the helper introduced earlier instead of re-implementing the loop for every function to test the gsd-power log. The helper was introduced in the commit 450a93619 ("power: Add helper to read plugin log during test"). https://bugzilla.gnome.org/show_bug.cgi?id=792210
-rwxr-xr-xplugins/power/test.py50
1 files changed, 8 insertions, 42 deletions
diff --git a/plugins/power/test.py b/plugins/power/test.py
index c60190da..c81e57d0 100755
--- a/plugins/power/test.py
+++ b/plugins/power/test.py
@@ -353,66 +353,32 @@ class PowerPluginTest(gsdtestcase.GSDTestCase):
def check_dim(self, timeout):
'''Check that mode is set to dim in the given time'''
- # wait for specified time to ensure it didn't do anything
- while timeout > 0:
- time.sleep(1)
- timeout -= 1
- # check that it requested dim
- log = self.plugin_log.read()
-
- if 'Doing a state transition: dim' in log:
- break
- else:
- self.fail('timed out waiting for dim')
+ self.check_plugin_log('Doing a state transition: dim', timeout,
+ 'timed out waiting for dim')
def check_undim(self, timeout):
'''Check that mode is set to normal in the given time'''
- # wait for specified time to ensure it didn't do anything
- while timeout > 0:
- time.sleep(1)
- timeout -= 1
- # check that it requested normal
- log = self.plugin_log.read()
-
- if 'Doing a state transition: normal' in log:
- break
- else:
- self.fail('timed out waiting for normal mode')
+ self.check_plugin_log('Doing a state transition: normal', timeout,
+ 'timed out waiting for normal mode')
def check_blank(self, timeout):
'''Check that blank is requested.
Fail after the given timeout.
'''
- # check that it request blank
- while timeout > 0:
- time.sleep(1)
- timeout -= 1
- # check that it requested blank
- log = self.plugin_log.read()
- if 'TESTSUITE: Blanked screen' in log:
- break
- else:
- self.fail('timed out waiting for blank')
+ self.check_plugin_log('TESTSUITE: Blanked screen', timeout,
+ 'timed out waiting for blank')
def check_unblank(self, timeout):
'''Check that unblank is requested.
Fail after the given timeout.
'''
- # check that it request blank
- while timeout > 0:
- time.sleep(1)
- timeout -= 1
- # check that it requested unblank
- log = self.plugin_log.read()
- if 'TESTSUITE: Unblanked screen' in log:
- break
- else:
- self.fail('timed out waiting for unblank')
+ self.check_plugin_log('TESTSUITE: Unblanked screen', timeout,
+ 'timed out waiting for unblank')
def check_no_blank(self, seconds):
'''Check that no blank is requested in the given time'''