2014-07-25 03:11:27 +08:00
/ *
*
* Licensed to the Apache Software Foundation ( ASF ) under one
* or more contributor license agreements . See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership . The ASF licenses this file
* to you under the Apache License , Version 2.0 ( the
* "License" ) ; you may not use this file except in compliance
* with the License . You may obtain a copy of the License at
*
* http : //www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing ,
* software distributed under the License is distributed on an
* "AS IS" BASIS , WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND , either express or implied . See the License for the
* specific language governing permissions and limitations
* under the License .
*
2020-07-02 18:12:16 +08:00
* /
2014-07-25 03:11:27 +08:00
2016-02-24 15:28:04 +08:00
/* global StatusBar */
2015-06-17 08:15:00 +08:00
exports . defineAutoTests = function ( ) {
2020-07-02 18:12:16 +08:00
describe ( 'StatusBar' , function ( ) {
it ( 'statusbar.spec.1 should exist' , function ( ) {
2015-06-17 08:15:00 +08:00
expect ( window . StatusBar ) . toBeDefined ( ) ;
} ) ;
2020-07-02 18:12:16 +08:00
it ( 'statusbar.spec.2 should have show|hide methods' , function ( ) {
2015-06-17 08:15:00 +08:00
expect ( window . StatusBar . show ) . toBeDefined ( ) ;
2020-07-02 18:12:16 +08:00
expect ( typeof window . StatusBar . show ) . toBe ( 'function' ) ;
2015-06-17 08:15:00 +08:00
expect ( window . StatusBar . hide ) . toBeDefined ( ) ;
2020-07-02 18:12:16 +08:00
expect ( typeof window . StatusBar . hide ) . toBe ( 'function' ) ;
2015-06-17 08:15:00 +08:00
} ) ;
2020-07-02 18:12:16 +08:00
it ( 'statusbar.spec.3 should have set backgroundColor methods' , function ( ) {
2015-06-17 08:15:00 +08:00
expect ( window . StatusBar . backgroundColorByName ) . toBeDefined ( ) ;
2020-07-02 18:12:16 +08:00
expect ( typeof window . StatusBar . backgroundColorByName ) . toBe ( 'function' ) ;
2015-06-17 08:15:00 +08:00
expect ( window . StatusBar . backgroundColorByHexString ) . toBeDefined ( ) ;
2020-07-02 18:12:16 +08:00
expect ( typeof window . StatusBar . backgroundColorByHexString ) . toBe ( 'function' ) ;
2015-06-17 08:15:00 +08:00
} ) ;
2020-07-02 18:12:16 +08:00
it ( 'statusbar.spec.4 should have set style methods' , function ( ) {
2015-06-17 08:15:00 +08:00
expect ( window . StatusBar . styleDefault ) . toBeDefined ( ) ;
2020-07-02 18:12:16 +08:00
expect ( typeof window . StatusBar . styleDefault ) . toBe ( 'function' ) ;
2015-06-17 08:15:00 +08:00
expect ( window . StatusBar . styleLightContent ) . toBeDefined ( ) ;
2020-07-02 18:12:16 +08:00
expect ( typeof window . StatusBar . styleLightContent ) . toBe ( 'function' ) ;
2015-06-17 08:15:00 +08:00
expect ( window . StatusBar . overlaysWebView ) . toBeDefined ( ) ;
2020-07-02 18:12:16 +08:00
expect ( typeof window . StatusBar . overlaysWebView ) . toBe ( 'function' ) ;
2015-06-17 08:15:00 +08:00
} ) ;
} ) ;
} ;
2014-07-25 03:11:27 +08:00
exports . defineManualTests = function ( contentEl , createActionButton ) {
2020-07-02 18:12:16 +08:00
function log ( msg ) {
var el = document . getElementById ( 'info' ) ;
2014-07-25 03:11:27 +08:00
var logLine = document . createElement ( 'div' ) ;
logLine . innerHTML = msg ;
el . appendChild ( logLine ) ;
}
2020-07-02 18:12:16 +08:00
function doShow ( ) {
2014-07-25 03:11:27 +08:00
StatusBar . show ( ) ;
log ( 'StatusBar.isVisible=' + StatusBar . isVisible ) ;
}
2020-07-02 18:12:16 +08:00
function doHide ( ) {
2014-07-25 03:11:27 +08:00
StatusBar . hide ( ) ;
log ( 'StatusBar.isVisible=' + StatusBar . isVisible ) ;
}
2020-07-02 18:12:16 +08:00
function doColor1 ( ) {
2014-07-25 03:11:27 +08:00
log ( 'set color=red' ) ;
StatusBar . backgroundColorByName ( 'red' ) ;
}
2020-07-02 18:12:16 +08:00
function doColor3 ( ) {
2014-07-25 03:11:27 +08:00
log ( 'set style=default' ) ;
StatusBar . styleDefault ( ) ;
}
var showOverlay = true ;
2020-07-02 18:12:16 +08:00
function doOverlay ( ) {
2014-07-25 03:11:27 +08:00
showOverlay = ! showOverlay ;
StatusBar . overlaysWebView ( showOverlay ) ;
log ( 'Set overlay=' + showOverlay ) ;
}
/******************************************************************************/
2020-07-02 18:12:16 +08:00
contentEl . innerHTML =
'<div id="info"></div>' +
2014-07-25 03:11:27 +08:00
'Also: tapping bar on iOS should emit a log.' +
'<div id="action-show"></div>' +
2014-07-29 23:53:53 +08:00
'Expected result: Status bar will be visible' +
'</p> <div id="action-hide"></div>' +
'Expected result: Status bar will be hidden' +
'</p> <div id="action-color2"></div>' +
'Expected result: Status bar text will be a light (white) color' +
'</p> <div id="action-color3"></div>' +
'Expected result: Status bar text will be a dark (black) color' +
'</p> <div id="action-overlays"></div>' +
'Expected result:<br>Overlay true = status bar will lay on top of web view content<br>Overlay false = status bar will be separate from web view and will not cover content' +
'</p> <div id="action-color1"></div>' +
'Expected result: If overlay false, background color for status bar will be red' ;
2014-07-25 03:11:27 +08:00
log ( 'StatusBar.isVisible=' + StatusBar . isVisible ) ;
2020-07-02 18:12:16 +08:00
window . addEventListener (
'statusTap' ,
function ( ) {
log ( 'tap!' ) ;
} ,
false
) ;
createActionButton (
'Show' ,
function ( ) {
doShow ( ) ;
} ,
'action-show'
) ;
createActionButton (
'Hide' ,
function ( ) {
doHide ( ) ;
} ,
'action-hide'
) ;
createActionButton (
'Style=red (background)' ,
function ( ) {
doColor1 ( ) ;
} ,
'action-color1'
) ;
createActionButton (
'Style=default' ,
function ( ) {
doColor3 ( ) ;
} ,
'action-color3'
) ;
createActionButton (
'Toggle Overlays' ,
function ( ) {
doOverlay ( ) ;
} ,
'action-overlays'
) ;
2014-07-25 03:11:27 +08:00
} ;