OLD | NEW |
(Empty) | |
| 1 dart_library.library('lib/html/element_dimensions_test', null, /* Imports */[ |
| 2 'dart_sdk', |
| 3 'unittest' |
| 4 ], function load__element_dimensions_test(exports, dart_sdk, unittest) { |
| 5 'use strict'; |
| 6 const core = dart_sdk.core; |
| 7 const html = dart_sdk.html; |
| 8 const _interceptors = dart_sdk._interceptors; |
| 9 const dart = dart_sdk.dart; |
| 10 const dartx = dart_sdk.dartx; |
| 11 const html_config = unittest.html_config; |
| 12 const src__matcher__core_matchers = unittest.src__matcher__core_matchers; |
| 13 const unittest$ = unittest.unittest; |
| 14 const src__matcher__expect = unittest.src__matcher__expect; |
| 15 const element_dimensions_test = Object.create(null); |
| 16 let JSArrayOfNode = () => (JSArrayOfNode = dart.constFn(_interceptors.JSArray$
(html.Node)))(); |
| 17 let dynamicTobool = () => (dynamicTobool = dart.constFn(dart.definiteFunctionT
ype(core.bool, [dart.dynamic])))(); |
| 18 let VoidTovoid = () => (VoidTovoid = dart.constFn(dart.definiteFunctionType(da
rt.void, [])))(); |
| 19 let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionT
ype(dart.dynamic, [])))(); |
| 20 element_dimensions_test.main = function() { |
| 21 html_config.useHtmlConfiguration(); |
| 22 let isElement = src__matcher__core_matchers.predicate(dart.fn(x => html.Elem
ent.is(x), dynamicTobool()), 'is an Element'); |
| 23 let isCanvasElement = src__matcher__core_matchers.predicate(dart.fn(x => htm
l.CanvasElement.is(x), dynamicTobool()), 'is a CanvasElement'); |
| 24 let isDivElement = src__matcher__core_matchers.predicate(dart.fn(x => html.D
ivElement.is(x), dynamicTobool()), 'is a isDivElement'); |
| 25 let div = html.DivElement.new(); |
| 26 div[dartx.id] = 'test'; |
| 27 html.document[dartx.body][dartx.nodes][dartx.add](div); |
| 28 function initDiv() { |
| 29 let style = div[dartx.style]; |
| 30 style[dartx.padding] = '4px'; |
| 31 style[dartx.border] = '0px solid #fff'; |
| 32 style[dartx.margin] = '6px'; |
| 33 style[dartx.height] = '10px'; |
| 34 style[dartx.width] = '11px'; |
| 35 style[dartx.boxSizing] = 'content-box'; |
| 36 style[dartx.overflow] = 'visible'; |
| 37 } |
| 38 dart.fn(initDiv, VoidTovoid()); |
| 39 div[dartx.nodes][dartx.addAll](JSArrayOfNode().of([html.DivElement.new(), ht
ml.CanvasElement.new(), html.DivElement.new(), html.Text.new('Hello'), html.DivE
lement.new(), html.Text.new('World'), html.CanvasElement.new()])); |
| 40 unittest$.group('dimensions', dart.fn(() => { |
| 41 unittest$.setUp(initDiv); |
| 42 unittest$.test('contentEdge.height', dart.fn(() => { |
| 43 let all1 = html.queryAll('#test'); |
| 44 src__matcher__expect.expect(all1.contentEdge.height, 10); |
| 45 src__matcher__expect.expect(all1.get(0)[dartx.getComputedStyle]()[dartx.
getPropertyValue]('height'), '10px'); |
| 46 all1.contentEdge.height = new html.Dimension.px(600); |
| 47 all1.contentEdge.height = 600; |
| 48 src__matcher__expect.expect(all1.contentEdge.height, 600); |
| 49 src__matcher__expect.expect(all1.get(0)[dartx.getComputedStyle]()[dartx.
getPropertyValue]('height'), '600px'); |
| 50 all1.get(0)[dartx.style][dartx.visibility] = 'hidden'; |
| 51 src__matcher__expect.expect(all1.contentEdge.height, 600); |
| 52 all1.get(0)[dartx.style][dartx.visibility] = 'visible'; |
| 53 all1.contentEdge.height = new html.Dimension.px(-1); |
| 54 src__matcher__expect.expect(all1.contentEdge.height, 0); |
| 55 div[dartx.style][dartx.padding] = '20pc'; |
| 56 src__matcher__expect.expect(all1.contentEdge.height, 0); |
| 57 div[dartx.style][dartx.border] = '2px solid #fff'; |
| 58 src__matcher__expect.expect(all1.contentEdge.height, 0); |
| 59 }, VoidTodynamic())); |
| 60 unittest$.test('contentEdge.height with border-box', dart.fn(() => { |
| 61 let all1 = html.queryAll('#test'); |
| 62 div[dartx.style][dartx.boxSizing] = 'border-box'; |
| 63 src__matcher__expect.expect(all1.contentEdge.height, 2); |
| 64 div[dartx.style][dartx.padding] = '20pc'; |
| 65 src__matcher__expect.expect(all1.contentEdge.height, 0); |
| 66 div[dartx.style][dartx.border] = '2px solid #fff'; |
| 67 src__matcher__expect.expect(all1.contentEdge.height, 0); |
| 68 }, VoidTodynamic())); |
| 69 unittest$.test('contentEdge.width', dart.fn(() => { |
| 70 let all1 = html.queryAll('#test'); |
| 71 src__matcher__expect.expect(all1.contentEdge.width, 11); |
| 72 src__matcher__expect.expect(all1.get(0)[dartx.getComputedStyle]()[dartx.
getPropertyValue]('width'), '11px'); |
| 73 all1.contentEdge.width = new html.Dimension.px(600); |
| 74 src__matcher__expect.expect(all1.contentEdge.width, 600); |
| 75 src__matcher__expect.expect(all1.get(0)[dartx.getComputedStyle]()[dartx.
getPropertyValue]('width'), '600px'); |
| 76 all1.get(0)[dartx.style][dartx.visibility] = 'hidden'; |
| 77 src__matcher__expect.expect(all1.contentEdge.width, 600); |
| 78 all1.get(0)[dartx.style][dartx.visibility] = 'visible'; |
| 79 all1.contentEdge.width = new html.Dimension.px(-1); |
| 80 src__matcher__expect.expect(all1.contentEdge.width, 0); |
| 81 div[dartx.style][dartx.padding] = '20pc'; |
| 82 src__matcher__expect.expect(all1.contentEdge.width, 0); |
| 83 div[dartx.style][dartx.border] = '2px solid #fff'; |
| 84 src__matcher__expect.expect(all1.contentEdge.width, 0); |
| 85 }, VoidTodynamic())); |
| 86 unittest$.test('contentEdge.width with border-box', dart.fn(() => { |
| 87 let all1 = html.queryAll('#test'); |
| 88 div[dartx.style][dartx.boxSizing] = 'border-box'; |
| 89 src__matcher__expect.expect(all1.contentEdge.width, 3); |
| 90 div[dartx.style][dartx.padding] = '20pc'; |
| 91 src__matcher__expect.expect(all1.contentEdge.width, 0); |
| 92 div[dartx.style][dartx.border] = '2px solid #fff'; |
| 93 src__matcher__expect.expect(all1.contentEdge.width, 0); |
| 94 }, VoidTodynamic())); |
| 95 unittest$.test('paddingEdge.height', dart.fn(() => { |
| 96 let all1 = html.queryAll('#test'); |
| 97 src__matcher__expect.expect(all1.paddingEdge.height, 18); |
| 98 all1.get(0)[dartx.style][dartx.visibility] = 'hidden'; |
| 99 src__matcher__expect.expect(all1.paddingEdge.height, 18); |
| 100 all1.get(0)[dartx.style][dartx.visibility] = 'visible'; |
| 101 div[dartx.style][dartx.border] = '2px solid #fff'; |
| 102 src__matcher__expect.expect(all1.paddingEdge.height, 18); |
| 103 div[dartx.style][dartx.padding] = '20pc'; |
| 104 src__matcher__expect.expect(all1.paddingEdge.height, 650); |
| 105 }, VoidTodynamic())); |
| 106 unittest$.test('paddingEdge.height with border-box', dart.fn(() => { |
| 107 let all1 = html.queryAll('#test'); |
| 108 div[dartx.style][dartx.boxSizing] = 'border-box'; |
| 109 src__matcher__expect.expect(all1.paddingEdge.height, 10); |
| 110 div[dartx.style][dartx.padding] = '20pc'; |
| 111 src__matcher__expect.expect(all1.paddingEdge.height, 640); |
| 112 div[dartx.style][dartx.border] = '2px solid #fff'; |
| 113 src__matcher__expect.expect(all1.paddingEdge.height, 640); |
| 114 }, VoidTodynamic())); |
| 115 unittest$.test('paddingEdge.width', dart.fn(() => { |
| 116 let all1 = html.queryAll('#test'); |
| 117 src__matcher__expect.expect(all1.paddingEdge.width, 19); |
| 118 all1.get(0)[dartx.style][dartx.visibility] = 'hidden'; |
| 119 src__matcher__expect.expect(all1.paddingEdge.width, 19); |
| 120 all1.get(0)[dartx.style][dartx.visibility] = 'visible'; |
| 121 div[dartx.style][dartx.border] = '2px solid #fff'; |
| 122 src__matcher__expect.expect(all1.paddingEdge.width, 19); |
| 123 div[dartx.style][dartx.padding] = '20pc'; |
| 124 src__matcher__expect.expect(all1.paddingEdge.width, 651); |
| 125 }, VoidTodynamic())); |
| 126 unittest$.test('paddingEdge.width with border-box', dart.fn(() => { |
| 127 let all1 = html.queryAll('#test'); |
| 128 div[dartx.style][dartx.boxSizing] = 'border-box'; |
| 129 src__matcher__expect.expect(all1.paddingEdge.width, 11); |
| 130 div[dartx.style][dartx.padding] = '20pc'; |
| 131 src__matcher__expect.expect(all1.paddingEdge.width, 640); |
| 132 div[dartx.style][dartx.border] = '2px solid #fff'; |
| 133 src__matcher__expect.expect(all1.paddingEdge.width, 640); |
| 134 }, VoidTodynamic())); |
| 135 unittest$.test('borderEdge.height and marginEdge.height', dart.fn(() => { |
| 136 let all1 = html.queryAll('#test'); |
| 137 src__matcher__expect.expect(div[dartx.borderEdge].height, 18); |
| 138 src__matcher__expect.expect(div[dartx.marginEdge].height, 30); |
| 139 src__matcher__expect.expect(all1.borderEdge.height, 18); |
| 140 src__matcher__expect.expect(all1.marginEdge.height, 30); |
| 141 all1.get(0)[dartx.style][dartx.visibility] = 'hidden'; |
| 142 src__matcher__expect.expect(all1.borderEdge.height, 18); |
| 143 all1.get(0)[dartx.style][dartx.visibility] = 'visible'; |
| 144 div[dartx.style][dartx.border] = '2px solid #fff'; |
| 145 src__matcher__expect.expect(all1.borderEdge.height, 22); |
| 146 div[dartx.style][dartx.padding] = '20pc'; |
| 147 src__matcher__expect.expect(all1.borderEdge.height, 654); |
| 148 src__matcher__expect.expect(all1.marginEdge.height, 666); |
| 149 }, VoidTodynamic())); |
| 150 unittest$.test('borderEdge.height and marginEdge.height with border-box',
dart.fn(() => { |
| 151 let all1 = html.queryAll('#test'); |
| 152 div[dartx.style][dartx.boxSizing] = 'border-box'; |
| 153 src__matcher__expect.expect(all1.borderEdge.height, 10); |
| 154 src__matcher__expect.expect(all1.marginEdge.height, 22); |
| 155 div[dartx.style][dartx.padding] = '20pc'; |
| 156 src__matcher__expect.expect(all1.borderEdge.height, 640); |
| 157 src__matcher__expect.expect(all1.marginEdge.height, 652); |
| 158 div[dartx.style][dartx.border] = '2px solid #fff'; |
| 159 src__matcher__expect.expect(all1.borderEdge.height, 644); |
| 160 src__matcher__expect.expect(all1.marginEdge.height, 656); |
| 161 }, VoidTodynamic())); |
| 162 unittest$.test('borderEdge.width and marginEdge.width', dart.fn(() => { |
| 163 let all1 = html.queryAll('#test'); |
| 164 src__matcher__expect.expect(all1.borderEdge.width, 19); |
| 165 src__matcher__expect.expect(all1.marginEdge.width, 31); |
| 166 div[dartx.style][dartx.border] = '2px solid #fff'; |
| 167 src__matcher__expect.expect(all1.borderEdge.width, 23); |
| 168 div[dartx.style][dartx.padding] = '20pc'; |
| 169 src__matcher__expect.expect(all1.borderEdge.width, 655); |
| 170 src__matcher__expect.expect(all1.marginEdge.width, 667); |
| 171 }, VoidTodynamic())); |
| 172 unittest$.test('borderEdge.width and marginEdge.width with border-box', da
rt.fn(() => { |
| 173 let all1 = html.queryAll('#test'); |
| 174 div[dartx.style][dartx.boxSizing] = 'border-box'; |
| 175 src__matcher__expect.expect(all1.borderEdge.width, 11); |
| 176 src__matcher__expect.expect(all1.marginEdge.width, 23); |
| 177 div[dartx.style][dartx.padding] = '20pc'; |
| 178 src__matcher__expect.expect(all1.borderEdge.width, 640); |
| 179 src__matcher__expect.expect(all1.marginEdge.width, 652); |
| 180 div[dartx.style][dartx.border] = '2px solid #fff'; |
| 181 src__matcher__expect.expect(all1.borderEdge.width, 644); |
| 182 src__matcher__expect.expect(all1.marginEdge.width, 656); |
| 183 }, VoidTodynamic())); |
| 184 unittest$.test('left and top', dart.fn(() => { |
| 185 div[dartx.style][dartx.border] = '1px solid #fff'; |
| 186 div[dartx.style][dartx.margin] = '6px 7px'; |
| 187 div[dartx.style][dartx.padding] = '4px 5px'; |
| 188 let all1 = html.queryAll('#test'); |
| 189 src__matcher__expect.expect(all1.borderEdge.left, all1.get(0)[dartx.getB
oundingClientRect]()[dartx.left]); |
| 190 src__matcher__expect.expect(all1.borderEdge.top, all1.get(0)[dartx.getBo
undingClientRect]()[dartx.top]); |
| 191 src__matcher__expect.expect(all1.contentEdge.left, dart.notNull(all1.get
(0)[dartx.getBoundingClientRect]()[dartx.left]) + 1 + 5); |
| 192 src__matcher__expect.expect(all1.contentEdge.top, dart.notNull(all1.get(
0)[dartx.getBoundingClientRect]()[dartx.top]) + 1 + 4); |
| 193 src__matcher__expect.expect(all1.marginEdge.left, dart.notNull(all1.get(
0)[dartx.getBoundingClientRect]()[dartx.left]) - 7); |
| 194 src__matcher__expect.expect(all1.marginEdge.top, dart.notNull(all1.get(0
)[dartx.getBoundingClientRect]()[dartx.top]) - 6); |
| 195 src__matcher__expect.expect(all1.paddingEdge.left, dart.notNull(all1.get
(0)[dartx.getBoundingClientRect]()[dartx.left]) + 1); |
| 196 src__matcher__expect.expect(all1.paddingEdge.top, dart.notNull(all1.get(
0)[dartx.getBoundingClientRect]()[dartx.top]) + 1); |
| 197 }, VoidTodynamic())); |
| 198 unittest$.test('setHeight ElementList', dart.fn(() => { |
| 199 div[dartx.style][dartx.border] = '1px solid #fff'; |
| 200 div[dartx.style][dartx.margin] = '6px 7px'; |
| 201 div[dartx.style][dartx.padding] = '4px 5px'; |
| 202 let all1 = html.queryAll('div'); |
| 203 all1.contentEdge.height = new html.Dimension.px(200); |
| 204 all1.contentEdge.height = 200; |
| 205 for (let elem of all1) { |
| 206 src__matcher__expect.expect(elem[dartx.contentEdge].height, 200); |
| 207 } |
| 208 all1.contentEdge.height = new html.Dimension.px(10); |
| 209 for (let elem of all1) { |
| 210 src__matcher__expect.expect(elem[dartx.contentEdge].height, 10); |
| 211 } |
| 212 }, VoidTodynamic())); |
| 213 }, VoidTovoid())); |
| 214 }; |
| 215 dart.fn(element_dimensions_test.main, VoidTodynamic()); |
| 216 // Exports: |
| 217 exports.element_dimensions_test = element_dimensions_test; |
| 218 }); |
OLD | NEW |