| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 @TestOn('browser') | 4 @TestOn('browser') |
| 5 library polymer_elements.test.iron_list_physical_count_test; | 5 library polymer_elements.test.iron_list_physical_count_test; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:html'; | 8 import 'dart:html'; |
| 9 import 'dart:js'; | 9 import 'dart:js'; |
| 10 import 'package:polymer_elements/iron_list.dart'; | 10 import 'package:polymer_elements/iron_list.dart'; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 container = fixture('trivialList'); | 26 container = fixture('trivialList'); |
| 27 list = container.list; | 27 list = container.list; |
| 28 }); | 28 }); |
| 29 | 29 |
| 30 test('increase pool size', () { | 30 test('increase pool size', () { |
| 31 list.items = buildDataSet(1000); | 31 list.items = buildDataSet(1000); |
| 32 return new Future(() {}).then((_) { | 32 return new Future(() {}).then((_) { |
| 33 var lastItem = getLastItemFromList(list); | 33 var lastItem = getLastItemFromList(list); |
| 34 var lastItemHeight = lastItem.offsetHeight; | 34 var lastItemHeight = lastItem.offsetHeight; |
| 35 var expectedFinalItem = (list.offsetHeight / lastItemHeight).floor(); | 35 var expectedFinalItem = (list.offsetHeight / lastItemHeight).floor(); |
| 36 expect(lastItemHeight, 1); | 36 expect(lastItemHeight, 2); |
| 37 expect(getLastItemFromList(list).text, expectedFinalItem.toString()); | 37 expect(getLastItemFromList(list).text, expectedFinalItem.toString()); |
| 38 }); | 38 }); |
| 39 }); | 39 }); |
| 40 | 40 |
| 41 test('increase pool size on resize', () async { | 41 test('increase pool size on resize', () async { |
| 42 list.items = buildDataSet(1000); | 42 list.items = buildDataSet(1000); |
| 43 | 43 |
| 44 await wait(1); | 44 await wait(1); |
| 45 // change the height of the list | 45 // change the height of the list |
| 46 container.set('listHeight', 500); | 46 container.set('listHeight', 500); |
| 47 // resize | 47 // resize |
| 48 list.fire('resize'); | 48 list.fire('iron-resize'); |
| 49 | 49 |
| 50 await wait(1); | 50 await wait(1); |
| 51 var lastItem = getLastItemFromList(list); | 51 var lastItem = getLastItemFromList(list); |
| 52 var lastItemHeight = lastItem.offsetHeight; | 52 var lastItemHeight = lastItem.offsetHeight; |
| 53 int expectedFinalItem = (list.offsetHeight/lastItemHeight - 1).round(); | 53 int expectedFinalItem = (list.offsetHeight / lastItemHeight).round(); |
| 54 | 54 |
| 55 expect(lastItemHeight, 1); | 55 expect(lastItemHeight, 2); |
| 56 expect(getLastItemFromList(list).text, '$expectedFinalItem'); | 56 expect(getLastItemFromList(list).text, '$expectedFinalItem'); |
| 57 }, skip: 'Fails in test runner since window is <500px tall'); | 57 }); |
| 58 }); | 58 }); |
| 59 } | 59 } |
| OLD | NEW |