Kea2-python 0.0.1a0__tar.gz → 0.0.1a1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of Kea2-python might be problematic. Click here for more details.
- {kea2_python-0.0.1a0 → kea2_python-0.0.1a1}/Kea2_python.egg-info/PKG-INFO +1 -1
- {kea2_python-0.0.1a0 → kea2_python-0.0.1a1}/PKG-INFO +1 -1
- kea2_python-0.0.1a1/kea2/assets/fastbot_configs/widget.block.py +18 -0
- kea2_python-0.0.1a1/kea2/assets/monkeyq.jar +0 -0
- {kea2_python-0.0.1a0 → kea2_python-0.0.1a1}/kea2/cli.py +18 -13
- {kea2_python-0.0.1a0 → kea2_python-0.0.1a1}/kea2/keaUtils.py +24 -7
- {kea2_python-0.0.1a0 → kea2_python-0.0.1a1}/kea2/kea_launcher.py +19 -11
- {kea2_python-0.0.1a0 → kea2_python-0.0.1a1}/kea2/u2Driver.py +14 -4
- {kea2_python-0.0.1a0 → kea2_python-0.0.1a1}/pyproject.toml +1 -1
- kea2_python-0.0.1a0/kea2/assets/fastbot_configs/widget.block.py +0 -22
- kea2_python-0.0.1a0/kea2/assets/monkeyq.jar +0 -0
- {kea2_python-0.0.1a0 → kea2_python-0.0.1a1}/Kea2_python.egg-info/SOURCES.txt +0 -0
- {kea2_python-0.0.1a0 → kea2_python-0.0.1a1}/Kea2_python.egg-info/dependency_links.txt +0 -0
- {kea2_python-0.0.1a0 → kea2_python-0.0.1a1}/Kea2_python.egg-info/entry_points.txt +0 -0
- {kea2_python-0.0.1a0 → kea2_python-0.0.1a1}/Kea2_python.egg-info/requires.txt +0 -0
- {kea2_python-0.0.1a0 → kea2_python-0.0.1a1}/Kea2_python.egg-info/top_level.txt +0 -0
- {kea2_python-0.0.1a0 → kea2_python-0.0.1a1}/LICENSE +0 -0
- {kea2_python-0.0.1a0 → kea2_python-0.0.1a1}/README.md +0 -0
- {kea2_python-0.0.1a0 → kea2_python-0.0.1a1}/kea2/__init__.py +0 -0
- {kea2_python-0.0.1a0 → kea2_python-0.0.1a1}/kea2/absDriver.py +0 -0
- {kea2_python-0.0.1a0 → kea2_python-0.0.1a1}/kea2/adbUtils.py +0 -0
- {kea2_python-0.0.1a0 → kea2_python-0.0.1a1}/kea2/assets/fastbot-thirdpart.jar +0 -0
- {kea2_python-0.0.1a0 → kea2_python-0.0.1a1}/kea2/assets/fastbot_configs/ADBKeyBoard.apk +0 -0
- {kea2_python-0.0.1a0 → kea2_python-0.0.1a1}/kea2/assets/fastbot_configs/abl.strings +0 -0
- {kea2_python-0.0.1a0 → kea2_python-0.0.1a1}/kea2/assets/fastbot_configs/awl.strings +0 -0
- {kea2_python-0.0.1a0 → kea2_python-0.0.1a1}/kea2/assets/fastbot_configs/max.config +0 -0
- {kea2_python-0.0.1a0 → kea2_python-0.0.1a1}/kea2/assets/fastbot_configs/max.fuzzing.strings +0 -0
- {kea2_python-0.0.1a0 → kea2_python-0.0.1a1}/kea2/assets/fastbot_configs/max.schema.strings +0 -0
- {kea2_python-0.0.1a0 → kea2_python-0.0.1a1}/kea2/assets/fastbot_configs/max.strings +0 -0
- {kea2_python-0.0.1a0 → kea2_python-0.0.1a1}/kea2/assets/fastbot_configs/max.tree.pruning +0 -0
- {kea2_python-0.0.1a0 → kea2_python-0.0.1a1}/kea2/assets/fastbot_libs/arm64-v8a/libfastbot_native.so +0 -0
- {kea2_python-0.0.1a0 → kea2_python-0.0.1a1}/kea2/assets/fastbot_libs/armeabi-v7a/libfastbot_native.so +0 -0
- {kea2_python-0.0.1a0 → kea2_python-0.0.1a1}/kea2/assets/fastbot_libs/x86/libfastbot_native.so +0 -0
- {kea2_python-0.0.1a0 → kea2_python-0.0.1a1}/kea2/assets/fastbot_libs/x86_64/libfastbot_native.so +0 -0
- {kea2_python-0.0.1a0 → kea2_python-0.0.1a1}/kea2/assets/framework.jar +0 -0
- {kea2_python-0.0.1a0 → kea2_python-0.0.1a1}/kea2/assets/quickstart.py +0 -0
- {kea2_python-0.0.1a0 → kea2_python-0.0.1a1}/kea2/assets/u2.jar +0 -0
- {kea2_python-0.0.1a0 → kea2_python-0.0.1a1}/kea2/logWatcher.py +0 -0
- {kea2_python-0.0.1a0 → kea2_python-0.0.1a1}/kea2/utils.py +0 -0
- {kea2_python-0.0.1a0 → kea2_python-0.0.1a1}/setup.cfg +0 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from kea2.utils import Device
|
|
2
|
+
from kea2.keaUtils import precondition
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def global_block_widgets(d: "Device"):
|
|
6
|
+
"""
|
|
7
|
+
global block widgets.
|
|
8
|
+
return the widgets you want to block globally
|
|
9
|
+
only available in mode `u2 agent`
|
|
10
|
+
"""
|
|
11
|
+
return []
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# conditional block list
|
|
15
|
+
@precondition(lambda d: d(text="In the home page").exists)
|
|
16
|
+
def block_sth(d: "Device"):
|
|
17
|
+
# Important: function shold starts with "block"
|
|
18
|
+
return [d(text="widgets to block"), d.xpath(".//node[@text='widget to block']")]
|
|
Binary file
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
# cli.py
|
|
3
3
|
|
|
4
4
|
from __future__ import absolute_import, print_function
|
|
5
|
+
import sys
|
|
5
6
|
from kea2.utils import getProjectRoot, getLogger
|
|
6
7
|
from .kea_launcher import run
|
|
7
8
|
import argparse
|
|
@@ -43,9 +44,7 @@ def cmd_run(args):
|
|
|
43
44
|
if base_dir is None:
|
|
44
45
|
logger.error("kea2 project not initialized. Use `kea2 init`.")
|
|
45
46
|
return
|
|
46
|
-
|
|
47
|
-
argv.extend(args.args)
|
|
48
|
-
run(argv)
|
|
47
|
+
run(args)
|
|
49
48
|
|
|
50
49
|
|
|
51
50
|
def cmd_install(args):
|
|
@@ -83,14 +82,14 @@ _commands = [
|
|
|
83
82
|
command="init",
|
|
84
83
|
help="init the Kea2 project in current directory",
|
|
85
84
|
),
|
|
86
|
-
dict(
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
),
|
|
85
|
+
# dict(
|
|
86
|
+
# action=cmd_run,
|
|
87
|
+
# command="run",
|
|
88
|
+
# help="run kea2",
|
|
89
|
+
# flags=[
|
|
90
|
+
# dict(args=["args"], nargs=argparse.REMAINDER),
|
|
91
|
+
# ],
|
|
92
|
+
# ),
|
|
94
93
|
# dict(
|
|
95
94
|
# action=cmd_install,
|
|
96
95
|
# command="",
|
|
@@ -157,11 +156,17 @@ def main():
|
|
|
157
156
|
kwargs.pop('args', None)
|
|
158
157
|
sp.add_argument(*args, **kwargs)
|
|
159
158
|
|
|
159
|
+
from .kea_launcher import _set_driver_parser
|
|
160
|
+
_set_driver_parser(subparser)
|
|
161
|
+
actions["run"] = cmd_run
|
|
162
|
+
if sys.argv[1:] == ["run"]:
|
|
163
|
+
sys.argv.append("-h")
|
|
160
164
|
args = parser.parse_args()
|
|
161
|
-
|
|
162
165
|
|
|
166
|
+
import logging
|
|
167
|
+
logging.getLogger("urllib3").setLevel(logging.INFO)
|
|
168
|
+
logging.getLogger("uiautomator2").setLevel(logging.INFO)
|
|
163
169
|
if args.debug:
|
|
164
|
-
import logging
|
|
165
170
|
logging.basicConfig(level=logging.DEBUG)
|
|
166
171
|
logger.debug("args: %s", args)
|
|
167
172
|
|
|
@@ -15,6 +15,8 @@ from time import sleep
|
|
|
15
15
|
from .adbUtils import push_file
|
|
16
16
|
from .logWatcher import LogWatcher
|
|
17
17
|
from .utils import TimeStamp, getProjectRoot, getLogger
|
|
18
|
+
from .u2Driver import StaticU2UiObject
|
|
19
|
+
import uiautomator2 as u2
|
|
18
20
|
import types
|
|
19
21
|
PRECONDITIONS_MARKER = "preconds"
|
|
20
22
|
PROP_MARKER = "prop"
|
|
@@ -404,8 +406,14 @@ class KeaTestRunner(TextTestRunner):
|
|
|
404
406
|
"""
|
|
405
407
|
send a step monkey request to the server and get the xml string.
|
|
406
408
|
"""
|
|
407
|
-
block_widgets = self._getBlockedWidgets()
|
|
408
|
-
|
|
409
|
+
block_widgets: List[str] = self._getBlockedWidgets()
|
|
410
|
+
URL = f"http://localhost:{self.scriptDriver.lport}/stepMonkey"
|
|
411
|
+
r = requests.post(
|
|
412
|
+
url=URL,
|
|
413
|
+
json={
|
|
414
|
+
"block_widgets": block_widgets
|
|
415
|
+
}
|
|
416
|
+
)
|
|
409
417
|
|
|
410
418
|
res = json.loads(r.content)
|
|
411
419
|
xml_raw = res["result"]
|
|
@@ -479,7 +487,7 @@ class KeaTestRunner(TextTestRunner):
|
|
|
479
487
|
print(f"[INFO] Load property: {getFullPropName(t)}", flush=True)
|
|
480
488
|
|
|
481
489
|
@property
|
|
482
|
-
def
|
|
490
|
+
def _blockWidgetFuncs(self):
|
|
483
491
|
if self._block_widgets_funcs is None:
|
|
484
492
|
self._block_widgets_funcs = list()
|
|
485
493
|
root_dir = getProjectRoot()
|
|
@@ -512,7 +520,7 @@ class KeaTestRunner(TextTestRunner):
|
|
|
512
520
|
|
|
513
521
|
def _getBlockedWidgets(self):
|
|
514
522
|
blocked_widgets = list()
|
|
515
|
-
for func in self.
|
|
523
|
+
for func in self._blockWidgetFuncs:
|
|
516
524
|
try:
|
|
517
525
|
script_driver = self.options.Driver.getScriptDriver()
|
|
518
526
|
preconds = getattr(func, PRECONDITIONS_MARKER)
|
|
@@ -520,9 +528,18 @@ class KeaTestRunner(TextTestRunner):
|
|
|
520
528
|
_widgets = func(self.options.Driver.getStaticChecker())
|
|
521
529
|
if not isinstance(_widgets, list):
|
|
522
530
|
_widgets = [_widgets]
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
531
|
+
for w in _widgets:
|
|
532
|
+
if isinstance(w, StaticU2UiObject):
|
|
533
|
+
blocked_widgets.append(w._getXPath(w.selector))
|
|
534
|
+
elif isinstance(w, u2.xpath.XPathSelector):
|
|
535
|
+
def getXPathRepr(w):
|
|
536
|
+
return w._parent.xpath
|
|
537
|
+
blocked_widgets.append(getXPathRepr(w))
|
|
538
|
+
else:
|
|
539
|
+
logger.warning(f"{w} Not supported")
|
|
540
|
+
# blocked_widgets.extend([
|
|
541
|
+
# w._getXPath(w.selector) for w in _widgets
|
|
542
|
+
# ])
|
|
526
543
|
except Exception as e:
|
|
527
544
|
logger.error(f"error when getting blocked widgets: {e}")
|
|
528
545
|
import traceback
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import sys
|
|
1
2
|
import argparse
|
|
2
|
-
from typing import List
|
|
3
3
|
import unittest
|
|
4
|
+
from typing import List
|
|
4
5
|
|
|
5
6
|
def _set_driver_parser(subparsers: "argparse._SubParsersAction[argparse.ArgumentParser]"):
|
|
6
|
-
parser = subparsers.add_parser("
|
|
7
|
+
parser = subparsers.add_parser("run", help="run kea2")
|
|
7
8
|
parser.add_argument(
|
|
8
9
|
"-s",
|
|
9
10
|
"--serial",
|
|
@@ -96,21 +97,28 @@ def parse_args(argv: List):
|
|
|
96
97
|
subparsers = parser.add_subparsers(dest="command", required=True)
|
|
97
98
|
|
|
98
99
|
_set_driver_parser(subparsers)
|
|
99
|
-
if len(argv) == 0:
|
|
100
|
-
argv.append("-h")
|
|
101
100
|
args = parser.parse_args(argv)
|
|
102
|
-
driver_info_logger(args)
|
|
103
|
-
unittest_info_logger(args)
|
|
104
101
|
return args
|
|
105
102
|
|
|
106
|
-
def
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
103
|
+
def _sanitize_args(args):
|
|
104
|
+
if args.agent == "u2" and not args.driver_name:
|
|
105
|
+
if args.extra == []:
|
|
106
|
+
args.driver_name = "d"
|
|
107
|
+
else:
|
|
108
|
+
raise ValueError("--driver-name should be specified when customizing script in --agent u2")
|
|
109
|
+
|
|
110
|
+
def run(args=None):
|
|
111
|
+
if args is None:
|
|
112
|
+
args = parse_args(sys.argv[1:])
|
|
113
|
+
|
|
114
|
+
_sanitize_args(args)
|
|
115
|
+
|
|
116
|
+
driver_info_logger(args)
|
|
117
|
+
unittest_info_logger(args)
|
|
111
118
|
|
|
112
119
|
from kea2 import KeaTestRunner, Options
|
|
113
120
|
from kea2.u2Driver import U2Driver
|
|
121
|
+
U2Driver.setDeviceSerial(args.serial)
|
|
114
122
|
options = Options(
|
|
115
123
|
agent=args.agent,
|
|
116
124
|
driverName=args.driver_name,
|
|
@@ -85,7 +85,8 @@ class StaticU2UiObject(u2.UiObject):
|
|
|
85
85
|
|
|
86
86
|
def _transferU2Keys(self, originKey):
|
|
87
87
|
filterDict = {
|
|
88
|
-
"resourceId": "resource-id"
|
|
88
|
+
"resourceId": "resource-id",
|
|
89
|
+
"description": "content-desc"
|
|
89
90
|
}
|
|
90
91
|
if filterDict.get(originKey, None):
|
|
91
92
|
return filterDict[originKey]
|
|
@@ -116,7 +117,7 @@ class StaticU2UiObject(u2.UiObject):
|
|
|
116
117
|
|
|
117
118
|
@property
|
|
118
119
|
def exists(self):
|
|
119
|
-
self.selector
|
|
120
|
+
dict.update(self.selector, {"covered": "true"})
|
|
120
121
|
xpath = self._getXPath(self.selector)
|
|
121
122
|
matched_widgets = self.session.xml.xpath(xpath)
|
|
122
123
|
return bool(matched_widgets)
|
|
@@ -124,7 +125,7 @@ class StaticU2UiObject(u2.UiObject):
|
|
|
124
125
|
def __len__(self):
|
|
125
126
|
xpath = self._getXPath(self.selector)
|
|
126
127
|
matched_widgets = self.session.xml.xpath(xpath)
|
|
127
|
-
return len(matched_widgets)
|
|
128
|
+
return len(matched_widgets)
|
|
128
129
|
|
|
129
130
|
|
|
130
131
|
def _get_bounds(raw_bounds):
|
|
@@ -216,12 +217,21 @@ class U2StaticDevice(u2.Device):
|
|
|
216
217
|
def get_page_source(self):
|
|
217
218
|
# print("[Debug] Using static get_page_source method")
|
|
218
219
|
return u2.xpath.PageSource.parse(self._d.xml_raw)
|
|
219
|
-
xpathEntry =
|
|
220
|
+
xpathEntry = _XPathEntry(self)
|
|
220
221
|
xpathEntry.get_page_source = types.MethodType(
|
|
221
222
|
get_page_source, xpathEntry
|
|
222
223
|
)
|
|
223
224
|
return xpathEntry
|
|
224
225
|
|
|
226
|
+
class _XPathEntry(u2.xpath.XPathEntry):
|
|
227
|
+
def __init__(self, d):
|
|
228
|
+
self.xpath = None
|
|
229
|
+
super().__init__(d)
|
|
230
|
+
|
|
231
|
+
def __call__(self, xpath, source = None):
|
|
232
|
+
self.xpath = xpath
|
|
233
|
+
return super().__call__(xpath, source)
|
|
234
|
+
|
|
225
235
|
|
|
226
236
|
class U2StaticChecker(AbstractStaticChecker):
|
|
227
237
|
"""
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
from kea2.utils import precondition
|
|
2
|
-
from uiautomator2 import Device
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
@precondition(lambda d:
|
|
6
|
-
d(text="Setting")
|
|
7
|
-
)
|
|
8
|
-
def sample_block_list(d: "Device"):
|
|
9
|
-
return d(text="Omni Notes Alpha").exists
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
if __name__ == "__main__":
|
|
13
|
-
from kea2.utils import BLOCK_WIDGET
|
|
14
|
-
func = getattr(sample_block_list, BLOCK_WIDGET)
|
|
15
|
-
import uiautomator2 as u2
|
|
16
|
-
d = u2.connect()
|
|
17
|
-
blocked_widgets = func(d)
|
|
18
|
-
if isinstance(blocked_widgets, u2.UiObject):
|
|
19
|
-
blocked_widgets = [blocked_widgets]
|
|
20
|
-
if not all([isinstance(w, u2.UiObject) for w in blocked_widgets]):
|
|
21
|
-
raise TypeError(f"Invalid widgets block list in {sample_block_list}")
|
|
22
|
-
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{kea2_python-0.0.1a0 → kea2_python-0.0.1a1}/kea2/assets/fastbot_libs/arm64-v8a/libfastbot_native.so
RENAMED
|
File without changes
|
|
File without changes
|
{kea2_python-0.0.1a0 → kea2_python-0.0.1a1}/kea2/assets/fastbot_libs/x86/libfastbot_native.so
RENAMED
|
File without changes
|
{kea2_python-0.0.1a0 → kea2_python-0.0.1a1}/kea2/assets/fastbot_libs/x86_64/libfastbot_native.so
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|