function assertDevicesMatch(expectedDevices, devices) {
  var deviceIds = {};
  devices.forEach(function(device) {
    chrome.test.assertFalse(!!deviceIds[device.id],
                            'Duplicated device id: \'' + device.id + '\'.');
    deviceIds[device.id] = true;
  });

  function sortedKeys(obj) {
    return Object.keys(obj).sort();
  }
  chrome.test.assertEq(sortedKeys(expectedDevices), sortedKeys(deviceIds));

  devices.forEach(function(device) {
    assertDeviceMatches(expectedDevices[device.id], device);
  });
}
/**
 * Verifies that list of devices contains all and only devices from set of
 * expected devices. If will fail the test if an unexpected device is found.
 *
 * @param {Object.<string, Object>} expectedDevices Expected set of test
 *     devices. Maps device ID to device properties.
 * @param {Array.<Object>} devices List of input devices.
 */
Verifies that list of devices contains all and only devices from set of
expected devices. If will fail the test if an unexpected device is found.

@param {Object.} expectedDevices Expected set of test
devices. Maps device ID to device properties.
@param {Array.} devices List of input devices.
Verifies that list of devices contains all and only devices from set of expected devices . If will fail the test if an unexpected device is found . @param { Object . } expectedDevices Expected set of test devices . Maps device ID to device properties . @param { Array . } devices List of input devices .
function assertDevicesMatch(expectedDevices, devices) {
  var deviceIds = {};
  devices.forEach(function(device) {
    chrome.test.assertFalse(!!deviceIds[device.id],
                            'Duplicated device id: \'' + device.id + '\'.');
    deviceIds[device.id] = true;
  });
  function sortedKeys(obj) {
    return Object.keys(obj).sort();
  }
  chrome.test.assertEq(sortedKeys(expectedDevices), sortedKeys(deviceIds));
  devices.forEach(function(device) {
    assertDeviceMatches(expectedDevices[device.id], device);
  });
}
function assertDevicesMatch ( expectedDevices , devices ) { var deviceIds = { } ; devices . forEach ( function ( device ) { chrome . test . assertFalse ( ! ! deviceIds [ device . id ] , 'Duplicated device id: \'' + device . id + '\'.' ) ; deviceIds [ device . id ] = true ; } ) ; function sortedKeys ( obj ) { return Object . keys ( obj ) . sort ( ) ; } chrome . test . assertEq ( sortedKeys ( expectedDevices ) , sortedKeys ( deviceIds ) ) ; devices . forEach ( function ( device ) { assertDeviceMatches ( expectedDevices [ device . id ] , device ) ; } ) ; }
Verifies that list of devices contains all and only devices from set of
 expected devices.
Verifies that list of devices contains all and only devices from set of expected devices .