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

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

Issue 12314030: Add test of crypto.getRandomValues. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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 | « no previous file | 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
(Empty)
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
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.
4
5 library crypto_test;
6 import '../../pkg/unittest/lib/unittest.dart';
7 import '../../pkg/unittest/lib/html_config.dart';
8 import 'dart:html';
9
10 main() {
11 useHtmlConfiguration();
Anton Muhin 2013/02/21 12:40:43 please, use useHtmlIndividualConfiguration
Mads Ager (google) 2013/02/21 13:38:57 But then I have to use 'group', right. And since I
12
13 test('exists', () {
14 var crypto = window.crypto;
15 expect(crypto is Crypto, isTrue);
16 });
17
18 test('successful call', () {
19 var crypto = window.crypto;
20 var data = new Uint8Array(100);
21 expect(data.every((e) => e == 0), isTrue);
22 crypto.getRandomValues(data);
23 // In theory this is flaky. However, in practice you will get 100 zeroes
24 // in a row from a cryptographically secure random number generator so
25 // rarely that we don't have to worry about it.
26 expect(data.any((e) => e != 0), isTrue);
27 });
28
29 test('type mismatch', () {
30 var crypto = window.crypto;
31 var data = new Float32Array(100);
32 expect(() {
33 crypto.getRandomValues(data);
34 }, throws, reason: "Only typed array views with integer types allowed");
Anton Muhin 2013/02/21 12:40:43 nit: ' instead of ", please
Mads Ager (google) 2013/02/21 13:38:57 Done.
35 });
36 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698