OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 /** | 5 /** |
6 * Tests the layout test functionality of test.dart. There is a .png image with | 6 * Tests the layout test functionality of test.dart. There is a .png image with |
7 * the same name as this file. The existence of the .png file indicates to the | 7 * the same name as this file. The existence of the .png file indicates to the |
8 * test framework that we want to compare the final state of this application | 8 * test framework that we want to compare the final state of this application |
9 * against an image file. | 9 * against an image file. |
10 */ | 10 */ |
11 library layouttest; | 11 library layouttest; |
12 | 12 |
13 import 'dart:html'; | 13 import 'dart:html'; |
14 | 14 |
15 main() { | 15 main() { |
16 var div1Style = _style('blue', 20, 10, 40, 10); | 16 var div1 = new DivElement(); |
17 var div2Style = _style('red', 25, 30, 40, 10); | 17 div1.attributes['style'] = _style('blue', 20, 10, 40, 10); |
18 var div1 = new Element.html('<div style="$div1Style"></div>'); | 18 var div2 = new DivElement(); |
19 var div2 = new Element.html('<div style="$div2Style"></div>'); | 19 div2.attributes['style'] = _style('red', 25, 30, 40, 10); |
20 document.body.children.add(div1); | 20 document.body.children.add(div1); |
21 document.body.children.add(div2); | 21 document.body.children.add(div2); |
22 } | 22 } |
23 | 23 |
24 _style(String color, int top, int left, int width, int height) { | 24 _style(String color, int top, int left, int width, int height) { |
25 return ('background-color:$color; position:absolute; ' | 25 return ('background-color:$color; position:absolute; ' |
26 'top:${top}px; left:${left}px; ' | 26 'top:${top}px; left:${left}px; ' |
27 'width:${width}px; height:${height}px;'); | 27 'width:${width}px; height:${height}px;'); |
28 } | 28 } |
OLD | NEW |