@@ -324,6 +324,66 @@ export function testSetAndRemoveBackgroundColor() {
324324 } ) ;
325325}
326326
327+ function getNativeBackgroundColor ( v : View ) : number {
328+ const drawable = ( < android . view . View > v . android ) . getBackground ( ) ;
329+ if ( drawable instanceof org . nativescript . widgets . BorderDrawable ) {
330+ return drawable . getBackgroundColor ( ) ;
331+ } else if ( drawable instanceof android . graphics . drawable . ColorDrawable ) {
332+ return drawable . getColor ( ) ;
333+ }
334+
335+ return drawable ? undefined : 0 ;
336+ }
337+
338+ export function testSetTransparentAndRemoveBackgroundColorWithBorderRadius ( ) {
339+ const lbl = new Label ( ) ;
340+ lbl . text = 'segment' ;
341+ lbl . borderRadius = 8 ;
342+ lbl . backgroundColor = new Color ( 'red' ) ;
343+ helper . buildUIAndRunTest ( lbl , function ( views : Array < View > ) {
344+ helper . waitUntilLayoutReady ( lbl ) ;
345+ TKUnit . assertEqual ( getNativeBackgroundColor ( lbl ) , new Color ( 'red' ) . android , 'BackgroundColor not applied correctly!' ) ;
346+
347+ lbl . backgroundColor = new Color ( 'transparent' ) ;
348+ TKUnit . assertEqual ( getNativeBackgroundColor ( lbl ) , 0 , 'transparent BackgroundColor not applied!' ) ;
349+
350+ lbl . backgroundColor = new Color ( 'red' ) ;
351+ TKUnit . assertEqual ( getNativeBackgroundColor ( lbl ) , new Color ( 'red' ) . android , 'BackgroundColor not applied correctly!' ) ;
352+
353+ lbl . backgroundColor = unsetValue ;
354+ TKUnit . assertEqual ( getNativeBackgroundColor ( lbl ) , 0 , 'BackgroundColor not removed!' ) ;
355+ } ) ;
356+ }
357+
358+ export function testToggleClassBackgroundColorFromCssVariableWithBorderRadius ( ) {
359+ const stack = new StackLayout ( ) ;
360+ stack . className = 'segments' ;
361+ stack . css = `
362+ .segments { --tile-color: red; }
363+ .segment { border-radius: 8; background-color: transparent; }
364+ .segment-selected { background-color: var(--tile-color); }
365+ .no-transparent-segment { border-radius: 8; }
366+ ` ;
367+ const lbl = new Label ( ) ;
368+ lbl . text = 'segment' ;
369+ lbl . className = 'segment segment-selected' ;
370+ stack . addChild ( lbl ) ;
371+ helper . buildUIAndRunTest ( stack , function ( views : Array < View > ) {
372+ helper . waitUntilLayoutReady ( lbl ) ;
373+ const red = new Color ( 'red' ) . android ;
374+ TKUnit . assertEqual ( getNativeBackgroundColor ( lbl ) , red , 'selected BackgroundColor not applied!' ) ;
375+
376+ lbl . className = 'segment' ;
377+ TKUnit . assertEqual ( getNativeBackgroundColor ( lbl ) , 0 , 'BackgroundColor should be transparent after deselection!' ) ;
378+
379+ lbl . className = 'no-transparent-segment segment-selected' ;
380+ TKUnit . assertEqual ( getNativeBackgroundColor ( lbl ) , red , 'selected BackgroundColor not applied!' ) ;
381+
382+ lbl . className = 'no-transparent-segment' ;
383+ TKUnit . assertEqual ( getNativeBackgroundColor ( lbl ) , 0 , 'BackgroundColor should be reset after deselection!' ) ;
384+ } ) ;
385+ }
386+
327387export function testBackgroundImage ( ) {
328388 const lbl = _createLabelWithBorder ( ) ;
329389 lbl . className = 'myClass' ;
0 commit comments