Beispiel #1
0
 def platform_added(app_name, platform, output, version=None):
     platform_string = str(platform)
     # Verify output
     assert 'Platform {0} successfully added'.format(
         platform_string) in output
     # Verify platform folder
     if platform == Platform.ANDROID:
         assert Folder.exists(
             TnsPaths.get_platforms_android_folder(app_name))
     else:
         assert Folder.exists(TnsPaths.get_platforms_ios_folder(app_name))
     # Verify package.json
     app_path = os.path.join(Settings.TEST_RUN_HOME, app_name)
     package_json = os.path.join(app_path, 'package.json')
     json = JsonUtils.read(package_json)
     if version is not None:
         if 'next' in version:
             assert json['nativescript'][
                 'tns-' + platform_string]['version'] is not None
         if 'rc' in version:
             assert 'rc' in json['nativescript']['tns-' +
                                                 platform_string]['version']
         else:
             assert version in json['nativescript'][
                 'tns-' + platform_string]['version']
     else:
         assert json['nativescript']['tns-' + platform_string]['version'] is not None, \
             'tns-' + platform_string + ' not available in package.json of the app.'
Beispiel #2
0
    def test_160_platform_clean_android(self):
        """Prepare after `platform clean` should add the same version that was before clean"""

        # Create project with [email protected]
        Tns.platform_add_android(self.app_name, version='5.0.0')

        # Clean platform and verify platform is 5.0.0
        Tns.platform_clean(self.app_name, platform=Platform.ANDROID)
        package_json = os.path.join(self.app_name, 'package.json')
        json = JsonUtils.read(package_json)
        assert json['nativescript']['tns-android']['version'] == '5.0.0'
Beispiel #3
0
    def create_app(app_data, shared, sample, theme, style, prefix, source_dir, webpack):
        # Create shared project with sample data
        result = NG.new(collection=NS_SCHEMATICS, project=NGNewTests.app_name, theme=theme, shared=shared,
                        sample=sample, style=style, prefix=prefix, source_dir=source_dir, webpack=webpack)

        # Verify valid {N} app is created
        # Temporary do not assert theme is created because in schematics we still use nativescript-theme-core@1
        # TODO: Replace with theme=theme when schematics use @nativescript/theme
        TnsAssert.created(app_name=NGNewTests.app_name, app_data=app_data, theme=False, webpack=webpack)
        assert 'Directory is already under version control. Skipping initialization of git.' in result.output, \
            'Git init should be skipped because app is created already existing repo (the one with tests).'

        # Check sample
        if sample:
            # TODO: Implement it
            pass

        # Check theme
        if theme:
            assert App.is_dependency(app_name=NGNewTests.app_name, dependency='@nativescript/theme')
        else:
            assert not App.is_dependency(app_name=NGNewTests.app_name, dependency='@nativescript/theme')

        # Check styling
        if style is None or style is StylingType.CSS:
            assert 'app.css' in result.output
        else:
            assert 'app.android.scss' in result.output
            assert 'app.ios.scss' in result.output
            assert '_app-common.scss' in result.output

        # Check webpack
        if webpack:
            assert App.is_dev_dependency(app_name=NGNewTests.app_name, dependency='nativescript-dev-webpack')
        else:
            assert not App.is_dev_dependency(app_name=NGNewTests.app_name, dependency='nativescript-dev-webpack')

        # Check prefix
        if prefix is None:
            prefix = 'app'
        path = os.path.join(Settings.TEST_RUN_HOME, NGNewTests.app_name, 'angular.json')
        actual_prefix = JsonUtils.read(file_path=path)['projects'][NGNewTests.app_name]['prefix']
        assert str(actual_prefix) == prefix, 'Prefix not set in angular.json'

        # Check source dir exists (applicable only for shared projects).
        if shared:
            if source_dir is None:
                source_dir = 'src'
            assert Folder.exists(os.path.join(Settings.TEST_RUN_HOME, NGNewTests.app_name, source_dir))
Beispiel #4
0
 def platform_removed(app_name, platform, output):
     platform_string = str(platform)
     # Verify output
     assert 'Platform {0} successfully removed'.format(
         platform_string) in output
     # Verify package.json
     app_path = TnsPaths.get_app_path(app_name)
     package_json = os.path.join(app_path, 'package.json')
     json = JsonUtils.read(package_json)
     assert not 'tns-' + platform_string in json
     if platform == Platform.ANDROID:
         assert not Folder.exists(
             TnsPaths.get_platforms_android_folder(app_name))
     else:
         assert not Folder.exists(
             TnsPaths.get_platforms_ios_folder(app_name))
 def platform_clean(app_name, platform=Platform.NONE, verify=True):
     platform_string = str(platform)
     command = 'platform clean ' + platform_string
     result = Tns.exec_command(command=command, path=app_name)
     if verify:
         assert "Platform {0} successfully removed".format(
             platform_string) in result.output
         assert "error" not in result.output
         if platform is Platform.ANDROID:
             assert Folder.exists(
                 TnsPaths.get_platforms_android_folder(app_name))
         if platform is Platform.IOS:
             assert Folder.exists(
                 TnsPaths.get_platforms_ios_folder(app_name))
         assert "Platform {0} successfully added".format(
             platform_string) in result.output
         package_json = os.path.join(TnsPaths.get_app_path(app_name),
                                     'package.json')
         json = JsonUtils.read(package_json)
         assert json['nativescript']['tns-' +
                                     platform_string]['version'] is not None
 def get_package_json(app_name):
     return JsonUtils.read(
         os.path.join(Settings.TEST_RUN_HOME, app_name, 'package.json'))
Beispiel #7
0
 def get_actual_result(template, platform, entry):
     result_file = Helpers.get_result_file_name(template, platform)
     return JsonUtils.read(result_file)[entry]
Beispiel #8
0
from core.enums.platform_type import Platform
from core.settings import Settings
from core.utils.file_utils import Folder, File
from core.utils.gradle import Gradle
from core.utils.json_utils import JsonUtils
from core.utils.npm import Npm
from core.utils.perf_utils import PerfUtils
from core.utils.xcode import Xcode
from data.changes import Changes, Sync
from data.templates import Template
from products.nativescript.tns import Tns

RETRY_COUNT = 3
TOLERANCE = 0.20
APP_NAME = Settings.AppName.DEFAULT
EXPECTED_RESULTS = JsonUtils.read(
    os.path.join(Settings.TEST_RUN_HOME, 'tests', 'perf', 'data.json'))


# noinspection PyMethodMayBeStatic,PyUnusedLocal
class PrepareAndBuildPerfTests(TnsTest):
    TEST_DATA = [
        ('hello-world-js', Template.HELLO_WORLD_JS.local_package,
         Changes.JSHelloWord.JS),
        ('hello-world-ng', Template.HELLO_WORLD_NG.local_package,
         Changes.NGHelloWorld.TS),
        ('master-detail-ng', Template.MASTER_DETAIL_NG.local_package,
         Changes.MasterDetailNG.TS),
    ]

    @classmethod
    def setUpClass(cls):