Chromium Code Reviews| Index: chrome/test/data/extensions/api_test/bluetooth_low_energy/reset_all_advertisements/runtest.js |
| diff --git a/chrome/test/data/extensions/api_test/bluetooth_low_energy/reset_all_advertisements/runtest.js b/chrome/test/data/extensions/api_test/bluetooth_low_energy/reset_all_advertisements/runtest.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c06a20d896dd499bc55f32ec3f4715594d4e1f50 |
| --- /dev/null |
| +++ b/chrome/test/data/extensions/api_test/bluetooth_low_energy/reset_all_advertisements/runtest.js |
| @@ -0,0 +1,68 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
|
tbarzic
2017/06/27 19:04:57
nit: s/2015/2017
Sonny Sasaka
2017/06/27 22:03:14
Done.
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +var registerAdvertisement = |
| + chrome.bluetoothLowEnergy.registerAdvertisement; |
| +var unregisterAdvertisement = |
| + chrome.bluetoothLowEnergy.unregisterAdvertisement; |
| +var resetAdvertising = |
| + chrome.bluetoothLowEnergy.resetAdvertising; |
| + |
| +var serviceUuidsValue = ['value1', 'value2']; |
|
tbarzic
2017/06/27 19:04:57
nit: rename these to kService...
Or even better,
Sonny Sasaka
2017/06/27 22:03:14
Done.
|
| +var manufacturerDataValue = [{id: 321, data: [1, 2, 3]}, |
| + {id: 567, data: [8, 2, 3]}] |
| +var solicitUuidsValue = ['value3', 'value4']; |
| +var serviceDataValue = [{uuid: 'uuid8', data: [1, 2, 3]}, |
| + {uuid: 'uuid36', data: [8, 2, 3]}] |
| + |
| +var advertisement = { |
| + type: 'broadcast', |
| + serviceUuids: serviceUuidsValue, |
| + manufacturerData: manufacturerDataValue, |
| + solicitUuids: solicitUuidsValue, |
| + serviceData: serviceDataValue |
| +}; |
| + |
| +var verifyAdvertisementsUnregistered = function (id1, id2) { |
| + unregisterAdvertisement(id1, function () { |
| + if (!chrome.runtime.lastError) { |
| + chrome.test.fail( |
| + 'unregisterAdvertisement should fail after resetAdvertising'); |
| + return; |
| + } |
| + |
| + unregisterAdvertisement(id2, function () { |
| + if (!chrome.runtime.lastError) { |
| + chrome.test.fail( |
| + 'unregisterAdvertisement should fail after resetAdvertising'); |
| + return; |
| + } |
| + chrome.test.succeed(); |
| + }); |
| + }); |
| +}; |
| + |
| +// Registers the first advertisement. |
|
tbarzic
2017/06/27 19:04:57
how about:
var registeredAdvertisements = [];
ch
Sonny Sasaka
2017/06/27 22:03:14
Done.
|
| +registerAdvertisement(advertisement, function (advertisementId1) { |
| + if (chrome.runtime.lastError || !advertisementId1) { |
| + chrome.test.fail(chrome.runtime.lastError.message); |
| + return; |
| + } |
| + |
| + // Registers the second advertisement. |
| + registerAdvertisement(advertisement, function (advertisementId2) { |
| + if (chrome.runtime.lastError || !advertisementId2) { |
|
tbarzic
2017/06/27 19:04:57
Use chrome.test.callbackPass/chrome.test.callbackF
Sonny Sasaka
2017/06/27 22:03:14
Done.
|
| + chrome.test.fail(chrome.runtime.lastError.message); |
| + return; |
| + } |
| + |
| + resetAdvertising(function () { |
| + if (chrome.runtime.lastError) { |
| + chrome.test.fail(chrome.runtime.lastError.message); |
| + return; |
| + } |
| + verifyAdvertisementsUnregistered(advertisementId1, advertisementId2); |
| + }); |
| + }); |
| +}); |