/* * * 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. * */ /* eslint-env jasmine */ exports.defineManualTests = function (contentEl, createActionButton) { var logMessage = function (message, color) { var log = document.getElementById('info'); var logLine = document.createElement('div'); if (color) { logLine.style.color = color; } logLine.innerHTML = message; log.appendChild(logLine); }; var clearLog = function () { var log = document.getElementById('info'); log.innerHTML = ''; }; // ------------------------------------------------------------------------- // Vibrations // ------------------------------------------------------------------------- // new standard vibrate call that aligns to w3c spec with param long var vibrateWithInt = function () { clearLog(); navigator.vibrate(3000); logMessage('navigator.vibrate(3000)', 'green'); }; // new standard vibrate call that aligns to w3c spec with param array var vibrateWithArray = function () { clearLog(); navigator.vibrate([3000]); logMessage('navigator.vibrate([3000])', 'green'); }; // vibrate with a pattern using w3c spec var vibrateWithPattern = function () { clearLog(); navigator.vibrate([1000, 2000, 3000, 2000, 5000]); logMessage('navigator.vibrate([1000, 2000, 3000, 2000, 5000])', 'green'); }; // cancel existing vibration using w3c spec navigator.vibrate(0) var cancelWithZero = function () { clearLog(); navigator.vibrate(0); logMessage('navigator.vibrate(0)', 'green'); }; // cancel existing vibration using w3c spec navigator.vibrate([]) var cancelWithEmpty = function () { clearLog(); navigator.vibrate([]); logMessage('navigator.vibrate([])', 'green'); }; // reference to the timeout variable var timeout; // check whether there is an ongoing vibration var vibrateOn = false; // special long vibrate used to test cancel var longVibrate = function () { clearLog(); navigator.vibrate(60000); vibrateOn = true; logMessage('navigator.vibrate(60000)', 'green'); timeout = setTimeout(resetVibrateOn, 60000); // if user doesn't cancel vibrate, reset vibrateOn var after 60 seconds }; // special long vibrate with pattern used to test cancel var longVibrateWithPattern = function () { clearLog(); navigator.vibrate([1000, 2000, 3000, 2000, 5000, 2000, 30000]); vibrateOn = true; logMessage('navigator.vibrate([1000, 2000, 3000, 2000, 5000, 2000, 30000])', 'green'); timeout = setTimeout(resetVibrateOn, 45000); // if user doesn't cancel vibrate, reset vibrateOn var after 45 seconds }; // initiate two vibrations to test cancel var multipleVibrations = function () { clearLog(); navigator.vibrate(20000); navigator.vibrate(45000); vibrateOn = true; logMessage('navigator.vibrate(15000)\nnavigator.vibrate(45000)', 'green'); timeout = setTimeout(resetVibrateOn, 45000); // if user doesn't cancel vibrate, reset vibrateOn var after 45 seconds }; function resetVibrateOn () { vibrateOn = false; } var vibrate_tests = '