[gnome-settings-daemon] power: Simplify test code by using the check_plugin_log helper
- From: Benjamin Berg <bberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon] power: Simplify test code by using the check_plugin_log helper
- Date: Mon, 15 Jan 2018 16:21:24 +0000 (UTC)
commit 9ad0468bba7743d9b5cd6c41b0bca7d2101af06a
Author: Benjamin Berg <bberg redhat com>
Date: Thu Jan 11 16:20:35 2018 +0100
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
plugins/power/test.py | 50 +++++++-----------------------------------------
1 files changed, 8 insertions(+), 42 deletions(-)
---
diff --git a/plugins/power/test.py b/plugins/power/test.py
index c60190d..c81e57d 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'''
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]