Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6706)

Unified Diff: chrome/test/data/extensions/api_test/bluetooth_low_energy/get_characteristics/runtest.js

Issue 593163002: Short-circuit failures in BLE js tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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) {

Powered by Google App Engine
This is Rietveld 408576698