Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Side by Side Diff: tests/html/utils.dart

Issue 21303002: Adding additional tests for serialized script value conversions (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/html/serialized_script_value_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 library TestUtils; 1 library TestUtils;
2 2
3 import 'dart:async'; 3 import 'dart:async';
4 import 'dart:html'; 4 import 'dart:html';
5 import 'dart:typed_data'; 5 import 'dart:typed_data';
6 import '../../pkg/unittest/lib/unittest.dart'; 6 import '../../pkg/unittest/lib/unittest.dart';
7 7
8 /** 8 /**
9 * Verifies that [actual] has the same graph structure as [expected]. 9 * Verifies that [actual] has the same graph structure as [expected].
10 * Detects cycles and DAG structure in Maps and Lists. 10 * Detects cycles and DAG structure in Maps and Lists.
(...skipping 23 matching lines...) Expand all
34 for (int i = 0; i < aItems.length; i++) { 34 for (int i = 0; i < aItems.length; i++) {
35 if (identical(actual, aItems[i])) { 35 if (identical(actual, aItems[i])) {
36 expect(expected, same(eItems[i]), 36 expect(expected, same(eItems[i]),
37 reason: message(path, 'extra back or side edge')); 37 reason: message(path, 'extra back or side edge'));
38 return; 38 return;
39 } 39 }
40 } 40 }
41 eItems.add(expected); 41 eItems.add(expected);
42 aItems.add(actual); 42 aItems.add(actual);
43 43
44 if (expected is Blob) {
45 expect(actual is Blob, isTrue,
46 reason: '$actual is Blob');
47 expect(expected.type, equals(actual.type),
48 reason: message(path, '.type'));
49 expect(expected.size, equals(actual.size),
50 reason: message(path, '.size'));
51 return;
52 }
53
44 if (expected is ByteBuffer) { 54 if (expected is ByteBuffer) {
45 expect(actual is ByteBuffer, isTrue, 55 expect(actual is ByteBuffer, isTrue,
46 reason: '$actual is ByteBuffer'); 56 reason: '$actual is ByteBuffer');
47 expect(expected.lengthInBytes, equals(actual.lengthInBytes), 57 expect(expected.lengthInBytes, equals(actual.lengthInBytes),
48 reason: message(path, '.lengthInBytes')); 58 reason: message(path, '.lengthInBytes'));
49 // TODO(antonm): one can create a view on top of those 59 // TODO(antonm): one can create a view on top of those
50 // and check if contents identical. Let's do it later. 60 // and check if contents identical. Let's do it later.
51 return; 61 return;
52 } 62 }
53 63
64 if (expected is DateTime) {
65 expect(actual is DateTime, isTrue,
66 reason: '$actual is DateTime');
67 expect(expected.millisecondsSinceEpoch,
68 equals(actual.millisecondsSinceEpoch),
69 reason: message(path, '.millisecondsSinceEpoch'));
70 return;
71 }
72
73 if (expected is ImageData) {
74 expect(actual is ImageData, isTrue,
75 reason: '$actual is ImageData');
76 expect(expected.width, equals(actual.width),
77 reason: message(path, '.width'));
78 expect(expected.height, equals(actual.height),
79 reason: message(path, '.height'));
80 walk('$path.data', expected.data, actual.data);
81 return;
82 }
83
54 if (expected is TypedData) { 84 if (expected is TypedData) {
55 expect(actual is TypedData, isTrue, 85 expect(actual is TypedData, isTrue,
56 reason: '$actual is TypedData'); 86 reason: '$actual is TypedData');
57 walk('$path/.buffer', expected.buffer, actual.buffer); 87 walk('$path/.buffer', expected.buffer, actual.buffer);
58 expect(expected.offsetInBytes, equals(actual.offsetInBytes), 88 expect(expected.offsetInBytes, equals(actual.offsetInBytes),
59 reason: message(path, '.offsetInBytes')); 89 reason: message(path, '.offsetInBytes'));
60 expect(expected.lengthInBytes, equals(actual.lengthInBytes), 90 expect(expected.lengthInBytes, equals(actual.lengthInBytes),
61 reason: message(path, '.lengthInBytes')); 91 reason: message(path, '.lengthInBytes'));
62 // And also fallback to elements check below. 92 // And also fallback to elements check below.
63 } 93 }
(...skipping 22 matching lines...) Expand all
86 } 116 }
87 } 117 }
88 return; 118 return;
89 } 119 }
90 120
91 expect(false, isTrue, reason: 'Unhandled type: $expected'); 121 expect(false, isTrue, reason: 'Unhandled type: $expected');
92 } 122 }
93 123
94 walk('', expected, actual); 124 walk('', expected, actual);
95 } 125 }
OLDNEW
« no previous file with comments | « tests/html/serialized_script_value_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698