OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 var assertEq = chrome.test.assertEq; |
| 6 var assertTrue = chrome.test.assertTrue; |
| 7 var fail = chrome.test.fail; |
| 8 var callback = chrome.test.callback; |
| 9 |
| 10 function getItemNamed(list, name) { |
| 11 for (var i = 0; i < list.length; i++) { |
| 12 if (list[i].name == name) { |
| 13 return list[i]; |
| 14 } |
| 15 } |
| 16 fail("didn't find item with name: " + name); |
| 17 return null; |
| 18 } |
| 19 |
| 20 // Verifies that the item's name, enabled, and type properties match |name|, |
| 21 // |enabled|, and |type|, and checks against any additional name/value |
| 22 // properties from |additional_properties|. |
| 23 function checkItem(item, name, enabled, type, additional_properties) { |
| 24 assertTrue(item !== null); |
| 25 assertEq(name, item.name); |
| 26 assertEq(type, item.type); |
| 27 assertEq(enabled, item.enabled); |
| 28 |
| 29 for (var propname in additional_properties) { |
| 30 var value = additional_properties[propname]; |
| 31 if (typeof value === 'string') |
| 32 value = value.replace("<ID>", item.id); |
| 33 assertTrue(propname in item); |
| 34 assertEq(value, item[propname]); |
| 35 } |
| 36 } |
| 37 |
| 38 // Gets an extension/app with |name| in |list|, verifies that its enabled |
| 39 // and type properties match |enabled| and |type|, and checks against any |
| 40 // additional name/value properties from |additional_properties|. |
| 41 function checkItemInList(list, name, enabled, type, additional_properties) { |
| 42 var item = getItemNamed(list, name); |
| 43 checkItem(item, name, enabled, type, additional_properties); |
| 44 } |
OLD | NEW |