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

Side by Side Diff: remoting/webapp/unittests/base_unittest.js

Issue 514343002: XMPP implementation in JavaScript. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 (function() { 5 (function() {
6 6
7 'use strict'; 7 'use strict';
8 8
9 module('base'); 9 module('base');
10 10
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 }); 225 });
226 226
227 source.addEventListener('foo', sink.listener); 227 source.addEventListener('foo', sink.listener);
228 source.raiseEvent('foo'); 228 source.raiseEvent('foo');
229 sinon.assert.calledOnce(sink.listener); 229 sinon.assert.calledOnce(sink.listener);
230 230
231 source.raiseEvent('foo'); 231 source.raiseEvent('foo');
232 sinon.assert.calledOnce(sink.listener); 232 sinon.assert.calledOnce(sink.listener);
233 }); 233 });
234 234
235 test('encodeUtf8() can encode UTF8 strings', function() {
236 function toJsArray(arrayBuffer) {
237 var result = [];
238 var array = new Uint8Array(arrayBuffer);
239 for (var i = 0; i < array.length; ++i) {
240 result.push(array[i]);
241 }
242 return result;
243 }
244
245 // ASCII.
246 QUnit.deepEqual(toJsArray(base.encodeUtf8("ABC")), [0x41, 0x42, 0x43]);
247
248 // Some arbitrary characters from the basic Unicode plane.
249 QUnit.deepEqual(toJsArray(base.encodeUtf8("挂Ѓф")),
250 [0xE6, 0x8C, 0x82, 0xD0, 0x83, 209, 132]);
Jamie 2014/08/29 02:14:08 Why not hex for the last two? Also, it might be wo
Sergey Ulanov 2014/08/29 23:40:28 Done.
251
252 // Unicode surrogate pair for U+1F603.
253 QUnit.deepEqual(toJsArray(base.encodeUtf8("😃")),
Jamie 2014/08/29 02:14:08 I always felt we needed more smiley faces in our s
Sergey Ulanov 2014/08/29 23:40:28 Acknowledged.
254 [0xF0, 0x9F, 0x98, 0x83]);
255 });
256
257 test('decodeUtf8() can decode UTF8 strings', function() {
258 // ASCII.
259 QUnit.equal(base.decodeUtf8(new Uint8Array([0x41, 0x42, 0x43]).buffer),
260 "ABC");
261
262 // Some arbitrary characters from the basic Unicode plane.
263 QUnit.equal(
264 base.decodeUtf8(
265 new Uint8Array([0xE6, 0x8C, 0x82, 0xD0, 0x83, 209, 132]).buffer),
266 "挂Ѓф");
267
268 // Unicode surrogate pair for U+1F603.
269 QUnit.equal(base.decodeUtf8(new Uint8Array([0xF0, 0x9F, 0x98, 0x83]).buffer),
270 "😃");
271 });
272
235 })(); 273 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698