OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 var error; | 5 var error; |
6 | 6 |
7 function testGetCharacteristics() { | 7 function testGetCharacteristics() { |
8 if (error !== undefined) { | 8 if (error !== undefined) { |
9 chrome.test.sendMessage('fail'); | 9 chrome.test.sendMessage('fail'); |
10 chrome.test.fail(error); | 10 chrome.test.fail(error); |
11 } | 11 } |
12 chrome.test.assertEq(2, chrcs.length); | 12 chrome.test.assertEq(2, chrcs.length); |
13 | 13 |
14 chrome.test.assertEq('char_id0', chrcs[0].instanceId); | 14 chrome.test.assertEq('char_id0', chrcs[0].instanceId); |
15 chrome.test.assertEq('00001211-0000-1000-8000-00805f9b34fb', chrcs[0].uuid); | 15 chrome.test.assertEq('00001211-0000-1000-8000-00805f9b34fb', chrcs[0].uuid); |
16 chrome.test.assertEq(false, chrcs[0].isLocal); | |
17 chrome.test.assertEq(serviceId, chrcs[0].service.instanceId); | 16 chrome.test.assertEq(serviceId, chrcs[0].service.instanceId); |
18 chrome.test.assertEq(4, chrcs[0].properties.length); | 17 chrome.test.assertEq(4, chrcs[0].properties.length); |
19 chrome.test.assertTrue(chrcs[0].properties.indexOf('broadcast') > -1, | 18 chrome.test.assertTrue(chrcs[0].properties.indexOf('broadcast') > -1, |
20 '\'broadcast\' not in chrcs[0].properties'); | 19 '\'broadcast\' not in chrcs[0].properties'); |
21 chrome.test.assertTrue(chrcs[0].properties.indexOf('read') > -1, | 20 chrome.test.assertTrue(chrcs[0].properties.indexOf('read') > -1, |
22 '\'read\' not in chrcs[0].properties'); | 21 '\'read\' not in chrcs[0].properties'); |
23 chrome.test.assertTrue(chrcs[0].properties.indexOf('indicate') > -1, | 22 chrome.test.assertTrue(chrcs[0].properties.indexOf('indicate') > -1, |
24 '\'indicate\' not in chrcs[0].properties'); | 23 '\'indicate\' not in chrcs[0].properties'); |
25 chrome.test.assertTrue( | 24 chrome.test.assertTrue( |
26 chrcs[0].properties.indexOf('writeWithoutResponse') > -1, | 25 chrcs[0].properties.indexOf('writeWithoutResponse') > -1, |
27 '\'writeWithoutResponse\' not in chrcs[0].properties'); | 26 '\'writeWithoutResponse\' not in chrcs[0].properties'); |
28 | 27 |
29 var valueBytes = new Uint8Array(chrcs[0].value); | 28 var valueBytes = new Uint8Array(chrcs[0].value); |
30 chrome.test.assertEq(5, chrcs[0].value.byteLength); | 29 chrome.test.assertEq(5, chrcs[0].value.byteLength); |
31 chrome.test.assertEq(0x01, valueBytes[0]); | 30 chrome.test.assertEq(0x01, valueBytes[0]); |
32 chrome.test.assertEq(0x02, valueBytes[1]); | 31 chrome.test.assertEq(0x02, valueBytes[1]); |
33 chrome.test.assertEq(0x03, valueBytes[2]); | 32 chrome.test.assertEq(0x03, valueBytes[2]); |
34 chrome.test.assertEq(0x04, valueBytes[3]); | 33 chrome.test.assertEq(0x04, valueBytes[3]); |
35 chrome.test.assertEq(0x05, valueBytes[4]); | 34 chrome.test.assertEq(0x05, valueBytes[4]); |
36 | 35 |
37 chrome.test.assertEq('char_id1', chrcs[1].instanceId), | 36 chrome.test.assertEq('char_id1', chrcs[1].instanceId), |
38 chrome.test.assertEq('00001212-0000-1000-8000-00805f9b34fb', chrcs[1].uuid); | 37 chrome.test.assertEq('00001212-0000-1000-8000-00805f9b34fb', chrcs[1].uuid); |
39 chrome.test.assertEq(false, chrcs[1].isLocal); | |
40 chrome.test.assertEq(serviceId, chrcs[1].service.instanceId); | 38 chrome.test.assertEq(serviceId, chrcs[1].service.instanceId); |
41 chrome.test.assertEq(3, chrcs[1].properties.length); | 39 chrome.test.assertEq(3, chrcs[1].properties.length); |
42 chrome.test.assertTrue(chrcs[1].properties.indexOf('read') > -1, | 40 chrome.test.assertTrue(chrcs[1].properties.indexOf('read') > -1, |
43 '\'read\' not in chrcs[1].properties'); | 41 '\'read\' not in chrcs[1].properties'); |
44 chrome.test.assertTrue(chrcs[1].properties.indexOf('write') > -1, | 42 chrome.test.assertTrue(chrcs[1].properties.indexOf('write') > -1, |
45 '\'write\' not in chrcs[1].properties'); | 43 '\'write\' not in chrcs[1].properties'); |
46 chrome.test.assertTrue(chrcs[1].properties.indexOf('notify') > -1, | 44 chrome.test.assertTrue(chrcs[1].properties.indexOf('notify') > -1, |
47 '\'notify\' not in chrcs[1].properties'); | 45 '\'notify\' not in chrcs[1].properties'); |
48 | 46 |
49 valueBytes = new Uint8Array(chrcs[1].value); | 47 valueBytes = new Uint8Array(chrcs[1].value); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 return; | 88 return; |
91 | 89 |
92 chrcs = result; | 90 chrcs = result; |
93 | 91 |
94 chrome.test.sendMessage('ready', function (message) { | 92 chrome.test.sendMessage('ready', function (message) { |
95 chrome.test.runTests([testGetCharacteristics]); | 93 chrome.test.runTests([testGetCharacteristics]); |
96 }); | 94 }); |
97 }); | 95 }); |
98 }); | 96 }); |
99 }); | 97 }); |
OLD | NEW |