forked from KDE/plasma-desktop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathemojiertest.py
executable file
·67 lines (52 loc) · 2.01 KB
/
emojiertest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env python3
# SPDX-FileCopyrightText: 2023 Fushan Wen <[email protected]>
# SPDX-License-Identifier: MIT
import subprocess
import time
import unittest
from typing import Final
from appium import webdriver
from appium.options.common.base import AppiumOptions
from appium.webdriver.common.appiumby import AppiumBy
KDE_VERSION: Final = 6
class EmojierTest(unittest.TestCase):
"""
Tests for plasma-emojier
"""
driver: webdriver.Remote
@classmethod
def setUpClass(cls) -> None:
options = AppiumOptions()
options.set_capability("app", f"plasma-emojier")
options.set_capability("timeouts", {'implicit': 10000})
cls.driver = webdriver.Remote(command_executor='http://127.0.0.1:4723', options=options)
def tearDown(self) -> None:
"""
Take screenshot when the current test fails
"""
if not self._outcome.result.wasSuccessful():
self.driver.get_screenshot_as_file(f"failed_test_shot_emojier_#{self.id()}.png")
@classmethod
def tearDownClass(cls) -> None:
"""
Make sure to terminate the driver again, lest it dangles.
"""
subprocess.check_call([f"kquitapp{KDE_VERSION}", "plasma.emojier"])
cls.driver.quit()
def test_0_open(self) -> None:
"""
Tests the app does not crash on opening
@see https://bugs.kde.org/show_bug.cgi?id=478458
"""
self.driver.find_element(AppiumBy.NAME, "Recent")
self.driver.find_element(AppiumBy.NAME, "Clear History")
def test_1_open_category(self) -> None:
self.driver.find_element(AppiumBy.NAME, "All").click()
self.driver.find_element(AppiumBy.NAME, "grinning face").click()
time.sleep(1)
self.assertEqual(self.driver.get_clipboard_text(), "😀")
def test_2_recent_usage(self) -> None:
self.driver.find_element(AppiumBy.NAME, "Recent").click()
self.driver.find_element(AppiumBy.NAME, "grinning face")
if __name__ == '__main__':
unittest.main()