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

Unified 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, 2 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/iron_list_dynamic_item_size_test.dart
diff --git a/test/iron_list_dynamic_item_size_test.dart b/test/iron_list_dynamic_item_size_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..06f647e091cb969b5655f64f4f2d548ee46dcd20
--- /dev/null
+++ b/test/iron_list_dynamic_item_size_test.dart
@@ -0,0 +1,94 @@
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+@TestOn('browser')
+library polymer_elements.test.iron_list_dynamic_item_size_test;
+
+import 'dart:async';
+import 'dart:js';
+import 'package:polymer_elements/iron_list.dart';
+import 'package:polymer/polymer.dart';
+import 'package:test/test.dart';
+import 'package:web_components/web_components.dart';
+import 'common.dart';
+import 'iron_list_test_helpers.dart';
+import 'fixtures/x_list.dart';
+
+/// Uses [XList].
+main() async {
+ await initPolymer();
+
+ group('Dynamic item size', () {
+ IronList list;
+ XList container;
+
+ setUp(() {
+ container = fixture('trivialList');
+ list = container.list;
+ });
+
+ test('update size using item index', () async {
+ list.items = buildDataSet(100);
+
+ await wait(1);
+
+ var firstItem = getFirstItemFromList(list);
+ var initHeight = firstItem.offsetHeight;
+
+ list.set('items.0.index', '1\n2\n3\n4');
+ list.updateSizeForItem(0);
+ expect(firstItem.offsetHeight, greaterThan(initHeight * 3));
+
+ list.set('items.0.index', '1');
+ list.updateSizeForItem(0);
+ expect(firstItem.offsetHeight, initHeight);
+ });
+
+ test('update size using item object', () async {
+ list.items = buildDataSet(100);
+
+ await wait(1);
+
+ var firstItem = getFirstItemFromList(list);
+ var initHeight = firstItem.offsetHeight;
+
+ list.set('items.0.index', '1\n2\n3\n4');
+ list.updateSizeForItem(list.items[0]);
+ expect(firstItem.offsetHeight, greaterThan(initHeight * 3));
+
+ list.set('items.0.index', '1');
+ list.updateSizeForItem(list.items[0]);
+ expect(firstItem.offsetHeight, initHeight);
+ });
+
+ test('ignore items that are not rendered', () async {
+ list.items = buildDataSet(100);
+
+ await wait(1);
+ list.updateSizeForItem(list.items[list.jsElement['_physicalCount'] + 1]);
+ });
+
+ test('throw if the item is invalid', () async {
+ list.items = buildDataSet(100);
+
+ await wait(1);
+ var firstItem = getFirstItemFromList(list);
+ var initHeight = firstItem.offsetHeight;
+ var throws = 0;
+
+ try {
+ list.updateSizeForItem(100);
+ } catch (error) {
+ throws++;
+ }
+
+ try {
+ list.updateSizeForItem({});
+ } catch (error) {
+ throws++;
+ }
+
+ expect(throws, 2);
+ });
+ });
+}
« 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