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

Unified Diff: chrome/test/data/extensions/api_test/bluetooth_low_energy/start_stop_notifications/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/start_stop_notifications/runtest.js
diff --git a/chrome/test/data/extensions/api_test/bluetooth_low_energy/start_stop_notifications/runtest.js b/chrome/test/data/extensions/api_test/bluetooth_low_energy/start_stop_notifications/runtest.js
index fad86d8054b402209ac6bfbc1577c4a3046473f1..3c67980d47097104138bd770fccd1b95afff3af3 100644
--- a/chrome/test/data/extensions/api_test/bluetooth_low_energy/start_stop_notifications/runtest.js
+++ b/chrome/test/data/extensions/api_test/bluetooth_low_energy/start_stop_notifications/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 testStartStopNotifications() {
+ if (error !== undefined) {
+ chrome.test.sendMessage('fail');
+ chrome.test.fail(error);
+ }
chrome.test.assertEq(1, Object.keys(changedChrcs).length);
chrome.test.assertEq(charId0, changedChrcs[charId0].instanceId);
chrome.test.succeed();
@@ -23,33 +29,27 @@ var ble = chrome.bluetoothLowEnergy;
var start = ble.startCharacteristicNotifications;
var stop = ble.stopCharacteristicNotifications;
-function sendReady(errorMessage) {
- chrome.test.sendMessage('ready', function (message) {
- if (errorMessage) {
- chrome.test.fail(errorMessage);
- return;
- }
- chrome.test.runTests([testStartStopNotifications]);
- });
+function earlyError(message) {
+ error = message;
+ chrome.test.runTests([testStartStopNotifications]);
}
function expectError(expectedMessage) {
if (!chrome.runtime.lastError) {
- sendReady('Expected error: ' + expectedMessage);
- return;
- }
-
- if (chrome.runtime.lastError.message != expectedMessage) {
- sendReady('Expected error: ' + expectedMessage + ', got error: ' +
- expectedMessage);
+ earlyError('Expected error: ' + expectedMessage);
+ } else if (chrome.runtime.lastError.message != expectedMessage) {
+ earlyError('Expected error: ' + expectedMessage + ', got error: ' +
+ expectedMessage);
}
+ return error !== undefined;
}
function expectSuccess() {
if (chrome.runtime.lastError) {
- sendReady('Unexpected error: ' + chrome.runtime.lastError.message);
+ earlyError('Unexpected error: ' + chrome.runtime.lastError.message);
}
+ return error !== undefined;
}
ble.onCharacteristicValueChanged.addListener(function (chrc) {
@@ -57,26 +57,48 @@ ble.onCharacteristicValueChanged.addListener(function (chrc) {
});
start('foo', function () {
- expectError(errorNotFound);
+ if (expectError(errorNotFound))
+ return;
+
start(charId2, function () {
- expectError(errorPermissionDenied);
+ if (expectError(errorPermissionDenied))
+ return;
+
stop(charId0, function () {
- expectError(errorNotNotifying);
+ if (expectError(errorNotNotifying))
+ return;
+
start(charId0, function () {
- expectError(errorOperationFailed);
+ if (expectError(errorOperationFailed))
+ return;
+
start(charId0, function () {
- expectSuccess();
+ if (expectSuccess())
+ return;
+
start(charId0, function () {
- expectError(errorAlreadyNotifying);
+ if (expectError(errorAlreadyNotifying))
+ return;
+
start(charId1, function () {
- expectSuccess();
+ if (expectSuccess())
+ return;
+
stop(charId1, function () {
- expectSuccess();
+ if (expectSuccess())
+ return;
+
stop(charId1, function () {
- expectError(errorNotNotifying);
+ if (expectError(errorNotNotifying))
+ return;
+
stop(charId2, function () {
- expectError(errorNotNotifying);
- sendReady(undefined);
+ if (expectError(errorNotNotifying))
+ return;
+
+ chrome.test.sendMessage('ready', function (message) {
+ chrome.test.runTests([testStartStopNotifications]);
+ });
});
});
});

Powered by Google App Engine
This is Rietveld 408576698