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

Side by Side Diff: test/iron_list_dynamic_item_size_test.dart

Issue 1418513006: update elements and fix some bugs (Closed) Base URL: git@github.com:dart-lang/polymer_elements.git@master
Patch Set: code review updates Created 5 years, 1 month 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
« no previous file with comments | « test/iron_list_different_heights_test.html ('k') | test/iron_list_dynamic_item_size_test.html » ('j') | 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) 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
3 // BSD-style license that can be found in the LICENSE file.
4 @TestOn('browser')
5 library polymer_elements.test.iron_list_dynamic_item_size_test;
6
7 import 'dart:async';
8 import 'dart:js';
9 import 'package:polymer_elements/iron_list.dart';
10 import 'package:polymer/polymer.dart';
11 import 'package:test/test.dart';
12 import 'package:web_components/web_components.dart';
13 import 'common.dart';
14 import 'iron_list_test_helpers.dart';
15 import 'fixtures/x_list.dart';
16
17 /// Uses [XList].
18 main() async {
19 await initPolymer();
20
21 group('Dynamic item size', () {
22 IronList list;
23 XList container;
24
25 setUp(() {
26 container = fixture('trivialList');
27 list = container.list;
28 });
29
30 test('update size using item index', () async {
31 list.items = buildDataSet(100);
32
33 await wait(1);
34
35 var firstItem = getFirstItemFromList(list);
36 var initHeight = firstItem.offsetHeight;
37
38 list.set('items.0.index', '1\n2\n3\n4');
39 list.updateSizeForItem(0);
40 expect(firstItem.offsetHeight, greaterThan(initHeight * 3));
41
42 list.set('items.0.index', '1');
43 list.updateSizeForItem(0);
44 expect(firstItem.offsetHeight, initHeight);
45 });
46
47 test('update size using item object', () async {
48 list.items = buildDataSet(100);
49
50 await wait(1);
51
52 var firstItem = getFirstItemFromList(list);
53 var initHeight = firstItem.offsetHeight;
54
55 list.set('items.0.index', '1\n2\n3\n4');
56 list.updateSizeForItem(list.items[0]);
57 expect(firstItem.offsetHeight, greaterThan(initHeight * 3));
58
59 list.set('items.0.index', '1');
60 list.updateSizeForItem(list.items[0]);
61 expect(firstItem.offsetHeight, initHeight);
62 });
63
64 test('ignore items that are not rendered', () async {
65 list.items = buildDataSet(100);
66
67 await wait(1);
68 list.updateSizeForItem(list.items[list.jsElement['_physicalCount'] + 1]);
69 });
70
71 test('throw if the item is invalid', () async {
72 list.items = buildDataSet(100);
73
74 await wait(1);
75 var firstItem = getFirstItemFromList(list);
76 var initHeight = firstItem.offsetHeight;
77 var throws = 0;
78
79 try {
80 list.updateSizeForItem(100);
81 } catch (error) {
82 throws++;
83 }
84
85 try {
86 list.updateSizeForItem({});
87 } catch (error) {
88 throws++;
89 }
90
91 expect(throws, 2);
92 });
93 });
94 }
OLDNEW
« no previous file with comments | « test/iron_list_different_heights_test.html ('k') | test/iron_list_dynamic_item_size_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698