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

Unified Diff: chrome/test/data/extensions/api_test/bluetooth_low_energy/write_characteristic_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_characteristic_value/runtest.js
diff --git a/chrome/test/data/extensions/api_test/bluetooth_low_energy/write_characteristic_value/runtest.js b/chrome/test/data/extensions/api_test/bluetooth_low_energy/write_characteristic_value/runtest.js
index 51fd4e96414ad0722a820c0c02c99678a6c5ff4c..e532f234682727211106da7feabc42301d48cf9f 100644
--- a/chrome/test/data/extensions/api_test/bluetooth_low_energy/write_characteristic_value/runtest.js
+++ b/chrome/test/data/extensions/api_test/bluetooth_low_energy/write_characteristic_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 testWriteCharacteristicValue() {
+ if (error !== undefined) {
+ chrome.test.sendMessage('fail');
+ chrome.test.fail(error);
+ }
chrome.test.assertTrue(characteristic != null, '\'characteristic\' is null');
chrome.test.assertEq(charId, characteristic.instanceId);
@@ -29,22 +35,30 @@ var writeValue = new ArrayBuffer(bytes.length);
var valueBytes = new Uint8Array(writeValue);
valueBytes.set(bytes);
+function earlyError(message) {
+ error = message;
+ chrome.test.runTests([testWriteCharacteristicValue]);
+}
+
// 1. Unknown characteristic instanceId.
writeCharacteristicValue(badCharId, writeValue, function (result) {
if (result || !chrome.runtime.lastError) {
- chrome.test.fail('\'badCharId\' did not cause failure');
+ earlyError('\'badCharId\' did not cause failure');
+ return;
}
// 2. Known characteristic instanceId, but call failure.
writeCharacteristicValue(charId, writeValue, function (result) {
if (result || !chrome.runtime.lastError) {
- chrome.test.fail('writeCharacteristicValue should have failed');
+ earlyError('writeCharacteristicValue should have failed');
+ return;
}
// 3. Call should succeed.
writeCharacteristicValue(charId, writeValue, function (result) {
if (chrome.runtime.lastError) {
- chrome.test.fail(chrome.runtime.lastError.message);
+ earlyError(chrome.runtime.lastError.message);
+ return;
}
chrome.bluetoothLowEnergy.getCharacteristic(charId, function (result) {

Powered by Google App Engine
This is Rietveld 408576698