File indexing completed on 2024-05-12 05:35:22

0001 #!/usr/bin/env python3
0002 
0003 # SPDX-FileCopyrightText: 2023 Fushan Wen <qydwhotmail@gmail.com>
0004 # SPDX-License-Identifier: MIT
0005 
0006 import unittest
0007 from typing import Final
0008 
0009 from appium import webdriver
0010 from appium.options.common.base import AppiumOptions
0011 from appium.webdriver.common.appiumby import AppiumBy
0012 
0013 KDE_VERSION: Final = 6
0014 KCM_ID: Final = "kcm_plasmasearch"
0015 
0016 
0017 class KCMTest(unittest.TestCase):
0018     """
0019     Tests for kcm_plasmasearch
0020     """
0021 
0022     driver: webdriver.Remote
0023 
0024     @classmethod
0025     def setUpClass(cls) -> None:
0026         """
0027         Opens the KCM and initialize the webdriver
0028         """
0029         options = AppiumOptions()
0030         options.set_capability("app", f"kcmshell{KDE_VERSION} {KCM_ID}")
0031         options.set_capability("timeouts", {'implicit': 10000})
0032         cls.driver = webdriver.Remote(command_executor='http://127.0.0.1:4723', options=options)
0033 
0034     def tearDown(self) -> None:
0035         """
0036         Take screenshot when the current test fails
0037         """
0038         if not self._outcome.result.wasSuccessful():
0039             self.driver.get_screenshot_as_file(f"failed_test_shot_{KCM_ID}_#{self.id()}.png")
0040 
0041     @classmethod
0042     def tearDownClass(cls) -> None:
0043         """
0044         Make sure to terminate the driver again, lest it dangles.
0045         """
0046         cls.driver.quit()
0047 
0048     def test_0_open(self) -> None:
0049         """
0050         Tests the plugin list is loaded
0051         @see https://bugs.kde.org/show_bug.cgi?id=476702
0052         """
0053         self.driver.find_element(AppiumBy.NAME, "Configure KRunner…")
0054         self.driver.find_element(AppiumBy.NAME, "Applications")
0055         self.driver.find_element(AppiumBy.NAME, "Remove from favorites")
0056         self.driver.find_element(AppiumBy.NAME, "File Search")
0057 
0058 
0059 if __name__ == '__main__':
0060     unittest.main()