Skip to content

Commit bcd577a

Browse files
committed
wip: update web pack tests
1 parent d19fd90 commit bcd577a

File tree

7 files changed

+399
-493
lines changed

7 files changed

+399
-493
lines changed

core/tns/tns.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,8 @@ def build_ios(attributes={}, assert_success=True, tns_path=None, log_trace=False
417417

418418
if assert_success:
419419
assert "Project successfully built" in output
420-
assert "ERROR" not in output
420+
if "--env.uglify" not in attributes.keys():
421+
assert "ERROR" not in output
421422
assert "malformed" not in output
422423

423424
if log_trace:
@@ -643,7 +644,7 @@ def wait_for_log(log_file, string_list, not_existing_string_list=None, timeout=4
643644
pass
644645
else:
645646
for item in not_existing_string_list:
646-
assert item not in log, "{0} found! It should not be in logs.".format(item)
647+
assert item not in log, "{0} found! It should not be in logs.\nLog:\n{1}".format(item, log)
647648
else:
648649
print "##### OUTPUT BEGIN #####\n"
649650
print log

tests/webpack/__init__.py

Whitespace-only changes.

tests/webpack/hello_world_js_tests.py

Lines changed: 104 additions & 143 deletions
Large diffs are not rendered by default.

tests/webpack/hello_world_ng_tests.py

Lines changed: 129 additions & 195 deletions
Large diffs are not rendered by default.

tests/webpack/hello_world_ts_tests.py

Lines changed: 108 additions & 153 deletions
Large diffs are not rendered by default.

tests/webpack/helpers/__init__.py

Whitespace-only changes.

tests/webpack/helpers/helpers.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import os
2+
3+
from core.device.device import Device
4+
from core.device.helpers.adb import Adb
5+
from core.settings.settings import EMULATOR_ID, EMULATOR_NAME, SIMULATOR_NAME
6+
from core.tns.tns import Tns
7+
from core.tns.tns_verifications import TnsAsserts
8+
9+
10+
class Helpers(object):
11+
@staticmethod
12+
def get_apk_path(app_name, config):
13+
if "debug" in config.lower():
14+
return os.path.join(app_name, TnsAsserts.PLATFORM_ANDROID_APK_PATH, app_name + "-debug.apk")
15+
else:
16+
return os.path.join(app_name, TnsAsserts.PLATFORM_ANDROID_APK_PATH, app_name + "-release.apk")
17+
18+
@staticmethod
19+
def get_ipa_path(app_name):
20+
return os.path.join(app_name, 'platforms', 'ios', 'build', 'device', app_name + '.ipa')
21+
22+
@staticmethod
23+
def get_app_path(app_name):
24+
return os.path.join(app_name, 'platforms', 'ios', 'build', 'emulator', app_name + '.app')
25+
26+
@staticmethod
27+
def run_android_via_adb(app_name, config, image):
28+
Tns.kill()
29+
Helpers.emulator_cleanup(app_name=app_name)
30+
Helpers.install_and_run_app(app_name=app_name, config=config)
31+
Helpers.android_screen_match(app_name=app_name, image=image)
32+
33+
@staticmethod
34+
def emulator_cleanup(app_name):
35+
app_id = Tns.get_app_id(app_name)
36+
Adb.clear_logcat(device_id=EMULATOR_ID)
37+
Adb.stop_application(device_id=EMULATOR_ID, app_id=app_id)
38+
Adb.uninstall(app_id=app_id, device_id=EMULATOR_ID, assert_success=False)
39+
assert not Adb.is_application_running(device_id=EMULATOR_ID, app_id=app_id)
40+
41+
@staticmethod
42+
def install_and_run_app(app_name, config):
43+
Adb.install(apk_file_path=Helpers.get_apk_path(app_name=app_name, config=config), device_id=EMULATOR_ID)
44+
Adb.start_app(device_id=EMULATOR_ID, app_id="org.nativescript." + app_name)
45+
46+
@staticmethod
47+
def android_screen_match(app_name, image):
48+
app_id = Tns.get_app_id(app_name)
49+
Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, expected_image=image)
50+
Adb.stop_application(device_id=EMULATOR_ID, app_id=Tns.get_app_id(app_name))
51+
assert not Adb.is_application_running(device_id=EMULATOR_ID, app_id=app_id)
52+
53+
@staticmethod
54+
def ios_screen_match(sim_id, image):
55+
Device.screen_match(device_name=SIMULATOR_NAME, device_id=sim_id, expected_image=image)

0 commit comments

Comments
 (0)