OLD | NEW |
| (Empty) |
1 // Copyright (c) 2014, 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 | |
5 library polymer.test.web.layout_test; | |
6 | |
7 import 'dart:async'; | |
8 import 'dart:html'; | |
9 import 'dart:js'; | |
10 import 'package:polymer/polymer.dart'; | |
11 import 'package:unittest/html_config.dart'; | |
12 import 'package:unittest/unittest.dart'; | |
13 | |
14 main() => initPolymer().then((zone) => zone.run(() { | |
15 useHtmlConfiguration(); | |
16 | |
17 setUp(() => Polymer.onReady); | |
18 | |
19 getTestElements(test) { | |
20 var t = document.getElementById(test); | |
21 return { | |
22 'h1': t.querySelector('[horizontal] > [flex]').getComputedStyle(), | |
23 'h2': t.querySelector('[horizontal] > [flex][sized]').getComputedStyle(), | |
24 'v1': t.querySelector('[vertical] > [flex]').getComputedStyle(), | |
25 'v2': t.querySelector('[vertical] > [flex][sized]').getComputedStyle() | |
26 }; | |
27 } | |
28 | |
29 // no-size container tests | |
30 | |
31 test('flex-layout-attributies', () { | |
32 var elements = getTestElements('test1'); | |
33 expect(elements['h1'].width, elements['h2'].width, | |
34 reason: 'unsized container: horizontal flex items have same width'); | |
35 expect(elements['v1'].height, '0px', | |
36 reason: 'unsized container: vertical flex items have no intrinsic ' | |
37 'height'); | |
38 }); | |
39 | |
40 test('flex auto layout attributes', () { | |
41 var elements = getTestElements('test2'); | |
42 expect(elements['h1'].width, isNot(elements['h2'].width), | |
43 reason: 'unsized container: horizontal flex auto items have intrinsic ' | |
44 'width + flex amount'); | |
45 expect(elements['v1'].height, isNot('0px'), | |
46 reason: 'unsized container: vertical flex auto items have intrinsic ' | |
47 'height'); | |
48 }); | |
49 | |
50 test('flex auto-vertical layout attributes', () { | |
51 var elements = getTestElements('test3'); | |
52 expect(elements['h1'].width, elements['h2'].width, | |
53 reason: 'unsized container: horizontal flex auto-vertical items have ' | |
54 'same width'); | |
55 expect(elements['v1'].height, isNot('0px'), | |
56 reason: 'unsized container: vertical flex auto-vertical items have ' | |
57 'intrinsic height'); | |
58 }); | |
59 | |
60 // Sized container tests | |
61 | |
62 test('flex layout attributes', () { | |
63 var elements = getTestElements('test4'); | |
64 expect(elements['h1'].width, elements['h2'].width, | |
65 reason: 'sized container: horizontal flex items have same width'); | |
66 expect(elements['v1'].height, elements['v2'].height, | |
67 reason: 'sized container: vertical flex items have same height'); | |
68 }); | |
69 | |
70 test('flex auto layout attributes', () { | |
71 var elements = getTestElements('test5'); | |
72 expect(elements['h1'].width, isNot(elements['h2'].width), | |
73 reason: 'sized container: horizontal flex auto items have intrinsic ' | |
74 'width + flex amount'); | |
75 expect(elements['v1'].height, isNot('0px'), | |
76 reason: 'sized container: vertical flex auto items have intrinsic ' | |
77 'height'); | |
78 expect(elements['v1'].height, isNot(elements['v2'].height), | |
79 reason: 'sized container: vertical flex auto items have intrinsic ' | |
80 'width + flex amount'); | |
81 }); | |
82 | |
83 test('flex auto-vertical layout attributes', () { | |
84 var elements = getTestElements('test3'); | |
85 expect(elements['h1'].width, elements['h2'].width, | |
86 reason: 'unsized container: horizontal flex auto-vertical items have ' | |
87 'same width'); | |
88 expect(elements['v1'].height, isNot('0px'), | |
89 reason: 'sized container: vertical flex auto-vertical items have ' | |
90 'intrinsic height'); | |
91 expect(elements['v1'].height, isNot(elements['v2'].height), | |
92 reason: 'sized container: vertical flex auto-vertical items have ' | |
93 'intrinsic width + flex amount'); | |
94 }); | |
95 })); | |
OLD | NEW |