|
| 1 | +import os |
| 2 | +import unittest |
| 3 | + |
| 4 | +from core.base_test.tns_run_test import TnsRunTest |
| 5 | +from core.enums.os_type import OSType |
| 6 | +from core.enums.platform_type import Platform |
| 7 | +from core.settings import Settings |
| 8 | +from core.utils.npm import Npm |
| 9 | +from data.changes import Changes |
| 10 | +from data.const import Colors |
| 11 | +from data.templates import Template |
| 12 | +from products.nativescript.run_type import RunType |
| 13 | +from products.nativescript.tns import Tns |
| 14 | +from products.nativescript.tns_logs import TnsLogs |
| 15 | + |
| 16 | + |
| 17 | +class TestRunWithScopePackageOnly(TnsRunTest): |
| 18 | + app_name = Settings.AppName.DEFAULT |
| 19 | + app_path = os.path.join(Settings.TEST_RUN_HOME, Settings.AppName.DEFAULT) |
| 20 | + @classmethod |
| 21 | + def setUpClass(cls): |
| 22 | + TnsRunTest.setUpClass() |
| 23 | + |
| 24 | + # Create app |
| 25 | + Tns.create(app_name=cls.app_name, template=Template.HELLO_WORLD_TS.local_package, update=True) |
| 26 | + Npm.uninstall(package='tns-core-modules', option='--save', folder=cls.app_path) |
| 27 | + Npm.install(package=Settings.Packages.NATIVESCRIPT_CORE, option='--save --save-exact', folder=cls.app_path) |
| 28 | + Tns.platform_add_android(app_name=cls.app_name, framework_path=Settings.Android.FRAMEWORK_PATH) |
| 29 | + if Settings.HOST_OS is OSType.OSX: |
| 30 | + Tns.platform_add_ios(app_name=cls.app_name, framework_path=Settings.IOS.FRAMEWORK_PATH) |
| 31 | + |
| 32 | + def setUp(self): |
| 33 | + TnsRunTest.setUp(self) |
| 34 | + |
| 35 | + @classmethod |
| 36 | + def tearDownClass(cls): |
| 37 | + TnsRunTest.tearDownClass() |
| 38 | + |
| 39 | + def test_100_run_android(self): |
| 40 | + self.run_app(Platform.ANDROID, self.emu) |
| 41 | + |
| 42 | + @unittest.skipIf(Settings.HOST_OS != OSType.OSX, 'iOS tests can be executed only on macOS.') |
| 43 | + def test_100_run_ios(self): |
| 44 | + self.run_app(Platform.IOS, self.sim) |
| 45 | + |
| 46 | + def run_app(self, platform, device): |
| 47 | + result = Tns.run(app_name=self.app_name, platform=platform, emulator=True, wait=False) |
| 48 | + strings = TnsLogs.run_messages(app_name=self.app_name, platform=platform, run_type=RunType.UNKNOWN, |
| 49 | + device=device) |
| 50 | + TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings, timeout=240) |
| 51 | + |
| 52 | + # Verify it looks properly |
| 53 | + device.wait_for_text(text=Changes.TSHelloWord.TS.old_text) |
| 54 | + device.wait_for_text(text=Changes.TSHelloWord.XML.old_text) |
| 55 | + blue_count = device.get_pixels_by_color(color=Colors.LIGHT_BLUE) |
| 56 | + assert blue_count > 100, 'Failed to find blue color on {0}'.format(device.name) |
0 commit comments