summaryrefslogtreecommitdiffstats
path: root/extensions/test/data/api_test/audio/add_nodes/background.js
blob: 6f4754d441cac0601b6336ec2510b151daed2544 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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");