Skip to content

Fix Api29 tests. Fix changing of time zone tests. increase the time for waiting an emulator. #478

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ max-locals=15
max-parents=7

# Maximum number of public methods for a class (see R0904).
max-public-methods=30
max-public-methods=35

# Maximum number of return / yield for function / method body.
max-returns=6
Expand Down
15 changes: 14 additions & 1 deletion core/utils/device/adb.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def is_running(device_id):
return bool('mSurface=Surface' in result.output)

@staticmethod
def wait_until_boot(device_id, timeout=180, check_interval=3):
def wait_until_boot(device_id, timeout=250, check_interval=3):
"""
Wait android device/emulator is up and running.
:param device_id: Device identifier.
Expand Down Expand Up @@ -413,6 +413,19 @@ def kill_process(device_id, process_name):
assert result.output == "", "Process {0} not killed! Logs:{1}".format(process_name, result.output)
time.sleep(5)

@staticmethod
def kill_application(device_id, app_id, process_id):
"""
Stop application
:param device_id: Device identifier
:param app_id: Bundle identifier (example: org.nativescript.TestApp)
:param process_id: The id of the process
"""
Adb.run_adb_command(command='shell run-as {0} kill {1}'.format(app_id, process_id),
device_id=device_id, wait=True)
# wait application to be killed
time.sleep(2)

@staticmethod
def run_adb_as_root(device_id):
"""
Expand Down
8 changes: 4 additions & 4 deletions tests/runtimes/android/android_runtime_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,10 +627,10 @@ def test_440_tns_run_android_new_date_work_as_expected_when_changing_timezone(se
period=5)
assert test_result, "Select time zone Button is missing on the device"
Device.click(self.emulator, text="Select time zone")
test_result = Wait.until(lambda: Device.is_text_visible(self.emulator, "Los Angeles", True),
test_result = Wait.until(lambda: Device.is_text_visible(self.emulator, "Tijuana", True),
timeout=30, period=5)
assert test_result, "Los Angeles Button is missing on the device."
Device.click(self.emulator, text="Los Angeles")
Device.click(self.emulator, text="Tijuana")

else:
output = Adb.run_adb_command("shell am start -a android.settings.DATE_SETTINGS", self.emulator.id,
Expand All @@ -654,10 +654,10 @@ def test_440_tns_run_android_new_date_work_as_expected_when_changing_timezone(se
period=5)
assert test_result, "TAP Button is missing on the device"
Device.click(self.emulator, text="TAP", case_sensitive=True)
assert_result = Wait.until(lambda: "GMT-0800 (PST)" in File.read(log.log_file), timeout=240, period=5)
assert_result = Wait.until(lambda: "GMT-0700 (PDT)" in File.read(log.log_file), timeout=240, period=5)
assert assert_result, "Missing log for time! Logs: " + File.read(log.log_file)
# Generate regex for asserting date and time
date_to_find_los_angeles = los_angeles_time.strftime(r'%a %b %d %Y %H:.{2}:.{2}') + r" GMT\-0800 \(PST\)"
date_to_find_los_angeles = los_angeles_time.strftime(r'%a %b %d %Y %H:.{2}:.{2}') + r" GMT\-0700 \(PDT\)"
# Assert date time is correct
assert_result = Wait.until(lambda: re.search(date_to_find_los_angeles, File.read(log.log_file)), timeout=20,
period=5)
Expand Down
10 changes: 6 additions & 4 deletions tests/runtimes/android/android_service_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ def test_200_test_foreground_sticky_services_are_working(self):
assert service_name in service_info, "{0} service not found! Logs: {1}".format(service_name, service_info)

pid = Adb.get_process_pid(self.emulator.id, "org.nativescript.TestApp")
Adb.kill_process(self.emulator.id, "org.nativescript.TestApp")
Adb.kill_application(self.emulator.id, "org.nativescript.TestApp", pid)
service_info = Adb.get_active_services(self.emulator.id)
assert service_name in service_info, "{0} service not found! Logs: {1}".format(service_name, service_info)
services = Adb.get_active_services(self.emulator.id, service_name)
assert service_name in services, "{0} service not found! Logs: {1}".format(service_name, services)

Expand All @@ -81,6 +83,7 @@ def test_201_test_foreground_not_sticky_services_are_working(self):
"""
https://github.com/NativeScript/android-runtime/issues/1347
"""
Adb.stop_application(self.emulator.id, "org.nativescript.TestApp")
File.copy(os.path.join(TEST_RUN_HOME, 'assets', 'runtime', 'android', 'files',
'android-runtime-1347', 'AndroidManifest.xml'),
os.path.join(TEST_RUN_HOME, APP_NAME, 'app', 'App_Resources', 'Android', 'src', 'main',
Expand Down Expand Up @@ -108,8 +111,7 @@ def test_201_test_foreground_not_sticky_services_are_working(self):
assert service_name in service_info, "{0} service not found! Logs: {1}".format(service_name, service_info)

pid = Adb.get_process_pid(self.emulator.id, "org.nativescript.TestApp")
Adb.kill_process(self.emulator.id, "org.nativescript.TestApp")

Adb.kill_application(self.emulator.id, "org.nativescript.TestApp", pid)
service_info = Adb.get_active_services(self.emulator.id, service_name)
assert service_name not in service_info, "{0} service found! Logs: {1}".format(service_name, service_info)
assert pid not in service_info, "{0} service with id {1} found! Logs: {2}".format(service_name, pid,
Expand Down Expand Up @@ -146,7 +148,7 @@ def test_202_test_foreground_service_without_oncreate_method_is_working(self):
assert service_name in service_info, "{0} service not found! Logs: {1}".format(service_name, service_info)

pid = Adb.get_process_pid(self.emulator.id, "org.nativescript.TestApp")
Adb.kill_process(self.emulator.id, "org.nativescript.TestApp")
Adb.kill_application(self.emulator.id, "org.nativescript.TestApp", pid)

service_info = Adb.get_active_services(self.emulator.id, service_name)
assert service_name not in service_info, "{0} service found! Logs: {1}".format(service_name, service_info)
Expand Down