OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import "dart:utf"; | 5 import "dart:utf"; |
6 import "dart:math"; | 6 import "dart:math"; |
7 import "dart:async"; | 7 import "dart:async"; |
8 import "dart:collection"; | 8 import "dart:collection"; |
9 import "dart:scalarlist"; | 9 import "dart:scalarlist"; |
10 | 10 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 Expect.isNotNull(mc.data); | 113 Expect.isNotNull(mc.data); |
114 Expect.equals(0, transformer._state); | 114 Expect.equals(0, transformer._state); |
115 | 115 |
116 mc.data = null; | 116 mc.data = null; |
117 | 117 |
118 // Only run this part on small messages. | 118 // Only run this part on small messages. |
119 if (message.length < 1000) { | 119 if (message.length < 1000) { |
120 // Update the transformer one byte at the time. | 120 // Update the transformer one byte at the time. |
121 messageCount++; | 121 messageCount++; |
122 for (int i = 0; i < frame.length; i++) { | 122 for (int i = 0; i < frame.length; i++) { |
123 controller.add(frame.getRange(i, 1)); | 123 controller.add(<int>[frame[i]]); |
124 } | 124 } |
125 Expect.equals(0, transformer._state); | 125 Expect.equals(0, transformer._state); |
126 Expect.isNotNull(mc.data); | 126 Expect.isNotNull(mc.data); |
127 mc.data = null; | 127 mc.data = null; |
128 | 128 |
129 // Update the transformer two bytes at the time. | 129 // Update the transformer two bytes at the time. |
130 messageCount++; | 130 messageCount++; |
131 for (int i = 0; i < frame.length; i += 2) { | 131 for (int i = 0; i < frame.length; i += 2) { |
132 controller.add(frame.getRange(i, i + 1 < frame.length ? 2 : 1)); | 132 controller.add(frame.sublist(i, min(i + 2, frame.length))); |
133 } | 133 } |
134 Expect.equals(0, transformer._state); | 134 Expect.equals(0, transformer._state); |
135 Expect.isNotNull(mc.data); | 135 Expect.isNotNull(mc.data); |
136 } | 136 } |
137 Expect.equals(messageCount, mc.messageCount); | 137 Expect.equals(messageCount, mc.messageCount); |
138 Expect.equals(0, mc.closeCount); | 138 Expect.equals(0, mc.closeCount); |
139 print("Messages test, messages $messageCount"); | 139 print("Messages test, messages $messageCount"); |
140 } | 140 } |
141 | 141 |
142 void runTest(int from, int to, int step) { | 142 void runTest(int from, int to, int step) { |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 runTest(65534, 65537, 1); | 222 runTest(65534, 65537, 1); |
223 print("Fragment messages test, messages $messageCount, frames $frameCount"); | 223 print("Fragment messages test, messages $messageCount, frames $frameCount"); |
224 Expect.equals(messageCount, mc.messageCount); | 224 Expect.equals(messageCount, mc.messageCount); |
225 Expect.equals(0, mc.closeCount); | 225 Expect.equals(0, mc.closeCount); |
226 } | 226 } |
227 | 227 |
228 void main() { | 228 void main() { |
229 testFullMessages(); | 229 testFullMessages(); |
230 testFragmentedMessages(); | 230 testFragmentedMessages(); |
231 } | 231 } |
OLD | NEW |