| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,5 @@ | |||
| 1 | + <Page loaded="onLoaded"> | ||
| 2 | + <StackLayout> | ||
| 3 | + <Button id="button" text="button"></Button> | ||
| 4 | + </StackLayout> | ||
| 5 | + </Page> | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,3 @@ | |||
| 1 | + export function onLoaded() { | ||
| 2 | + console.log("Button page loaded!"); | ||
| 3 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,5 @@ | |||
| 1 | + <Page loaded="onLoaded"> | ||
| 2 | + <StackLayout> | ||
| 3 | + <Button id="button" text="button"></Button> | ||
| 4 | + </StackLayout> | ||
| 5 | + </Page> | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,3 @@ | |||
| 1 | + export function onLoaded() { | ||
| 2 | + console.log("Label page loaded!"); | ||
| 3 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,5 @@ | |||
| 1 | + <Page loaded="onLoaded"> | ||
| 2 | + <StackLayout> | ||
| 3 | + <Label id="label" text="label"></Label> | ||
| 4 | + </StackLayout> | ||
| 5 | + </Page> | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,110 +1,110 @@ | |||
| 1 | - import * as app from "tns-core-modules/application/application"; | ||
| 2 | - import * as frame from "tns-core-modules/ui/frame"; | ||
| 3 | 1 | import * as helper from "../ui/helper"; | |
| 4 | 2 | import * as TKUnit from "../TKUnit"; | |
| 3 | + | ||
| 4 | + import * as app from "tns-core-modules/application/application"; | ||
| 5 | + import * as frame from "tns-core-modules/ui/frame"; | ||
| 6 | + | ||
| 5 | 7 | import { Color } from "tns-core-modules/color"; | |
| 6 | - import { parse } from "tns-core-modules/ui/builder"; | ||
| 8 | + import { isAndroid } from "tns-core-modules/platform"; | ||
| 9 | + import { createViewFromEntry } from "tns-core-modules/ui/builder"; | ||
| 7 | 10 | import { Page } from "tns-core-modules/ui/page"; | |
| 11 | + import { Frame } from "tns-core-modules/ui/frame"; | ||
| 8 | 12 | ||
| 9 | 13 | const appCssFileName = "./app/application.css"; | |
| 10 | 14 | const appNewCssFileName = "./app/app-new.css"; | |
| 11 | 15 | const appNewScssFileName = "./app/app-new.scss"; | |
| 12 | - const appJsFileName = "./app/app.js"; | ||
| 13 | - const appTsFileName = "./app/app.ts"; | ||
| 14 | - const mainPageCssFileName = "./app/main-page.css"; | ||
| 15 | - const mainPageHtmlFileName = "./app/main-page.html"; | ||
| 16 | - const mainPageXmlFileName = "./app/main-page.xml"; | ||
| 17 | - | ||
| 18 | - const black = new Color("black"); | ||
| 19 | - const green = new Color("green"); | ||
| 16 | + const buttonCssFileName = "./app/button-page.css"; | ||
| 20 | 17 | ||
| 21 | - const mainPageTemplate = ` | ||
| 22 | - <Page> | ||
| 23 | - <StackLayout> | ||
| 24 | - <Label id="label" text="label"></Label> | ||
| 25 | - </StackLayout> | ||
| 26 | - </Page>`; | ||
| 18 | + const buttonPageModuleName = "livesync/livesync-button-page"; | ||
| 19 | + const buttonHtmlPageFileName = "./livesync/livesync-button-page.html"; | ||
| 20 | + const buttonXmlPageFileName = "./livesync/livesync-button-page.xml"; | ||
| 21 | + const buttonJsPageFileName = "./livesync/livesync-button-page.js"; | ||
| 22 | + const buttonTsPageFileName = "./livesync/livesync-button-page.ts"; | ||
| 23 | + const labelPageModuleName = "livesync/livesync-label-page"; | ||
| 27 | 24 | ||
| 28 | - const pageTemplate = ` | ||
| 29 | - <Page> | ||
| 30 | - <StackLayout> | ||
| 31 | - <Button id="button" text="button"></Button> | ||
| 32 | - </StackLayout> | ||
| 33 | - </Page>`; | ||
| 25 | + const green = new Color("green"); | ||
| 34 | 26 | ||
| 35 | 27 | export function test_onLiveSync_ModuleContext_AppStyle_AppNewCss() { | |
| 28 | + debugger; | ||
| 36 | 29 | _test_onLiveSync_ModuleContext_AppStyle(appNewCssFileName); | |
| 37 | 30 | } | |
| 38 | 31 | ||
| 39 | 32 | export function test_onLiveSync_ModuleContext_AppStyle_AppNewScss() { | |
| 33 | + debugger; | ||
| 40 | 34 | _test_onLiveSync_ModuleContext_AppStyle(appNewScssFileName); | |
| 41 | 35 | } | |
| 42 | 36 | ||
| 43 | 37 | export function test_onLiveSync_ModuleContext_ContextUndefined() { | |
| 38 | + debugger; | ||
| 44 | 39 | _test_onLiveSync_ModuleContext({ type: undefined, path: undefined }); | |
| 45 | 40 | } | |
| 46 | 41 | ||
| 47 | 42 | export function test_onLiveSync_ModuleContext_ModuleUndefined() { | |
| 43 | + debugger; | ||
| 48 | 44 | _test_onLiveSync_ModuleContext({ type: "script", path: undefined }); | |
| 49 | 45 | } | |
| 50 | 46 | ||
| 51 | - export function test_onLiveSync_ModuleContext_Script_AppJs() { | ||
| 52 | - _test_onLiveSync_ModuleContext({ type: "script", path: appJsFileName }); | ||
| 47 | + export function test_onLiveSync_ModuleContext_Script_JsFile() { | ||
| 48 | + debugger; | ||
| 49 | + _test_onLiveSync_ModuleReplace({ type: "script", path: buttonJsPageFileName }); | ||
| 53 | 50 | } | |
| 54 | 51 | ||
| 55 | - export function test_onLiveSync_ModuleContext_Script_AppTs() { | ||
| 56 | - _test_onLiveSync_ModuleContext({ type: "script", path: appTsFileName }); | ||
| 52 | + export function test_onLiveSync_ModuleContext_Script_TsFile() { | ||
| 53 | + debugger; | ||
| 54 | + _test_onLiveSync_ModuleReplace({ type: "script", path: buttonTsPageFileName }); | ||
| 57 | 55 | } | |
| 58 | 56 | ||
| 59 | - export function test_onLiveSync_ModuleContext_Style_MainPageCss() { | ||
| 60 | - _test_onLiveSync_ModuleContext_TypeStyle({ type: "style", path: mainPageCssFileName }); | ||
| 57 | + export function test_onLiveSync_ModuleContext_Style_CssFile() { | ||
| 58 | + debugger; | ||
| 59 | + _test_onLiveSync_ModuleContext_TypeStyle({ type: "style", path: buttonCssFileName }); | ||
| 61 | 60 | } | |
| 62 | 61 | ||
| 63 | - export function test_onLiveSync_ModuleContext_Markup_MainPageHtml() { | ||
| 64 | - _test_onLiveSync_ModuleContext({ type: "markup", path: mainPageHtmlFileName }); | ||
| 62 | + export function test_onLiveSync_ModuleContext_Markup_HtmlFile() { | ||
| 63 | + debugger; | ||
| 64 | + _test_onLiveSync_ModuleReplace({ type: "markup", path: buttonHtmlPageFileName }); | ||
| 65 | 65 | } | |
| 66 | 66 | ||
| 67 | - export function test_onLiveSync_ModuleContext_Markup_MainPageXml() { | ||
| 68 | - _test_onLiveSync_ModuleContext({ type: "markup", path: mainPageXmlFileName }); | ||
| 67 | + export function test_onLiveSync_ModuleContext_Markup_XmlFile() { | ||
| 68 | + debugger; | ||
| 69 | + _test_onLiveSync_ModuleReplace({ type: "markup", path: buttonXmlPageFileName }); | ||
| 69 | 70 | } | |
| 70 | 71 | ||
| 71 | - export function setUpModule() { | ||
| 72 | - const mainPage = <Page>parse(mainPageTemplate); | ||
| 73 | - helper.navigate(() => mainPage); | ||
| 72 | + export function setUp() { | ||
| 73 | + debugger; | ||
| 74 | + const labelPage = <Page>createViewFromEntry(({ moduleName: labelPageModuleName })); | ||
| 75 | + helper.navigate(() => labelPage); | ||
| 74 | 76 | } | |
| 75 | 77 | ||
| 76 | 78 | export function tearDown() { | |
| 79 | + debugger; | ||
| 77 | 80 | app.setCssFileName(appCssFileName); | |
| 78 | 81 | } | |
| 79 | 82 | ||
| 80 | 83 | function _test_onLiveSync_ModuleContext_AppStyle(styleFileName: string) { | |
| 81 | 84 | const pageBeforeNavigation = helper.getCurrentPage(); | |
| 85 | + const buttonPage = <Page>createViewFromEntry(({ moduleName: buttonPageModuleName })); | ||
| 86 | + helper.navigateWithHistory(() => buttonPage); | ||
| 82 | 87 | ||
| 83 | - const page = <Page>parse(pageTemplate); | ||
| 84 | - helper.navigateWithHistory(() => page); | ||
| 85 | 88 | app.setCssFileName(styleFileName); | |
| 86 | - | ||
| 87 | 89 | const pageBeforeLiveSync = helper.getCurrentPage(); | |
| 88 | 90 | global.__onLiveSync({ type: "style", path: styleFileName }); | |
| 89 | 91 | ||
| 90 | 92 | const pageAfterLiveSync = helper.getCurrentPage(); | |
| 91 | 93 | TKUnit.waitUntilReady(() => pageAfterLiveSync.getViewById("button").style.color.toString() === green.toString()); | |
| 92 | - | ||
| 93 | - TKUnit.assertTrue(pageAfterLiveSync.frame.canGoBack(), "App styles NOT applied - livesync navigation executed!"); | ||
| 94 | - TKUnit.assertEqual(pageAfterLiveSync, pageBeforeLiveSync, "Pages are different - livesync navigation executed!"); | ||
| 95 | - TKUnit.assertTrue(pageAfterLiveSync._cssState.isSelectorsLatestVersionApplied(), "Latest selectors version NOT applied!"); | ||
| 94 | + TKUnit.assertTrue(pageAfterLiveSync.frame.canGoBack(), "Can NOT go back!"); | ||
| 95 | + TKUnit.assertEqual(pageAfterLiveSync, pageBeforeLiveSync, "Pages are different!"); | ||
| 96 | + TKUnit.assertTrue(pageAfterLiveSync._cssState.isSelectorsLatestVersionApplied(), "Latest selectors version is NOT applied!"); | ||
| 96 | 97 | ||
| 97 | 98 | helper.goBack(); | |
| 98 | - | ||
| 99 | 99 | const pageAfterNavigationBack = helper.getCurrentPage(); | |
| 100 | 100 | TKUnit.assertEqual(pageAfterNavigationBack.getViewById("label").style.color, green, "App styles NOT applied on back navigation!"); | |
| 101 | - TKUnit.assertEqual(pageBeforeNavigation, pageAfterNavigationBack, "Pages are different - livesync navigation executed!"); | ||
| 101 | + TKUnit.assertEqual(pageBeforeNavigation, pageAfterNavigationBack, "Pages are different"); | ||
| 102 | 102 | TKUnit.assertTrue(pageAfterNavigationBack._cssState.isSelectorsLatestVersionApplied(), "Latest selectors version is NOT applied!"); | |
| 103 | 103 | } | |
| 104 | 104 | ||
| 105 | 105 | function _test_onLiveSync_ModuleContext(context: { type, path }) { | |
| 106 | - const page = <Page>parse(pageTemplate); | ||
| 107 | - helper.navigateWithHistory(() => page); | ||
| 106 | + const buttonPage = <Page>createViewFromEntry(({ moduleName: buttonPageModuleName })); | ||
| 107 | + helper.navigateWithHistory(() => buttonPage); | ||
| 108 | 108 | global.__onLiveSync({ type: context.type, path: context.path }); | |
| 109 | 109 | ||
| 110 | 110 | TKUnit.waitUntilReady(() => !!frame.topmost()); | |
@@ -113,27 +113,53 @@ function _test_onLiveSync_ModuleContext(context: { type, path }) { | |||
| 113 | 113 | TKUnit.assertTrue(topmostFrame.currentPage.getViewById("label").isLoaded); | |
| 114 | 114 | } | |
| 115 | 115 | ||
| 116 | - function _test_onLiveSync_ModuleContext_TypeStyle(context: { type, path }) { | ||
| 116 | + function _test_onLiveSync_ModuleReplace(context: { type, path }) { | ||
| 117 | 117 | const pageBeforeNavigation = helper.getCurrentPage(); | |
| 118 | + const buttonPage = <Page>createViewFromEntry(({ moduleName: buttonPageModuleName })); | ||
| 119 | + helper.navigateWithHistory(() => buttonPage); | ||
| 120 | + | ||
| 121 | + global.__onLiveSync({ type: context.type, path: context.path }); | ||
| 122 | + const topmostFrame = frame.topmost(); | ||
| 123 | + waitUntilLivesyncComplete(topmostFrame); | ||
| 124 | + TKUnit.assertTrue(topmostFrame.currentPage.getViewById("button").isLoaded, "Button page is NOT loaded!"); | ||
| 125 | + TKUnit.assertEqual(topmostFrame.backStack.length, 1, "Backstack is clean!"); | ||
| 126 | + TKUnit.assertTrue(topmostFrame.canGoBack(), "Can NOT go back!"); | ||
| 118 | 127 | ||
| 119 | - const page = <Page>parse(pageTemplate); | ||
| 120 | - helper.navigateWithHistory(() => page); | ||
| 128 | + helper.goBack(); | ||
| 129 | + const pageAfterBackNavigation = helper.getCurrentPage(); | ||
| 130 | + TKUnit.assertTrue(topmostFrame.currentPage.getViewById("label").isLoaded, "Label page is NOT loaded!"); | ||
| 131 | + TKUnit.assertEqual(topmostFrame.backStack.length, 0, "Backstack is NOT clean!"); | ||
| 132 | + TKUnit.assertEqual(pageBeforeNavigation, pageAfterBackNavigation, "Pages are different!"); | ||
| 133 | + } | ||
| 134 | + | ||
| 135 | + function _test_onLiveSync_ModuleContext_TypeStyle(context: { type, path }) { | ||
| 136 | + const pageBeforeNavigation = helper.getCurrentPage(); | ||
| 137 | + const buttonPage = <Page>createViewFromEntry(({ moduleName: buttonPageModuleName })); | ||
| 138 | + helper.navigateWithHistory(() => buttonPage); | ||
| 121 | 139 | ||
| 122 | 140 | const pageBeforeLiveSync = helper.getCurrentPage(); | |
| 123 | - pageBeforeLiveSync._moduleName = "main-page"; | ||
| 141 | + pageBeforeLiveSync._moduleName = "button-page"; | ||
| 142 | + | ||
| 124 | 143 | global.__onLiveSync({ type: context.type, path: context.path }); | |
| 144 | + const topmostFrame = frame.topmost(); | ||
| 145 | + waitUntilLivesyncComplete(topmostFrame); | ||
| 125 | 146 | ||
| 126 | 147 | const pageAfterLiveSync = helper.getCurrentPage(); | |
| 127 | 148 | TKUnit.waitUntilReady(() => pageAfterLiveSync.getViewById("button").style.color.toString() === green.toString()); | |
| 128 | - | ||
| 129 | - TKUnit.assertTrue(pageAfterLiveSync.frame.canGoBack(), "Local styles NOT applied - livesync navigation executed!"); | ||
| 130 | - TKUnit.assertEqual(pageAfterLiveSync, pageBeforeLiveSync, "Pages are different - livesync navigation executed!"); | ||
| 131 | - TKUnit.assertTrue(pageAfterLiveSync._cssState.isSelectorsLatestVersionApplied(), "Latest selectors version NOT applied!"); | ||
| 149 | + TKUnit.assertTrue(pageAfterLiveSync.frame.canGoBack(), "Can NOT go back!"); | ||
| 150 | + TKUnit.assertEqual(topmostFrame.backStack.length, 1, "Backstack is clean!"); | ||
| 151 | + TKUnit.assertTrue(pageAfterLiveSync._cssState.isSelectorsLatestVersionApplied(), "Latest selectors version is NOT applied!"); | ||
| 132 | 152 | ||
| 133 | 153 | helper.goBack(); | |
| 134 | - | ||
| 135 | 154 | const pageAfterNavigationBack = helper.getCurrentPage(); | |
| 136 | - TKUnit.assertEqual(pageAfterNavigationBack.getViewById("label").style.color, black, "App styles applied on back navigation!"); | ||
| 137 | - TKUnit.assertEqual(pageBeforeNavigation, pageAfterNavigationBack, "Pages are different - livesync navigation executed!"); | ||
| 155 | + TKUnit.assertEqual(pageBeforeNavigation, pageAfterNavigationBack, "Pages are different!"); | ||
| 138 | 156 | TKUnit.assertTrue(pageAfterNavigationBack._cssState.isSelectorsLatestVersionApplied(), "Latest selectors version is NOT applied!"); | |
| 139 | - } | ||
| 157 | + } | ||
| 158 | + | ||
| 159 | + function waitUntilLivesyncComplete(frame: Frame) { | ||
| 160 | + if (isAndroid) { | ||
| 161 | + TKUnit.waitUntilReady(() => frame._executingEntry === null); | ||
| 162 | + } else { | ||
| 163 | + TKUnit.waitUntilReady(() => frame.currentPage.isLoaded); | ||
| 164 | + } | ||
| 165 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,11 +5,11 @@ | |||
| 5 | 5 | "repository": "<fill-your-repository-here>", | |
| 6 | 6 | "nativescript": { | |
| 7 | 7 | "id": "org.nativescript.UnitTestApp", | |
| 8 | - "tns-ios": { | ||
| 9 | - "version": "5.2.0" | ||
| 10 | - }, | ||
| 11 | 8 | "tns-android": { | |
| 12 | - "version": "5.2.1" | ||
| 9 | + "version": "5.3.1" | ||
| 10 | + }, | ||
| 11 | + "tns-ios": { | ||
| 12 | + "version": "5.3.1" | ||
| 13 | 13 | } | |
| 14 | 14 | }, | |
| 15 | 15 | "dependencies": { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments