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

Unified Diff: chrome/test/data/extensions/api_test/bluetooth_low_energy/get_services/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_services/runtest.js
diff --git a/chrome/test/data/extensions/api_test/bluetooth_low_energy/get_services/runtest.js b/chrome/test/data/extensions/api_test/bluetooth_low_energy/get_services/runtest.js
index ed16734c785b5f579659247af67dd228cef94963..f7a5e757729a3e832207c0427f530a636344f031 100644
--- a/chrome/test/data/extensions/api_test/bluetooth_low_energy/get_services/runtest.js
+++ b/chrome/test/data/extensions/api_test/bluetooth_low_energy/get_services/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 testGetServices() {
+ if (error !== undefined) {
+ chrome.test.sendMessage('fail');
+ chrome.test.fail(error);
+ }
chrome.test.assertEq(2, services.length);
chrome.test.assertEq('service_id0', services[0].instanceId);
@@ -25,25 +31,38 @@ function testGetServices() {
var deviceAddress = '11:22:33:44:55:66';
var services = null;
+function earlyError(message) {
+ error = message;
+ chrome.test.runTests([testGetServices]);
+}
+
function failOnError() {
if (chrome.runtime.lastError) {
- chrome.test.fail(chrome.runtime.lastError.message);
+ earlyError(chrome.runtime.lastError.message);
+ return true;
}
+ return false;
}
chrome.bluetoothLowEnergy.getServices(deviceAddress, function(result) {
if (result || !chrome.runtime.lastError) {
- chrome.test.fail('Unexpected device.');
+ earlyError('Unexpected device.');
+ return;
}
chrome.bluetoothLowEnergy.getServices(deviceAddress, function(result) {
- failOnError();
+ if (failOnError())
+ return;
+
if (!result || result.length != 0) {
- chrome.test.fail('Services should be empty.');
+ earlyError('Services should be empty.');
+ return;
}
chrome.bluetoothLowEnergy.getServices(deviceAddress, function(result) {
- failOnError();
+ if (failOnError())
+ return;
+
services = result;
chrome.test.sendMessage('ready', function(message) {

Powered by Google App Engine
This is Rietveld 408576698