OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 element_offset_test; | 5 library element_offset_test; |
6 import 'package:unittest/unittest.dart'; | 6 import 'package:unittest/unittest.dart'; |
7 import 'package:unittest/html_individual_config.dart'; | 7 import 'package:unittest/html_individual_config.dart'; |
8 import 'dart:async'; | 8 import 'dart:async'; |
9 import 'dart:html'; | 9 import 'dart:html'; |
10 | 10 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 var item1 = query('.item-1'); | 74 var item1 = query('.item-1'); |
75 var itemii = query('.item-ii'); | 75 var itemii = query('.item-ii'); |
76 var level1 = query('.level-1'); | 76 var level1 = query('.level-1'); |
77 var baz = query('.baz'); | 77 var baz = query('.baz'); |
78 var bar = query('.bar'); | 78 var bar = query('.bar'); |
79 var qux = query('.qux'); | 79 var qux = query('.qux'); |
80 var quux = query('.quux'); | 80 var quux = query('.quux'); |
81 | 81 |
82 var point = itema.offsetTo(itemii); | 82 var point = itema.offsetTo(itemii); |
83 expect(point.x, 40); | 83 expect(point.x, 40); |
84 expect(point.y, inInclusiveRange(17, 20)); | 84 expect(point.y, inInclusiveRange(16, 20)); |
85 | 85 |
86 expect(baz.offsetTo(bar).x, 7000); | 86 expect(baz.offsetTo(bar).x, 7000); |
87 expect(baz.offsetTo(bar).y, inInclusiveRange(599, 604)); | 87 expect(baz.offsetTo(bar).y, inInclusiveRange(599, 604)); |
88 | 88 |
89 qux.style.position = 'fixed'; | 89 qux.style.position = 'fixed'; |
90 expect(quux.offsetTo(qux).x, 0); | 90 expect(quux.offsetTo(qux).x, 0); |
91 expect(quux.offsetTo(qux).y, 0); | 91 expect(quux.offsetTo(qux).y, 0); |
92 | 92 |
93 point = item1.offsetTo(itemb); | 93 point = item1.offsetTo(itemb); |
94 expect(point.x, 40); | 94 expect(point.x, 40); |
95 expect(point.y, inInclusiveRange(17, 20)); | 95 expect(point.y, inInclusiveRange(16, 20)); |
96 point = itemb.offsetTo(itemii); | 96 point = itemb.offsetTo(itemii); |
97 expect(point.x, 190); | 97 expect(point.x, 190); |
98 expect(point.y, inInclusiveRange(54, 60)); | 98 expect(point.y, inInclusiveRange(52, 60)); |
99 point = item1.offsetTo(itemii); | 99 point = item1.offsetTo(itemii); |
100 expect(point.x, 230); | 100 expect(point.x, 230); |
101 expect(point.y, inInclusiveRange(74, 80)); | 101 expect(point.y, inInclusiveRange(68, 80)); |
102 }); | 102 }); |
103 | 103 |
104 test('documentOffset', () { | 104 test('documentOffset', () { |
105 var bar = query('.bar'); | 105 var bar = query('.bar'); |
106 var baz = query('.baz'); | 106 var baz = query('.baz'); |
107 var qux = query('.qux'); | 107 var qux = query('.qux'); |
108 var quux = query('.quux'); | 108 var quux = query('.quux'); |
109 var itema = query('.item-a'); | 109 var itema = query('.item-a'); |
110 var itemb = query('.item-b'); | 110 var itemb = query('.item-b'); |
111 var item1 = query('.item-1'); | 111 var item1 = query('.item-1'); |
112 var itemii = query('.item-ii'); | 112 var itemii = query('.item-ii'); |
113 | 113 |
114 expect(itema.documentOffset.x, 88); | 114 expect(itema.documentOffset.x, 88); |
115 expect(itema.documentOffset.y, inInclusiveRange(119, 160)); | 115 expect(itema.documentOffset.y, inInclusiveRange(111, 160)); |
116 | 116 |
117 expect(itemii.documentOffset.x, 48); | 117 expect(itemii.documentOffset.x, 48); |
118 expect(itemii.documentOffset.y, inInclusiveRange(101, 145)); | 118 expect(itemii.documentOffset.y, inInclusiveRange(95, 145)); |
119 | 119 |
120 expect(itemb.documentOffset.x, 238); | 120 expect(itemb.documentOffset.x, 238); |
121 expect(itemb.documentOffset.y, inInclusiveRange(157, 205)); | 121 expect(itemb.documentOffset.y, inInclusiveRange(147, 205)); |
122 | 122 |
123 expect(item1.documentOffset.x, 278); | 123 expect(item1.documentOffset.x, 278); |
124 expect(item1.documentOffset.y, inInclusiveRange(175, 222)); | 124 expect(item1.documentOffset.y, inInclusiveRange(163, 222)); |
125 | 125 |
126 expect(bar.documentOffset.x, 90); | 126 expect(bar.documentOffset.x, 90); |
127 expect(bar.documentOffset.y, 8); | 127 expect(bar.documentOffset.y, 8); |
128 | 128 |
129 expect(baz.documentOffset.x, 7090); | 129 expect(baz.documentOffset.x, 7090); |
130 expect(baz.documentOffset.y, 608); | 130 expect(baz.documentOffset.y, 608); |
131 | 131 |
132 expect(qux.documentOffset.x, 8); | 132 expect(qux.documentOffset.x, 8); |
133 expect(qux.documentOffset.y, inInclusiveRange(221, 240)); | 133 expect(qux.documentOffset.y, inInclusiveRange(203, 240)); |
134 | 134 |
135 expect(quux.documentOffset.x, 8); | 135 expect(quux.documentOffset.x, 8); |
136 expect(quux.documentOffset.y, inInclusiveRange(221, 240)); | 136 expect(quux.documentOffset.y, inInclusiveRange(203, 240)); |
137 }); | 137 }); |
138 }); | 138 }); |
139 } | 139 } |
OLD | NEW |