diff --git a/tests/app/testRunner.ts b/tests/app/testRunner.ts index 0b08a74fc..1d1f877b3 100644 --- a/tests/app/testRunner.ts +++ b/tests/app/testRunner.ts @@ -79,7 +79,7 @@ allTests["TAB-VIEW"] = require("./ui/tab-view/tab-view-tests"); // allTests["IMAGE"] = require("./ui/image/image-tests"); // allTests["SLIDER"] = require("./ui/slider/slider-tests"); allTests["SWITCH"] = require("./ui/switch/switch-tests"); -// allTests["PROGRESS"] = require("./ui/progress/progress-tests"); +allTests["PROGRESS"] = require("./ui/progress/progress-tests"); // allTests["PLACEHOLDER"] = require("./ui/placeholder/placeholder-tests"); // allTests["PAGE"] = require("./ui/page/page-tests"); // allTests["LISTVIEW"] = require("./ui/list-view/list-view-tests"); diff --git a/tests/app/ui/progress/progress-tests.ts b/tests/app/ui/progress/progress-tests.ts index 91bf6aecd..ec0aa669c 100644 --- a/tests/app/ui/progress/progress-tests.ts +++ b/tests/app/ui/progress/progress-tests.ts @@ -103,18 +103,24 @@ export function test_property_changed_event_when_setting_maxValue_with_adjust() function testAction(views: Array) { var changedProperties = {}; var allChanges = 0; - progress.on(observable.Observable.propertyChangeEvent, function (data: observable.EventData) { + progress.on("valueChange", function (data: observable.EventData) { + allChanges++; + changedProperties[(data).propertyName] = true; + }); + + progress.on("maxValueChange", function (data: observable.EventData) { allChanges++; changedProperties[(data).propertyName] = true; }); // Act progress.maxValue = 40; - progress.off(observable.Observable.propertyChangeEvent); + progress.off("valueChange"); + progress.off("maxValueChange"); // Assert - TKUnit.assert(changedProperties["value"], "Property changed for 'value' not called."); TKUnit.assert(changedProperties["maxValue"], "Property changed for 'maxValue' not called."); + TKUnit.assert(changedProperties["value"], "Property changed for 'value' not called."); TKUnit.assertEqual(allChanges, 2, "Property changed callbacks."); }; diff --git a/tns-core-modules/ui/core/properties.ts b/tns-core-modules/ui/core/properties.ts index b5ef1036d..4f57a1df7 100644 --- a/tns-core-modules/ui/core/properties.ts +++ b/tns-core-modules/ui/core/properties.ts @@ -204,7 +204,8 @@ export class CoercibleProperty implements PropertyDescrip this.coerce = function (target: T): void { const originalValue: U = coerceKey in target ? target[coerceKey] : defaultValue; - target[key] = coerceCallback(target, originalValue); + // need that to make coercing but also fire change events + this.set.call(target, originalValue); } this.set = function (this: T, value: U): void { @@ -238,13 +239,13 @@ export class CoercibleProperty implements PropertyDescrip delete this[defaultValueKey]; } } else { - this[key] = value; + this[key] = unboxedValue; if (setNativeValue) { if (!(defaultValueKey in this)) { this[defaultValueKey] = this[native]; } - this[native] = value; + this[native] = unboxedValue; } } diff --git a/tns-core-modules/ui/progress/progress-common.ts b/tns-core-modules/ui/progress/progress-common.ts index 4317bce67..3ee304db3 100644 --- a/tns-core-modules/ui/progress/progress-common.ts +++ b/tns-core-modules/ui/progress/progress-common.ts @@ -30,11 +30,25 @@ export class ProgressBase extends View implements ProgressDefinition { /** * Represents the observable property backing the value property of each Progress instance. */ -export const valueProperty = new CoercibleProperty({ name: "value", defaultValue: 0, coerceValue: (t, v) => v < 0 ? 0 : Math.min(v, t.maxValue) }); +export const valueProperty = new CoercibleProperty({ + name: "value", + defaultValue: 0, + coerceValue: (t, v) => { + return v < 0 ? 0 : Math.min(v, t.maxValue) + }, + valueConverter: (v) => parseInt(v) +}); valueProperty.register(ProgressBase); /** * Represents the observable property backing the maxValue property of each Progress instance. */ -export const maxValueProperty = new Property({ name: "maxValue", defaultValue: 100, valueChanged: (target, oldValue, newValue) => valueProperty.coerce(target) }); +export const maxValueProperty = new Property({ + name: "maxValue", + defaultValue: 100, + valueChanged: (target, oldValue, newValue) => { + valueProperty.coerce(target); + }, + valueConverter: (v) => parseInt(v) +}); maxValueProperty.register(ProgressBase); \ No newline at end of file diff --git a/tns-core-modules/ui/progress/progress.android.ts b/tns-core-modules/ui/progress/progress.android.ts index 7eb481bba..bd54ee0f1 100644 --- a/tns-core-modules/ui/progress/progress.android.ts +++ b/tns-core-modules/ui/progress/progress.android.ts @@ -18,6 +18,10 @@ export class Progress extends ProgressBase { return this._android; } + get nativeView(): android.widget.ProgressBar { + return this._android; + } + get [valueProperty.native](): number { return 0; } diff --git a/tns-core-modules/ui/progress/progress.ios.ts b/tns-core-modules/ui/progress/progress.ios.ts index 8cd1e1bcb..1bfeef91d 100644 --- a/tns-core-modules/ui/progress/progress.ios.ts +++ b/tns-core-modules/ui/progress/progress.ios.ts @@ -12,6 +12,14 @@ export class Progress extends ProgressBase { return this._ios; } + get nativeView(): UIProgressView { + return this._ios; + } + + get _nativeView(): UIProgressView { + return this._ios; + } + get [valueProperty.native](): number { return 0; }