Index: chrome/test/data/extensions/api_test/bluetooth_low_energy/get_characteristics/runtest.js |
diff --git a/chrome/test/data/extensions/api_test/bluetooth_low_energy/get_characteristics/runtest.js b/chrome/test/data/extensions/api_test/bluetooth_low_energy/get_characteristics/runtest.js |
index 0e64237f044421dc11f61b442a08a82f29138642..b86c7a7e0ba7ef9e5100fd0a6b6c7e111a0750e0 100644 |
--- a/chrome/test/data/extensions/api_test/bluetooth_low_energy/get_characteristics/runtest.js |
+++ b/chrome/test/data/extensions/api_test/bluetooth_low_energy/get_characteristics/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 testGetCharacteristics() { |
+ if (error !== undefined) { |
+ chrome.test.sendMessage('fail'); |
+ chrome.test.fail(error); |
+ } |
chrome.test.assertEq(2, chrcs.length); |
chrome.test.assertEq('char_id0', chrcs[0].instanceId); |
@@ -52,25 +58,37 @@ function testGetCharacteristics() { |
var serviceId = 'service_id0'; |
var chrcs = null; |
-function failOnError() { |
+function earlyError(message) { |
+ error = message; |
+ chrome.test.runTests([testGetCharacteristics]); |
+} |
+ |
+function expectSuccess() { |
if (chrome.runtime.lastError) { |
- chrome.test.fail(chrome.runtime.lastError.message); |
+ earlyError('Unexpected Error: ' + chrome.runtime.lastError.message); |
} |
+ return error !== undefined; |
} |
chrome.bluetoothLowEnergy.getCharacteristics(serviceId, function (result) { |
if (result || !chrome.runtime.lastError) { |
- chrome.test.fail('getCharacteristics should have failed.'); |
+ earlyError('getCharacteristics should have failed.'); |
+ return; |
} |
chrome.bluetoothLowEnergy.getCharacteristics(serviceId, function (result) { |
- failOnError(); |
+ if (expectSuccess()) |
+ return; |
+ |
if (!result || result.length != 0) { |
- chrome.test.fail('Characteristics should be empty.'); |
+ earlyError('Characteristics should be empty.'); |
+ return; |
} |
chrome.bluetoothLowEnergy.getCharacteristics(serviceId, function (result) { |
- failOnError(); |
+ if (expectSuccess()) |
+ return; |
+ |
chrcs = result; |
chrome.test.sendMessage('ready', function (message) { |