mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 21:01:34 +08:00
Merge pull request #366 from NativeScript/visibility-fix
visibility fixed
This commit is contained in:
@ -13,6 +13,7 @@ import layoutModule = require("ui/layouts/layout");
|
|||||||
import observable = require("data/observable");
|
import observable = require("data/observable");
|
||||||
import bindable = require("ui/core/bindable");
|
import bindable = require("ui/core/bindable");
|
||||||
import definition = require("./view-tests");
|
import definition = require("./view-tests");
|
||||||
|
import enums = require("ui/enums");
|
||||||
|
|
||||||
export var test_eachDescendant = function () {
|
export var test_eachDescendant = function () {
|
||||||
var test = function (views: Array<viewModule.View>) {
|
var test = function (views: Array<viewModule.View>) {
|
||||||
@ -125,18 +126,18 @@ export var test_event_LoadedUnloaded_IsRaised = function () {
|
|||||||
var layoutUnloaded = false,
|
var layoutUnloaded = false,
|
||||||
buttonUnloaded = false;
|
buttonUnloaded = false;
|
||||||
|
|
||||||
views[1].on(viewModule.View.unloadedEvent, (data) => {
|
views[1].on(viewModule.View.unloadedEvent,(data) => {
|
||||||
layoutUnloaded = true;
|
layoutUnloaded = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
views[2].on(viewModule.View.unloadedEvent, (data) => {
|
views[2].on(viewModule.View.unloadedEvent,(data) => {
|
||||||
buttonUnloaded = true;
|
buttonUnloaded = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
var newButton = new button.Button(),
|
var newButton = new button.Button(),
|
||||||
buttonLoaded = false;
|
buttonLoaded = false;
|
||||||
|
|
||||||
newButton.on(viewModule.View.loadedEvent, (data) => {
|
newButton.on(viewModule.View.loadedEvent,(data) => {
|
||||||
buttonLoaded = true;
|
buttonLoaded = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -260,13 +261,13 @@ var inheritanceTestProperty = new dependensyObservable.Property(
|
|||||||
"inheritanceTest",
|
"inheritanceTest",
|
||||||
"TestView",
|
"TestView",
|
||||||
new proxy.PropertyMetadata(inheritanceTestDefaultValue, dependensyObservable.PropertyMetadataSettings.Inheritable)
|
new proxy.PropertyMetadata(inheritanceTestDefaultValue, dependensyObservable.PropertyMetadataSettings.Inheritable)
|
||||||
);
|
);
|
||||||
|
|
||||||
var dummyProperty = new dependensyObservable.Property(
|
var dummyProperty = new dependensyObservable.Property(
|
||||||
"dummy",
|
"dummy",
|
||||||
"TestView",
|
"TestView",
|
||||||
new proxy.PropertyMetadata(0)
|
new proxy.PropertyMetadata(0)
|
||||||
);
|
);
|
||||||
|
|
||||||
class TestView extends layoutModule.Layout {
|
class TestView extends layoutModule.Layout {
|
||||||
|
|
||||||
@ -282,7 +283,7 @@ class TestView extends layoutModule.Layout {
|
|||||||
}
|
}
|
||||||
set tralala(value: string) {
|
set tralala(value: string) {
|
||||||
this._tralala = value;
|
this._tralala = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
get inheritanceTest(): number {
|
get inheritanceTest(): number {
|
||||||
return this._getValue(inheritanceTestProperty);
|
return this._getValue(inheritanceTestProperty);
|
||||||
@ -322,7 +323,7 @@ export var test_InheritableProperties_getValuesFromParent = function () {
|
|||||||
|
|
||||||
firstView.addChild(secondView);
|
firstView.addChild(secondView);
|
||||||
secondView.addChild(thirdView);
|
secondView.addChild(thirdView);
|
||||||
|
|
||||||
helper.do_PageTest(test, firstView, secondView, thirdView);
|
helper.do_PageTest(test, firstView, secondView, thirdView);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -388,11 +389,11 @@ export var test_InheritableProperties_ChangeNotification = function () {
|
|||||||
helper.do_PageTest(test, firstView, secondView, thirdView);
|
helper.do_PageTest(test, firstView, secondView, thirdView);
|
||||||
}
|
}
|
||||||
|
|
||||||
function property_binding_test (propName: string, firstValue: any, secondValue: any, view?: viewModule.View) {
|
function property_binding_test(propName: string, firstValue: any, secondValue: any, view?: viewModule.View) {
|
||||||
var actualResult;
|
var actualResult;
|
||||||
var model = new observable.Observable();
|
var model = new observable.Observable();
|
||||||
model.set(propName, firstValue);
|
model.set(propName, firstValue);
|
||||||
|
|
||||||
var options: bindable.BindingOptions = {
|
var options: bindable.BindingOptions = {
|
||||||
sourceProperty: propName,
|
sourceProperty: propName,
|
||||||
targetProperty: propName
|
targetProperty: propName
|
||||||
@ -401,7 +402,7 @@ function property_binding_test (propName: string, firstValue: any, secondValue:
|
|||||||
if (!view) {
|
if (!view) {
|
||||||
view = new TestView("view");
|
view = new TestView("view");
|
||||||
}
|
}
|
||||||
|
|
||||||
view.bind(options, model);
|
view.bind(options, model);
|
||||||
|
|
||||||
actualResult = view.get(propName);
|
actualResult = view.get(propName);
|
||||||
@ -594,6 +595,23 @@ function _createLabelWithBorder(): viewModule.View {
|
|||||||
return lbl;
|
return lbl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export var testIsVisible = function () {
|
||||||
|
var lbl = new label.Label();
|
||||||
|
|
||||||
|
helper.buildUIAndRunTest(lbl, function (views: Array<viewModule.View>) {
|
||||||
|
TKUnit.assert(lbl.visibility === enums.Visibility.visible, "Actual: " + lbl.visibility + "; Expected: " + enums.Visibility.visible);
|
||||||
|
TKUnit.assert(lbl._isVisible, "Actual: " + lbl._isVisible + "; Expected: true;");
|
||||||
|
|
||||||
|
lbl.visibility = enums.Visibility.collapse;
|
||||||
|
TKUnit.assert(lbl.visibility === enums.Visibility.collapse, "Actual: " + lbl.visibility + "; Expected: " + enums.Visibility.collapse);
|
||||||
|
TKUnit.assert(!lbl._isVisible, "Actual: " + lbl._isVisible + "; Expected: false;");
|
||||||
|
|
||||||
|
lbl.visibility = enums.Visibility.collapsed;
|
||||||
|
TKUnit.assert(lbl.visibility === enums.Visibility.collapsed, "Actual: " + lbl.visibility + "; Expected: " + enums.Visibility.collapsed);
|
||||||
|
TKUnit.assert(!lbl._isVisible, "Actual: " + lbl._isVisible + "; Expected: false;");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export var testBorderWidth = function () {
|
export var testBorderWidth = function () {
|
||||||
helper.buildUIAndRunTest(_createLabelWithBorder(), function (views: Array<viewModule.View>) {
|
helper.buildUIAndRunTest(_createLabelWithBorder(), function (views: Array<viewModule.View>) {
|
||||||
var lbl = <label.Label>views[0];
|
var lbl = <label.Label>views[0];
|
||||||
|
@ -671,7 +671,7 @@ function isVisibilityValid(value: string): boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setLayoutInfoVisibility(data: observable.PropertyChangeData) {
|
function setLayoutInfoVisibility(data: observable.PropertyChangeData) {
|
||||||
(<any>data.object)._view._isVisibleCache = (data.newValue !== enums.Visibility.collapse || data.newValue !== enums.Visibility.collapsed);
|
(<any>data.object)._view._isVisibleCache = (data.newValue === enums.Visibility.visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
export var visibilityProperty = new styleProperty.Property("visibility", "visibility",
|
export var visibilityProperty = new styleProperty.Property("visibility", "visibility",
|
||||||
|
Reference in New Issue
Block a user