@@ -19,8 +19,11 @@ sap.ui.define([
1919 "sap/ui/core/Core" ,
2020 "sap/m/Panel" ,
2121 "sap/m/GenericTile" ,
22- "sap/ui/qunit/utils/nextUIUpdate"
23- ] , function ( Localization , Element , jQuery , HeaderContainer , FlexBox , Label , VerticalLayout , Button , Device , Icon , coreLibrary , PseudoEvents , Mobile , mobileLibrary , Log , Text , oCore , Panel , GenericTile , nextUIUpdate ) {
22+ "sap/ui/qunit/utils/nextUIUpdate" ,
23+ "sap/ui/qunit/QUnitUtils" ,
24+ "sap/ui/events/KeyCodes" ,
25+ "sap/ui/core/theming/Parameters"
26+ ] , function ( Localization , Element , jQuery , HeaderContainer , FlexBox , Label , VerticalLayout , Button , Device , Icon , coreLibrary , PseudoEvents , Mobile , mobileLibrary , Log , Text , oCore , Panel , GenericTile , nextUIUpdate , qutils , KeyCodes , Parameters ) {
2427 "use strict" ;
2528
2629 // shortcut for sap.m.BackgroundDesign
@@ -32,6 +35,23 @@ sap.ui.define([
3235 // shortcut for sap.m.ScreenSizes
3336 var ScreenSizes = mobileLibrary . ScreenSizes ;
3437
38+ function remToPx ( remValue ) {
39+ const fontSize = parseFloat ( getComputedStyle ( document . documentElement ) . fontSize ) ;
40+ return parseFloat ( remValue ) * fontSize + "px" ;
41+ }
42+ function hexToRgb ( hex ) {
43+ var result = / ^ # ? ( [ a - f \d ] { 1 , 2 } ) ( [ a - f \d ] { 1 , 2 } ) ( [ a - f \d ] { 1 , 2 } ) $ / i. exec ( hex ) ;
44+ var clr = result ? {
45+ r : parseInt ( result [ 1 ] . length === 1 ? result [ 1 ] + result [ 1 ] : result [ 1 ] , 16 ) ,
46+ g : parseInt ( result [ 2 ] . length === 1 ? result [ 2 ] + result [ 2 ] : result [ 2 ] , 16 ) ,
47+ b : parseInt ( result [ 3 ] . length === 1 ? result [ 3 ] + result [ 3 ] : result [ 3 ] , 16 )
48+ } : null ;
49+ if ( clr ) {
50+ return "rgb(" + clr . r + ", " + clr . g + ", " + clr . b + ")" ;
51+ }
52+ return hex ;
53+ }
54+
3555 Mobile . init ( ) ;
3656
3757 QUnit . module ( "Default Property Values" , {
@@ -613,6 +633,78 @@ sap.ui.define([
613633 assert . equal ( this . oHeaderContainer . _oItemNavigation . getItemDomRefs ( ) [ 0 ] . style [ "border-color" ] , "transparent" , "Headercontainer border is transparent." ) ;
614634 } ) ;
615635
636+ QUnit . module ( "HeaderContainer :focus-visible outline" , {
637+ beforeEach : async function ( ) {
638+ document . documentElement . classList . add ( "sap-desktop" ) ;
639+ this . oHeaderContainer = new HeaderContainer ( {
640+ content : [
641+ new VerticalLayout ( ) ,
642+ new VerticalLayout ( ) ,
643+ new VerticalLayout ( )
644+ ]
645+ } ) ;
646+ this . oHeaderContainer . placeAt ( "qunit-fixture" ) ;
647+ await nextUIUpdate ( ) ;
648+ } ,
649+ afterEach : function ( ) {
650+ document . documentElement . classList . remove ( "sap-desktop" ) ;
651+ this . oHeaderContainer . destroy ( ) ;
652+ this . oHeaderContainer = null ;
653+ }
654+ } ) ;
655+
656+ QUnit . test ( "Checks Outline width, style, color and offset are correct" , async function ( assert ) {
657+ const oInnerDomRef = this . oHeaderContainer . $ ( )
658+ . find ( ".sapMHrdrCntrInner" ) [ 0 ] ;
659+ assert . ok ( oInnerDomRef , "Inner container exists" ) ;
660+
661+ // Helper to get Parameters asynchronously
662+ function getParameterAsync ( key , oElement ) {
663+ return new Promise ( ( resolve ) => {
664+ const value = Parameters . get ( {
665+ name : key ,
666+ scopeElement : oElement ,
667+ callback : resolve
668+ } ) ;
669+ if ( value !== undefined ) {
670+ resolve ( value ) ;
671+ }
672+ } ) ;
673+ }
674+
675+ // Trigger keyboard mode and focus the element
676+ qutils . triggerKeydown ( document , KeyCodes . TAB ) ;
677+ oInnerDomRef . focus ( ) ;
678+ await nextUIUpdate ( ) ;
679+
680+ // Fetch all theme parameters asynchronously
681+ const expectedWidth = remToPx ( await getParameterAsync ( "sapContent_FocusWidth" , oInnerDomRef ) ) ;
682+ const expectedStyle = await getParameterAsync ( "sapContent_FocusStyle" , oInnerDomRef ) ;
683+ const expectedColor = hexToRgb ( await getParameterAsync ( "sapContent_FocusColor" , oInnerDomRef ) ) ;
684+
685+ const computedStyle = window . getComputedStyle ( oInnerDomRef ) ;
686+
687+ assert . strictEqual (
688+ computedStyle . outlineWidth ,
689+ expectedWidth ,
690+ `Outline width matches theme parameter (expected: ${ expectedWidth } , actual: ${ computedStyle . outlineWidth } )`
691+ ) ;
692+ assert . strictEqual (
693+ computedStyle . outlineStyle ,
694+ expectedStyle ,
695+ `Outline style matches theme parameter (expected: ${ expectedStyle } , actual: ${ computedStyle . outlineStyle } )`
696+ ) ;
697+ assert . strictEqual (
698+ computedStyle . outlineColor ,
699+ expectedColor ,
700+ `Outline color matches theme parameter (expected: ${ expectedColor } , actual: ${ computedStyle . outlineColor } )`
701+ ) ;
702+ assert . strictEqual (
703+ computedStyle . outlineOffset ,
704+ "-2px" ,
705+ `Outline offset is -2px (expected: -2px, actual: ${ computedStyle . outlineOffset } )`
706+ ) ;
707+ } ) ;
616708 } //End of Device.system.desktop
617709
618710 QUnit . module ( "Padding removed when scrolling to begin and end" , {
0 commit comments