| Index: chrome/test/data/extensions/api_test/bluetooth_low_energy/start_stop_notifications/runtest.js
|
| diff --git a/chrome/test/data/extensions/api_test/bluetooth_low_energy/start_stop_notifications/runtest.js b/chrome/test/data/extensions/api_test/bluetooth_low_energy/start_stop_notifications/runtest.js
|
| index fad86d8054b402209ac6bfbc1577c4a3046473f1..3c67980d47097104138bd770fccd1b95afff3af3 100644
|
| --- a/chrome/test/data/extensions/api_test/bluetooth_low_energy/start_stop_notifications/runtest.js
|
| +++ b/chrome/test/data/extensions/api_test/bluetooth_low_energy/start_stop_notifications/runtest.js
|
| @@ -2,7 +2,13 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| +var error;
|
| +
|
| function testStartStopNotifications() {
|
| + if (error !== undefined) {
|
| + chrome.test.sendMessage('fail');
|
| + chrome.test.fail(error);
|
| + }
|
| chrome.test.assertEq(1, Object.keys(changedChrcs).length);
|
| chrome.test.assertEq(charId0, changedChrcs[charId0].instanceId);
|
| chrome.test.succeed();
|
| @@ -23,33 +29,27 @@ var ble = chrome.bluetoothLowEnergy;
|
| var start = ble.startCharacteristicNotifications;
|
| var stop = ble.stopCharacteristicNotifications;
|
|
|
| -function sendReady(errorMessage) {
|
| - chrome.test.sendMessage('ready', function (message) {
|
| - if (errorMessage) {
|
| - chrome.test.fail(errorMessage);
|
| - return;
|
| - }
|
|
|
| - chrome.test.runTests([testStartStopNotifications]);
|
| - });
|
| +function earlyError(message) {
|
| + error = message;
|
| + chrome.test.runTests([testStartStopNotifications]);
|
| }
|
|
|
| function expectError(expectedMessage) {
|
| if (!chrome.runtime.lastError) {
|
| - sendReady('Expected error: ' + expectedMessage);
|
| - return;
|
| - }
|
| -
|
| - if (chrome.runtime.lastError.message != expectedMessage) {
|
| - sendReady('Expected error: ' + expectedMessage + ', got error: ' +
|
| - expectedMessage);
|
| + earlyError('Expected error: ' + expectedMessage);
|
| + } else if (chrome.runtime.lastError.message != expectedMessage) {
|
| + earlyError('Expected error: ' + expectedMessage + ', got error: ' +
|
| + expectedMessage);
|
| }
|
| + return error !== undefined;
|
| }
|
|
|
| function expectSuccess() {
|
| if (chrome.runtime.lastError) {
|
| - sendReady('Unexpected error: ' + chrome.runtime.lastError.message);
|
| + earlyError('Unexpected error: ' + chrome.runtime.lastError.message);
|
| }
|
| + return error !== undefined;
|
| }
|
|
|
| ble.onCharacteristicValueChanged.addListener(function (chrc) {
|
| @@ -57,26 +57,48 @@ ble.onCharacteristicValueChanged.addListener(function (chrc) {
|
| });
|
|
|
| start('foo', function () {
|
| - expectError(errorNotFound);
|
| + if (expectError(errorNotFound))
|
| + return;
|
| +
|
| start(charId2, function () {
|
| - expectError(errorPermissionDenied);
|
| + if (expectError(errorPermissionDenied))
|
| + return;
|
| +
|
| stop(charId0, function () {
|
| - expectError(errorNotNotifying);
|
| + if (expectError(errorNotNotifying))
|
| + return;
|
| +
|
| start(charId0, function () {
|
| - expectError(errorOperationFailed);
|
| + if (expectError(errorOperationFailed))
|
| + return;
|
| +
|
| start(charId0, function () {
|
| - expectSuccess();
|
| + if (expectSuccess())
|
| + return;
|
| +
|
| start(charId0, function () {
|
| - expectError(errorAlreadyNotifying);
|
| + if (expectError(errorAlreadyNotifying))
|
| + return;
|
| +
|
| start(charId1, function () {
|
| - expectSuccess();
|
| + if (expectSuccess())
|
| + return;
|
| +
|
| stop(charId1, function () {
|
| - expectSuccess();
|
| + if (expectSuccess())
|
| + return;
|
| +
|
| stop(charId1, function () {
|
| - expectError(errorNotNotifying);
|
| + if (expectError(errorNotNotifying))
|
| + return;
|
| +
|
| stop(charId2, function () {
|
| - expectError(errorNotNotifying);
|
| - sendReady(undefined);
|
| + if (expectError(errorNotNotifying))
|
| + return;
|
| +
|
| + chrome.test.sendMessage('ready', function (message) {
|
| + chrome.test.runTests([testStartStopNotifications]);
|
| + });
|
| });
|
| });
|
| });
|
|
|