Skip to content

Commit 048112b

Browse files
committed
Merge remote-tracking branch 'origin/main' into pr/10530
2 parents 5c21bda + 7036f12 commit 048112b

File tree

100 files changed

+38418
-1066
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+38418
-1066
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
# dependencies
99
**/node_modules
10-
**/package-lock.json
1110
**/yarn.lock
1211
**/pnpm-lock.yaml
1312
.npmrc
@@ -41,6 +40,7 @@ apps/**/*/*.js
4140
apps/**/*/*.map
4241
apps/**/*/platforms
4342
apps/**/*/webpack.*.js
43+
apps/**/package-lock.json
4444
*.tgz
4545
.npmrc
4646
**/**/*.log

apps/automated/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
"nativescript-theme-core": "file:../../node_modules/nativescript-theme-core"
1212
},
1313
"devDependencies": {
14-
"@nativescript/android": "rc",
15-
"@nativescript/ios": "rc",
16-
"@nativescript/visionos": "rc",
14+
"@nativescript/android": "~8.7.0",
15+
"@nativescript/ios": "~8.7.0",
16+
"@nativescript/visionos": "~8.7.0",
1717
"@nativescript/webpack": "file:../../dist/packages/nativescript-webpack.tgz",
1818
"circular-dependency-plugin": "^5.2.2",
1919
"typescript": "~5.4.0"

apps/automated/src/data/observable-tests.ts

Lines changed: 71 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ export var test_Observable_addEventListener_MultipleEvents = function () {
163163
obj.addEventListener(events, callback);
164164
obj.set('testName', 1);
165165
obj.test();
166-
TKUnit.assert(receivedCount === 2, 'Callbacks not raised properly.');
166+
TKUnit.assert(receivedCount === 0, "Expected no event handlers to fire upon the 'propertyChange' event when listening for event name 'propertyChange,tested', as we have dropped support for listening to plural event names.");
167167
};
168168

169169
export var test_Observable_addEventListener_MultipleEvents_ShouldTrim = function () {
@@ -176,13 +176,14 @@ export var test_Observable_addEventListener_MultipleEvents_ShouldTrim = function
176176

177177
var events = Observable.propertyChangeEvent + ' , ' + TESTED_NAME;
178178
obj.addEventListener(events, callback);
179-
TKUnit.assert(obj.hasListeners(Observable.propertyChangeEvent), 'Observable.addEventListener for multiple events should trim each event name.');
180-
TKUnit.assert(obj.hasListeners(TESTED_NAME), 'Observable.addEventListener for multiple events should trim each event name.');
179+
TKUnit.assert(obj.hasListeners(events), "Expected a listener to be present for event name 'propertyChange , tested', as we have dropped support for splitting plural event names.");
180+
TKUnit.assert(!obj.hasListeners(Observable.propertyChangeEvent), "Expected no listeners to be present for event name 'propertyChange', as we have dropped support for splitting plural event names.");
181+
TKUnit.assert(!obj.hasListeners(TESTED_NAME), "Expected no listeners to be present for event name 'tested', as we have dropped support for splitting plural event names.");
181182

182183
obj.set('testName', 1);
183184
obj.test();
184185

185-
TKUnit.assert(receivedCount === 2, 'Callbacks not raised properly.');
186+
TKUnit.assert(receivedCount === 0, "Expected no event handlers to fire upon the 'propertyChange' event when listening for event name 'propertyChange , tested', as we have dropped support for listening to plural event names (and trimming whitespace in event names).");
186187
};
187188

188189
export var test_Observable_addEventListener_MultipleCallbacks = function () {
@@ -223,7 +224,7 @@ export var test_Observable_addEventListener_MultipleCallbacks_MultipleEvents = f
223224
obj.set('testName', 1);
224225
obj.test();
225226

226-
TKUnit.assert(receivedCount === 4, 'The propertyChanged notification should be raised twice.');
227+
TKUnit.assert(receivedCount === 0, "Expected no event handlers to fire upon the 'propertyChange' event when listening for event name 'propertyChange , tested' with two different callbacks, as we have dropped support for listening to plural event names (and trimming whitespace in event names).");
227228
};
228229

229230
export var test_Observable_removeEventListener_SingleEvent_SingleCallback = function () {
@@ -273,7 +274,65 @@ export var test_Observable_removeEventListener_SingleEvent_MultipleCallbacks = f
273274
TKUnit.assert(receivedCount === 3, 'Observable.removeEventListener not working properly with multiple listeners.');
274275
};
275276

276-
export var test_Observable_removeEventListener_MutlipleEvents_SingleCallback = function () {
277+
export var test_Observable_identity = function () {
278+
const obj = new Observable();
279+
280+
let receivedCount = 0;
281+
const callback = () => receivedCount++;
282+
const eventName = Observable.propertyChangeEvent;
283+
284+
// The identity of an event listener is determined by the tuple of
285+
// [eventType, callback, thisArg], and influences addition and removal.
286+
287+
// If you try to add the same callback for a given event name twice, without
288+
// distinguishing by its thisArg, the second addition will no-op.
289+
obj.addEventListener(eventName, callback);
290+
obj.addEventListener(eventName, callback);
291+
obj.set('testName', 1);
292+
TKUnit.assert(receivedCount === 1, 'Expected Observable to fire exactly once upon a property change, having passed the same callback into addEventListener() twice');
293+
obj.removeEventListener(eventName, callback);
294+
TKUnit.assert(!obj.hasListeners(eventName), 'Expected removeEventListener(eventName, callback) to remove all matching callbacks regardless of thisArg');
295+
receivedCount = 0;
296+
297+
// All truthy thisArgs are distinct, so we have three distinct identities here
298+
// and they should all get added.
299+
obj.addEventListener(eventName, callback);
300+
obj.addEventListener(eventName, callback, 1);
301+
obj.addEventListener(eventName, callback, 2);
302+
obj.set('testName', 2);
303+
TKUnit.assert(receivedCount === 3, 'Expected Observable to fire exactly three times upon a property change, having passed the same callback into addEventListener() three times, with the latter two distinguished by each having a different truthy thisArg');
304+
obj.removeEventListener(eventName, callback);
305+
TKUnit.assert(!obj.hasListeners(eventName), 'Expected removeEventListener(eventName, callback) to remove all matching callbacks regardless of thisArg');
306+
receivedCount = 0;
307+
308+
// If you specify thisArg when removing an event listener, it should remove
309+
// just the event listener with the corresponding thisArg.
310+
obj.addEventListener(eventName, callback, 1);
311+
obj.addEventListener(eventName, callback, 2);
312+
obj.set('testName', 3);
313+
TKUnit.assert(receivedCount === 2, 'Expected Observable to fire exactly three times upon a property change, having passed the same callback into addEventListener() three times, with the latter two distinguished by each having a different truthy thisArg');
314+
obj.removeEventListener(eventName, callback, 2);
315+
TKUnit.assert(obj.hasListeners(eventName), 'Expected removeEventListener(eventName, callback, thisArg) to remove just the event listener that matched the callback and thisArg');
316+
obj.removeEventListener(eventName, callback, 1);
317+
TKUnit.assert(!obj.hasListeners(eventName), 'Expected removeEventListener(eventName, callback, thisArg) to remove the remaining event listener that matched the callback and thisArg');
318+
receivedCount = 0;
319+
320+
// All falsy thisArgs are treated alike, so these all have the same identity
321+
// and only the first should get added.
322+
obj.addEventListener(eventName, callback);
323+
obj.addEventListener(eventName, callback, 0);
324+
obj.addEventListener(eventName, callback, false);
325+
obj.addEventListener(eventName, callback, null);
326+
obj.addEventListener(eventName, callback, undefined);
327+
obj.addEventListener(eventName, callback, '');
328+
obj.set('testName', 4);
329+
TKUnit.assert(receivedCount === 1, 'Expected Observable to fire exactly once upon a property change, having passed the same callback into addEventListener() multiple times, each time with a different falsy (and therefore indistinct) thisArg');
330+
obj.removeEventListener(eventName, callback);
331+
TKUnit.assert(!obj.hasListeners(eventName), 'Expected removeEventListener(eventName, callback) to remove all matching callbacks regardless of thisArg');
332+
receivedCount = 0;
333+
};
334+
335+
export var test_Observable_removeEventListener_MultipleEvents_SingleCallback = function () {
277336
var obj = new TestObservable();
278337

279338
var receivedCount = 0;
@@ -283,19 +342,22 @@ export var test_Observable_removeEventListener_MutlipleEvents_SingleCallback = f
283342

284343
var events = Observable.propertyChangeEvent + ' , ' + TESTED_NAME;
285344
obj.addEventListener(events, callback);
345+
TKUnit.assert(obj.hasListeners(events), "Expected a listener to be present for event name 'propertyChange , tested', as we have dropped support for splitting plural event names.");
346+
TKUnit.assert(!obj.hasListeners(Observable.propertyChangeEvent), "Expected no listeners to be present for event name 'propertyChange', as we have dropped support for splitting plural event names.");
347+
TKUnit.assert(!obj.hasListeners(TESTED_NAME), "Expected no listeners to be present for event name 'tested', as we have dropped support for splitting plural event names.");
348+
TKUnit.assert(receivedCount === 0, "Expected no event handlers to fire upon the 'propertyChange' event when listening for event name 'propertyChange , tested', as we have dropped support for listening to plural event names (and trimming whitespace in event names).");
286349

287350
obj.set('testName', 1);
288351
obj.test();
289352

290353
obj.removeEventListener(events, callback);
291354

292-
TKUnit.assert(!obj.hasListeners(Observable.propertyChangeEvent), 'Expected result for hasObservers is false');
293-
TKUnit.assert(!obj.hasListeners(TESTED_NAME), 'Expected result for hasObservers is false.');
355+
TKUnit.assert(!obj.hasListeners(events), "Expected the listener for event name 'propertyChange , tested' to have been removed, as we have dropped support for splitting plural event names.");
294356

295357
obj.set('testName', 2);
296358
obj.test();
297359

298-
TKUnit.assert(receivedCount === 2, 'Expected receive count is 2');
360+
TKUnit.assert(receivedCount === 0, "Expected no event handlers to fire upon the 'propertyChange' event when listening for event name 'propertyChange , tested', as we have dropped support for listening to plural event names (and trimming whitespace in event names).");
299361
};
300362

301363
export var test_Observable_removeEventListener_SingleEvent_NoCallbackSpecified = function () {

apps/automated/src/file-system/file-system-tests.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export var testFileFromPath = function () {
6161
function (error) {
6262
TKUnit.assert(false, 'Failed to read/write text');
6363
//console.dir(error);
64-
}
64+
},
6565
);
6666
// << (hide)
6767
},
@@ -71,7 +71,7 @@ export var testFileFromPath = function () {
7171
TKUnit.assert(false, 'Failed to read/write text');
7272
//console.dir(error);
7373
// << (hide)
74-
}
74+
},
7575
);
7676
// << file-system-create
7777
};
@@ -106,7 +106,7 @@ export var testFileWrite = function () {
106106
function (error) {
107107
TKUnit.assert(false, 'Failed to read/write text');
108108
//console.dir(error);
109-
}
109+
},
110110
);
111111
// << (hide)
112112
},
@@ -116,7 +116,7 @@ export var testFileWrite = function () {
116116
TKUnit.assert(false, 'Failed to read/write text');
117117
//console.dir(error);
118118
// << (hide)
119-
}
119+
},
120120
);
121121
// << file-system-write-string
122122
};
@@ -172,7 +172,7 @@ export var testFileRead = function () {
172172
TKUnit.assert(false, 'Failed to read/write text');
173173
//console.dir(error);
174174
// << (hide)
175-
}
175+
},
176176
);
177177
},
178178
function (error) {
@@ -181,7 +181,7 @@ export var testFileRead = function () {
181181
TKUnit.assert(false, 'Failed to read/write text');
182182
//console.dir(error);
183183
// << (hide)
184-
}
184+
},
185185
);
186186
// << file-system-example-text
187187
};
@@ -245,13 +245,13 @@ export var testFileReadWriteBinaryAsync = function () {
245245
},
246246
function (error) {
247247
TKUnit.assert(false, 'Failed to read destination binary async');
248-
}
248+
},
249249
);
250250
},
251251
function (error) {
252252
// Failed to write the file.
253253
TKUnit.assert(false, 'Failed to write binary async');
254-
}
254+
},
255255
);
256256
// << (hide)
257257
},
@@ -260,7 +260,7 @@ export var testFileReadWriteBinaryAsync = function () {
260260
// >> (hide)
261261
TKUnit.assert(false, 'Failed to read binary async');
262262
// << (hide)
263-
}
263+
},
264264
);
265265
// << file-system-read-binary-async
266266
};
@@ -358,7 +358,7 @@ export var testGetEntities = function () {
358358
function (error) {
359359
// Failed to obtain folder's contents.
360360
// globalConsole.error(error.message);
361-
}
361+
},
362362
);
363363
// << file-system-folders-content
364364
};
@@ -493,7 +493,7 @@ export var testFileRename = function () {
493493
// >> (hide)
494494
TKUnit.assert(false, 'Failed to rename file');
495495
// << (hide)
496-
}
496+
},
497497
);
498498
// << file-system-renaming
499499
};
@@ -517,7 +517,7 @@ export var testFolderRename = function () {
517517
// >> (hide)
518518
TKUnit.assert(false, 'Folder.rename API not working.');
519519
// << (hide)
520-
}
520+
},
521521
);
522522
// << file-system-renaming-folder
523523
};
@@ -538,7 +538,7 @@ export var testFileRemove = function () {
538538
// >> (hide)
539539
TKUnit.assert(false, 'File.remove API not working.');
540540
// << (hide)
541-
}
541+
},
542542
);
543543
// << file-system-remove-file
544544
};
@@ -560,7 +560,7 @@ export var testFolderRemove = function () {
560560
// >> (hide)
561561
TKUnit.assert(false, 'File.remove API not working.');
562562
// << (hide)
563-
}
563+
},
564564
);
565565
// << file-system-remove-folder
566566
};
@@ -587,7 +587,7 @@ export var testFolderClear = function () {
587587
// >> (hide)
588588
TKUnit.assert(false, error.message);
589589
// << (hide)
590-
}
590+
},
591591
);
592592
// >> (hide)
593593
folder.getEntities().then(function (entities) {
@@ -609,7 +609,7 @@ export var testKnownFolderRename = function () {
609609
},
610610
function (error) {
611611
TKUnit.assert(true);
612-
}
612+
},
613613
);
614614
}
615615
};
@@ -625,7 +625,7 @@ export function testKnownFolderRemove(done) {
625625
},
626626
function (error) {
627627
done(null);
628-
}
628+
},
629629
);
630630
}
631631

apps/automated/src/ui/activity-indicator/activity-indicator-tests.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ function binding_busy_to_image() {
7979
sourceProperty: 'isLoading',
8080
targetProperty: 'busy',
8181
},
82-
image
82+
image,
8383
);
8484
// << activity-indicator-loading
8585
}

apps/automated/src/ui/button/button-tests-native.android.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Color, Button, Utils, CoreTypes } from '@nativescript/core';
2+
import { AndroidHelper } from '@nativescript/core/ui/core/view';
23

34
export function getNativeText(button: Button): string {
45
return button.android.getText();
@@ -19,15 +20,7 @@ export function getNativeColor(button: Button): Color {
1920
}
2021

2122
export function getNativeBackgroundColor(button: Button): Color {
22-
let bg = <any>button.android.getBackground();
23-
if (bg instanceof org.nativescript.widgets.BorderDrawable) {
24-
return new Color(bg.getBackgroundColor());
25-
} else if (bg instanceof android.graphics.drawable.ColorDrawable) {
26-
console.log(bg);
27-
return new Color(bg.getColor());
28-
} else {
29-
return new Color(bg.backgroundColor);
30-
}
23+
return AndroidHelper.getDrawableColor(button.android.getBackground());
3124
}
3225

3326
export function getNativeTextAlignment(button: Button): string {

0 commit comments

Comments
 (0)