chore: cleanup

This commit is contained in:
Nathan Walker
2020-07-09 23:43:28 -07:00
parent 0ae8dba962
commit 8100cf7089
89 changed files with 493 additions and 704 deletions

View File

@@ -1,8 +0,0 @@
// >> border-require
import { Border } from "@nativescript/core/ui/border";
// << border-require
import * as helper from "../../ui-helper";
export function test_recycling() {
helper.nativeView_recycling_test(() => new Border());
}

View File

@@ -1,19 +0,0 @@
---
nav-title: "Border How-To"
title: "border"
environment: nativescript
description: "Examples for using Border"
previous_url: /ApiReference/ui/border/HOW-TO
---
# Border
Using borders requires the Border module.
{%snippet border-require%}
### Declaring a Border.
``` XML
<Page>
<Border borderRadius="10" borderWidth="2" borderColor="#FF0000">
<Button text="OK"/>
</Border>
</Page>
```

View File

@@ -1,9 +1,6 @@
import { Builder } from "@nativescript/core/ui/builder";
import { assertEqual, assertNull, assertThrows, assertNotNull, assert } from "../../tk-unit";
import { _setResolver, ModuleNameResolver, PlatformContext } from "@nativescript/core/module-name-resolver";
import { Button } from "@nativescript/core/ui/button";
import { Button, Builder, Page, Color, _setResolver, ModuleNameResolver, PlatformContext } from "@nativescript/core";
import { navigate } from "../../ui-helper";
import { Page, Color } from "@nativescript/core";
const testPrefix = "bundle-file-qualifiers-tests";
let modulesToCleanup: string[] = [];

View File

@@ -1,5 +1,4 @@
import { Builder } from "@nativescript/core/ui/builder";
import { sanitizeModuleName } from "@nativescript/core/ui/builder/module-name-sanitizer";
import { Builder, sanitizeModuleName } from "@nativescript/core";
import { assertEqual, assertNull, assertThrows, assertNotNull } from "../../tk-unit";

View File

@@ -1,13 +1,10 @@
/* tslint:disable:no-unused-variable */
// >> gestures-require
import * as gestures from "@nativescript/core/ui/gestures";
// << gestures-require
import * as labelModule from "@nativescript/core/ui/label";
import { GestureEventData, Label, GestureTypes, PanGestureEventData, PinchGestureEventData, SwipeGestureEventData, RotationGestureEventData } from "@nativescript/core";
export var test_DummyTestForSnippetOnly0 = function () {
// >> gestures-double-tap
var label = new labelModule.Label();
var observer = label.on(gestures.GestureTypes.doubleTap, function (args: gestures.GestureEventData) {
var label = new Label();
var observer = label.on(GestureTypes.doubleTap, function (args: GestureEventData) {
console.log("Double Tap");
});
// << gestures-double-tap
@@ -15,8 +12,8 @@ export var test_DummyTestForSnippetOnly0 = function () {
export var test_DummyTestForSnippetOnly01 = function () {
// >> gestures-double-tap-alt
var label = new labelModule.Label();
var observer = label.on("doubleTap", function (args: gestures.GestureEventData) {
var label = new Label();
var observer = label.on("doubleTap", function (args: GestureEventData) {
console.log("Double Tap");
});
// << gestures-double-tap-alt
@@ -24,8 +21,8 @@ export var test_DummyTestForSnippetOnly01 = function () {
export var test_DummyTestForSnippetOnly1 = function () {
// >> gestures-long-press
var label = new labelModule.Label();
var observer = label.on(gestures.GestureTypes.longPress, function (args: gestures.GestureEventData) {
var label = new Label();
var observer = label.on(GestureTypes.longPress, function (args: GestureEventData) {
console.log("Long Press");
});
// << gestures-long-press
@@ -33,8 +30,8 @@ export var test_DummyTestForSnippetOnly1 = function () {
export var test_DummyTestForSnippetOnly11 = function () {
// >> gestures-long-press-alt
var label = new labelModule.Label();
var observer = label.on("longPress", function (args: gestures.GestureEventData) {
var label = new Label();
var observer = label.on("longPress", function (args: GestureEventData) {
console.log("Long Press");
});
// << gestures-long-press-alt
@@ -42,8 +39,8 @@ export var test_DummyTestForSnippetOnly11 = function () {
export var test_DummyTestForSnippetOnly2 = function () {
// >> gestures-pan
var label = new labelModule.Label();
var observer = label.on(gestures.GestureTypes.pan, function (args: gestures.PanGestureEventData) {
var label = new Label();
var observer = label.on(GestureTypes.pan, function (args: PanGestureEventData) {
console.log("Pan deltaX:" + args.deltaX + "; deltaY:" + args.deltaY + ";");
});
// << gestures-pan
@@ -51,8 +48,8 @@ export var test_DummyTestForSnippetOnly2 = function () {
export var test_DummyTestForSnippetOnly22 = function () {
// >> gestures-pan-alt
var label = new labelModule.Label();
var observer = label.on("pan", function (args: gestures.PanGestureEventData) {
var label = new Label();
var observer = label.on("pan", function (args: PanGestureEventData) {
console.log("Pan deltaX:" + args.deltaX + "; deltaY:" + args.deltaY + ";");
});
// << gestures-pan-alt
@@ -60,8 +57,8 @@ export var test_DummyTestForSnippetOnly22 = function () {
export var test_DummyTestForSnippetOnly3 = function () {
// >> gestures-pan-pinch
var label = new labelModule.Label();
var observer = label.on(gestures.GestureTypes.pinch, function (args: gestures.PinchGestureEventData) {
var label = new Label();
var observer = label.on(GestureTypes.pinch, function (args: PinchGestureEventData) {
console.log("Pinch scale: " + args.scale);
});
// << gestures-pan-pinch
@@ -69,8 +66,8 @@ export var test_DummyTestForSnippetOnly3 = function () {
export var test_DummyTestForSnippetOnly33 = function () {
// >> gestures-pan-pinch-alt
var label = new labelModule.Label();
var observer = label.on("pinch", function (args: gestures.PinchGestureEventData) {
var label = new Label();
var observer = label.on("pinch", function (args: PinchGestureEventData) {
console.log("Pinch scale: " + args.scale);
});
// << gestures-pan-pinch-alt
@@ -78,8 +75,8 @@ export var test_DummyTestForSnippetOnly33 = function () {
export var test_DummyTestForSnippetOnly4 = function () {
// >> gestures-rotation
var label = new labelModule.Label();
var observer = label.on(gestures.GestureTypes.rotation, function (args: gestures.RotationGestureEventData) {
var label = new Label();
var observer = label.on(GestureTypes.rotation, function (args: RotationGestureEventData) {
console.log("Rotation: " + args.rotation);
});
// << gestures-rotation
@@ -87,8 +84,8 @@ export var test_DummyTestForSnippetOnly4 = function () {
export var test_DummyTestForSnippetOnly44 = function () {
// >> gestures-rotation-alt
var label = new labelModule.Label();
var observer = label.on("rotation", function (args: gestures.RotationGestureEventData) {
var label = new Label();
var observer = label.on("rotation", function (args: RotationGestureEventData) {
console.log("Rotation: " + args.rotation);
});
// << gestures-rotation-alt
@@ -96,8 +93,8 @@ export var test_DummyTestForSnippetOnly44 = function () {
export var test_DummyTestForSnippetOnly5 = function () {
// >> gestures-swipe
var label = new labelModule.Label();
var observer = label.on(gestures.GestureTypes.swipe, function (args: gestures.SwipeGestureEventData) {
var label = new Label();
var observer = label.on(GestureTypes.swipe, function (args: SwipeGestureEventData) {
console.log("Swipe direction: " + args.direction);
});
// << gestures-swipe
@@ -105,8 +102,8 @@ export var test_DummyTestForSnippetOnly5 = function () {
export var test_DummyTestForSnippetOnly55 = function () {
// >> gestures-swipe-alt
var label = new labelModule.Label();
var observer = label.on("swipe", function (args: gestures.SwipeGestureEventData) {
var label = new Label();
var observer = label.on("swipe", function (args: SwipeGestureEventData) {
console.log("Swipe direction: " + args.direction);
});
// << gestures-swipe-alt
@@ -114,8 +111,8 @@ export var test_DummyTestForSnippetOnly55 = function () {
export var test_DummyTestForSnippetOnly6 = function () {
// >> gestures-tap
var label = new labelModule.Label();
var observer = label.on(gestures.GestureTypes.tap, function (args: gestures.GestureEventData) {
var label = new Label();
var observer = label.on(GestureTypes.tap, function (args: GestureEventData) {
console.log("Tap");
});
// << gestures-tap
@@ -123,8 +120,8 @@ export var test_DummyTestForSnippetOnly6 = function () {
export var test_DummyTestForSnippetOnly66 = function () {
// >> gestures-tap-alt
var label = new labelModule.Label();
var observer = label.on("tap", function (args: gestures.GestureEventData) {
var label = new Label();
var observer = label.on("tap", function (args: GestureEventData) {
console.log("Tap");
});
// << gestures-tap-alt
@@ -132,8 +129,8 @@ export var test_DummyTestForSnippetOnly66 = function () {
export var test_DummyTestForSnippetOnly7 = function () {
// >> gestures-stop-observe
var label = new labelModule.Label();
var observer = label.on(gestures.GestureTypes.tap, function (args: gestures.GestureEventData) {
var label = new Label();
var observer = label.on(GestureTypes.tap, function (args: GestureEventData) {
console.log("Tap");
});
observer.disconnect();
@@ -142,8 +139,8 @@ export var test_DummyTestForSnippetOnly7 = function () {
export var test_DummyTestForSnippetOnly8 = function () {
// >> gestures-multiple
var label = new labelModule.Label();
var observer = label.on(gestures.GestureTypes.tap | gestures.GestureTypes.doubleTap | gestures.GestureTypes.longPress, function (args: gestures.GestureEventData) {
var label = new Label();
var observer = label.on(GestureTypes.tap | GestureTypes.doubleTap | GestureTypes.longPress, function (args: GestureEventData) {
console.log("Event: " + args.eventName);
});
// << gestures-multiple
@@ -151,8 +148,8 @@ export var test_DummyTestForSnippetOnly8 = function () {
export var test_DummyTestForSnippetOnly88 = function () {
// >> gestures-string
var label = new labelModule.Label();
var observer = label.on("tap, doubleTap, longPress", function (args: gestures.GestureEventData) {
var label = new Label();
var observer = label.on("tap, doubleTap, longPress", function (args: GestureEventData) {
console.log("Event: " + args.eventName);
});
// << gestures-string
@@ -160,8 +157,8 @@ export var test_DummyTestForSnippetOnly88 = function () {
export var test_DummyTestForSnippetOnly9 = function () {
// >> gestures-events-string
var label = new labelModule.Label();
var observer = label.on("loaded, tap, longPress", function (args: gestures.GestureEventData) {
var label = new Label();
var observer = label.on("loaded, tap, longPress", function (args: GestureEventData) {
console.log("Event: " + args.eventName);
});
// << gestures-events-string

View File

@@ -1,9 +1,5 @@
import * as TKUnit from "../../tk-unit";
import { Page, View } from "@nativescript/core";
import { Frame, NavigationEntry, _stack } from "@nativescript/core/ui/frame";
import { _resetRootView, getRootView } from "@nativescript/core/application";
import { TabView } from "@nativescript/core/ui/tab-view";
import { GridLayout } from "@nativescript/core/ui/layouts/grid-layout";
import { Page, TabView, View, GridLayout, Frame, NavigationEntry, Application } from "@nativescript/core";
import * as helper from "../../ui-helper";
function createTestFrameRootEntry() {
@@ -12,7 +8,7 @@ function createTestFrameRootEntry() {
frameRoot.navigate(() => page);
const entry: NavigationEntry = {
create: () => frameRoot
create: () => <any>frameRoot
};
return {
@@ -27,9 +23,9 @@ export function test_custom_component_rootview_css_applied() {
moduleName: "ui/root-view/root-modules/custom-component-root"
};
_resetRootView(entry);
Application.resetRootView(entry);
var rootView = getRootView();
var rootView = Application.getRootView();
TKUnit.waitUntilReady(() => rootView.isLoaded);
TKUnit.assertNotNull(rootView);
@@ -46,9 +42,9 @@ export function test_tabview_rootview_css_applied() {
moduleName: "ui/root-view/root-modules/tabview-root"
};
_resetRootView(entry);
Application.resetRootView(entry);
var rootView = getRootView();
var rootView = Application.getRootView();
TKUnit.waitUntilReady(() => rootView.isLoaded);
TKUnit.assert(rootView instanceof TabView);
@@ -60,9 +56,9 @@ export function test_gridlayout_rootview_css_applied() {
moduleName: "ui/root-view/root-modules/gridlayout-root"
};
_resetRootView(entry);
Application.resetRootView(entry);
var rootView = getRootView();
var rootView = Application.getRootView();
TKUnit.waitUntilReady(() => rootView.isLoaded);
TKUnit.assert(rootView instanceof GridLayout);
@@ -80,9 +76,9 @@ export function test_tabview_rootview_layout_updates() {
function layout_invalidate_test(moduleName: string) {
var entry = { moduleName };
_resetRootView(entry);
Application.resetRootView(entry);
var rootView = getRootView();
var rootView = Application.getRootView();
TKUnit.waitUntilReady(() => rootView.isLayoutValid);
const lbl = <View>rootView.getViewById("my-test-label");
@@ -101,6 +97,6 @@ export function tearDownModule() {
// reset the root to frame for other tests
const resetFrameRoot = createTestFrameRootEntry();
_resetRootView(resetFrameRoot.entry);
Application.resetRootView(resetFrameRoot.entry);
TKUnit.waitUntilReady(() => resetFrameRoot.page.isLoaded);
}

View File

@@ -1,8 +1,5 @@
import * as TKUnit from "../../tk-unit";
import { _resetRootView } from "@nativescript/core/application/";
import { Frame, NavigationEntry, } from "@nativescript/core/ui/frame";
import { Page } from "@nativescript/core/ui/page";
import { Tabs, TabContentItem, TabStrip, TabStripItem } from "@nativescript/core/ui/tabs";
import { Page, Frame, Tabs, TabContentItem, TabStrip, TabStripItem, NavigationEntry, Application } from "@nativescript/core";
function waitUntilNavigatedToMaxTimeout(pages: Page[], action: Function) {
const maxTimeout = 8;
@@ -84,7 +81,7 @@ export function test_frame_topmost_matches_selectedIndex() {
create: () => tabView
};
waitUntilNavigatedToMaxTimeout([items[0].page], () => _resetRootView(entry));
waitUntilNavigatedToMaxTimeout([items[0].page], () => Application.resetRootView(entry));
TKUnit.assertEqual(Frame.topmost().id, "Tab0 Frame0");
waitUntilNavigatedToMaxTimeout([items[1].page], () => tabView.selectedIndex = 1);
@@ -131,7 +128,7 @@ export function test_frame_topmost_matches_selectedIndex() {
// create: () => tabView
// };
// waitUntilNavigatedToMaxTimeout([items[0].page], () => _resetRootView(entry));
// waitUntilNavigatedToMaxTimeout([items[0].page], () => Application.resetRootView(entry));
// const expectedEventsRaisedAfterTabCreated = [
// [
@@ -193,5 +190,5 @@ export function tearDownModule() {
create: () => frame
};
waitUntilNavigatedToMaxTimeout([page], () => _resetRootView(entry));
waitUntilNavigatedToMaxTimeout([page], () => Application.resetRootView(entry));
}

View File

@@ -1,19 +1,7 @@
import * as TKUnit from "../../tk-unit";
import { View, eachDescendant, getViewById, InheritedProperty, CssProperty, CssAnimationProperty, ShorthandProperty, Property, Style } from "@nativescript/core";
import { Frame } from "@nativescript/core/ui/frame";
import { Page } from "@nativescript/core/ui/page";
import { Button } from "@nativescript/core/ui/button";
import { Label } from "@nativescript/core/ui/label";
import { Color } from "@nativescript/core/color";
import { StackLayout } from "@nativescript/core/ui/layouts/stack-layout";
import { AbsoluteLayout } from "@nativescript/core/ui/layouts/absolute-layout";
import * as types from "@nativescript/core/utils/types";
import { View, eachDescendant, getViewById, InheritedProperty, CssProperty, CssAnimationProperty, ShorthandProperty, Property, Style, Frame, Page, Button, Label, Color, StackLayout, AbsoluteLayout, Observable, Utils, BindingOptions, isAndroid, LayoutBase } from "@nativescript/core";
import * as helper from "../../ui-helper";
import * as observable from "@nativescript/core/data/observable";
import * as bindable from "@nativescript/core/ui/core/bindable";
import * as definition from "./view-tests";
import { isAndroid } from "@nativescript/core/platform";
import { LayoutBase } from "@nativescript/core/ui/layouts/layout-base";
export function test_eachDescendant() {
const test = function (views: Array<View>) {
@@ -27,7 +15,7 @@ export function test_eachDescendant() {
return true;
};
eachDescendant(Frame.topmost(), callback);
eachDescendant(<any>Frame.topmost(), callback);
// Descendants: page, actionBar, button
TKUnit.assertEqual(counter, 3, "descendants");
};
@@ -40,7 +28,7 @@ export function test_getViewById_Static() {
views[1].id = "myLayout";
// traverse the visual tree and verify the hierarchy
const result = getViewById(Frame.topmost(), "myLayout");
const result = getViewById(<any>Frame.topmost(), "myLayout");
TKUnit.assert(result === views[1]);
};
@@ -72,7 +60,7 @@ export function test_eachDescendant_Break_Iteration() {
return false;
};
eachDescendant(Frame.topmost(), callback);
eachDescendant(<any>Frame.topmost(), callback);
TKUnit.assert(counter === 1);
};
@@ -82,11 +70,11 @@ export function test_eachDescendant_Break_Iteration() {
export function test_parent_IsValid_WhenAttached_ToVisualTree() {
const test = function (views: Array<View>) {
// views[0] is a Page instance, its parent should be the topmost frame
TKUnit.assert(types.isDefined(views[0].parent));
TKUnit.assert(views[0].parent === Frame.topmost());
TKUnit.assert(Utils.isDefined(views[0].parent));
TKUnit.assert(views[0].parent === <any>Frame.topmost());
// views[1] is a Button instance, its parent should be the Page (views[0])
TKUnit.assert(types.isDefined(views[1].parent));
TKUnit.assert(Utils.isDefined(views[1].parent));
TKUnit.assert(views[1].parent === views[0]);
};
@@ -102,8 +90,8 @@ export function test_parent_IsReset_WhenDetached_FromVisualTree() {
helper.do_PageTest_WithStackLayout_AndButton(test);
TKUnit.assert(types.isUndefined(cachedViews[1].parent));
TKUnit.assert(types.isDefined(cachedViews[2].parent));
TKUnit.assert(Utils.isUndefined(cachedViews[1].parent));
TKUnit.assert(Utils.isDefined(cachedViews[2].parent));
TKUnit.assert(cachedViews[2].parent === cachedViews[1]);
}
@@ -165,7 +153,7 @@ export function test_bindingContext_IsInherited() {
};
helper.do_PageTest_WithStackLayout_AndButton(test);
Frame.topmost().bindingContext = undefined;
(<any>Frame.topmost()).bindingContext = undefined;
}
export function test_isAddedToNativeVisualTree_IsUpdated() {
@@ -705,10 +693,10 @@ export function test_InheritableProperties_ChangeNotification() {
function property_binding_test(propName: string, firstValue: any, secondValue: any, view?: View) {
let actualResult;
const model = new observable.Observable();
const model = new Observable();
model.set(propName, firstValue);
const options: bindable.BindingOptions = {
const options: BindingOptions = {
sourceProperty: propName,
targetProperty: propName
};
@@ -729,10 +717,10 @@ function property_binding_test(propName: string, firstValue: any, secondValue: a
function property_binding_style_test(propName: string, firstValue: any, secondValue: any, view?: View) {
let actualResult;
const model = new observable.Observable();
const model = new Observable();
model.set(propName, firstValue);
const options: bindable.BindingOptions = {
const options: BindingOptions = {
sourceProperty: propName,
targetProperty: "style." + propName
};