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().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]') |
| 24 .getComputedStyle(), |
| 25 'v1': t.querySelector('[vertical] > [flex]').getComputedStyle(), |
| 26 'v2': t.querySelector('[vertical] > [flex][sized]').getComputedStyle() |
| 27 }; |
| 28 } |
| 29 |
| 30 // no-size container tests |
| 31 |
| 32 test('flex-layout-attributies', () { |
| 33 var elements = getTestElements('test1'); |
| 34 expect(elements['h1'].width, elements['h2'].width, |
| 35 reason: 'unsized container: horizontal flex items have same width'); |
| 36 expect(elements['v1'].height, '0px', |
| 37 reason: 'unsized container: vertical flex items have no intrinsic ' |
| 38 'height'); |
| 39 }); |
| 40 |
| 41 test('flex auto layout attributes', () { |
| 42 var elements = getTestElements('test2'); |
| 43 expect(elements['h1'].width, isNot(elements['h2'].width), |
| 44 reason: 'unsized container: horizontal flex auto items have intrinsic ' |
| 45 'width + flex amount'); |
| 46 expect(elements['v1'].height, isNot('0px'), |
| 47 reason: 'unsized container: vertical flex auto items have intrinsic ' |
| 48 'height'); |
| 49 }); |
| 50 |
| 51 test('flex auto-vertical layout attributes', () { |
| 52 var elements = getTestElements('test3'); |
| 53 expect(elements['h1'].width, elements['h2'].width, |
| 54 reason: 'unsized container: horizontal flex auto-vertical items have ' |
| 55 'same width'); |
| 56 expect(elements['v1'].height, isNot('0px'), |
| 57 reason: 'unsized container: vertical flex auto-vertical items have ' |
| 58 'intrinsic height'); |
| 59 }); |
| 60 |
| 61 // Sized container tests |
| 62 |
| 63 test('flex layout attributes', () { |
| 64 var elements = getTestElements('test4'); |
| 65 expect(elements['h1'].width, elements['h2'].width, |
| 66 reason: 'sized container: horizontal flex items have same width'); |
| 67 expect(elements['v1'].height, elements['v2'].height, |
| 68 reason: 'sized container: vertical flex items have same height'); |
| 69 }); |
| 70 |
| 71 test('flex auto layout attributes', () { |
| 72 var elements = getTestElements('test5'); |
| 73 expect(elements['h1'].width, isNot(elements['h2'].width), |
| 74 reason: 'sized container: horizontal flex auto items have intrinsic ' |
| 75 'width + flex amount'); |
| 76 expect(elements['v1'].height, isNot('0px'), |
| 77 reason: 'sized container: vertical flex auto items have intrinsic ' |
| 78 'height'); |
| 79 expect(elements['v1'].height, isNot(elements['v2'].height), |
| 80 reason: 'sized container: vertical flex auto items have intrinsic ' |
| 81 'width + flex amount'); |
| 82 }); |
| 83 |
| 84 test('flex auto-vertical layout attributes', () { |
| 85 var elements = getTestElements('test3'); |
| 86 expect(elements['h1'].width, elements['h2'].width, |
| 87 reason: 'unsized container: horizontal flex auto-vertical items have ' |
| 88 'same width'); |
| 89 expect(elements['v1'].height, isNot('0px'), |
| 90 reason: 'sized container: vertical flex auto-vertical items have ' |
| 91 'intrinsic height'); |
| 92 expect(elements['v1'].height, isNot(elements['v2'].height), |
| 93 reason: 'sized container: vertical flex auto-vertical items have ' |
| 94 'intrinsic width + flex amount'); |
| 95 }); |
| 96 |
| 97 }); |
OLD | NEW |