Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / trace-viewer / third_party / tvcm / src / tvcm / base64_test.html
1 <!DOCTYPE html>
2 <!--
3 Copyright (c) 2014 The Chromium Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style license that can be
5 found in the LICENSE file.
6 -->
7 <link rel="import" href="/tvcm/base64.html">
8 <script>
9 'use strict';
10
11 tvcm.unittest.testSuite(function() {
12
13   test('getDecodedLength', function() {
14     assertTrue(tvcm.Base64.getDecodedBufferLength('YQ==') >= 1);
15     assertTrue(tvcm.Base64.getDecodedBufferLength('YWJjZA==') >= 4);
16     assertTrue(tvcm.Base64.getDecodedBufferLength('YWJjZGVm') >= 6);
17   });
18
19   test('DecodeToTypedArray', function() {
20     var buffer = new DataView(new ArrayBuffer(256));
21     tvcm.Base64.DecodeToTypedArray('YQ==', buffer);
22     assertTrue(buffer.getInt8(0) == 97);
23
24     tvcm.Base64.DecodeToTypedArray('YWJjZA==', buffer);
25     for (var i = 0; i < 4; i++)
26       assertTrue(buffer.getInt8(i) == 97 + i);
27
28     tvcm.Base64.DecodeToTypedArray('YWJjZGVm', buffer);
29     for (var i = 0; i < 4; i++)
30       assertTrue(buffer.getInt8(i) == 97 + i);
31   });
32
33   test('DecodeLengthReturn', function() {
34     var buffer = new DataView(new ArrayBuffer(256));
35     var len = tvcm.Base64.DecodeToTypedArray(btoa('hello'), buffer);
36     assertEquals(5, len);
37
38   });
39
40 });
41 </script>