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

Unified Diff: chrome/test/data/extensions/api_test/bluetooth_low_energy/get_descriptor/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_descriptor/runtest.js
diff --git a/chrome/test/data/extensions/api_test/bluetooth_low_energy/get_descriptor/runtest.js b/chrome/test/data/extensions/api_test/bluetooth_low_energy/get_descriptor/runtest.js
index 49418e4926f681b302a4331bffe07574ded54c1c..99e2830eafaaaa47eaee59def909eaf316687c94 100644
--- a/chrome/test/data/extensions/api_test/bluetooth_low_energy/get_descriptor/runtest.js
+++ b/chrome/test/data/extensions/api_test/bluetooth_low_energy/get_descriptor/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 testGetDescriptor() {
+ if (error !== undefined) {
+ chrome.test.sendMessage('fail');
+ chrome.test.fail(error);
+ }
chrome.test.assertTrue(descriptor != null, '\'descriptor\' is null');
chrome.test.assertEq('desc_id0', descriptor.instanceId);
@@ -27,42 +33,52 @@ var badDescId = 'desc_id1';
var descriptor = null;
+function earlyError(message) {
+ error = message;
+ chrome.test.runTests([testGetDescriptor]);
+}
+
+function expectError(result) {
+ if (result || !chrome.runtime.lastError) {
+ earlyError('getDescriptor should have failed');
+ }
+ return error !== undefined;
+}
+
// 1. Unknown descriptor instanceId.
getDescriptor(badDescId, function (result) {
if (result || !chrome.runtime.lastError) {
- chrome.test.fail('getDescriptor should have failed for \'badDescId\'');
+ earlyError('getDescriptor should have failed for \'badDescId\'');
+ return;
}
// 2. Known descriptor instanceId, but the mapped device is unknown.
getDescriptor(descId, function (result) {
- if (result || !chrome.runtime.lastError) {
- chrome.test.fail('getDescriptor should have failed');
- }
+ if (expectError(result))
+ return;
// 3. Known descriptor instanceId, but the mapped service is unknown.
getDescriptor(descId, function (result) {
- if (result || !chrome.runtime.lastError) {
- chrome.test.fail('getDescriptor should have failed');
- }
+ if (expectError(result))
+ return;
// 4. Known descriptor instanceId, but the mapped characteristic is
// unknown.
getDescriptor(descId, function (result) {
- if (result || !chrome.runtime.lastError) {
- chrome.test.fail('getDescriptor should have failed');
- }
+ if (expectError(result))
+ return;
// 5. Known descriptor instanceId, but the mapped the characteristic
// does not know about the descriptor.
getDescriptor(descId, function (result) {
- if (result || !chrome.runtime.lastError) {
- chrome.test.fail('getDescriptor should have failed');
- }
+ if (expectError(result))
+ return;
// 6. Success.
getDescriptor(descId, function (result) {
if (chrome.runtime.lastError) {
- chrome.test.fail(chrome.runtime.lastError.message);
+ earlyError(chrome.runtime.lastError.message);
+ return;
}
descriptor = result;

Powered by Google App Engine
This is Rietveld 408576698