-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c189745
commit be4d698
Showing
10 changed files
with
66 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# coding: utf-8 | ||
# author: codeskyblue | ||
|
||
from typing import Optional | ||
import uiautomator2 as u2 | ||
|
||
|
||
def get_app_process_pid(d: u2.Device) -> Optional[int]: | ||
for line in d.shell("ps -u shell").output.splitlines(): | ||
fields = line.split() | ||
if fields[-1] == 'app_process': | ||
pid = fields[1] | ||
return int(pid) | ||
return None | ||
|
||
|
||
def kill_app_process(d: u2.Device) -> bool: | ||
pid = get_app_process_pid(d) | ||
if not pid: | ||
return False | ||
d.shell(f"kill {pid}") | ||
return True | ||
|
||
|
||
def test_uiautomator_keeper(d: u2.Device): | ||
kill_app_process(d) | ||
d.sleep(.2) | ||
assert get_app_process_pid(d) is None | ||
d.shell('rm /data/local/tmp/u2.jar') | ||
|
||
d.start_uiautomator() | ||
assert get_app_process_pid(d) > 0 | ||
|
||
d.stop_uiautomator() | ||
assert get_app_process_pid(d) is None | ||
|
||
|
||
def test_debug(d: u2.Device): | ||
d.debug = True | ||
d.info | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# coding: utf-8 | ||
# author: codeskyblue | ||
|
||
# TODO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters