def test_201_build_app_for_both_platforms(self): Tns.plugin_add(plugin_name='tns-plugin', path=self.app_name) # Verify files of the plugin assert File.exists( os.path.join(TnsPaths.get_app_node_modules_path(self.app_name), 'tns-plugin', 'index.js')) assert File.exists( os.path.join(TnsPaths.get_app_node_modules_path(self.app_name), 'tns-plugin', 'package.json')) assert File.exists( os.path.join(TnsPaths.get_app_node_modules_path(self.app_name), 'tns-plugin', 'test.android.js')) assert File.exists( os.path.join(TnsPaths.get_app_node_modules_path(self.app_name), 'tns-plugin', 'test.ios.js')) assert File.exists( os.path.join(TnsPaths.get_app_node_modules_path(self.app_name), 'tns-plugin', 'test2.android.xml')) assert File.exists( os.path.join(TnsPaths.get_app_node_modules_path(self.app_name), 'tns-plugin', 'test2.ios.xml')) Tns.build_ios(app_name=self.app_name) Tns.build_android(app_name=self.app_name) apk_path = os.path.join(TnsPaths.get_apk_path(self.app_name)) output = Adb.get_package_permission(apk_path) assert 'android.permission.READ_EXTERNAL_STORAGE' in output assert 'android.permission.WRITE_EXTERNAL_STORAGE' in output assert 'android.permission.INTERNET' in output
def test_002_build_ios(self, repo, org, text): Tns.build_ios(app_name=repo, release=True, for_device=True, bundle=True, aot=True, uglify=True)
def test_320_build_ios_with_custom_entitlements(self): # Add entitlements in app/App_Resources/iOS/app.entitlements source = os.path.join(TEST_RUN_HOME, 'assets', 'entitlements', 'app.entitlements') target = os.path.join(self.app_name, 'app', 'App_Resources', 'iOS', 'app.entitlements') File.copy(source, target) # Build again and verify entitlements are merged Tns.build_ios(self.app_name) entitlements_path = os.path.join(TnsPaths.get_platforms_ios_folder(self.app_name), self.app_name, 'TestApp.entitlements') assert File.exists(entitlements_path), "Entitlements file is missing!" entitlements_content = File.read(entitlements_path) assert '<key>aps-environment</key>' in entitlements_content, "Entitlements file content is wrong!" assert '<string>development</string>' in entitlements_content, "Entitlements file content is wrong!" # Install plugin with entitlements, build again and verify entitlements are merged plugin_path = os.path.join(TEST_RUN_HOME, 'assets', 'plugins', 'nativescript-test-entitlements-1.0.0.tgz') Npm.install(package=plugin_path, option='--save', folder=self.app_name) Tns.build_ios(self.app_name) entitlements_content = File.read(entitlements_path) assert '<key>aps-environment</key>' in entitlements_content, "Entitlements file content is wrong!" assert '<string>development</string>' in entitlements_content, "Entitlements file content is wrong!" assert '<key>inter-app-audio</key>' in entitlements_content, "Entitlements file content is wrong!" assert '<true/>' in entitlements_content, "Entitlements file content is wrong!" # Build in release, for device (provision without entitlements) result = Tns.build_ios(self.app_name, for_device=True, release=True, verify=False) assert "Provisioning profile" in result.output assert "doesn't include the aps-environment and inter-app-audio entitlements" in result.output
def test_311_plugin_platforms_should_not_exist_in_tnsmodules_ios(self): """ Test for issue https://github.com/NativeScript/nativescript-cli/issues/3932 """ Tns.platform_remove(app_name=self.app_name, platform=Platform.IOS) Tns.plugin_add(plugin_name='nativescript-ui-listview', path=self.app_name) Folder.clean(os.path.join(self.app_name, 'node_modules')) File.delete(os.path.join(self.app_name, 'package.json')) copy = os.path.join('assets', 'issues', 'nativescript-cli-3932', 'nativescript-ui-listview') paste = os.path.join(self.app_name, 'nativescript-ui-listview') Folder.copy(copy, paste) copy = os.path.join('assets', 'issues', 'nativescript-cli-3932', 'package.json') paste = os.path.join(self.app_name) File.copy(copy, paste) Tns.platform_add_ios(app_name=self.app_name, framework_path=Settings.IOS.FRAMEWORK_PATH) folder_path = os.path.join(self.app_name, 'nativescript-ui-listview') Npm.install(option='--ignore-scripts', folder=folder_path) Tns.build_ios(app_name=self.app_name, bundle=False) app_path = os.path.join( TnsPaths.get_platforms_ios_folder(self.app_name)) assert not File.exists( os.path.join(app_path, 'nativescript-ui-listview', 'node_modules', 'nativescript-ui-core', 'platforms'))
def test_190_build_ios_distribution_provisions(self): Tns.platform_remove(self.app_name, platform=Platform.ANDROID) result = Tns.exec_command(command='build ios --provision', path=self.app_name) assert "Provision Name" in result.output assert "Provision UUID" in result.output assert "App Id" in result.output assert "Team" in result.output assert "Type" in result.output assert "Due" in result.output assert "Devices" in result.output assert Settings.IOS.PROVISIONING in result.output assert Settings.IOS.DISTRIBUTION_PROVISIONING in result.output assert Settings.IOS.DEVELOPMENT_TEAM in result.output # Build with correct distribution provision if Xcode.get_version() < 11: Log.info( "Skip this check because we use new type of certificated that require Xcode 11." ) else: Tns.build_ios(self.app_name, provision=Settings.IOS.DISTRIBUTION_PROVISIONING, for_device=True, release=True) # Verify that passing wrong provision shows user friendly error result = Tns.build_ios(self.app_name, provision="fake", verify=False) assert "Failed to find mobile provision with UUID or Name: fake" in result.output
def test_300_build_demo(self): # TODO: Run npm scripts from plugin seed (build plugin, link plugin and then build the app). Tns.plugin_create(self.plugin_name, type_script=True) demo_path = os.path.join(self.plugin_name, 'demo') Tns.build_android(demo_path) if Settings.HOST_OS is OSType.OSX: Tns.build_ios(demo_path)
def test_201_build_ios_release(self): Tns.build_ios(app_name=self.ng_app, release=True, for_device=True, bundle=True, aot=True, uglify=True)
def setUpClass(cls): TnsTest.setUpClass() Docker.start() # Create JS app and copy to temp data folder Tns.create(app_name=cls.js_app, template=Template.HELLO_WORLD_JS.local_package, update=True) Tns.platform_add_android( app_name=cls.js_app, framework_path=Settings.Android.FRAMEWORK_PATH) if Settings.HOST_OS is OSType.OSX: Tns.platform_add_ios(app_name=cls.js_app, framework_path=Settings.IOS.FRAMEWORK_PATH) # Create NG app and copy to temp data folder Tns.create(app_name=cls.ng_app, template=Template.HELLO_WORLD_NG.local_package, update=True) Tns.platform_add_android( app_name=cls.ng_app, framework_path=Settings.Android.FRAMEWORK_PATH) if Settings.HOST_OS is OSType.OSX: Tns.platform_add_ios(app_name=cls.ng_app, framework_path=Settings.IOS.FRAMEWORK_PATH) # Build apps Tns.build_android(cls.js_app, release=True, bundle=True, aot=True, uglify=True, snapshot=True) Tns.build_android(cls.ng_app, release=True, bundle=True, aot=True, uglify=True, snapshot=True) if Settings.HOST_OS == OSType.OSX: Tns.build_ios(cls.js_app, release=True, bundle=True, aot=True, uglify=True, for_device=True) Tns.build_ios(cls.ng_app, release=True, bundle=True, aot=True, uglify=True, for_device=True)
def __create_and_build_app(self): Tns.create(app_name=self.app_name, template=Template.HELLO_WORLD_JS.local_package, update=False) Tns.platform_add_android( app_name=self.app_name, framework_path=Settings.Android.FRAMEWORK_PATH) if Settings.HOST_OS == OSType.OSX: Tns.platform_add_ios(app_name=self.app_name, framework_path=Settings.IOS.FRAMEWORK_PATH) Tns.build_android(self.app_name) if Settings.HOST_OS == OSType.OSX: Tns.build_ios(self.app_name)
def test_001_build_ios(self): Tns.platform_remove(self.app_name, platform=Platform.ANDROID) Tns.build_ios(self.app_name) Tns.build_ios(self.app_name, release=True) Tns.build_ios(self.app_name, for_device=True) Tns.build_ios(self.app_name, for_device=True, release=True) assert not File.exists(os.path.join(TnsPaths.get_platforms_ios_folder(self.app_name), '*.aar')) assert not File.exists(os.path.join(TnsPaths.get_platforms_ios_npm_modules(self.app_name), '*.framework')) # Verify ipa has both armv7 and arm64 archs ipa_path = TnsPaths.get_ipa_path(app_name=self.app_name, release=True, for_device=True) run("mv " + ipa_path + " TestApp-ipa.tgz") run("unzip -o TestApp-ipa.tgz") result = run("lipo -info Payload/TestApp.app/TestApp") Folder.clean("Payload") assert "Architectures in the fat file: Payload/TestApp.app/TestApp are: armv7 arm64" in result.output
def test_401_plugin_add_invalid_plugin(self): Tns.platform_remove(app_name=self.app_name, platform=Platform.IOS) Tns.platform_remove(app_name=self.app_name, platform=Platform.ANDROID) result = Tns.plugin_add(plugin_name='wd', path=self.app_name, verify=False) assert 'wd is not a valid NativeScript plugin' in result.output assert 'Verify that the plugin package.json file ' + \ 'contains a nativescript key and try again' in result.output Tns.platform_add_android( self.app_name, framework_path=Settings.Android.FRAMEWORK_PATH) Tns.platform_add_ios(self.app_name, framework_path=Settings.IOS.FRAMEWORK_PATH) # Verify iOS only plugin result = Tns.plugin_add(plugin_name='[email protected]', path=self.app_name) assert 'tns-plugin is not supported for android' in result.output assert 'Successfully installed plugin tns-plugin' in result.output # Verify Android only plugin result = Tns.plugin_add(plugin_name='acra-telerik-analytics', path=self.app_name) assert 'acra-telerik-analytics is not supported for ios' in result.output assert 'Successfully installed plugin acra-telerik-analytics' in result.output Tns.build_ios(app_name=self.app_name, bundle=False) ios_path = os.path.join( TnsPaths.get_platforms_ios_folder(self.app_name)) assert not File.pattern_exists(ios_path, pattern='*.aar') assert not File.pattern_exists(ios_path, pattern='*acra*') Tns.build_android(app_name=self.app_name, bundle=False) android_path = os.path.join( TnsPaths.get_platforms_android_folder(self.app_name)) assert File.pattern_exists(android_path, pattern='*.aar') assert File.pattern_exists(android_path, pattern='*acra*')
def test_202_plugin_add_pod_google_maps_after_platform_add_ios(self): plugin_path = os.path.join(Settings.TEST_RUN_HOME, 'assets', 'plugins', 'CocoaPods', 'googlesdk.tgz') result = Tns.plugin_add(plugin_path, path=Settings.AppName.DEFAULT) assert "Successfully installed plugin googlesdk." in result.output assert File.exists( os.path.join(TnsPaths.get_app_node_modules_path(self.app_name), 'googlesdk', 'package.json')) assert File.exists( os.path.join(TnsPaths.get_app_node_modules_path(self.app_name), 'googlesdk', 'platforms', 'ios', 'Podfile')) output = File.read(os.path.join(self.app_name, 'package.json')) assert self.app_identifier in output.lower() assert "dependencies" in output assert "googlesdk" in output result = Tns.build_ios(self.app_name) assert "Installing pods..." in result.output output = File.read( os.path.join(TnsPaths.get_platforms_ios_folder(self.app_name), 'Podfile')) assert "source 'https://github.com/CocoaPods/Specs.git'" in output assert "platform :ios, '8.1'" in output assert "pod 'GoogleMaps'" in output assert "use_frameworks!" in output output = File.read( os.path.join(TnsPaths.get_platforms_ios_folder(self.app_name), 'TestApp.xcworkspace', 'contents.xcworkspacedata')) assert "location = \"group:TestApp.xcodeproj\">" in output assert "location = \"group:Pods/Pods.xcodeproj\">" in output assert Folder.exists( os.path.join(TnsPaths.get_platforms_ios_folder(self.app_name), 'Pods', 'Pods.xcodeproj')) # This deployment target comes from the CLI output = File.read( os.path.join(TnsPaths.get_platforms_ios_folder(self.app_name), 'TestApp.xcodeproj', 'project.pbxproj')) assert "IPHONEOS_DEPLOYMENT_TARGET = 9.0;" in output
def test_101_plugin_add_prepare_verify_app_ios(self): Tns.plugin_add(plugin_name='tns-plugin', path=self.app_name) Tns.build_ios(app_name=self.app_name) path_app = os.path.join(TnsPaths.get_ipa_path(self.app_name)) assert Folder.exists(path_app)