Files
sdk/tests/html/element_constructor_1_test.dart
T
sra@google.com 31ab9dec79 Element constructors
Elements with distinct types can now be constructed directly.

Example:
  var div = new DivElement();

There are many elements that cannot be created this way.  For example, the <b>bold</b> element is simply a HTMLElement with styling, not a separate subclass of HTMLElement.

Review URL: https://chromiumcodereview.appspot.com//10384024

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@7921 260f80e4-7a28-3924-810f-c04153c831b5
2012-05-23 19:25:17 +00:00

62 lines
1.6 KiB
Dart

// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// Put universally passing event constructors in this file.
// Move constructors that fail on some configuration to their own
// element_constructor_foo_test.dart file.
#library('ElementConstructorTest');
#import('../../lib/unittest/unittest.dart');
#import('../../lib/unittest/html_config.dart');
#import('dart:html');
main() {
useHtmlConfiguration();
test('anchor1', () {
var e = new AnchorElement();
Expect.isTrue(e is AnchorElement);
});
test('anchor2', () {
var e = new AnchorElement(href: '#blah');
Expect.isTrue(e is AnchorElement);
Expect.isTrue(e.href.endsWith('#blah'));
});
test('area', () {
var e = new AreaElement();
Expect.isTrue(e is AreaElement);
});
// AudioElement tested in audioelement_test.dart
test('div', () {
var e = new DivElement();
Expect.isTrue(e is DivElement);
});
test('canvas1', () {
var e = new CanvasElement();
Expect.isTrue(e is CanvasElement);
});
test('canvas2', () {
var e = new CanvasElement(height: 100, width: 200);
Expect.isTrue(e is CanvasElement);
Expect.equals(200, e.width);
Expect.equals(100, e.height);
});
test('p', () {
var e = new ParagraphElement();
Expect.isTrue(e is ParagraphElement);
});
test('span', () {
var e = new SpanElement();
Expect.isTrue(e is SpanElement);
});
}