| Index: chrome/test/data/extensions/api_test/bluetooth_low_energy/read_descriptor_value/runtest.js
|
| diff --git a/chrome/test/data/extensions/api_test/bluetooth_low_energy/read_descriptor_value/runtest.js b/chrome/test/data/extensions/api_test/bluetooth_low_energy/read_descriptor_value/runtest.js
|
| index 550052023a478531e5fd54ba4e4093bf3539a53c..34cecd08af75ba3d779c5e60aaa24d5ee27e58d5 100644
|
| --- a/chrome/test/data/extensions/api_test/bluetooth_low_energy/read_descriptor_value/runtest.js
|
| +++ b/chrome/test/data/extensions/api_test/bluetooth_low_energy/read_descriptor_value/runtest.js
|
| @@ -26,32 +26,81 @@ function earlyError(message) {
|
| chrome.test.runTests([testReadDescriptorValue]);
|
| }
|
|
|
| -// 1. Unknown descriptor instanceId.
|
| -readDescriptorValue(badDescId, function (result) {
|
| +var queue = [];
|
| +
|
| +function runNext(result) {
|
| + if (queue.length == 0)
|
| + chrome.test.fail("No more tests!");
|
| +
|
| + (queue.shift())(result);
|
| +}
|
| +
|
| +var errorFailed = 'Operation failed';
|
| +var errorInProgress = 'In progress';
|
| +var errorInvalidLength = 'Invalid data length';
|
| +var errorPermissionDenied = 'Permission denied';
|
| +var errorNotConnected = 'Not connected';
|
| +var errorGattNotSupported = 'Operation not supported by this service';
|
| +var errorNotNotifying = 'Not notifying';
|
| +var errorNotFound = 'Instance not found';
|
| +var errorOperationFailed = 'Operation failed';
|
| +var errorAuthenticationFailed = 'Authentication failed';
|
| +var errorCanceled = 'Request canceled';
|
| +var errorTimeout = 'Operation timed out';
|
| +var errorUnsupportedDevice =
|
| + 'This device is not supported on the current platform';
|
| +var errorPlatformNotSupported =
|
| + 'This operation is not supported on the current platform';
|
| +
|
| +function makeExpectedErrorCallback(expectedError) {
|
| + return function(result) {
|
| + console.log('Expecting error ' + expectedError);
|
| + if (result || !chrome.runtime.lastError ||
|
| + chrome.runtime.lastError.message != expectedError) {
|
| + errorMsg = 'readDescriptorValue expected error \'' + expectedError + '\'';
|
| + if (chrome.runtime.lastError) {
|
| + errorMsg = errorMsg + ' but got \'' + chrome.runtime.lastError.message +
|
| + '\'';
|
| + }
|
| + earlyError(errorMsg);
|
| + return;
|
| + }
|
| +
|
| + readDescriptorValue(descId, runNext);
|
| + };
|
| +}
|
| +
|
| +queue = [function () {
|
| + // 1. Unknown descriptor instanceId.
|
| + readDescriptorValue(badDescId, runNext);
|
| +}, function (result) {
|
| if (result || !chrome.runtime.lastError) {
|
| earlyError('\'badDescId\' did not cause failure');
|
| return;
|
| }
|
|
|
| // 2. Known descriptor instanceId, but call failure.
|
| - readDescriptorValue(descId, function (result) {
|
| - if (result || !chrome.runtime.lastError) {
|
| - earlyError('readDescriptorValue should have failed');
|
| - return;
|
| - }
|
| -
|
| - // 3. Call should succeed.
|
| - readDescriptorValue(descId, function (result) {
|
| - if (chrome.runtime.lastError) {
|
| - earlyError(chrome.runtime.lastError.message);
|
| - return;
|
| - }
|
| + readDescriptorValue(descId, runNext);
|
| +},
|
| + makeExpectedErrorCallback(errorFailed),
|
| + makeExpectedErrorCallback(errorInvalidLength),
|
| + makeExpectedErrorCallback(errorPermissionDenied),
|
| + makeExpectedErrorCallback(errorPermissionDenied),
|
| + makeExpectedErrorCallback(errorNotConnected),
|
| + makeExpectedErrorCallback(errorGattNotSupported),
|
| + makeExpectedErrorCallback(errorInProgress),
|
| + function (result) {
|
| + if (chrome.runtime.lastError) {
|
| + earlyError(chrome.runtime.lastError.message);
|
| + return;
|
| + }
|
|
|
| - descriptor = result;
|
| + descriptor = result;
|
|
|
| - chrome.test.sendMessage('ready', function (message) {
|
| - chrome.test.runTests([testReadDescriptorValue]);
|
| - });
|
| - });
|
| + chrome.test.sendMessage('ready', function (message) {
|
| + chrome.test.runTests([testReadDescriptorValue]);
|
| });
|
| -});
|
| +}];
|
| +
|
| +runNext();
|
| +
|
|
|