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

Side by Side Diff: chrome/test/data/webui/array_data_model_test.html

Issue 17315020: Port passing closure tests for cr.ui framework to browser tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reviewer feedback fixes. Created 7 years, 6 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
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <script src="http://closure-library.googlecode.com/svn/trunk/closure/goog/base.j s"></script> 4 <script src="webui_resource_test.js"></script>
5 <script src="../../cr.js"></script>
6 <script src="../event_target.js"></script>
7 <script src="array_data_model.js"></script>
8 <script>
9
10 goog.require('goog.testing.jsunit');
11
12 </script>
13
14 </head> 5 </head>
15 <body> 6 <body>
16 7
17 <script> 8 <script>
18 9
19 function testSlice() { 10 function testSlice() {
20 var m = new cr.ui.ArrayDataModel([0, 1, 2]); 11 var m = new cr.ui.ArrayDataModel([0, 1, 2]);
21 assertArrayEquals([0, 1, 2], m.slice()); 12 assertArrayEquals([0, 1, 2], m.slice());
22 assertArrayEquals([1, 2], m.slice(1)); 13 assertArrayEquals([1, 2], m.slice(1));
23 assertArrayEquals([1], m.slice(1, 2)); 14 assertArrayEquals([1], m.slice(1, 2));
24 } 15 }
25 16
26 function testPush() { 17 function testPush() {
27 var m = new cr.ui.ArrayDataModel([0, 1, 2]); 18 var m = new cr.ui.ArrayDataModel([0, 1, 2]);
28 19
29 var count = 0; 20 var count = 0;
30 m.addEventListener('splice', function(e) { 21 m.addEventListener('splice', function(e) {
31 count++; 22 count++;
32 assertEquals(3, e.index); 23 assertEquals(3, e.index);
33 assertArrayEquals([], e.removed); 24 assertArrayEquals([], e.removed);
34 assertArrayEquals([3, 4], e.added); 25 assertArrayEquals([3, 4], e.added);
35 }); 26 });
36 27
37 assertEquals(5, m.push(3, 4)); 28 assertEquals(5, m.push(3, 4));
38 var a = m.slice(); 29 var a = m.slice();
39 assertArrayEquals([0, 1, 2, 3, 4], a); 30 assertArrayEquals([0, 1, 2, 3, 4], a);
40 31
41 assertEquals('The splice event should only fire once', 1, count); 32 assertEquals(1, count, 'The splice event should only fire once');
42 } 33 }
43 34
44 function testSplice() { 35 function testSplice() {
45 function compare(array, args) { 36 function compare(array, args) {
46 var m = new cr.ui.ArrayDataModel(array.slice()); 37 var m = new cr.ui.ArrayDataModel(array.slice());
47 var expected = array.slice(); 38 var expected = array.slice();
48 var result = expected.splice.apply(expected, args); 39 var result = expected.splice.apply(expected, args);
49 assertArrayEquals(result, m.splice.apply(m, args)); 40 assertArrayEquals(result, m.splice.apply(m, args));
50 assertArrayEquals(expected, m.slice()); 41 assertArrayEquals(expected, m.slice());
51 } 42 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 doTest([1, 2, 3], [1, 1]); 74 doTest([1, 2, 3], [1, 1]);
84 doTest([1, 2, 3], [0, 3]); 75 doTest([1, 2, 3], [0, 3]);
85 doTest([1, 2, 3], [0, 1, 5]); 76 doTest([1, 2, 3], [0, 1, 5]);
86 doTest([1, 2, 3], [0, 3, 1, 2, 3]); 77 doTest([1, 2, 3], [0, 3, 1, 2, 3]);
87 } 78 }
88 79
89 </script> 80 </script>
90 81
91 </body> 82 </body>
92 </html> 83 </html>
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/webui/event_target_test.html » ('j') | chrome/test/data/webui/event_target_test.html » ('J')

Powered by Google App Engine
This is Rietveld 408576698