logoutgreetertest.py | logoutgreetertest.py | |||
---|---|---|---|---|
#!/usr/bin/env python3 | #!/usr/bin/env python3 | |||
# SPDX-License-Identifier: MIT | # SPDX-License-Identifier: MIT | |||
# SPDX-FileCopyrightText: 2021-2022 Harald Sitter <sitter@kde.org> | # SPDX-FileCopyrightText: 2021-2022 Harald Sitter <sitter@kde.org> | |||
# SPDX-FileCopyrightText: 2023 Marco Martin <mart@kde.org> | # SPDX-FileCopyrightText: 2023 Marco Martin <mart@kde.org> | |||
import subprocess | ||||
import sys | ||||
import unittest | import unittest | |||
from appium import webdriver | from appium import webdriver | |||
from appium.options.common.base import AppiumOptions | ||||
from appium.webdriver.common.appiumby import AppiumBy | from appium.webdriver.common.appiumby import AppiumBy | |||
from selenium.webdriver.support.ui import WebDriverWait | ||||
from datetime import date | ||||
from dateutil.relativedelta import relativedelta | ||||
import subprocess | ||||
import time | ||||
import sys | ||||
class LogoutGreeterTests(unittest.TestCase): | class LogoutGreeterTests(unittest.TestCase): | |||
def setUp(self): | def setUp(self): | |||
self.proc = subprocess.Popen(["{}/ksmserver-logout-greeter".format( sys.argv[1]), "--windowed"], stdout=subprocess.PIPE, stderr=subprocess.PIPE ) | self.proc = subprocess.Popen(["{}/ksmserver-logout-greeter".format( sys.argv[1]), "--windowed"], stdout=subprocess.PIPE, stderr=subprocess.PIPE ) | |||
desired_caps = {} | options = AppiumOptions() | |||
desired_caps["app"] = str(self.proc.pid) | options.set_capability("app", str(self.proc.pid)) | |||
desired_caps["timeouts"] = {'implicit': 10000} | options.set_capability("timeouts", {'implicit': 10000}) | |||
self.driver = webdriver.Remote( | self.driver = webdriver.Remote(command_executor='http://127.0.0.1:4 | |||
command_executor='http://127.0.0.1:4723', | 723', options=options) | |||
desired_capabilities=desired_caps) | ||||
self.driver.implicitly_wait = 10 | ||||
def tearDown(self): | def tearDown(self): | |||
self.driver.quit() | self.driver.quit() | |||
self.assertEqual(self.proc.returncode != None, True) | self.assertEqual(self.proc.returncode != None, True) | |||
try: | try: | |||
self.proc.terminate(timeout=5) | self.proc.terminate(timeout=5) | |||
except TimeoutExpired: | except subprocess.TimeoutExpired: | |||
self.proc.kill() | self.proc.kill() | |||
if not self._outcome.result.wasSuccessful(): | if not self._outcome.result.wasSuccessful(): | |||
self.driver.get_screenshot_as_file("failed_test_shot_{}.png".fo rmat(self.id())) | self.driver.get_screenshot_as_file(f"failed_test_shot_logoutgre etertest_{self.id()}.png") | |||
def assertStdErrLine(self, expected): | def assertStdErrLine(self, expected): | |||
out, err = self.proc.communicate() | out, err = self.proc.communicate() | |||
errLines = err.splitlines() | errLines = err.splitlines() | |||
self.assertEqual(expected, errLines[(len(errLines) - 1)].decode('UT F-8')) | self.assertEqual(expected, errLines[(len(errLines) - 1)].decode('UT F-8')) | |||
def test_sleep(self): | def test_sleep(self): | |||
self.driver.find_element(by=AppiumBy.NAME, value="Sleep").click() | self.driver.find_element(by=AppiumBy.NAME, value="Sleep").click() | |||
self.assertStdErrLine("suspend") | self.assertStdErrLine("suspend") | |||
End of changes. 8 change blocks. | ||||
15 lines changed or deleted | 12 lines changed or added | |||
This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |