Exemple #1
0
def test_untypedcontainers(parcel):
    p = Parcel()
    keys, values = zip(*primitives)
    map(lambda x: p.writeValue(x), values)
    p.writeArray(values)
    p.writeList(values)
    p.setDataPosition(0)
    q = map(lambda x: p.readValue(None), range(len(keys)))
    qa = p.readArray(None)
    ql = len(values) * [0]
    p.readList(ql, None)
    for anArray in [q, qa, ql]:
        for k, key in enumerate(keys):
            if key in ['double', 'float']:
                bFlag = abs(values[k] - anArray[k]) < 0.01
            else:
                bFlag = values[k] == anArray[k]
            assert bFlag, 'Error read/writeArray: %s' % key

    aMap = dict(uno=1, dos=2.5, tres='parejas cruzadas')
    p = Parcel()
    p.writeMap(aMap)
    p.setDataPosition(0)
    q = {}
    p.readMap(q, None)
    assert aMap == q, "ERROR read/writeMap"
 def _contentConverter(self, item):
     componentType, componentContent = item[-2], str(item[-1])
     ifilterStr = bytearray(componentContent.decode('base64'))
     parcel = Parcel()
     parcel.unmarshall(ifilterStr, 0, len(ifilterStr))
     parcel.setDataPosition(0)
     if componentType == 'intent-filter':
         return parcel.readTypedObject(IntentFilter.CREATOR)
     ifilter = {}
     parcel.readMap(ifilter, None)
     return ifilter