Merge pull request #3479 from NativeScript/run-more-green-tests

Minor fixes + more green tests
This commit is contained in:
Alexander Vakrilov
2017-01-12 16:22:28 +02:00
committed by GitHub
19 changed files with 101 additions and 139 deletions

View File

@ -58,7 +58,7 @@ export function applyTapWithActionBarHiddenAndSpan(args) {
reset(page);
page.backgroundSpanUnderStatusBar = true;
page.actionBarHidden = true;;
page.actionBarHidden = true;
var css = "#test-element { " + args.object.tag + " }";
page.css = css;
}

View File

@ -29,7 +29,7 @@ import * as stackLayoutDef from "ui/layouts/stack-layout";
// }
// else if (view.ios) {
// var fontSize = (<UIButton>view._nativeView).titleLabel.font.pointSize;
// (<UIButton>view._nativeView).titleLabel.font = UIFont.fontWithNameSize(nativeValue, fontSize);;
// (<UIButton>view._nativeView).titleLabel.font = UIFont.fontWithNameSize(nativeValue, fontSize);
// }
// }

View File

@ -22,7 +22,7 @@ export function createPage() {
var fileName = resolver.resolveFileName(moduleNamePath, "xml");
lbl.text = fileName;
lbl.textWrap = true;;
lbl.textWrap = true;
page.content = lbl;
return page;

View File

@ -53,7 +53,7 @@ allTests["FILE-NAME-RESOLVER"] = require("./file-name-resolver-tests/file-name-r
allTests["WEAK-EVENTS"] = require("./weak-event-listener-tests");
allTests["CONNECTIVITY"] = require("./connectivity-tests");
// allTests["PROXY-VIEW-CONTAINER"] = require("./ui/proxy-view-container/proxy-view-container-tests")
allTests["PROXY-VIEW-CONTAINER"] = require("./ui/proxy-view-container/proxy-view-container-tests")
allTests["SCROLL-VIEW"] = require("./ui/scroll-view/scroll-view-tests");
allTests["ACTION-BAR"] = require("./ui/action-bar/action-bar-tests");
allTests["XML-DECLARATION"] = require("./xml-declaration/xml-declaration-tests");
@ -67,12 +67,12 @@ allTests["STYLE-PROPERTIES"] = require("./ui/styling/style-properties-tests");
allTests["FRAME"] = require("./ui/frame/frame-tests");
allTests["VIEW"] = require("./ui/view/view-tests");
allTests["STYLE"] = require("./ui/styling/style-tests");
// allTests["VISUAL-STATE"] = require("./ui/styling/visual-state-tests");
allTests["VISUAL-STATE"] = require("./ui/styling/visual-state-tests");
// allTests["VALUE-SOURCE"] = require("./ui/styling/value-source-tests");
allTests["CSS-SELECTOR-PARSER"] = require("./ui/styling/css-selector-parser");
// allTests["CSS-SELECTOR"] = require("./ui/styling/css-selector");
allTests["CSS-SELECTOR"] = require("./ui/styling/css-selector");
allTests["BUTTON"] = require("./ui/button/button-tests");
// allTests["BORDER"] = require("./ui/border/border-tests");
allTests["BORDER"] = require("./ui/border/border-tests");
allTests["LABEL"] = require("./ui/label/label-tests");
allTests["TAB-VIEW"] = require("./ui/tab-view/tab-view-tests");
// allTests["TAB-VIEW-NAVIGATION"] = require("./ui/tab-view/tab-view-navigation-tests");
@ -90,9 +90,9 @@ allTests["LIST-PICKER"] = require("./ui/list-picker/list-picker-tests");
allTests["DATE-PICKER"] = require("./ui/date-picker/date-picker-tests");
allTests["TIME-PICKER"] = require("./ui/time-picker/time-picker-tests");
// allTests["WEB-VIEW"] = require("./ui/web-view/web-view-tests");
// allTests["HTML-VIEW"] = require("./ui/html-view/html-view-tests");
allTests["HTML-VIEW"] = require("./ui/html-view/html-view-tests");
// allTests["REPEATER"] = require("./ui/repeater/repeater-tests");
// allTests["SEARCH-BAR"] = require('./ui/search-bar/search-bar-tests');
allTests["SEARCH-BAR"] = require('./ui/search-bar/search-bar-tests');
allTests["SEGMENTED-BAR"] = require("./ui/segmented-bar/segmented-bar-tests");
// allTests["ANIMATION"] = require("./ui/animation/animation-tests");
// allTests["CSS-ANIMATION"] = require("./ui/animation/css-animation-tests");

View File

@ -51,7 +51,7 @@ if (platform.device.os === platform.platformNames.ios) {
ai.color = new color.Color("red");
function testAction(views: Array<viewModule.View>) {
TKUnit.assertEqual(ai.color.ios.CGColor, ai.ios.color.CGColor, "ai.color");
TKUnit.assertEqual(ai.color.ios.CGColor, ai.nativeView.color.CGColor, "ai.color");
};
helper.buildUIAndRunTest(ai, testAction);

View File

@ -1,18 +1,18 @@
import * as TKUnit from "../../TKUnit";
import * as helper from "../helper";
import {View} from "ui/core/view";
import {Button} from "ui/button";
import {Page} from "ui/page";
import {ScrollView} from "ui/scroll-view";
import {LayoutBase} from "ui/layouts/layout-base"
import {StackLayout} from "ui/layouts/stack-layout"
import {GridLayout} from "ui/layouts/grid-layout"
import {ProxyViewContainer} from "ui/proxy-view-container";
import {ListView} from "ui/list-view";
import { View } from "ui/core/view";
import { Button } from "ui/button";
import { Page } from "ui/page";
import { ScrollView } from "ui/scroll-view";
import { LayoutBase } from "ui/layouts/layout-base";
import { StackLayout } from "ui/layouts/stack-layout";
import { GridLayout } from "ui/layouts/grid-layout";
import { ProxyViewContainer } from "ui/proxy-view-container";
import { ListView } from "ui/list-view";
export function test_add_children_to_attached_proxy() {
var outer = new StackLayout();
var proxy = new ProxyViewContainer();
const outer = new StackLayout();
const proxy = new ProxyViewContainer();
function testAction(views: Array<View>) {
outer.addChild(createBtn("1"));
@ -30,8 +30,8 @@ export function test_add_children_to_attached_proxy() {
}
export function test_children_immediately_registered_in_parent_grid_layout() {
var outer = new GridLayout();
var proxy = new ProxyViewContainer();
const outer = new GridLayout();
const proxy = new ProxyViewContainer();
function testAction(views: Array<View>) {
outer.addChild(proxy);
@ -44,10 +44,11 @@ export function test_children_immediately_registered_in_parent_grid_layout() {
}
export function test_children_registered_in_parent_grid_layout_on_attach() {
var outer = new GridLayout();
var proxy = new ProxyViewContainer();
const outer = new GridLayout();
const proxy = new ProxyViewContainer();
function testAction(views: Array<View>) {
proxy.addChild(createBtn("1"));
outer.addChild(proxy);
@ -58,8 +59,8 @@ export function test_children_registered_in_parent_grid_layout_on_attach() {
}
export function test_add_children_to_detached_proxy() {
var outer = new StackLayout();
var proxy = new ProxyViewContainer();
const outer = new StackLayout();
const proxy = new ProxyViewContainer();
function testAction(views: Array<View>) {
outer.addChild(createBtn("1"));
@ -78,8 +79,8 @@ export function test_add_children_to_detached_proxy() {
}
export function test_remove_proxy() {
var outer = new StackLayout();
var proxy = new ProxyViewContainer();
const outer = new StackLayout();
const proxy = new ProxyViewContainer();
outer.addChild(createBtn("1"));
@ -100,14 +101,14 @@ export function test_remove_proxy() {
}
export function test_remove_child_of_attached_proxy() {
var outer = new StackLayout();
var proxy = new ProxyViewContainer();
const outer = new StackLayout();
const proxy = new ProxyViewContainer();
outer.addChild(createBtn("1"));
outer.addChild(proxy);
proxy.addChild(createBtn("2"));
var testBtn = createBtn("3")
const testBtn = createBtn("3");
proxy.addChild(testBtn);
proxy.addChild(createBtn("4"));
@ -122,9 +123,9 @@ export function test_remove_child_of_attached_proxy() {
helper.buildUIAndRunTest(outer, testAction);
}
export function test_insert_inside_porxy() {
var outer = new StackLayout();
var proxy = new ProxyViewContainer();
export function test_insert_inside_proxy() {
const outer = new StackLayout();
const proxy = new ProxyViewContainer();
outer.addChild(createBtn("1"));
@ -143,9 +144,9 @@ export function test_insert_inside_porxy() {
helper.buildUIAndRunTest(outer, testAction);
}
export function test_insert_after_porxy() {
var outer = new StackLayout();
var proxy = new ProxyViewContainer();
export function test_insert_after_proxy() {
const outer = new StackLayout();
const proxy = new ProxyViewContainer();
outer.addChild(createBtn("1"));
@ -164,12 +165,12 @@ export function test_insert_after_porxy() {
}
export function test_proxy_does_not_stop_request_layout_bubble() {
var outer = new StackLayout();
var proxy = new ProxyViewContainer();
const outer = new StackLayout();
const proxy = new ProxyViewContainer();
outer.addChild(createBtn("1"));
outer.addChild(proxy);
var btn = createBtn("2");
const btn = createBtn("2");
proxy.addChild(btn);
function testAction(views: Array<View>) {
@ -184,51 +185,51 @@ export function test_proxy_does_not_stop_request_layout_bubble() {
}
export function test_proxy_iniside_page() {
var proxy = new ProxyViewContainer();
const proxy = new ProxyViewContainer();
proxy.addChild(createBtn("1"));
function testAction(views: Array<View>) {
var page = <Page>views[1];
const page = <Page>views[1];
waitUntilElementLayoutIsValid(page);
};
helper.buildUIAndRunTest(proxy, testAction);
}
export function test_proxy_iniside_scroll_view() {
var scroll = new ScrollView();
export function test_proxy_inside_scroll_view() {
const scroll = new ScrollView();
const proxy = new ProxyViewContainer();
scroll.content = proxy;
var proxy = new ProxyViewContainer();
proxy.addChild(createBtn("1"));
function testAction(views: Array<View>) {
var page = <Page>views[1];
const page = <Page>views[1];
waitUntilElementLayoutIsValid(page);
};
helper.buildUIAndRunTest(scroll, testAction);
}
export function test_proxy_iniside_border() {
var scroll = new ScrollView();
export function test_proxy_inside_border() {
const scroll = new ScrollView();
const proxy = new ProxyViewContainer();
scroll.content = proxy;
var proxy = new ProxyViewContainer();
proxy.addChild(createBtn("1"));
function testAction(views: Array<View>) {
var page = <Page>views[1];
const page = <Page>views[1];
waitUntilElementLayoutIsValid(page);
};
helper.buildUIAndRunTest(scroll, testAction);
}
export function test_proxy_iniside_listview_itemtemplate_crash() {
export function test_proxy_inside_listview_itemTemplate_crash() {
// Usually reproducible with an Angular component in the template
// We use a simple declaration here to simulate it.
var list = new ListView();
const list = new ListView();
list.items = ["item 1"];
list.itemTemplate = `
<ProxyViewContainer>
@ -237,7 +238,7 @@ export function test_proxy_iniside_listview_itemtemplate_crash() {
`;
function testAction(views: Array<View>) {
var page = <Page>views[1];
const page = <Page>views[1];
waitUntilElementLayoutIsValid(page);
};
@ -245,17 +246,17 @@ export function test_proxy_iniside_listview_itemtemplate_crash() {
}
// TODO: Proxy as a direct child to of TabItem is not supported. Not sure if we want to support it.
//export function test_proxy_iniside_tab() {
// var proxy = new ProxyViewContainer();
//export function test_proxy_inside_tab() {
// const proxy = new ProxyViewContainer();
// proxy.addChild(createBtn("1"));
// var tab = new TabView();
// var items = new Array<TabViewItem>();
// const tab = new TabView();
// const items = new Array<TabViewItem>();
// items.push(new TabViewItem({ title: "tab with proxy", view: proxy }));
// tab.items = items;
// function testAction(views: Array<View>) {
// var page = <Page>views[1];
// const page = <Page>views[1];
// waitUntilElementLayoutIsValid(page);
// };
@ -263,10 +264,10 @@ export function test_proxy_iniside_listview_itemtemplate_crash() {
//}
// TODO: Proxy as a direct child to of ActionBar is not supported. Not sure if we want to support it.
//export function test_proxy_iniside_actionBar() {
//export function test_proxy_inside_actionBar() {
// function testAction(views: Array<View>) {
// var page = <Page>views[1];
// var proxy = new ProxyViewContainer();
// const page = <Page>views[1];
// const proxy = new ProxyViewContainer();
// proxy.addChild(createBtn("1"));
// page.actionBar.titleView = proxy;
// waitUntilElementLayoutIsValid(page);
@ -282,7 +283,7 @@ function waitUntilElementLayoutIsValid(view: View, timeoutSec?: number): void {
}
function createBtn(text: string): Button {
var b = new Button();
const b = new Button();
b.text = text;
return b;
}

View File

@ -128,7 +128,7 @@ export class TimePickerTest extends testModule.UITest<timePickerModule.TimePicke
this.testView.hour = 14;
this.testView.maxHour = this.testView.hour + 1;
TKUnit.assertThrows(function() {
this.testView.hour = this.testView.maxHour + 1;;
this.testView.hour = this.testView.maxHour + 1;
}, "Setting hour property to a value greater than maxHour property value should throw.");
}

View File

@ -13,8 +13,7 @@
}
},
"dependencies": {
"tns-core-modules": "2.4.0",
"tns-core-modules-widgets": "file:///Users/vakrilov/Work/Projects/tns-core-modules-widgets/dist/tns-core-modules-widgets-2.5.0.tgz"
"tns-core-modules": "2.4.0"
},
"devDependencies": {
"tns-platform-declarations": "*",

View File

@ -80,6 +80,6 @@ export function stopMonitoring(): void {
if (_monitorReachabilityRef) {
SCNetworkReachabilityUnscheduleFromRunLoop(_monitorReachabilityRef, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
_monitorReachabilityRef = undefined;
_connectionTypeChangedCallback = undefined;;
_connectionTypeChangedCallback = undefined;
}
}

View File

@ -159,7 +159,7 @@ export class ImageSource implements definition.ImageSource {
public toBase64String(format: string, quality = 100): string {
if (!this.android) {
return null;;
return null;
}
var targetFormat = getTargetFormat(format);

View File

@ -38,6 +38,6 @@ export class ActivityIndicator extends ActivityIndicatorBase {
return this.nativeView.color;
}
set [colorProperty.native](value: UIColor | Color) {
this.nativeView.color = value instanceof Color ? value.ios : value;;
this.nativeView.color = value instanceof Color ? value.ios : value;
}
}

View File

@ -104,7 +104,7 @@ export class ViewBase extends Observable implements ViewBaseDefinition {
public bindingContext: any;
public nativeView: any;
public parent: ViewBase;
public isCollapsed = false;
public isCollapsed; // Default(false) set in prototype
public id: string;
public className: string;
@ -487,7 +487,8 @@ export class ViewBase extends Observable implements ViewBaseDefinition {
this._initNativeView();
if (this.parent) {
this._isAddedToNativeVisualTree = this.parent._addViewToNativeVisualTree(this, atIndex);
let nativeIndex = this.parent._childIndexToNativeChildIndex(atIndex);
this._isAddedToNativeVisualTree = this.parent._addViewToNativeVisualTree(this, nativeIndex);
}
if (this.nativeView) {
@ -614,6 +615,8 @@ export class ViewBase extends Observable implements ViewBaseDefinition {
}
}
ViewBase.prototype.isCollapsed = false;
export const bindingContextProperty = new InheritedProperty<ViewBase, any>({ name: "bindingContext" });
bindingContextProperty.register(ViewBase);

View File

@ -785,14 +785,6 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition {
return callback(this);
}
_addToSuperview(superview: any, index?: number): boolean {
// IOS specific
return false;
}
_removeFromSuperview(): void {
// IOS specific
}
// public unsetInheritedProperties(): void {
// // this._setValue(ProxyObject.bindingContextProperty, undefined, ValueSource.Inherited);
// // this._eachSetProperty((property) => {

View File

@ -536,9 +536,6 @@ declare module "ui/core/view" {
_eachLayoutView(callback: (View) => void): void;
_addToSuperview(superview: any, index?: number): boolean;
_removeFromSuperview();
public _applyXmlAttribute(attribute: string, value: any): boolean;
public eachChildView(callback: (view: View) => boolean): void;

View File

@ -268,26 +268,6 @@ export class View extends ViewCommon {
}
}
public _addToSuperview(superview: any, atIndex: number = Number.POSITIVE_INFINITY): boolean {
if (superview && this.nativeView) {
if (atIndex >= superview.subviews.count) {
superview.addSubview(this.nativeView);
} else {
superview.insertSubviewAtIndex(this.nativeView, atIndex);
}
return true;
}
return false;
}
public _removeFromSuperview() {
if (this.nativeView) {
this.nativeView.removeFromSuperview();
}
}
// By default we update the view's presentation layer when setting backgroundColor and opacity properties.
// This is done by calling CATransaction begin and commit methods.
// This action should be disabled when updating those properties during an animation.
@ -457,12 +437,27 @@ export class CustomLayoutView extends View {
public _addViewToNativeVisualTree(child: View, atIndex: number): boolean {
super._addViewToNativeVisualTree(child, atIndex);
return child._addToSuperview(this.nativeView, atIndex);
const parentNativeView = this.nativeView;
const childNativeView = child.nativeView;
if (parentNativeView && childNativeView) {
if (typeof atIndex !== "number" || atIndex >= parentNativeView.subviews.count) {
parentNativeView.addSubview(childNativeView);
} else {
parentNativeView.insertSubviewAtIndex(childNativeView, atIndex);
}
return true;
}
return false;
}
public _removeViewFromNativeVisualTree(child: View): void {
super._removeViewFromNativeVisualTree(child);
child._removeFromSuperview();
if (child.nativeView) {
child.nativeView.removeFromSuperview();
}
}
}

View File

@ -3,7 +3,7 @@ import {
traceEnabled, traceWrite, traceCategories
} from "./image-common";
export * from "./image-common";;
export * from "./image-common";
export class Image extends ImageBase {
private _ios: UIImageView;

View File

@ -149,5 +149,5 @@ export class LayoutBaseCommon extends CustomLayoutView implements LayoutBaseDefi
}
}
export const clipToBoundsProperty = new Property<LayoutBaseCommon, boolean>({name: "clipToBounds", defaultValue: true});
export const clipToBoundsProperty = new Property<LayoutBaseCommon, boolean>({ name: "clipToBounds", defaultValue: true });
clipToBoundsProperty.register(LayoutBaseCommon);

View File

@ -37,8 +37,8 @@ export class Progress extends ProgressBase {
get [colorProperty.native](): UIColor {
return this._ios.progressTintColor;
}
set [colorProperty.native](value: Color) {
this._ios.progressTintColor = value instanceof Color ? value.ios : value;;
set [colorProperty.native](value: Color | UIColor) {
this._ios.progressTintColor = value instanceof Color ? value.ios : value;
}
get [backgroundColorProperty.native](): UIColor {

View File

@ -6,13 +6,9 @@ import { LayoutBase, View, traceEnabled, traceWrite, traceCategories } from "ui/
*/
// Cases to cover:
// * Child is added to the attached proxy. Handled in _addViewToNativeVisualTree.
// * Proxy (with children) is added to the DOM.
// - IOS: Handled in _addToSuperview - when the proxy is added, it adds all its children to the new parent.
// - Android: _onAttached calls _addViewToNativeVisualTree recursively when the proxy is added to the parent.
// * Proxy (with children) is added to the DOM. In _addViewToNativeVisualTree _addViewToNativeVisualTree recursively when the proxy is added to the parent.
// * Child is removed from attached proxy. Handled in _removeViewFromNativeVisualTree.
// * Proxy (with children) is removed form the DOM.
// - IOS: Handled in _removeFromSuperview - when the proxy is removed, it removes all its children from its parent.
// - Android: _onDetached calls _removeViewFromNativeVisualTree recursively when the proxy is removed from its parent.
// * Proxy (with children) is removed form the DOM. In _removeViewFromNativeVisualTree recursively when the proxy is removed from its parent.
export class ProxyViewContainer extends LayoutBase implements ProxyViewContainerDefinition {
// No native view for proxy container.
get ios(): any {
@ -97,27 +93,6 @@ export class ProxyViewContainer extends LayoutBase implements ProxyViewContainer
}
}
public _addToSuperview(superview: any, atIndex?: number): boolean {
let index = 0;
this.eachChildView((cv) => {
if (!cv._isAddedToNativeVisualTree) {
cv._isAddedToNativeVisualTree = this._addViewToNativeVisualTree(cv, index++);
}
return true;
});
return true;
}
public _removeFromSuperview() {
this.eachChildView((cv) => {
if (cv._isAddedToNativeVisualTree) {
this._removeViewFromNativeVisualTree(cv);
}
return true;
});
}
/*
* Some layouts (e.g. GridLayout) need to get notified when adding and
* removing children, so that they can update private measure data.