diff --git a/.prettierrc.json b/.prettierrc.json index 958685113..bc8dae834 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -1,6 +1,6 @@ { "useTabs": true, - "printWidth": 90, + "printWidth": 600, "tabWidth": 2, "singleQuote": true } diff --git a/apps/automated/src/application/application-tests.android.ts b/apps/automated/src/application/application-tests.android.ts index 0f4c62f34..d927fb1cc 100644 --- a/apps/automated/src/application/application-tests.android.ts +++ b/apps/automated/src/application/application-tests.android.ts @@ -23,55 +23,35 @@ if (androidApp.foregroundActivity === androidApp.startActivity) { // >> application-app-android-broadcast //// Register the broadcast receiver if (androidApp) { - Application.android.registerBroadcastReceiver( - android.content.Intent.ACTION_BATTERY_CHANGED, - function onReceiveCallback( - context: android.content.Context, - intent: android.content.Intent - ) { - const level = intent.getIntExtra(android.os.BatteryManager.EXTRA_LEVEL, -1); - const scale = intent.getIntExtra(android.os.BatteryManager.EXTRA_SCALE, -1); - const percent = (level / scale) * 100.0; - ////console.log("Battery: " + percent + "%"); - } - ); + Application.android.registerBroadcastReceiver(android.content.Intent.ACTION_BATTERY_CHANGED, function onReceiveCallback(context: android.content.Context, intent: android.content.Intent) { + const level = intent.getIntExtra(android.os.BatteryManager.EXTRA_LEVEL, -1); + const scale = intent.getIntExtra(android.os.BatteryManager.EXTRA_SCALE, -1); + const percent = (level / scale) * 100.0; + ////console.log("Battery: " + percent + "%"); + }); } //// When no longer needed, unregister the broadcast receiver if (androidApp) { - Application.android.unregisterBroadcastReceiver( - android.content.Intent.ACTION_BATTERY_CHANGED - ); + Application.android.unregisterBroadcastReceiver(android.content.Intent.ACTION_BATTERY_CHANGED); } // << application-app-android-broadcast export function testAndroidApplicationInitialized() { TKUnit.assert(Application.android, 'Android application not initialized.'); TKUnit.assert(Application.android.context, 'Android context not initialized.'); - TKUnit.assert( - Application.android.foregroundActivity, - 'Android foregroundActivity not initialized.' - ); + TKUnit.assert(Application.android.foregroundActivity, 'Android foregroundActivity not initialized.'); TKUnit.assert( // @ts-expect-error Application.android.foregroundActivity.isNativeScriptActivity, 'Android foregroundActivity.isNativeScriptActivity is false.' ); - TKUnit.assert( - Application.android.startActivity, - 'Android startActivity not initialized.' - ); + TKUnit.assert(Application.android.startActivity, 'Android startActivity not initialized.'); TKUnit.assert(Application.android.nativeApp, 'Android nativeApp not initialized.'); TKUnit.assert(Application.android.orientation, 'Android orientation not initialized.'); TKUnit.assert(Application.android.packageName, 'Android packageName not initialized.'); - TKUnit.assert( - Application.android.systemAppearance, - 'Android system appearance not initialized.' - ); + TKUnit.assert(Application.android.systemAppearance, 'Android system appearance not initialized.'); } export function testSystemAppearance() { - TKUnit.assert( - Application.android.systemAppearance, - 'System appearance not initialized.' - ); + TKUnit.assert(Application.android.systemAppearance, 'System appearance not initialized.'); } diff --git a/apps/automated/src/file-system/file-system-tests.ts b/apps/automated/src/file-system/file-system-tests.ts index ef6bdae2f..3a2ba03c8 100644 --- a/apps/automated/src/file-system/file-system-tests.ts +++ b/apps/automated/src/file-system/file-system-tests.ts @@ -210,10 +210,7 @@ export var testFileReadWriteBinary = function () { if (Device.os === platformNames.ios) { TKUnit.assertTrue(source.isEqualToData(destination)); } else { - TKUnit.assertEqual( - new java.io.File(sourceFile.path).length(), - new java.io.File(destinationFile.path).length() - ); + TKUnit.assertEqual(new java.io.File(sourceFile.path).length(), new java.io.File(destinationFile.path).length()); } destinationFile.removeSync(); @@ -241,10 +238,7 @@ export var testFileReadWriteBinaryAsync = function () { if (Device.os === platformNames.ios) { TKUnit.assertTrue(source.isEqualToData(destination)); } else { - TKUnit.assertEqual( - new java.io.File(sourceFile.path).length(), - new java.io.File(destinationFile.path).length() - ); + TKUnit.assertEqual(new java.io.File(sourceFile.path).length(), new java.io.File(destinationFile.path).length()); } destinationFile.removeSync(); @@ -277,19 +271,13 @@ export var testGetKnownFolders = function () { var documents = fs.knownFolders.documents(); // >> (hide) TKUnit.assert(documents, 'Could not retrieve the Documents known folder.'); - TKUnit.assert( - documents.isKnown, - 'The Documents folder should have its isKnown property set to true.' - ); + TKUnit.assert(documents.isKnown, 'The Documents folder should have its isKnown property set to true.'); // << (hide) // Getting the application's 'temp' folder. var temp = fs.knownFolders.temp(); // >> (hide) TKUnit.assert(temp, 'Could not retrieve the Temporary known folder.'); - TKUnit.assert( - temp.isKnown, - 'The Temporary folder should have its isKnown property set to true.' - ); + TKUnit.assert(temp.isKnown, 'The Temporary folder should have its isKnown property set to true.'); // << (hide) // << file-system-known-folders }; @@ -307,30 +295,13 @@ function _testIOSSpecificKnownFolder(knownFolderName: string) { if (isIOS) { testFunc(); if (knownFolder) { - TKUnit.assertTrue( - knownFolder.isKnown, - `The ${knownFolderName} folder should have its "isKnown" property set to true.` - ); - TKUnit.assertNotNull( - createdFile, - `Could not create a new file in the ${knownFolderName} known folder.` - ); - TKUnit.assertTrue( - fs.File.exists(createdFile.path), - `Could not create a new file in the ${knownFolderName} known folder.` - ); - TKUnit.assertEqual( - createdFile.readTextSync(), - 'some text', - `The contents of the new file created in the ${knownFolderName} known folder are not as expected.` - ); + TKUnit.assertTrue(knownFolder.isKnown, `The ${knownFolderName} folder should have its "isKnown" property set to true.`); + TKUnit.assertNotNull(createdFile, `Could not create a new file in the ${knownFolderName} known folder.`); + TKUnit.assertTrue(fs.File.exists(createdFile.path), `Could not create a new file in the ${knownFolderName} known folder.`); + TKUnit.assertEqual(createdFile.readTextSync(), 'some text', `The contents of the new file created in the ${knownFolderName} known folder are not as expected.`); } } else { - TKUnit.assertThrows( - testFunc, - `Trying to retrieve the ${knownFolderName} known folder on a platform different from iOS should throw!`, - `The "${knownFolderName}" known folder is available on iOS only!` - ); + TKUnit.assertThrows(testFunc, `Trying to retrieve the ${knownFolderName} known folder on a platform different from iOS should throw!`, `The "${knownFolderName}" known folder is available on iOS only!`); } } @@ -440,10 +411,7 @@ export var testGetParent = function () { // The parent folder of the file would be the documents folder. var parent = file.parent; // >> (hide) - TKUnit.assert( - documents === parent, - 'The parent folder should be the Documents folder.' - ); + TKUnit.assert(documents === parent, 'The parent folder should be the Documents folder.'); file.remove(); // << (hide) // << file-system-parent @@ -621,11 +589,7 @@ export var testFolderClear = function () { ); // >> (hide) folder.getEntities().then(function (entities) { - TKUnit.assertEqual( - entities.length, - 0, - `${entities.length} entities left after clearing a folder.` - ); + TKUnit.assertEqual(entities.length, 0, `${entities.length} entities left after clearing a folder.`); folder.remove(); }); // << (hide) @@ -669,10 +633,7 @@ export function test_FSEntity_Properties() { TKUnit.assert(file.extension === '.txt', 'FileEntity.extension not working.'); TKUnit.assert(file.isLocked === false, 'FileEntity.isLocked not working.'); - TKUnit.assert( - file.lastModified instanceof Date, - 'FileEntity.lastModified not working.' - ); + TKUnit.assert(file.lastModified instanceof Date, 'FileEntity.lastModified not working.'); TKUnit.assert(file.size === 0, 'FileEntity.size not working.'); TKUnit.assert(file.name === 'Test_File.txt', 'FileEntity.name not working.'); TKUnit.assert(file.parent === documents, 'FileEntity.parent not working.'); @@ -711,12 +672,7 @@ export function test_UnlockAfterWrite(done) { export function test_CreateParentOnNewFile(done) { var documentsFolderName = fs.knownFolders.documents().path; - var tempFileName = fs.path.join( - documentsFolderName, - 'folder1', - 'folder2', - 'Test_File_Create_Parent.txt' - ); + var tempFileName = fs.path.join(documentsFolderName, 'folder1', 'folder2', 'Test_File_Create_Parent.txt'); var file = fs.File.fromPath(tempFileName); file .writeText('Hello World!') @@ -731,17 +687,11 @@ export function test_FolderClear_RemovesEmptySubfolders(done) { let documents = fs.knownFolders.documents(); let rootFolder = documents.getFolder('rootFolder'); let emptySubfolder = rootFolder.getFolder('emptySubfolder'); - TKUnit.assertTrue( - fs.Folder.exists(emptySubfolder.path), - 'emptySubfolder should exist before parent folder is cleared.' - ); + TKUnit.assertTrue(fs.Folder.exists(emptySubfolder.path), 'emptySubfolder should exist before parent folder is cleared.'); rootFolder .clear() .then(() => { - TKUnit.assertFalse( - fs.File.exists(emptySubfolder.path), - 'emptySubfolder should not exist after parent folder was cleared.' - ); + TKUnit.assertFalse(fs.File.exists(emptySubfolder.path), 'emptySubfolder should not exist after parent folder was cleared.'); rootFolder.remove(); done(); }) @@ -750,14 +700,10 @@ export function test_FolderClear_RemovesEmptySubfolders(done) { export function test_FileCopy(done) { const now = Date.now(); - const tempFile = fs.File.fromPath( - fs.path.join(fs.knownFolders.temp().path, `${now}.txt`) - ); + const tempFile = fs.File.fromPath(fs.path.join(fs.knownFolders.temp().path, `${now}.txt`)); const content = 'Hello World: ' + now; tempFile.writeTextSync(content); - const tempCopy = fs.File.fromPath( - fs.path.join(fs.knownFolders.temp().path, `${now}-copy.txt`) - ); + const tempCopy = fs.File.fromPath(fs.path.join(fs.knownFolders.temp().path, `${now}-copy.txt`)); tempFile .copy(tempCopy.path) .then(() => { @@ -788,30 +734,18 @@ export function testAndroidCreate() { }; if (isAndroid) { const file = testFunc(); - TKUnit.assertEqual( - file.readTextSync(), - 'some text', - `The contents of the new file created in the 'AndroidDirectory.DOWNLOADS' folder are not as expected.` - ); + TKUnit.assertEqual(file.readTextSync(), 'some text', `The contents of the new file created in the 'AndroidDirectory.DOWNLOADS' folder are not as expected.`); file.removeSync(); TKUnit.assertTrue(!fs.File.exists(file.path)); } else { - TKUnit.assertThrows( - testFunc, - `Trying to retrieve createFile on a platform different from Android should throw!`, - `createFile is available on Android only!` - ); + TKUnit.assertThrows(testFunc, `Trying to retrieve createFile on a platform different from Android should throw!`, `createFile is available on Android only!`); } } export function test_FileAppend(done) { const content = 'Hello World'; - const hello_world = global.isIOS - ? NSString.stringWithString(content).dataUsingEncoding(NSUTF8StringEncoding) - : new java.lang.String(content).getBytes('UTF-8'); - const file = fs.File.fromPath( - fs.path.join(fs.knownFolders.temp().path, `${Date.now()}-app.txt`) - ); + const hello_world = global.isIOS ? NSString.stringWithString(content).dataUsingEncoding(NSUTF8StringEncoding) : new java.lang.String(content).getBytes('UTF-8'); + const file = fs.File.fromPath(fs.path.join(fs.knownFolders.temp().path, `${Date.now()}-app.txt`)); file .appendText('Hello') .then(() => file.appendText(' World')) @@ -830,9 +764,7 @@ export function test_FileAppend(done) { export function test_FileAppendText(done) { const content = 'Hello World'; - const file = fs.File.fromPath( - fs.path.join(fs.knownFolders.temp().path, `${Date.now()}-app.txt`) - ); + const file = fs.File.fromPath(fs.path.join(fs.knownFolders.temp().path, `${Date.now()}-app.txt`)); file .appendText('Hello') .then(() => file.appendText(' World')) diff --git a/apps/automated/src/image-source/image-source-tests.ts b/apps/automated/src/image-source/image-source-tests.ts index 98c73596d..2c0715616 100644 --- a/apps/automated/src/image-source/image-source-tests.ts +++ b/apps/automated/src/image-source/image-source-tests.ts @@ -24,18 +24,10 @@ export function testDrawableSetNativeSource() { const rDrawable = `${context.getPackageName()}.R$drawable`; const rClazz = java.lang.Class.forName(`${rDrawable}`); const iconId = rClazz.getDeclaredField('icon').get(null) as java.lang.Integer; - const splashScreenId = rClazz - .getDeclaredField('splash_screen') - .get(null) as java.lang.Integer; + const splashScreenId = rClazz.getDeclaredField('splash_screen').get(null) as java.lang.Integer; - const icon = androidx.appcompat.content.res.AppCompatResources.getDrawable( - context, - iconId?.intValue?.() ?? 0 - ); - const splashScreen = androidx.appcompat.content.res.AppCompatResources.getDrawable( - context, - splashScreenId?.intValue?.() ?? 0 - ); + const icon = androidx.appcompat.content.res.AppCompatResources.getDrawable(context, iconId?.intValue?.() ?? 0); + const splashScreen = androidx.appcompat.content.res.AppCompatResources.getDrawable(context, splashScreenId?.intValue?.() ?? 0); let type = icon?.getClass?.().toString?.() ?? ''; @@ -264,10 +256,8 @@ export function testNativeFields() { TKUnit.assert(img.ios != null, 'Image.ios not updated.'); } } -const fullAndroidPng = - 'iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAIAAAAmkwkpAAAAA3NCSVQICAjb4U/gAAAAFUlEQVQImWP8z4AAjAz/kTnIPGQAAG86AwGcuMlCAAAAAElFTkSuQmCC'; -const fullIosPng = - 'iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAIAAAAmkwkpAAAAAXNSR0IArs4c6QAAABxpRE9UAAAAAgAAAAAAAAACAAAAKAAAAAIAAAACAAAARiS4uJEAAAASSURBVBgZYvjPwABHSMz/DAAAAAD//0GWpK0AAAAOSURBVGNgYPiPhBgQAACEvQv1D5y/pAAAAABJRU5ErkJggg=='; +const fullAndroidPng = 'iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAIAAAAmkwkpAAAAA3NCSVQICAjb4U/gAAAAFUlEQVQImWP8z4AAjAz/kTnIPGQAAG86AwGcuMlCAAAAAElFTkSuQmCC'; +const fullIosPng = 'iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAIAAAAmkwkpAAAAAXNSR0IArs4c6QAAABxpRE9UAAAAAgAAAAAAAAACAAAAKAAAAAIAAAACAAAARiS4uJEAAAASSURBVBgZYvjPwABHSMz/DAAAAAD//0GWpK0AAAAOSURBVGNgYPiPhBgQAACEvQv1D5y/pAAAAABJRU5ErkJggg=='; const jpgImageAsBase64String = '/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/2wBDAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/wAARCAAEAAQDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD+Pz/h5j+1Z/z9fBr/AMRt+AH/AM7uiiiv9fV9E36KOn/HMX0f+n/NlvDT/p3/ANUv/V3vrf8AP1nueaf8LOa9P+ZjjP8Ap3/0/wD6u99b/wD/2Q=='; @@ -335,11 +325,7 @@ export function testLoadFromBase64Encode_PNG() { export function testLoadFromFontIconCode() { let img: ImageSource; - img = ImageSource.fromFontIconCodeSync( - 'F10B', - Font.default.withFontFamily('FontAwesome'), - new Color('red') - ); + img = ImageSource.fromFontIconCodeSync('F10B', Font.default.withFontFamily('FontAwesome'), new Color('red')); TKUnit.assert(img !== null, 'Actual: ' + img); TKUnit.assert(img.width !== null, 'img.width'); @@ -353,8 +339,5 @@ export function testResize() { const resized = img.resize(newSize); - TKUnit.assert( - resized.width === newSize || resized.height === newSize, - 'Image not resized correctly' - ); + TKUnit.assert(resized.width === newSize || resized.height === newSize, 'Image not resized correctly'); } diff --git a/apps/automated/src/livesync/livesync-tests.ts b/apps/automated/src/livesync/livesync-tests.ts index c89481ff7..67e69e8a9 100644 --- a/apps/automated/src/livesync/livesync-tests.ts +++ b/apps/automated/src/livesync/livesync-tests.ts @@ -35,9 +35,7 @@ const modalViewCssFileName = `${LIVESYNC_FOLDER}livesync-modal-view-page.css`; const green = new Color('green'); export function setUp() { - const labelPage = ( - Builder.createViewFromEntry({ moduleName: labelPageModuleName }) - ); + const labelPage = Builder.createViewFromEntry({ moduleName: labelPageModuleName }); helper.navigate(() => labelPage); } @@ -135,14 +133,9 @@ export function test_onLiveSync_ModalViewClosed_StyleScss() { _test_onLiveSync_ModalViewClosed({ type: 'style', path: modalViewScssPageFileName }); } -function _test_onLiveSync_ModuleContext_AppStyle( - appStyleFileName: string, - livesyncStyleFileName: string -) { +function _test_onLiveSync_ModuleContext_AppStyle(appStyleFileName: string, livesyncStyleFileName: string) { const pageBeforeNavigation = helper.getCurrentPage(); - const buttonPage = ( - Builder.createViewFromEntry({ moduleName: buttonPageModuleName }) - ); + const buttonPage = Builder.createViewFromEntry({ moduleName: buttonPageModuleName }); helper.navigateWithHistory(() => buttonPage); Application.setCssFileName(appStyleFileName); @@ -150,92 +143,51 @@ function _test_onLiveSync_ModuleContext_AppStyle( livesync({ type: 'style', path: livesyncStyleFileName }); const pageAfterLiveSync = helper.getCurrentPage(); - TKUnit.waitUntilReady( - () => - pageAfterLiveSync.getViewById('button').style.color.toString() === green.toString() - ); + TKUnit.waitUntilReady(() => pageAfterLiveSync.getViewById('button').style.color.toString() === green.toString()); TKUnit.assertTrue(pageAfterLiveSync.frame.canGoBack(), 'Can NOT go back!'); TKUnit.assertEqual(pageAfterLiveSync, pageBeforeLiveSync, 'Pages are different!'); - TKUnit.assertTrue( - pageAfterLiveSync._cssState.isSelectorsLatestVersionApplied(), - 'Latest selectors version is NOT applied!' - ); + TKUnit.assertTrue(pageAfterLiveSync._cssState.isSelectorsLatestVersionApplied(), 'Latest selectors version is NOT applied!'); helper.goBack(); const pageAfterNavigationBack = helper.getCurrentPage(); - TKUnit.assertEqual( - pageAfterNavigationBack.getViewById('label').style.color, - green, - 'App styles NOT applied on back navigation!' - ); - TKUnit.assertEqual( - pageBeforeNavigation, - pageAfterNavigationBack, - 'Pages are different' - ); - TKUnit.assertTrue( - pageAfterNavigationBack._cssState.isSelectorsLatestVersionApplied(), - 'Latest selectors version is NOT applied!' - ); + TKUnit.assertEqual(pageAfterNavigationBack.getViewById('label').style.color, green, 'App styles NOT applied on back navigation!'); + TKUnit.assertEqual(pageBeforeNavigation, pageAfterNavigationBack, 'Pages are different'); + TKUnit.assertTrue(pageAfterNavigationBack._cssState.isSelectorsLatestVersionApplied(), 'Latest selectors version is NOT applied!'); } function _test_onLiveSync_ModuleContext(context: ModuleContext) { - const buttonPage = ( - Builder.createViewFromEntry({ moduleName: buttonPageModuleName }) - ); + const buttonPage = Builder.createViewFromEntry({ moduleName: buttonPageModuleName }); helper.navigateWithHistory(() => buttonPage); livesync({ type: context.type, path: context.path }); TKUnit.waitUntilReady(() => !!Frame.topmost()); const topmostFrame = Frame.topmost(); - TKUnit.waitUntilReady( - () => - topmostFrame.currentPage && - topmostFrame.currentPage.isLoaded && - !topmostFrame.canGoBack() - ); + TKUnit.waitUntilReady(() => topmostFrame.currentPage && topmostFrame.currentPage.isLoaded && !topmostFrame.canGoBack()); TKUnit.assertTrue(topmostFrame.currentPage.getViewById('label').isLoaded); } function _test_onLiveSync_ModuleReplace(context: ModuleContext) { const pageBeforeNavigation = helper.getCurrentPage(); - const buttonPage = ( - Builder.createViewFromEntry({ moduleName: buttonPageModuleName }) - ); + const buttonPage = Builder.createViewFromEntry({ moduleName: buttonPageModuleName }); helper.navigateWithHistory(() => buttonPage); livesync({ type: context.type, path: context.path }); const topmostFrame = Frame.topmost(); waitUntilLivesyncComplete(topmostFrame); - TKUnit.assertTrue( - topmostFrame.currentPage.getViewById('button').isLoaded, - 'Button page is NOT loaded!' - ); + TKUnit.assertTrue(topmostFrame.currentPage.getViewById('button').isLoaded, 'Button page is NOT loaded!'); TKUnit.assertEqual(topmostFrame.backStack.length, 1, 'Backstack is clean!'); TKUnit.assertTrue(topmostFrame.canGoBack(), 'Can NOT go back!'); helper.goBack(); const pageAfterBackNavigation = helper.getCurrentPage(); - TKUnit.assertTrue( - topmostFrame.currentPage.getViewById('label').isLoaded, - 'Label page is NOT loaded!' - ); + TKUnit.assertTrue(topmostFrame.currentPage.getViewById('label').isLoaded, 'Label page is NOT loaded!'); TKUnit.assertEqual(topmostFrame.backStack.length, 0, 'Backstack is NOT clean!'); - TKUnit.assertEqual( - pageBeforeNavigation, - pageAfterBackNavigation, - 'Pages are different!' - ); + TKUnit.assertEqual(pageBeforeNavigation, pageAfterBackNavigation, 'Pages are different!'); } -function _test_onLiveSync_ModuleContext_TypeStyle( - styleModuleName: string, - livesyncStyleFileName: string -) { +function _test_onLiveSync_ModuleContext_TypeStyle(styleModuleName: string, livesyncStyleFileName: string) { const pageBeforeNavigation = helper.getCurrentPage(); - const buttonPage = ( - Builder.createViewFromEntry({ moduleName: buttonPageModuleName }) - ); + const buttonPage = Builder.createViewFromEntry({ moduleName: buttonPageModuleName }); helper.navigateWithHistory(() => buttonPage); const pageBeforeLiveSync = helper.getCurrentPage(); @@ -246,35 +198,20 @@ function _test_onLiveSync_ModuleContext_TypeStyle( waitUntilLivesyncComplete(topmostFrame); const pageAfterLiveSync = helper.getCurrentPage(); - TKUnit.waitUntilReady( - () => - pageAfterLiveSync.getViewById('button').style.color.toString() === green.toString() - ); + TKUnit.waitUntilReady(() => pageAfterLiveSync.getViewById('button').style.color.toString() === green.toString()); TKUnit.assertTrue(pageAfterLiveSync.frame.canGoBack(), 'Can NOT go back!'); TKUnit.assertEqual(topmostFrame.backStack.length, 1, 'Backstack is clean!'); - TKUnit.assertTrue( - pageAfterLiveSync._cssState.isSelectorsLatestVersionApplied(), - 'Latest selectors version is NOT applied!' - ); + TKUnit.assertTrue(pageAfterLiveSync._cssState.isSelectorsLatestVersionApplied(), 'Latest selectors version is NOT applied!'); helper.goBack(); const pageAfterNavigationBack = helper.getCurrentPage(); - TKUnit.assertEqual( - pageBeforeNavigation, - pageAfterNavigationBack, - 'Pages are different!' - ); - TKUnit.assertTrue( - pageAfterNavigationBack._cssState.isSelectorsLatestVersionApplied(), - 'Latest selectors version is NOT applied!' - ); + TKUnit.assertEqual(pageBeforeNavigation, pageAfterNavigationBack, 'Pages are different!'); + TKUnit.assertTrue(pageAfterNavigationBack._cssState.isSelectorsLatestVersionApplied(), 'Latest selectors version is NOT applied!'); } function _test_onLiveSync_ModuleReplace_Multiple(context: ModuleContext[]) { const pageBeforeNavigation = helper.getCurrentPage(); - const buttonPage = ( - Builder.createViewFromEntry({ moduleName: buttonPageModuleName }) - ); + const buttonPage = Builder.createViewFromEntry({ moduleName: buttonPageModuleName }); helper.navigateWithHistory(() => buttonPage); context.forEach((item) => { @@ -283,42 +220,25 @@ function _test_onLiveSync_ModuleReplace_Multiple(context: ModuleContext[]) { const topmostFrame = Frame.topmost(); waitUntilLivesyncComplete(topmostFrame); - TKUnit.assertTrue( - topmostFrame.currentPage.getViewById('button').isLoaded, - 'Button page is NOT loaded!' - ); + TKUnit.assertTrue(topmostFrame.currentPage.getViewById('button').isLoaded, 'Button page is NOT loaded!'); TKUnit.assertEqual(topmostFrame.backStack.length, 1, 'Backstack is clean!'); TKUnit.assertTrue(topmostFrame.canGoBack(), 'Can NOT go back!'); helper.goBack(); const pageAfterBackNavigation = helper.getCurrentPage(); - TKUnit.assertTrue( - topmostFrame.currentPage.getViewById('label').isLoaded, - 'Label page is NOT loaded!' - ); + TKUnit.assertTrue(topmostFrame.currentPage.getViewById('label').isLoaded, 'Label page is NOT loaded!'); TKUnit.assertEqual(topmostFrame.backStack.length, 0, 'Backstack is NOT clean!'); - TKUnit.assertEqual( - pageBeforeNavigation, - pageAfterBackNavigation, - 'Pages are different!' - ); + TKUnit.assertEqual(pageBeforeNavigation, pageAfterBackNavigation, 'Pages are different!'); } function _test_onLiveSync_ModalViewClosed(context: ModuleContext) { - const modalViewPage = ( - Builder.createViewFromEntry({ moduleName: modalViewPageModuleName }) - ); + const modalViewPage = Builder.createViewFromEntry({ moduleName: modalViewPageModuleName }); helper.navigateWithHistory(() => modalViewPage); livesync({ type: context.type, path: context.path }); TKUnit.waitUntilReady(() => !!Frame.topmost()); const topmostFrame = Frame.topmost(); - TKUnit.waitUntilReady( - () => - topmostFrame.currentPage && - topmostFrame.currentPage.isLoaded && - topmostFrame.canGoBack() - ); + TKUnit.waitUntilReady(() => topmostFrame.currentPage && topmostFrame.currentPage.isLoaded && topmostFrame.canGoBack()); TKUnit.assertTrue(topmostFrame._getRootModalViews().length === 0); } diff --git a/apps/automated/src/main.ts b/apps/automated/src/main.ts index 04498b7b1..81ea18a15 100644 --- a/apps/automated/src/main.ts +++ b/apps/automated/src/main.ts @@ -5,31 +5,15 @@ if (typeof NSDate !== 'undefined') { start = java.lang.System.currentTimeMillis(); } -import { - Application, - ApplicationEventData, - UnhandledErrorEventData, - DiscardedErrorEventData, - AndroidActivityBundleEventData, - AndroidActivityEventData, - AndroidApplication, - AndroidActivityNewIntentEventData, - AndroidActivityResultEventData, - AndroidActivityBackPressedEventData, - Label, - LaunchEventData, -} from '@nativescript/core'; +import { Application, ApplicationEventData, UnhandledErrorEventData, DiscardedErrorEventData, AndroidActivityBundleEventData, AndroidActivityEventData, AndroidApplication, AndroidActivityNewIntentEventData, AndroidActivityResultEventData, AndroidActivityBackPressedEventData, Label, LaunchEventData } from '@nativescript/core'; // import * as Application from "@nativescript/core/application"; if (Application.ios) { // Observe application notifications. - Application.ios.addNotificationObserver( - UIApplicationDidFinishLaunchingNotification, - (notification: NSNotification) => { - console.log('UIApplicationDidFinishLaunchingNotification:', notification); - } - ); + Application.ios.addNotificationObserver(UIApplicationDidFinishLaunchingNotification, (notification: NSNotification) => { + console.log('UIApplicationDidFinishLaunchingNotification:', notification); + }); } // Common events for both Android and iOS. @@ -110,104 +94,46 @@ Application.on(Application.discardedErrorEvent, function (args: DiscardedErrorEv // Android activity events. if (Application.android) { - Application.android.on( - Application.android.activityCreatedEvent, - function (args: AndroidActivityBundleEventData) { - console.log( - 'Event: ' + args.eventName + ', Activity:', - args.activity, - ', Bundle:', - args.bundle - ); - } - ); + Application.android.on(Application.android.activityCreatedEvent, function (args: AndroidActivityBundleEventData) { + console.log('Event: ' + args.eventName + ', Activity:', args.activity, ', Bundle:', args.bundle); + }); - Application.android.on( - Application.android.activityDestroyedEvent, - function (args: AndroidActivityEventData) { - console.log('Event: ' + args.eventName + ', Activity: ', args.activity); - } - ); + Application.android.on(Application.android.activityDestroyedEvent, function (args: AndroidActivityEventData) { + console.log('Event: ' + args.eventName + ', Activity: ', args.activity); + }); - Application.android.on( - Application.android.activityStartedEvent, - function (args: AndroidActivityEventData) { - console.log('Event: ' + args.eventName + ', Activity:', args.activity); - } - ); + Application.android.on(Application.android.activityStartedEvent, function (args: AndroidActivityEventData) { + console.log('Event: ' + args.eventName + ', Activity:', args.activity); + }); - Application.android.on( - Application.android.activityPausedEvent, - function (args: AndroidActivityEventData) { - console.log('Event: ' + args.eventName + ', Activity:', args.activity); - } - ); + Application.android.on(Application.android.activityPausedEvent, function (args: AndroidActivityEventData) { + console.log('Event: ' + args.eventName + ', Activity:', args.activity); + }); - Application.android.on( - Application.android.activityResumedEvent, - function (args: AndroidActivityEventData) { - console.log('Event: ' + args.eventName + ', Activity:', args.activity); - } - ); + Application.android.on(Application.android.activityResumedEvent, function (args: AndroidActivityEventData) { + console.log('Event: ' + args.eventName + ', Activity:', args.activity); + }); - Application.android.on( - Application.android.activityStoppedEvent, - function (args: AndroidActivityEventData) { - console.log('Event: ' + args.eventName + ', Activity:', args.activity); - } - ); + Application.android.on(Application.android.activityStoppedEvent, function (args: AndroidActivityEventData) { + console.log('Event: ' + args.eventName + ', Activity:', args.activity); + }); - Application.android.on( - Application.android.saveActivityStateEvent, - function (args: AndroidActivityBundleEventData) { - console.log( - 'Event: ' + args.eventName + ', Activity:', - args.activity, - ', Bundle:', - args.bundle - ); - } - ); + Application.android.on(Application.android.saveActivityStateEvent, function (args: AndroidActivityBundleEventData) { + console.log('Event: ' + args.eventName + ', Activity:', args.activity, ', Bundle:', args.bundle); + }); - Application.android.on( - Application.android.activityResultEvent, - function (args: AndroidActivityResultEventData) { - console.log( - 'Event:', - args.eventName, - ', Activity:', - args.activity, - ', requestCode: ', - args.requestCode, - ', resultCode: ', - args.resultCode, - ', Intent: ', - args.intent - ); - } - ); + Application.android.on(Application.android.activityResultEvent, function (args: AndroidActivityResultEventData) { + console.log('Event:', args.eventName, ', Activity:', args.activity, ', requestCode: ', args.requestCode, ', resultCode: ', args.resultCode, ', Intent: ', args.intent); + }); - Application.android.on( - Application.android.activityBackPressedEvent, - function (args: AndroidActivityBackPressedEventData) { - console.log('Event:', args.eventName, ', Activity:', args.activity); - // Set args.cancel = true to cancel back navigation and do something custom. - } - ); + Application.android.on(Application.android.activityBackPressedEvent, function (args: AndroidActivityBackPressedEventData) { + console.log('Event:', args.eventName, ', Activity:', args.activity); + // Set args.cancel = true to cancel back navigation and do something custom. + }); - Application.android.on( - Application.android.activityNewIntentEvent, - function (args: AndroidActivityNewIntentEventData) { - console.log( - 'Event: ', - args.eventName, - ', Activity:', - args.activity, - ', Intent:', - args.intent - ); - } - ); + Application.android.on(Application.android.activityNewIntentEvent, function (args: AndroidActivityNewIntentEventData) { + console.log('Event: ', args.eventName, ', Activity:', args.activity, ', Intent:', args.intent); + }); } let time; diff --git a/apps/automated/src/ui/core/bindable/bindable-tests.ts b/apps/automated/src/ui/core/bindable/bindable-tests.ts index a290927f9..8007ee0ff 100644 --- a/apps/automated/src/ui/core/bindable/bindable-tests.ts +++ b/apps/automated/src/ui/core/bindable/bindable-tests.ts @@ -1,24 +1,11 @@ -import { - Observable, - fromObject, - fromObjectRecursive, -} from '@nativescript/core/data/observable'; +import { Observable, fromObject, fromObjectRecursive } from '@nativescript/core/data/observable'; import { ViewBase } from '@nativescript/core/ui/core/view-base'; import { BindingOptions } from '@nativescript/core/ui/core/bindable'; import * as TKUnit from '../../../tk-unit'; import * as types from '@nativescript/core/utils/types'; import * as helper from '../../../ui-helper'; import * as bindingBuilder from '@nativescript/core/ui/builder/binding-builder'; -import { - Application, - View, - Button, - Page, - StackLayout, - Label, - TextField, - Trace, -} from '@nativescript/core'; +import { Application, View, Button, Page, StackLayout, Label, TextField, Trace } from '@nativescript/core'; declare var WeakRef: any; // // For information and examples how to use bindings please refer to special [**Data binding**](../../../../bindings.md) topic. @@ -55,17 +42,11 @@ export function test_Bindable_Bind_ToTarget_OneWay() { const obj = new Label(); obj.bind(options, model); - TKUnit.assert( - obj.get('text') === 'John', - "Expected result after binding is [test value] === 'John'" - ); + TKUnit.assert(obj.get('text') === 'John', "Expected result after binding is [test value] === 'John'"); model.set('name', 'Changed'); - TKUnit.assert( - obj.get('text') === 'Changed', - "Expected result after binding is [test value] === 'Changed'" - ); + TKUnit.assert(obj.get('text') === 'Changed', "Expected result after binding is [test value] === 'Changed'"); } export function test_Bindable_Bind_ToTarget_TwoWay() { @@ -82,19 +63,11 @@ export function test_Bindable_Bind_ToTarget_TwoWay() { obj.bind(options, model); obj.set('text', 'Changed'); - TKUnit.assertEqual( - model.get('name'), - 'Changed', - 'Two-way binding not updating the source when target is changed.' - ); + TKUnit.assertEqual(model.get('name'), 'Changed', 'Two-way binding not updating the source when target is changed.'); model.set('name', 'John'); - TKUnit.assertEqual( - obj.get('text'), - 'John', - 'Two-way binding not updating the target when source is changed.' - ); + TKUnit.assertEqual(obj.get('text'), 'John', 'Two-way binding not updating the target when source is changed.'); } export function test_Bindable_Bind_ToBindingContext_OneWay() { @@ -111,10 +84,7 @@ export function test_Bindable_Bind_ToBindingContext_OneWay() { obj.set('text', 'local'); obj.bindingContext = model; - TKUnit.assert( - obj.get('text') === 'John', - 'Binding to a context does not update the target property.' - ); + TKUnit.assert(obj.get('text') === 'John', 'Binding to a context does not update the target property.'); } export function test_Bindable_Bind_ToBindingContext_TwoWay() { @@ -133,19 +103,11 @@ export function test_Bindable_Bind_ToBindingContext_TwoWay() { obj.set('text', 'local'); obj.bindingContext = model; - TKUnit.assertEqual( - obj.get('text'), - 'John', - 'Binding to a context does not update the target property.' - ); + TKUnit.assertEqual(obj.get('text'), 'John', 'Binding to a context does not update the target property.'); obj.set('text', 'local'); - TKUnit.assertEqual( - model.get('name'), - 'local', - 'Two-way binding to a context does not update the source property.' - ); + TKUnit.assertEqual(model.get('name'), 'local', 'Two-way binding to a context does not update the source property.'); } export function test_Bindable_Unbind() { @@ -181,11 +143,7 @@ export function test_bind_NoSource_WillUse_BindingContext() { }); const button =