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

Unified Diff: chrome/test/data/extensions/api_test/bluetooth_low_energy/get_descriptors/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_descriptors/runtest.js
diff --git a/chrome/test/data/extensions/api_test/bluetooth_low_energy/get_descriptors/runtest.js b/chrome/test/data/extensions/api_test/bluetooth_low_energy/get_descriptors/runtest.js
index 86c4d7c8fa20a66adc66493ba651c38567a06287..4589e27c816ab915174f90a0b3ed064b5590fdb2 100644
--- a/chrome/test/data/extensions/api_test/bluetooth_low_energy/get_descriptors/runtest.js
+++ b/chrome/test/data/extensions/api_test/bluetooth_low_energy/get_descriptors/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 testGetDescriptors() {
+ if (error !== undefined) {
+ chrome.test.sendMessage('fail');
+ chrome.test.fail(error);
+ }
chrome.test.assertEq(2, descrs.length);
chrome.test.assertEq('desc_id0', descrs[0].instanceId);
@@ -35,34 +41,48 @@ var badCharId = 'char_id1';
var descrs = null;
+function earlyError(message) {
+ error = message;
+ chrome.test.runTests([testGetDescriptors]);
+}
+
function failOnError() {
if (chrome.runtime.lastError) {
- chrome.test.fail(chrome.runtime.lastError.message);
+ earlyError(chrome.runtime.lastError.message);
+ return true;
}
+ return false;
}
// 1. Unknown characteristic ID.
getDescriptors(badCharId, function (result) {
if (result || !chrome.runtime.lastError) {
- chrome.test.fail('getDescriptors should have failed for \'badCharId\'');
+ earlyError('getDescriptors should have failed for \'badCharId\'');
+ return;
}
// 2. Known ID, unknown characteristic.
getDescriptors(charId, function (result) {
if (result || !chrome.runtime.lastError) {
- chrome.test.fail('getDescriptors should have failed');
+ earlyError('getDescriptors should have failed');
+ return;
}
// 3. Empty descriptors.
getDescriptors(charId, function (result) {
- failOnError();
+ if (failOnError())
+ return;
+
if (!result || result.length != 0) {
- chrome.test.fail('Descriptors should be empty');
+ earlyError('Descriptors should be empty');
+ return;
}
// 4. Success.
getDescriptors(charId, function (result) {
- failOnError();
+ if (failOnError())
+ return;
+
descrs = result;
chrome.test.sendMessage('ready', function (message) {

Powered by Google App Engine
This is Rietveld 408576698