Files
sdk/tests/html/query_test.dart
T
gram@google.com 981c4b11df Restructure pkg/unittest and pkg/webdriver to follow the pub conventions.
This means all imports of unittest in our test code had to change to include 'lib' in the path.
While doing that change I changed the library/imports to the new syntax in the affected files.
Review URL: https://codereview.chromium.org//11301046

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@14443 260f80e4-7a28-3924-810f-c04153c831b5
2012-11-01 23:09:47 +00:00

58 lines
1.5 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.
library QueryTest;
import '../../pkg/unittest/lib/unittest.dart';
import '../../pkg/unittest/lib/html_config.dart';
import 'dart:html';
main() {
useHtmlConfiguration();
final div = new DivElement();
final canvas = new CanvasElement(width: 200, height: 200);
canvas.id = 'testcanvas';
final element =
new Element.html("<div><br/><img/><input/><img/></div>");
document.body.nodes.addAll([div, canvas, element]);
var isCanvasElement =
predicate((x) => x is CanvasElement, 'is a CanvasElement');
var isImageElement =
predicate((x) => x is ImageElement, 'is an ImageElement');
test('query', () {
Element e = query('#testcanvas');
expect(e, isNotNull);
expect(e.id, 'testcanvas');
expect(e, isCanvasElement);
expect(e, canvas);
});
test('query (None)', () {
Element e = query('#nothere');
expect(e, isNull);
});
test('queryAll (One)', () {
List l = queryAll('canvas');
expect(l.length, 1);
expect(l[0], canvas);
});
test('queryAll (Multiple)', () {
List l = queryAll('img');
expect(l.length, 2);
expect(l[0], isImageElement);
expect(l[1], isImageElement);
expect(l[0], isNot(equals(l[1])));
});
test('queryAll (None)', () {
List l = queryAll('video');
expect(l.isEmpty, isTrue);
});
}