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

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

Issue 2771453003: Format all tests. (Closed)
Patch Set: Format files Created 3 years, 8 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 (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 library LocalStorageTest; 5 library LocalStorageTest;
6
6 import 'package:unittest/unittest.dart'; 7 import 'package:unittest/unittest.dart';
7 import 'package:unittest/html_config.dart'; 8 import 'package:unittest/html_config.dart';
8 import 'dart:html'; 9 import 'dart:html';
9 10
10 main() { 11 main() {
11 useHtmlConfiguration(); 12 useHtmlConfiguration();
12 13
13 void testWithLocalStorage(String name, fn()) { 14 void testWithLocalStorage(String name, fn()) {
14 test(name, () { 15 test(name, () {
15 window.localStorage['key1'] = 'val1'; 16 window.localStorage['key1'] = 'val1';
16 window.localStorage['key2'] = 'val2'; 17 window.localStorage['key2'] = 'val2';
17 window.localStorage['key3'] = 'val3'; 18 window.localStorage['key3'] = 'val3';
18 19
19 try { 20 try {
20 fn(); 21 fn();
21 } finally { 22 } finally {
22 window.localStorage.clear(); 23 window.localStorage.clear();
23 } 24 }
24 }); 25 });
25 } 26 }
26 27
27 testWithLocalStorage('containsValue', () { 28 testWithLocalStorage('containsValue', () {
28 expect(window.localStorage.containsValue('does not exist'), isFalse); 29 expect(window.localStorage.containsValue('does not exist'), isFalse);
29 expect(window.localStorage.containsValue('key1'), isFalse); 30 expect(window.localStorage.containsValue('key1'), isFalse);
30 expect(window.localStorage.containsValue('val1'), isTrue); 31 expect(window.localStorage.containsValue('val1'), isTrue);
31 expect(window.localStorage.containsValue('val3'), isTrue); 32 expect(window.localStorage.containsValue('val3'), isTrue);
32 }); 33 });
(...skipping 20 matching lines...) Expand all
53 window.localStorage['key3'] = 'val3-new'; 54 window.localStorage['key3'] = 'val3-new';
54 expect(window.localStorage['key3'], 'val3-new'); 55 expect(window.localStorage['key3'], 'val3-new');
55 }); 56 });
56 57
57 testWithLocalStorage('putIfAbsent', () { 58 testWithLocalStorage('putIfAbsent', () {
58 expect(window.localStorage['key4'], isNull); 59 expect(window.localStorage['key4'], isNull);
59 expect(window.localStorage.putIfAbsent('key4', () => 'val4'), 'val4'); 60 expect(window.localStorage.putIfAbsent('key4', () => 'val4'), 'val4');
60 expect(window.localStorage['key4'], 'val4'); 61 expect(window.localStorage['key4'], 'val4');
61 62
62 expect(window.localStorage['key3'], 'val3'); 63 expect(window.localStorage['key3'], 'val3');
63 expect(window.localStorage.putIfAbsent('key3', 64 expect(
64 () => expect(false, isTrue, reason: 'should not be called')), 'val3'); 65 window.localStorage.putIfAbsent('key3',
66 () => expect(false, isTrue, reason: 'should not be called')),
67 'val3');
65 expect(window.localStorage['key3'], 'val3'); 68 expect(window.localStorage['key3'], 'val3');
66 }); 69 });
67 70
68 testWithLocalStorage('remove', () { 71 testWithLocalStorage('remove', () {
69 expect(window.localStorage.remove('does not exist'), isNull); 72 expect(window.localStorage.remove('does not exist'), isNull);
70 expect(window.localStorage.remove('key3'), 'val3'); 73 expect(window.localStorage.remove('key3'), 'val3');
71 expect(window.localStorage, equals({'key1': 'val1', 'key2': 'val2'})); 74 expect(window.localStorage, equals({'key1': 'val1', 'key2': 'val2'}));
72 }); 75 });
73 76
74 testWithLocalStorage('clear', () { 77 testWithLocalStorage('clear', () {
(...skipping 24 matching lines...) Expand all
99 window.localStorage.clear(); 102 window.localStorage.clear();
100 expect(window.localStorage.length, 0); 103 expect(window.localStorage.length, 0);
101 }); 104 });
102 105
103 testWithLocalStorage('isEmpty', () { 106 testWithLocalStorage('isEmpty', () {
104 expect(window.localStorage.isEmpty, isFalse); 107 expect(window.localStorage.isEmpty, isFalse);
105 window.localStorage.clear(); 108 window.localStorage.clear();
106 expect(window.localStorage.isEmpty, isTrue); 109 expect(window.localStorage.isEmpty, isTrue);
107 }); 110 });
108 } 111 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698