mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 03:31:45 +08:00

* chore: move tns-core-modules to nativescript-core * chore: preparing compat generate script * chore: add missing definitions * chore: no need for http-request to be private * chore: packages chore * test: generate tests for tns-core-modules * chore: add anroid module for consistency * chore: add .npmignore * chore: added privateModulesWhitelist * chore(webpack): added bundle-entry-points * chore: scripts * chore: tests changed to use @ns/core * test: add scoped-packages test project * test: fix types * test: update test project * chore: build scripts * chore: update build script * chore: npm scripts cleanup * chore: make the compat pgk work with old wp config * test: generate diff friendly tests * chore: create barrel exports * chore: move files after rebase * chore: typedoc config * chore: compat mode * chore: review of barrels * chore: remove tns-core-modules import after rebase * chore: dev workflow setup * chore: update developer-workflow * docs: experiment with API extractor * chore: api-extractor and barrel exports * chore: api-extractor configs * chore: generate d.ts rollup with api-extractor * refactor: move methods inside Frame * chore: fic tests to use Frame static methods * refactor: create Builder class * refactor: use Builder class in tests * refactor: include Style in ui barrel * chore: separate compat build script * chore: fix tslint errors * chore: update NATIVESCRIPT_CORE_ARGS * chore: fix compat pack * chore: fix ui-test-app build with linked modules * chore: Application, ApplicationSettings, Connectivity and Http * chore: export Trace, Profiling and Utils * refactor: Static create methods for ImageSource * chore: fix deprecated usages of ImageSource * chore: move Span and FormattedString to ui * chore: add events-args and ImageSource to index files * chore: check for CLI >= 6.2 when building for IOS * chore: update travis build * chore: copy Pod file to compat package * chore: update error msg ui-tests-app * refactor: Apply suggestions from code review Co-Authored-By: Martin Yankov <m.i.yankov@gmail.com> * chore: typings and refs * chore: add missing d.ts files for public API * chore: adress code review FB * chore: update api-report * chore: dev-workflow for other apps * chore: api update * chore: update api-report
98 lines
3.9 KiB
TypeScript
98 lines
3.9 KiB
TypeScript
import * as TKUnit from "../../tk-unit";
|
|
import * as helper from "../../ui-helper";
|
|
import { addLabelToPage } from "./page-tests-common";
|
|
import { Page } from "@nativescript/core/ui/page";
|
|
import { Label } from "@nativescript/core/ui/label";
|
|
import { Frame } from "@nativescript/core/ui/frame";
|
|
|
|
export * from "./page-tests-common";
|
|
|
|
export function test_NavigateToNewPage_WithAndroidCache() {
|
|
// Clear history if any.
|
|
helper.navigate(() => {
|
|
const launchPage = new Page();
|
|
launchPage.id = "launchPage_test_NavigateToNewPage_WithAndroidCache";
|
|
|
|
return launchPage;
|
|
});
|
|
|
|
TKUnit.assertEqual(Frame.topmost().backStack.length, 0, "The backstack should be empty before this test can be run.");
|
|
|
|
let testPage: Page;
|
|
let label: Label;
|
|
|
|
const pageFactory = function (): Page {
|
|
testPage = new Page();
|
|
testPage.id = "testPage_test_NavigateToNewPage_WithAndroidCache";
|
|
label = new Label();
|
|
label.text = "The quick brown fox jumps over the lazy dog.";
|
|
testPage.content = label;
|
|
|
|
return testPage;
|
|
};
|
|
|
|
const currentPage = Frame.topmost().currentPage;
|
|
helper.navigateWithHistory(pageFactory);
|
|
TKUnit.assertNotNull(currentPage.nativeView);
|
|
helper.goBack();
|
|
|
|
TKUnit.assertNull(testPage.parent, "Page.parent should become undefined after navigating back");
|
|
TKUnit.assertFalse(testPage.isLoaded, "Page.isLoaded should become false after navigating back");
|
|
TKUnit.assertNull(testPage.frame, "Page.frame should become undefined after navigating back");
|
|
TKUnit.assertFalse(testPage._isAddedToNativeVisualTree, "Page._isAddedToNativeVisualTree should become false after navigating back");
|
|
|
|
TKUnit.assertNull(label._context, "InnerControl._context should not be set after navigate back.");
|
|
TKUnit.assertNull(label.android, "InnerControl.android should not be set after navigate back.");
|
|
TKUnit.assertNull(label.nativeViewProtected, "InnerControl.nativeView hould not be set after navigate back.");
|
|
TKUnit.assertFalse(label.isLoaded, "InnerControl.isLoaded should become false after navigating back");
|
|
TKUnit.assertFalse(label._isAddedToNativeVisualTree, "InnerControl._isAddedToNativeVisualTree should not be true after navigating back");
|
|
}
|
|
|
|
export function test_NavigateToNewPage_InnerControl() {
|
|
let testPage: Page;
|
|
const pageFactory = function () {
|
|
testPage = new Page();
|
|
testPage.id = "testPage_test_NavigateToNewPage_InnerControl";
|
|
addLabelToPage(testPage);
|
|
|
|
return testPage;
|
|
};
|
|
|
|
helper.navigateWithHistory(pageFactory);
|
|
helper.goBack();
|
|
|
|
const label = <Label>testPage.content;
|
|
TKUnit.assertNull(label._context, "InnerControl._context should be undefined after navigate back.");
|
|
TKUnit.assertNull(label.android, "InnerControl.android should be undefined after navigate back.");
|
|
TKUnit.assertNull(label.nativeViewProtected, "InnerControl.nativeView should be undefined after navigate back.");
|
|
TKUnit.assertFalse(label.isLoaded, "InnerControl.isLoaded should become false after navigating back");
|
|
TKUnit.assertFalse(label._isAddedToNativeVisualTree, "InnerControl._isAddedToNativeVisualTree should become false after navigating back");
|
|
}
|
|
|
|
export function test_SetPageCaching_ToTheSameValue_AfterNavigated_DoesNotThrow() {
|
|
const pageFactory = function () {
|
|
const testPage = new Page();
|
|
testPage.id = "testPage_test_SetPageCaching_ToTheSameValue_AfterNavigated_DoesNotThrow";
|
|
|
|
return testPage;
|
|
};
|
|
|
|
helper.navigate(pageFactory);
|
|
}
|
|
|
|
export function test_Resolve_Fragment_ForPage() {
|
|
let testPage: Page;
|
|
const pageFactory = () => {
|
|
testPage = new Page();
|
|
|
|
return testPage;
|
|
};
|
|
|
|
const frame = Frame.topmost();
|
|
frame.navigate(pageFactory);
|
|
TKUnit.waitUntilReady(() => frame.navigationQueueIsEmpty());
|
|
|
|
const fragment = frame.android.fragmentForPage(frame._currentEntry);
|
|
TKUnit.assertNotNull(fragment, "Failed to resolve native fragment for page");
|
|
}
|