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

Unified Diff: extensions/test/data/api_test/audio/add_nodes/background.js

Issue 2462833002: Refactor audio API tests (Closed)
Patch Set: Refactor audio API tests Created 4 years, 1 month 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: extensions/test/data/api_test/audio/add_nodes/background.js
diff --git a/extensions/test/data/api_test/audio/add_nodes/background.js b/extensions/test/data/api_test/audio/add_nodes/background.js
index 8af4237ce2ca4c17718d7ed8f5789dccbab184c1..1acaf6639e8559ffb64080c5e80437ddadbad4f5 100644
--- a/extensions/test/data/api_test/audio/add_nodes/background.js
+++ b/extensions/test/data/api_test/audio/add_nodes/background.js
@@ -2,42 +2,46 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-chrome.audio.OnDevicesChanged.addListener(function (devices) {
- if (devices.length === 3) {
- if (devices[0].id != "30001" ||
- devices[0].stableDeviceId != "80001" ||
- devices[0].isInput != false ||
- devices[0].deviceType != "USB" ||
- devices[0].deviceName != "Jabra Speaker" ||
- devices[0].displayName != "Jabra Speaker 1") {
- console.error("Got wrong device property for device:" +
- JSON.stringify(devices[0]));
- chrome.test.sendMessage("failure");
- }
- if (devices[1].id != "30002" ||
- devices[1].stableDeviceId != "80002" ||
- devices[1].isInput != false ||
- devices[1].deviceType != "USB" ||
- devices[1].deviceName != "Jabra Speaker" ||
- devices[1].displayName != "Jabra Speaker 2") {
- console.error("Got wrong device property for device:" +
- JSON.stringify(devices[1]));
- chrome.test.sendMessage("failure");
- }
- if (devices[2].id != "30003" ||
- devices[2].stableDeviceId != "80003" ||
- devices[2].isInput != false ||
- devices[2].deviceType != "HDMI" ||
- devices[2].deviceName != "HDMI output" ||
- devices[2].displayName != "HDA Intel MID") {
- console.error("Got wrong device property for device:" +
- JSON.stringify(devices[2]));
- chrome.test.sendMessage("failure");
- }
- chrome.test.sendMessage("success");
- } else {
- console.error("Got unexpected OnNodesChanged event failed");
- chrome.test.sendMessage("failure");
+chrome.test.runTests([
+ function waitForDeviceChangedEventTests() {
+ chrome.test.listenOnce(chrome.audio.OnDevicesChanged, function(devices) {
+ var deviceList = devices.map(function(device) {
+ return {
+ id: device.id,
+ stableDeviceId: device.stableDeviceId,
+ isInput: device.isInput,
+ deviceType: device.deviceType,
+ deviceName: device.deviceName,
+ displayName: device.displayName
+ };
+ }).sort(function(lhs, rhs) {
+ return Number.parseInt(lhs.id) - Number.parseInt(rhs.id);
+ });
+
+ chrome.test.assertEq([{
+ id: '30001',
+ stableDeviceId: '80001',
+ isInput: false,
+ deviceType: 'USB',
+ deviceName: 'Jabra Speaker',
+ displayName: 'Jabra Speaker 1'
+ }, {
+ id: '30002',
+ stableDeviceId: '80002',
+ isInput: false,
+ deviceType: 'USB',
+ deviceName: 'Jabra Speaker',
+ displayName: 'Jabra Speaker 2'
+ }, {
+ id: '30003',
+ stableDeviceId: '80003',
+ isInput: false,
+ deviceType: 'HDMI',
+ deviceName: 'HDMI output',
+ displayName: 'HDA Intel MID'
+ }], deviceList);
+ });
}
-});
-chrome.test.sendMessage("loaded");
+]);
+
+chrome.test.sendMessage('loaded');
« no previous file with comments | « extensions/browser/api/audio/audio_apitest.cc ('k') | extensions/test/data/api_test/audio/input_mute_change/background.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698