diff options
author | jennyz <jennyz@chromium.org> | 2015-04-09 18:11:00 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-04-10 01:12:17 +0000 |
commit | b69390365c56bb0c234934a435731430050dd770 (patch) | |
tree | fd3b263a4e30b737a1a535551fa2ee6a70b9219c /extensions/test | |
parent | b57804d8bb5373211a5280f5495c05721f484cfb (diff) | |
download | chromium_src-b69390365c56bb0c234934a435731430050dd770.zip chromium_src-b69390365c56bb0c234934a435731430050dd770.tar.gz chromium_src-b69390365c56bb0c234934a435731430050dd770.tar.bz2 |
Add new audio extension event OnNodesChanged.
This is the part of audio extension redesign efforts. The original audio extension only has one OnDeviceChanged event without any input arguments to notify all sorts of audio events, which is not efficient. The hotrod app has to query getInfo to get all sets of the devices with properties, comparing the old data to decide what change really happens and handles the change. Therefore, in the new design, we will add new events to accurately report what exact audio change occurs. Eventually, we will migrate to use the new events and retire the old OnDeviceChanged event.
See details in design doc:
https://docs.google.com/a/google.com/document/d/1YFFLwX4mcKJyuAsZB13GhDid0MEt0QguKX0AxgvBoko/edit?usp=sharing
BUG=429312
Review URL: https://codereview.chromium.org/1044313002
Cr-Commit-Position: refs/heads/master@{#324556}
Diffstat (limited to 'extensions/test')
4 files changed, 97 insertions, 0 deletions
diff --git a/extensions/test/data/api_test/audio/add_nodes/background.js b/extensions/test/data/api_test/audio/add_nodes/background.js new file mode 100644 index 0000000..6f4754d --- /dev/null +++ b/extensions/test/data/api_test/audio/add_nodes/background.js @@ -0,0 +1,40 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// 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].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].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].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.sendMessage("loaded"); diff --git a/extensions/test/data/api_test/audio/add_nodes/manifest.json b/extensions/test/data/api_test/audio/add_nodes/manifest.json new file mode 100644 index 0000000..587b70a --- /dev/null +++ b/extensions/test/data/api_test/audio/add_nodes/manifest.json @@ -0,0 +1,13 @@ +{ + "name": "chrome.audio.OnNodesChangedAddNodes", + "version": "1.0", + "description": "browser test for chrome.audio.OnNodesChanged event", + "app": { + "background": { + "scripts": ["background.js"] + } + }, + "permissions": [ + "audio" + ] +} diff --git a/extensions/test/data/api_test/audio/remove_nodes/background.js b/extensions/test/data/api_test/audio/remove_nodes/background.js new file mode 100644 index 0000000..8758834 --- /dev/null +++ b/extensions/test/data/api_test/audio/remove_nodes/background.js @@ -0,0 +1,31 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// 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 === 2) { + if (devices[0].id != "40001" || + devices[0].isInput != true || + devices[0].deviceType != "USB" || + devices[0].deviceName != "Jabra Mic" || + devices[0].displayName != "Jabra Mic 1") { + console.error("Got wrong device property for device:" + + JSON.stringify(devices[0])); + chrome.test.sendMessage("failure"); + } + if (devices[1].id != "40002" || + devices[1].isInput != true || + devices[1].deviceType != "USB" || + devices[1].deviceName != "Jabra Mic" || + devices[1].displayName != "Jabra Mic 2") { + console.error("Got wrong device property for device:" + + JSON.stringify(devices[1])); + chrome.test.sendMessage("failure"); + } + chrome.test.sendMessage("success"); + } else { + console.error("Got unexpected OnNodesChanged event failed"); + chrome.test.sendMessage("failure"); + } +}); +chrome.test.sendMessage("loaded"); diff --git a/extensions/test/data/api_test/audio/remove_nodes/manifest.json b/extensions/test/data/api_test/audio/remove_nodes/manifest.json new file mode 100644 index 0000000..d55c69b --- /dev/null +++ b/extensions/test/data/api_test/audio/remove_nodes/manifest.json @@ -0,0 +1,13 @@ +{ + "name": "chrome.audio.OnNodesChangedRemoveNodes", + "version": "1.0", + "description": "browser test for chrome.audio.OnNodesChanged event", + "app": { + "background": { + "scripts": ["background.js"] + } + }, + "permissions": [ + "audio" + ] +} |