set readonly property on array attributes.
authorCorentin Lecouvey <corentin.lecouvey@open.eurogiciel.org>
Wed, 20 Aug 2014 15:01:29 +0000 (17:01 +0200)
committerCorentin Lecouvey <corentin.lecouvey@open.eurogiciel.org>
Wed, 20 Aug 2014 15:06:56 +0000 (17:06 +0200)
It fixes TCT test cases :
- BluetoothClass
- BluetoothDevice_uuid_attribute

Change-Id: I9656b462a61b307c80cc3b869d28e67cafd38527

bluetooth/bluetooth_api.js

index b235dc3..5b2cfb1 100644 (file)
@@ -815,31 +815,37 @@ function BluetoothDevice(msg) {
   _addConstProperty(this, 'isConnected', (msg.Connected == 'true') ? true : false);
 
   if (msg.UUIDs) {
+    var uuids_array = [];
     if (typeof msg.UUIDs === 'string') {
       // FIXME(clecou) BlueZ backend sends a string to convert it into an array
       // A better approach would be to adapt backends instances to have a single JSON protocol.
-      var uuids_array = [];
       uuids_array = msg.UUIDs.substring(msg.UUIDs.indexOf('[') + 1,
           msg.UUIDs.indexOf(']')).split(',');
       for (var i = 0; i < uuids_array.length; i++) {
         uuids_array[i] = uuids_array[i].substring(2, uuids_array[i].length - 1);
       }
-      _addConstProperty(this, 'uuids', uuids_array);
+
     } else {
       // Tizen C API backend directly sends an array
-      _addConstProperty(this, 'uuids', msg.UUIDs);
+      uuids_array = msg.UUIDs;
+      for (var i = 0; i < msg.UUIDs.length; i++)
+        _addConstProperty(uuids_array, i.toString(), msg.UUIDs[i]);
     }
+    _addConstProperty(this, 'uuids', uuids_array);
   }
 
   var services = (msg.ClassService >> 13) & _deviceClassMask.SERVICE;
   var services_array = [];
+  var index = 0;
 
   // 11 is the number of bits in _deviceClassMask.SERVICE
   for (var i = 0; i < 11; i++)
-    if ((services & (1 << i)) !== 0)
-      services_array.push(1 << i);
+    if ((services & (1 << i)) !== 0) {
+      _addConstProperty(services_array, index.toString(), (1 << i));
+      index++;
+    }
 
-    _addConstProperty(this.deviceClass, 'services', services_array);
+  _addConstProperty(this.deviceClass, 'services', services_array);
 }
 
 BluetoothDevice.prototype.connectToServiceByUUID =