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

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

Issue 20606002: Make element offset test machine independent. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Make offset test cross-machine Created 7 years, 4 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 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 ElementTest; 5 library ElementTest;
6 import '../../pkg/unittest/lib/unittest.dart'; 6 import '../../pkg/unittest/lib/unittest.dart';
7 import '../../pkg/unittest/lib/html_individual_config.dart'; 7 import '../../pkg/unittest/lib/html_individual_config.dart';
8 import 'dart:async'; 8 import 'dart:async';
9 import 'dart:html'; 9 import 'dart:html';
10 import 'dart:svg' as svg; 10 import 'dart:svg' as svg;
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 expect(filtered, isElementIterable); 721 expect(filtered, isElementIterable);
722 }); 722 });
723 723
724 test('sublist', () { 724 test('sublist', () {
725 var range = makeElList().sublist(1, 3); 725 var range = makeElList().sublist(1, 3);
726 expect(range, isElementList); 726 expect(range, isElementList);
727 expect(range[0], isImageElement); 727 expect(range[0], isImageElement);
728 expect(range[1], isInputElement); 728 expect(range[1], isInputElement);
729 }); 729 });
730 }); 730 });
731 void initPage() {
732 var level1 = new UListElement()
733 ..classes.add('level-1')
734 ..children.add(new LIElement()..innerHtml = 'I');
735 var itemii = new LIElement()
736 ..classes.add('item-ii')
737 ..style.position = 'relative'
738 ..style.top = '4px'
739 ..innerHtml = 'II';
740 level1.children.add(itemii);
741 var level2 = new UListElement();
742 itemii.children.add(level2);
743 var itema = new LIElement()
744 ..classes.add('item-a')
745 ..innerHtml = 'A';
746 var item1 = new LIElement()
747 ..classes.add('item-1')
748 ..innerHtml = '1';
749 var item2 = new LIElement()
750 ..classes.add('item-2')
751 ..innerHtml = '2';
752 var level3 = new UListElement()
753 ..children.addAll([item1, item2]);
754 var itemb = new LIElement()
755 ..classes.add('item-b')
756 ..style.position = 'relative'
757 ..style.top = '20px'
758 ..style.left = '150px'
759 ..innerHtml = 'B'
760 ..children.add(level3);
761 level2.children.addAll([itema, itemb, new LIElement()..innerHtml = 'C']);
762 document.body.append(level1);
763
764 var bar = new DivElement()..classes.add('bar');
765 var style = bar.style;
766 style..position = 'absolute'
767 ..top = '8px'
768 ..left = '90px';
769 var baz = new DivElement()..classes.add('baz');
770 style = baz.style;
771 style..position = 'absolute'
772 ..top = '600px'
773 ..left = '7000px';
774 bar.children.add(baz);
775
776 var quux = new DivElement()..classes.add('quux');
777 var qux = new DivElement()
778 ..classes.add('qux')
779 ..children.add(quux);
780
781 document.body.append(bar);
782 document.body.append(qux);
783 }
784
785 group('offset', () {
786 setUp(initPage);
787
788 test('offsetTo', () {
789 var itema = query('.item-a');
790 var itemb = query('.item-b');
791 var item1 = query('.item-1');
792 var itemii = query('.item-ii');
793 var level1 = query('.level-1');
794 var baz = query('.baz');
795 var bar = query('.bar');
796 var qux = query('.qux');
797 var quux = query('.quux');
798
799 var point = itema.offsetTo(itemii);
800 // TODO(efortuna): Make cross-machine reproducible.
801 /*expect(point.x, 40);
802 expect(point.y, inInclusiveRange(17, 20));
803
804 expect(baz.offsetTo(bar).x, 7000);
805 expect(baz.offsetTo(bar).y, inInclusiveRange(599, 604));
806
807 qux.style.position = 'fixed';
808 expect(quux.offsetTo(qux).x, 0);
809 expect(quux.offsetTo(qux).y, 0);
810
811 point = item1.offsetTo(itemb);
812 expect(point.x, 40);
813 expect(point.y, inInclusiveRange(17, 20));
814 point = itemb.offsetTo(itemii);
815 expect(point.x, 190);
816 expect(point.y, inInclusiveRange(54, 60));
817 point = item1.offsetTo(itemii);
818 expect(point.x, 230);
819 expect(point.y, inInclusiveRange(74, 80));*/
820 });
821
822 test('documentOffset', () {
823 var bar = query('.bar');
824 var baz = query('.baz');
825 var qux = query('.qux');
826 var quux = query('.quux');
827 var itema = query('.item-a');
828 var itemb = query('.item-b');
829 var item1 = query('.item-1');
830 var itemii = query('.item-ii');
831
832 // TODO(efortuna): Make cross-machine reproducible.
833 /*expect(itema.documentOffset.x, 88);
834 expect(itema.documentOffset.y, inInclusiveRange(119, 160));
835
836 expect(itemii.documentOffset.x, 48);
837 expect(itemii.documentOffset.y, inInclusiveRange(101, 145));
838
839 expect(itemb.documentOffset.x, 238);
840 expect(itemb.documentOffset.y, inInclusiveRange(157, 205));
841
842 expect(item1.documentOffset.x, 278);
843 expect(item1.documentOffset.y, inInclusiveRange(175, 222));
844
845 expect(bar.documentOffset.x, 90);
846 expect(bar.documentOffset.y, 8);
847
848 expect(baz.documentOffset.x, 7090);
849 expect(baz.documentOffset.y, 608);
850
851 expect(qux.documentOffset.x, 8);
852 expect(qux.documentOffset.y, inInclusiveRange(221, 232));
853
854 expect(quux.documentOffset.x, 8);
855 expect(quux.documentOffset.y, inInclusiveRange(221, 232));*/
856 });
857 });
858
859 } 731 }
OLDNEW
« tests/html/element_offset_test.dart ('K') | « tests/html/element_offset_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698