You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

151 lines
5.3 KiB

8 years ago
  1. /*
  2. *
  3. * Licensed to the Apache Software Foundation (ASF) under one
  4. * or more contributor license agreements. See the NOTICE file
  5. * distributed with this work for additional information
  6. * regarding copyright ownership. The ASF licenses this file
  7. * to you under the Apache License, Version 2.0 (the
  8. * "License"); you may not use this file except in compliance
  9. * with the License. You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing,
  14. * software distributed under the License is distributed on an
  15. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  16. * KIND, either express or implied. See the License for the
  17. * specific language governing permissions and limitations
  18. * under the License.
  19. *
  20. */
  21. /* jshint jasmine: true */
  22. /* global StatusBar */
  23. exports.defineAutoTests = function () {
  24. describe("StatusBar", function () {
  25. it("statusbar.spec.1 should exist", function() {
  26. expect(window.StatusBar).toBeDefined();
  27. });
  28. it("statusbar.spec.2 should have show|hide methods", function() {
  29. expect(window.StatusBar.show).toBeDefined();
  30. expect(typeof window.StatusBar.show).toBe("function");
  31. expect(window.StatusBar.hide).toBeDefined();
  32. expect(typeof window.StatusBar.hide).toBe("function");
  33. });
  34. it("statusbar.spec.3 should have set backgroundColor methods", function() {
  35. expect(window.StatusBar.backgroundColorByName).toBeDefined();
  36. expect(typeof window.StatusBar.backgroundColorByName).toBe("function");
  37. expect(window.StatusBar.backgroundColorByHexString).toBeDefined();
  38. expect(typeof window.StatusBar.backgroundColorByHexString).toBe("function");
  39. });
  40. it("statusbar.spec.4 should have set style methods", function() {
  41. expect(window.StatusBar.styleBlackTranslucent).toBeDefined();
  42. expect(typeof window.StatusBar.styleBlackTranslucent).toBe("function");
  43. expect(window.StatusBar.styleDefault).toBeDefined();
  44. expect(typeof window.StatusBar.styleDefault).toBe("function");
  45. expect(window.StatusBar.styleLightContent).toBeDefined();
  46. expect(typeof window.StatusBar.styleLightContent).toBe("function");
  47. expect(window.StatusBar.styleBlackOpaque).toBeDefined();
  48. expect(typeof window.StatusBar.styleBlackOpaque).toBe("function");
  49. expect(window.StatusBar.overlaysWebView).toBeDefined();
  50. expect(typeof window.StatusBar.overlaysWebView).toBe("function");
  51. });
  52. });
  53. };
  54. exports.defineManualTests = function (contentEl, createActionButton) {
  55. function log(msg) {
  56. var el = document.getElementById("info");
  57. var logLine = document.createElement('div');
  58. logLine.innerHTML = msg;
  59. el.appendChild(logLine);
  60. }
  61. function doShow() {
  62. StatusBar.show();
  63. log('StatusBar.isVisible=' + StatusBar.isVisible);
  64. }
  65. function doHide() {
  66. StatusBar.hide();
  67. log('StatusBar.isVisible=' + StatusBar.isVisible);
  68. }
  69. function doColor1() {
  70. log('set color=red');
  71. StatusBar.backgroundColorByName('red');
  72. }
  73. function doColor2() {
  74. log('set style=translucent black');
  75. StatusBar.styleBlackTranslucent();
  76. }
  77. function doColor3() {
  78. log('set style=default');
  79. StatusBar.styleDefault();
  80. }
  81. var showOverlay = true;
  82. function doOverlay() {
  83. showOverlay = !showOverlay;
  84. StatusBar.overlaysWebView(showOverlay);
  85. log('Set overlay=' + showOverlay);
  86. }
  87. /******************************************************************************/
  88. contentEl.innerHTML = '<div id="info"></div>' +
  89. 'Also: tapping bar on iOS should emit a log.' +
  90. '<div id="action-show"></div>' +
  91. 'Expected result: Status bar will be visible' +
  92. '</p> <div id="action-hide"></div>' +
  93. 'Expected result: Status bar will be hidden' +
  94. '</p> <div id="action-color2"></div>' +
  95. 'Expected result: Status bar text will be a light (white) color' +
  96. '</p> <div id="action-color3"></div>' +
  97. 'Expected result: Status bar text will be a dark (black) color' +
  98. '</p> <div id="action-overlays"></div>' +
  99. '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' +
  100. '</p> <div id="action-color1"></div>' +
  101. 'Expected result: If overlay false, background color for status bar will be red';
  102. log('StatusBar.isVisible=' + StatusBar.isVisible);
  103. window.addEventListener('statusTap', function () {
  104. log('tap!');
  105. }, false);
  106. createActionButton("Show", function () {
  107. doShow();
  108. }, 'action-show');
  109. createActionButton("Hide", function () {
  110. doHide();
  111. }, 'action-hide');
  112. createActionButton("Style=red (background)", function () {
  113. doColor1();
  114. }, 'action-color1');
  115. createActionButton("Style=translucent black", function () {
  116. doColor2();
  117. }, 'action-color2');
  118. createActionButton("Style=default", function () {
  119. doColor3();
  120. }, 'action-color3');
  121. createActionButton("Toggle Overlays", function () {
  122. doOverlay();
  123. }, 'action-overlays');
  124. };