OLD | NEW |
(Empty) | |
| 1 library SerializedScriptValueTest; |
| 2 import 'package:unittest/unittest.dart'; |
| 3 import 'package:unittest/html_config.dart'; |
| 4 import 'dart:html'; |
| 5 import 'utils.dart'; |
| 6 |
| 7 serializationTest(name, value) => test(name, () { |
| 8 // To check how value is serialized and deserialized, we create a |
| 9 // MessageEvent. |
| 10 final event = |
| 11 new MessageEvent('', data: value, origin: '', lastEventId: ''); |
| 12 verifyGraph(value, event.data); |
| 13 }); |
| 14 |
| 15 |
| 16 main() { |
| 17 useHtmlConfiguration(); |
| 18 |
| 19 serializationTest('null', null); |
| 20 serializationTest('int', 1); |
| 21 serializationTest('double', 2.39); |
| 22 serializationTest('string', 'hey!'); |
| 23 |
| 24 final simpleMap = {'a': 100, 'b': 's'}; |
| 25 final dagMap = { 'x': simpleMap, 'y': simpleMap }; |
| 26 final cyclicMap = { 'b': dagMap }; |
| 27 cyclicMap['a'] = cyclicMap; |
| 28 serializationTest('simple map', simpleMap); |
| 29 serializationTest('dag map', dagMap); |
| 30 serializationTest('cyclic map', cyclicMap); |
| 31 |
| 32 final simpleList = [ 100, 's']; |
| 33 final dagList = [ simpleList, simpleList ]; |
| 34 final cyclicList = [ dagList ]; |
| 35 cyclicList.add(cyclicList); |
| 36 serializationTest('simple list', simpleList); |
| 37 serializationTest('dag list', dagList); |
| 38 serializationTest('cyclic list', cyclicList); |
| 39 |
| 40 serializationTest('datetime', [new DateTime.now()]); |
| 41 |
| 42 var blob = new Blob( |
| 43 ['Indescribable... Indestructible! Nothing can stop it!'], |
| 44 'text/plain'); |
| 45 serializationTest('blob', [blob]); |
| 46 |
| 47 var canvas = new CanvasElement(); |
| 48 canvas.width = 100; |
| 49 canvas.height = 100; |
| 50 var imageData = canvas.context2D.getImageData(0, 0, 1, 1); |
| 51 serializationTest('imagedata', [imageData]); |
| 52 } |
OLD | NEW |