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

Unified Diff: chrome/test/data/extensions/api_test/bluetooth_low_energy/write_descriptor_value/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/write_descriptor_value/runtest.js
diff --git a/chrome/test/data/extensions/api_test/bluetooth_low_energy/write_descriptor_value/runtest.js b/chrome/test/data/extensions/api_test/bluetooth_low_energy/write_descriptor_value/runtest.js
index ca687b10d375ec87d3c01bfb338a91379985ce0c..151c3587845af7a5838f4f1ee09965fc86d050f5 100644
--- a/chrome/test/data/extensions/api_test/bluetooth_low_energy/write_descriptor_value/runtest.js
+++ b/chrome/test/data/extensions/api_test/bluetooth_low_energy/write_descriptor_value/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 testWriteDescriptorValue() {
+ if (error !== undefined) {
+ chrome.test.sendMessage('fail');
+ chrome.test.fail(error);
+ }
chrome.test.assertTrue(descriptor != null, '\'descriptor\' is null');
chrome.test.assertEq(descId, descriptor.instanceId);
@@ -16,6 +22,11 @@ function testWriteDescriptorValue() {
chrome.test.succeed();
}
+function earlyError(message) {
+ error = message;
+ chrome.test.runTests([testWriteDescriptorValue]);
+}
+
var writeDescriptorValue = chrome.bluetoothLowEnergy.writeDescriptorValue;
var descId = 'desc_id0';
var badDescId = 'desc_id1';
@@ -30,19 +41,22 @@ valueBytes.set(bytes);
// 1. Unknown descriptor instanceId.
writeDescriptorValue(badDescId, writeValue, function (result) {
if (result || !chrome.runtime.lastError) {
- chrome.test.fail('\'badDescId\' did not cause failure');
+ earlyError('\'badDescId\' did not cause failure');
+ return;
}
// 2. Known descriptor instanceId, but call failure.
writeDescriptorValue(descId, writeValue, function (result) {
if (result || !chrome.runtime.lastError) {
- chrome.test.fail('writeDescriptorValue should have failed');
+ earlyError('writeDescriptorValue should have failed');
+ return;
}
// 3. Call should succeed.
writeDescriptorValue(descId, writeValue, function (result) {
if (chrome.runtime.lastError) {
- chrome.test.fail(chrome.runtime.lastError.message);
+ earlyError(chrome.runtime.lastError.message);
+ return;
}
chrome.bluetoothLowEnergy.getDescriptor(descId, function (result) {

Powered by Google App Engine
This is Rietveld 408576698