M module-services/service-gui/SynchronizationMechanism.cpp => module-services/service-gui/SynchronizationMechanism.cpp +2 -0
@@ 3,6 3,8 @@
#include "SynchronizationMechanism.hpp"
+#include <stdexcept>
+
namespace service::gui
{
class FreeRtosSynchronization : public SynchronizationMechanism
M test/README.md => test/README.md +11 -5
@@ 78,17 78,23 @@ from harness.harness import Harness
from harness.interface.defs import key_codes
# try to init Harness object with automatic port detection
-harness = Harness.from_magic()
+harness = Harness.from_detect()
-#get current application name
+# get current application name
current_window = harness.get_window_name()
#open messages when phone is unlocked
-@harness.with_phone_unlocked()
+@harness.with_phone_unlocked
def do_after_unlock(connection):
+ # open menu
+ connection.send_key_code(key_codes["enter"])
+
harness.open_application("messages")
- #send joystick down keypress
- connection.send_key(key_codes["down"])
+ # send joystick down keypress
+ connection.send_key_code(key_codes["down"])
+
+ # open a thread
+ connection.send_key_code(key_codes["enter"])
```
### pyTest running
M test/harness/harness.py => test/harness/harness.py +7 -7
@@ 30,7 30,7 @@ class Harness:
found = serial.CDCSerial.find_Pures()
if found:
port = found[0]
- return cls(found[0])
+ return cls(port)
else:
raise TestError(Error.PORT_NOT_FOUND)
@@ 42,12 42,12 @@ class Harness:
def unlock_phone(self):
if self.connection.is_phone_locked():
- self.connection.send_key(key_codes["enter"])
- self.connection.send_key(key_codes["#"])
- self.connection.send_key(3)
- self.connection.send_key(3)
- self.connection.send_key(3)
- self.connection.send_key(3)
+ self.connection.send_key_code(key_codes["enter"])
+ self.connection.send_key_code(key_codes["#"])
+ self.connection.send_key_code(3)
+ self.connection.send_key_code(3)
+ self.connection.send_key_code(3)
+ self.connection.send_key_code(3)
log.info("Phone unlocked")
else:
log.info("Phone already unlocked")
M test/harness/interface/CDCSerial.py => test/harness/interface/CDCSerial.py +1 -1
@@ 82,7 82,7 @@ class CDCSerial:
self.serial.write(message.encode())
self.serial.timeout = timeout
- def send_key(self, key_code, key_type=Keytype.short_press, wait=10):
+ def send_key_code(self, key_code, key_type=Keytype.short_press, wait=10):
if key_type is Keytype.long_press:
body = {"keyPressed": key_code, "state": 4}
else:
M test/harness/interface/defs.py => test/harness/interface/defs.py +12 -2
@@ 1,5 1,6 @@
# Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
# For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+from enum import Enum
endpoint = {
"deviceInfo": 1,
@@ 45,6 46,15 @@ key_codes = {
"sliderMid": 18,
"sliderDown": 17,
"#": ord('#'),
- "*": ord('*')
-
+ "*": ord('*'),
}
+
+
+class SMSType(Enum):
+ DRAFT = 0x01
+ FAILED = 0x02
+ INBOX = 0x04
+ OUTBOX = 0x08
+ QUEUED = 0x10
+ INPUT = 0x12
+ UNKNOWN = 0xFF
M test/harness/utils.py => test/harness/utils.py +34 -34
@@ 55,32 55,32 @@ application_keypath = {
}
keymap = {
- "a": "2",
- "b": "22",
- "c": "222",
- "d": "3",
- "e": "33",
- "f": "333",
- "g": "4",
- "h": "44",
- "i": "444",
- "j": "5",
- "k": "55",
- "l": "555",
- "m": "6",
- "n": "66",
- "o": "666",
- "p": "7",
- "q": "77",
- "r": "777",
- "s": "7777",
- "t": "8",
- "u": "88",
- "v": "888",
- "w": "9",
- "x": "99",
- "y": "999",
- "z": "9999",
+ "A": "2",
+ "B": "22",
+ "C": "222",
+ "D": "3",
+ "E": "33",
+ "F": "333",
+ "G": "4",
+ "H": "44",
+ "I": "444",
+ "J": "5",
+ "K": "55",
+ "L": "555",
+ "M": "6",
+ "N": "66",
+ "O": "666",
+ "P": "7",
+ "Q": "77",
+ "R": "777",
+ "S": "7777",
+ "T": "8",
+ "U": "88",
+ "V": "888",
+ "W": "9",
+ "X": "99",
+ "Y": "999",
+ "Z": "9999",
" ": "0",
".": "1",
",": "11",
@@ 101,8 101,8 @@ keymap = {
def send_keystoke(keypath, connection):
- for i in keypath:
- connection.send_key(key_codes[i])
+ for key in keypath:
+ connection.send_key_code(key_codes[key])
time.sleep(0.3)
@@ 116,23 116,23 @@ def send_char(char: str, connection):
key_type = Keytype.long_press
if last_char is char:
print("repeated key!")
- connection.send_key(key_codes["right"])
- connection.send_key(int(char), key_type)
- connection.send_key(key_codes["right"])
+ connection.send_key_code(key_codes["right"])
+ connection.send_key_code(int(char), key_type)
+ connection.send_key_code(key_codes["right"])
last_char = char
else:
if last_char is keymap[char][0]:
print("repeated key!")
- connection.send_key(key_codes["right"], key_type)
+ connection.send_key_code(key_codes["right"], key_type)
for key in keymap[char]:
- connection.send_key(int(key), key_type)
+ connection.send_key_code(int(key), key_type)
last_char = keymap[char][0]
def send_number(number: str, connection):
if number.isnumeric():
for digit in number:
- connection.send_key(int(digit))
+ connection.send_key_code(int(digit))
time.sleep(0.3)
M test/make_a_call.py => test/make_a_call.py +2 -2
@@ 17,10 17,10 @@ def call(harness, phone_number: str, duration: int):
# enter number
harness.send_number(phone_number)
# call
- connection.send_key(key_codes["fnLeft"])
+ connection.send_key_code(key_codes["fnLeft"])
time.sleep(duration)
- connection.send_key(key_codes["fnRight"])
+ connection.send_key_code(key_codes["fnRight"])
def get_calllog_count(harness):
D test/phone_switch_app.py => test/phone_switch_app.py +0 -20
@@ 1,20 0,0 @@
-#!/usr/bin/env python
-# Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
-# For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
-
-# script walking on desktop
-import time
-from harness.uart import connection, log
-
-
-# get in sms and back 100 times
-for el in range(1, 100):
- log.info("TEST ex: {}".format(el))
- # back
- # move left , enter, read for entry
- connection.send_key(ord('d'))
- connection.send_key(ord('d'))
- connection.send_key(ord('\n'))
- time.sleep(1)
- connection.send_key(12)
- time.sleep(1)
M test/phone_unlock.py => test/phone_unlock.py +5 -10
@@ 3,14 3,9 @@
# For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
# unlock Desktop
-from harness.uart import connection
-from interface.defs import key_codes
-
-# write pin
-connection.send_key(key_codes["enter"])
-connection.send_key(key_codes["#"])
-connection.send_key(3)
-connection.send_key(3)
-connection.send_key(3)
-connection.send_key(3)
+from harness.harness import Harness
+harness = Harness.from_detect()
+@harness.with_phone_unlocked
+def done(connection):
+ pass
D test/phone_walk.py => test/phone_walk.py +0 -13
@@ 1,13 0,0 @@
-#!/usr/bin/env python
-# Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
-# For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
-
-# script walking on desktop
-
-from harness.uart import connection
-
-for lol in range(1, 60 * 30):
- connection.send_key(ord('d'))
- connection.send_key(ord('s'))
- connection.send_key(ord('s'))
- connection.send_key(ord('d'))
M test/pytest/test_call.py => test/pytest/test_call.py +2 -2
@@ 18,10 18,10 @@ def test_call(harness, phone_number, call_duration):
# enter number
harness.send_number(str(phone_number))
# call
- harness.connection.send_key(key_codes["fnLeft"])
+ harness.connection.send_key_code(key_codes["fnLeft"])
time.sleep(call_duration)
# hang up
- harness.connection.send_key(key_codes["fnRight"])
+ harness.connection.send_key_code(key_codes["fnRight"])
count_after = get_calllog_count(harness)
assert count_before + 1 == count_after
M test/pytest/test_call_back.py => test/pytest/test_call_back.py +4 -4
@@ 17,21 17,21 @@ def test_call(harness, call_duration):
count_before = get_calllog_count(harness)
# enter menu
- harness.connection.send_key(key_codes["enter"])
+ harness.connection.send_key_code(key_codes["enter"])
harness.open_application("calllog")
if harness.connection.get_window_name() != "ApplicationCallLog":
time.sleep(2)
assert harness.connection.get_window_name() == "ApplicationCallLog"
# call
- harness.connection.send_key(key_codes["fnLeft"])
+ harness.connection.send_key_code(key_codes["fnLeft"])
time.sleep(call_duration)
# hang up
- harness.connection.send_key(key_codes["fnRight"])
+ harness.connection.send_key_code(key_codes["fnRight"])
count_after = get_calllog_count(harness)
for _ in range(3):
- harness.connection.send_key(key_codes["fnRight"])
+ harness.connection.send_key_code(key_codes["fnRight"])
time.sleep(1)
assert count_before + 1 == count_after
M test/pytest/test_send_message.py => test/pytest/test_send_message.py +16 -12
@@ 3,7 3,7 @@
import time
import pytest
-from harness.interface.defs import key_codes
+from harness.interface.defs import key_codes, SMSType
def get_message_by_text(harness, message: str, phone_number: str):
@@ 14,33 14,37 @@ def get_message_by_text(harness, message: str, phone_number: str):
@pytest.mark.rt1051
@pytest.mark.usefixtures("phone_unlocked")
def test_send_message(harness, phone_number, sms_text):
- messages = get_message_by_text(harness, sms_text.upper(), str(phone_number))
+ old_messages = get_message_by_text(harness, sms_text.upper(), str(phone_number))
# enter menu
- harness.connection.send_key(key_codes["enter"])
+ harness.connection.send_key_code(key_codes["enter"])
harness.open_application("messages")
if harness.connection.get_window_name() != "ApplicationMessages":
time.sleep(2)
assert harness.connection.get_window_name() == "ApplicationMessages"
# create new message
- harness.connection.send_key(key_codes["left"])
+ harness.connection.send_key_code(key_codes["left"])
# enter phone number
harness.send_number(str(phone_number))
# move down to message body
- harness.connection.send_key(key_codes["down"])
+ harness.connection.send_key_code(key_codes["down"])
# write a message
harness.send_text(sms_text)
# send
- harness.connection.send_key(key_codes["enter"])
-
+ harness.connection.send_key_code(key_codes["enter"])
# go back to main screen
for _ in range(3):
- harness.connection.send_key(key_codes["fnRight"])
+ time.sleep(1.2) # it take horrendous amount of time to go back to thread view
+ harness.connection.send_key_code(key_codes["fnRight"])
- time.sleep(2)
new_messages = get_message_by_text(harness, sms_text.upper(), str(phone_number))
+ diff_messages = []
+
+ for message in new_messages:
+ if message not in old_messages:
+ diff_messages.append(message)
+
+ assert len(diff_messages) == 1
+ assert SMSType(diff_messages[0]["type"]) == SMSType.OUTBOX
- diff = [i for i in messages + new_messages if i not in messages or i not in new_messages]
- assert len(diff) == 1
- assert diff[0]["type"] == 0x08