Skip to content
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
95 changes: 95 additions & 0 deletions tests/device/debug_device_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import os

from core.base_class.BaseClass import BaseClass
from core.device.device import Device
from core.chrome.chrome import Chrome
from core.osutils.file import File
from core.settings.settings import ANDROID_PACKAGE, IOS_PACKAGE
from core.tns.tns import Tns
from core.tns.tns_platform_type import Platform
from core.osutils.command import run

class DebugBothPlatformsTests(BaseClass):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PEP8 require 2 blank lines between imports and class DebugBothPlatformsTests(BaseClass):

ANDROID_DEVICES = Device.get_ids(platform=Platform.ANDROID, include_emulators=True)
IOS_DEVICES = Device.get_ids(platform=Platform.IOS)
DEVICE_ID = Device.get_id(platform=Platform.ANDROID)

@classmethod
def setUpClass(cls):
BaseClass.setUpClass(cls.__name__)
Device.ensure_available(platform=Platform.ANDROID)
Device.ensure_available(platform=Platform.IOS)
Device.uninstall_app(app_prefix="org.nativescript.", platform=Platform.ANDROID)
Device.uninstall_app(app_prefix="org.nativescript.", platform=Platform.IOS)

Tns.create_app(cls.app_name,
attributes={'--template': os.path.join('data', 'apps', 'livesync-hello-world.tgz')},
update_modules=True)
Tns.platform_add_android(attributes={'--path': cls.app_name, '--frameworkPath': ANDROID_PACKAGE})
Tns.platform_add_ios(attributes={'--path': cls.app_name, '--frameworkPath': IOS_PACKAGE})

def setUp(self):
BaseClass.setUp(self)
Tns.kill()

def tearDown(self):
Tns.kill()
BaseClass.tearDown(self)

@classmethod
def tearDownClass(cls):
BaseClass.tearDownClass()

def __verify_debugger_start(self, log):
strings = ['NativeScript Debugger started', 'To start debugging, open the following URL in Chrome',
'chrome-devtools', 'localhost:4000']
Tns.wait_for_log(log_file=log, string_list=strings, timeout=180, check_interval=10, clean_log=False)
output = File.read(file_path=log, print_content=True)
assert "closed" not in output
assert "detached" not in output
assert "did not start in time" not in output

def __verify_debugger_attach(self, log):
strings = ['To start debugging', 'Chrome', 'chrome-devtools', 'localhost:4000']
Tns.wait_for_log(log_file=log, string_list=strings, timeout=180, check_interval=10, clean_log=False)
output = File.read(file_path=log, print_content=True)
assert "closed" not in output
assert "detached" not in output
assert "did not start in time" not in output
assert "NativeScript Debugger started" not in output

def test_001_tns_run_android(self):
log = Tns.debug_android(attributes={'--path': self.app_name})
strings = ['Successfully installed on device with identifier']
for android_device_id in self.ANDROID_DEVICES:
strings.append(android_device_id)
Tns.wait_for_log(log_file=log, string_list=strings, timeout=120, check_interval=10, clean_log=False)

# Verify app is deployed and running on all available android devices
for device_id in self.ANDROID_DEVICES:
Device.wait_until_app_is_running(app_id=Tns.get_app_id(self.app_name), device_id=device_id, timeout=30)

log = Tns.debug_android(attributes={'--path': self.app_name})
self.__verify_debugger_start(log)

# Get Chrome URL and open it
url = run(command="grep chrome-devtools " + log)
Chrome.start(url)

def test_002_tns_run_ios(self):
log = Tns.debug_ios(attributes={'--path': self.app_name})
strings = ['Successfully installed on device with identifier']
for ios_device_id in self.IOS_DEVICES:
strings.append(ios_device_id)
Tns.wait_for_log(log_file=log, string_list=strings, timeout=120, check_interval=10, clean_log=False)

# Verify app is deployed and running on all available android devices
for device_id in self.IOS_DEVICES:
Device.wait_until_app_is_running(app_id=Tns.get_app_id(self.app_name), device_id=device_id, timeout=30)

log = Tns.debug_ios(attributes={'--path': self.app_name})
self.__verify_debugger_start(log)

# Get Chrome URL and open it
url = run(command="grep chrome-devtools " + log)
Chrome.start(url)
29 changes: 28 additions & 1 deletion tests/nsconfig/create_apps/create_ns_config_apps.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import os
import unittest

from core.npm.npm import Npm
from core.osutils.file import File
from core.osutils.folder import Folder
from core.settings.settings import TEST_RUN_HOME
from core.settings.settings import TEST_RUN_HOME, TYPESCRIPT_PACKAGE, WEBPACK_PACKAGE, SASS_PACKAGE
from core.tns.tns import Tns


Expand Down Expand Up @@ -359,6 +360,19 @@ def createAppsNG(cls):
# Initial create of all projects
app_name_change_app_location_ng = "ChangeAppLocationNG"
Tns.create_app_ng(app_name=app_name_change_app_location_ng)
Tns.update_angular(app_name_change_app_location_ng)
Npm.uninstall(package="nativescript-dev-typescript", option='--save-dev',
folder=app_name_change_app_location_ng)
Npm.install(package=TYPESCRIPT_PACKAGE, option='--save-dev', folder=app_name_change_app_location_ng)
Npm.uninstall(package="nativescript-dev-webpack", option='--save-dev', folder=app_name_change_app_location_ng)

# Old webpack adds old webpack config. Cleanup to make sure we get the new config.
File.remove(os.path.join(TEST_RUN_HOME, app_name_change_app_location_ng, 'webpack.config.js'))
Tns.install_npm(package=WEBPACK_PACKAGE, option='--save-dev', folder=app_name_change_app_location_ng)
Npm.uninstall(package="nativescript-dev-sass", option='--save-dev', folder=app_name_change_app_location_ng)
Npm.install(package=SASS_PACKAGE, option='--save-dev', folder=app_name_change_app_location_ng)
File.remove(TEST_RUN_HOME + "/" + app_name_change_app_location_ng + "/"
+ "node_modules/.bin/babylon")

@dtopuzov dtopuzov Jun 7, 2018 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PEP8 warning for visual indent, can be fixed by auto formatting shortcuts.


# Create the other projects using the initial setup but in different folder
app_name_change_app_location_and_name_ng = "ChangeAppLocationAndNameNG"
Expand Down Expand Up @@ -513,6 +527,19 @@ def createAppsLiveSyncNG(cls):
# Initial create of all projects
app_name_change_app_location_ls_ng = "ChangeAppLocationLSNG"
Tns.create_app_ng(app_name=app_name_change_app_location_ls_ng)
Tns.update_angular(app_name_change_app_location_ls_ng)
Npm.uninstall(package="nativescript-dev-typescript", option='--save-dev',
folder=app_name_change_app_location_ls_ng)
Npm.install(package=TYPESCRIPT_PACKAGE, option='--save-dev', folder=app_name_change_app_location_ls_ng)
Npm.uninstall(package="nativescript-dev-webpack", option='--save-dev', folder=app_name_change_app_location_ls_ng)

# Old webpack adds old webpack config. Cleanup to make sure we get the new config.
File.remove(os.path.join(TEST_RUN_HOME, app_name_change_app_location_ls_ng, 'webpack.config.js'))
Tns.install_npm(package=WEBPACK_PACKAGE, option='--save-dev', folder=app_name_change_app_location_ls_ng)
Npm.uninstall(package="nativescript-dev-sass", option='--save-dev', folder=app_name_change_app_location_ls_ng)
Npm.install(package=SASS_PACKAGE, option='--save-dev', folder=app_name_change_app_location_ls_ng)
File.remove(TEST_RUN_HOME + "/" + app_name_change_app_location_ls_ng + "/"
+ "node_modules/.bin/babylon")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PEP8 warning for visual indent, can be fixed by auto formatting shortcuts.


# Copy the app folder (app is modified in order to get some console logs on loaded)
source = os.path.join('data', 'apps', 'livesync-hello-world-ng', 'app')
Expand Down