@@ -22,6 +22,7 @@ import {
2222} from "tns-core-modules/ui/core/view/view-common" ;
2323import { DeviceType } from "tns-core-modules/ui/enums/enums" ;
2424
25+ const CLASS_NAME = "class-name" ;
2526const ROOT_CSS_CLASS = "ns-root" ;
2627const MODAL_CSS_CLASS = "ns-modal" ;
2728const ANDROID_PLATFORM_CSS_CLASS = "ns-android" ;
@@ -32,18 +33,41 @@ const PORTRAIT_ORIENTATION_CSS_CLASS = "ns-portrait";
3233const LANDSCAPE_ORIENTATION_CSS_CLASS = "ns-landscape" ;
3334const UNKNOWN_ORIENTATION_CSS_CLASS = "ns-unknown" ;
3435
35- export function test_root_view_root_css_class ( ) {
36- const rootViewCssClasses = getRootView ( ) . cssClasses ;
36+ function _test_root_view_root_css_class ( shouldSetClassName : boolean ) {
37+ const rootView = getRootView ( ) ;
38+ if ( shouldSetClassName ) {
39+ rootView . className = CLASS_NAME ;
40+ }
3741
42+ const rootViewCssClasses = rootView . cssClasses ;
3843 TKUnit . assertTrue ( rootViewCssClasses . has (
3944 ROOT_CSS_CLASS ) ,
4045 `${ ROOT_CSS_CLASS } CSS class is missing`
4146 ) ;
47+
48+ if ( shouldSetClassName ) {
49+ TKUnit . assertTrue ( rootViewCssClasses . has (
50+ CLASS_NAME ) ,
51+ `${ CLASS_NAME } CSS class is missing`
52+ ) ;
53+ }
4254}
4355
44- export function test_root_view_platform_css_class ( ) {
45- const rootViewCssClasses = getRootView ( ) . cssClasses ;
56+ export function test_root_view_root_css_class ( ) {
57+ _test_root_view_root_css_class ( false ) ;
58+ }
59+
60+ export function test_root_view_class_name_preserve_root_css_class ( ) {
61+ _test_root_view_root_css_class ( true ) ;
62+ }
4663
64+ function _test_root_view_platform_css_class ( shouldSetClassName : boolean ) {
65+ const rootView = getRootView ( ) ;
66+ if ( shouldSetClassName ) {
67+ rootView . className = CLASS_NAME ;
68+ }
69+
70+ const rootViewCssClasses = rootView . cssClasses ;
4771 if ( isAndroid ) {
4872 TKUnit . assertTrue ( rootViewCssClasses . has (
4973 ANDROID_PLATFORM_CSS_CLASS ) ,
@@ -63,10 +87,30 @@ export function test_root_view_platform_css_class() {
6387 `${ ANDROID_PLATFORM_CSS_CLASS } CSS class is present`
6488 ) ;
6589 }
90+
91+ if ( shouldSetClassName ) {
92+ TKUnit . assertTrue ( rootViewCssClasses . has (
93+ CLASS_NAME ) ,
94+ `${ CLASS_NAME } CSS class is missing`
95+ ) ;
96+ }
6697}
6798
68- export function test_root_view_device_type_css_class ( ) {
69- const rootViewCssClasses = getRootView ( ) . cssClasses ;
99+ export function test_root_view_platform_css_class ( ) {
100+ _test_root_view_platform_css_class ( false ) ;
101+ }
102+
103+ export function test_root_view_class_name_preserve_platform_css_class ( ) {
104+ _test_root_view_platform_css_class ( true ) ;
105+ }
106+
107+ function _test_root_view_device_type_css_class ( shouldSetClassName : boolean ) {
108+ const rootView = getRootView ( ) ;
109+ if ( shouldSetClassName ) {
110+ rootView . className = CLASS_NAME ;
111+ }
112+
113+ const rootViewCssClasses = rootView . cssClasses ;
70114 const deviceType = device . deviceType ;
71115
72116 if ( deviceType === DeviceType . Phone ) {
@@ -88,10 +132,30 @@ export function test_root_view_device_type_css_class() {
88132 `${ PHONE_DEVICE_TYPE_CSS_CLASS } CSS class is present`
89133 ) ;
90134 }
135+
136+ if ( shouldSetClassName ) {
137+ TKUnit . assertTrue ( rootViewCssClasses . has (
138+ CLASS_NAME ) ,
139+ `${ CLASS_NAME } CSS class is missing`
140+ ) ;
141+ }
91142}
92143
93- export function test_root_view_orientation_css_class ( ) {
94- const rootViewCssClasses = getRootView ( ) . cssClasses ;
144+ export function test_root_view_device_type_css_class ( ) {
145+ _test_root_view_device_type_css_class ( false ) ;
146+ }
147+
148+ export function test_root_view_class_name_preserve_device_type_css_class ( ) {
149+ _test_root_view_device_type_css_class ( true ) ;
150+ }
151+
152+ function _test_root_view_orientation_css_class ( shouldSetClassName : boolean ) {
153+ const rootView = getRootView ( ) ;
154+ if ( shouldSetClassName ) {
155+ rootView . className = CLASS_NAME ;
156+ }
157+
158+ const rootViewCssClasses = rootView . cssClasses ;
95159 let appOrientation ;
96160
97161 if ( isAndroid ) {
@@ -140,9 +204,24 @@ export function test_root_view_orientation_css_class() {
140204 `${ PORTRAIT_ORIENTATION_CSS_CLASS } CSS class is present`
141205 ) ;
142206 }
207+
208+ if ( shouldSetClassName ) {
209+ TKUnit . assertTrue ( rootViewCssClasses . has (
210+ CLASS_NAME ) ,
211+ `${ CLASS_NAME } CSS class is missing`
212+ ) ;
213+ }
143214}
144215
145- export function test_modal_root_view_modal_css_class ( ) {
216+ export function test_root_view_orientation_css_class ( ) {
217+ _test_root_view_orientation_css_class ( false ) ;
218+ }
219+
220+ export function test_root_view_class_name_preserve_orientation_css_class ( ) {
221+ _test_root_view_orientation_css_class ( true ) ;
222+ }
223+
224+ function _test_modal_root_view_modal_css_class ( shouldSetClassName : boolean ) {
146225 let modalClosed = false ;
147226
148227 const modalCloseCallback = function ( ) {
@@ -153,7 +232,20 @@ export function test_modal_root_view_modal_css_class() {
153232 const page = < Page > args . object ;
154233 page . off ( View . shownModallyEvent , modalPageShownModallyEventHandler ) ;
155234
156- TKUnit . assertTrue ( _rootModalViews [ 0 ] . cssClasses . has ( MODAL_CSS_CLASS ) ) ;
235+ const rootModalView = _rootModalViews [ 0 ] ;
236+ if ( shouldSetClassName ) {
237+ rootModalView . className = CLASS_NAME ;
238+ }
239+
240+ const rootModalViewCssClasses = rootModalView . cssClasses ;
241+ TKUnit . assertTrue ( rootModalViewCssClasses . has ( MODAL_CSS_CLASS ) ,
242+ `${ MODAL_CSS_CLASS } CSS class is missing` ) ;
243+
244+ if ( shouldSetClassName ) {
245+ TKUnit . assertTrue ( rootModalViewCssClasses . has ( CLASS_NAME ) ,
246+ `${ CLASS_NAME } CSS class is missing` ) ;
247+ }
248+
157249 args . closeCallback ( ) ;
158250 } ;
159251
@@ -186,3 +278,11 @@ export function test_modal_root_view_modal_css_class() {
186278 helper . navigate ( hostPageFactory ) ;
187279 TKUnit . waitUntilReady ( ( ) => modalClosed ) ;
188280}
281+
282+ export function test_modal_root_view_modal_css_class ( ) {
283+ _test_modal_root_view_modal_css_class ( false ) ;
284+ }
285+
286+ export function test_modal_root_view_class_name_preserve_modal_css_class ( ) {
287+ _test_modal_root_view_modal_css_class ( true ) ;
288+ }
0 commit comments