Files
sdk/tests/html/cssstyledeclaration_test.dart
T
gram@google.com 9b79e27e17 Some unit test fixes:
Fixed a couple of issues in the ensureInitialized() function.
Added expectAsyncUntil methods to support callbackDone style tests.
Split the matcher tests up so that we can exclude those that use isInstance
from the environments where they don't work.
Eliminated the need for two functions calls in throws/throwsA.
Fixed some tests.
Changed some uses of Expect to expect.
Fixed a bug when using expectAsync with a count of zero.
Fixed a bug where we weren't updating the call count in invoke0/1/2.
Made expect behave sensibly in cases where the user doesn't supply a 
matcher (e.g. expect(foo, 0)). USing the predicate form with a 
reason now requires a named parameter.
Review URL: https://chromiumcodereview.appspot.com//10544167

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@8753 260f80e4-7a28-3924-810f-c04153c831b5
2012-06-15 23:17:57 +00:00

79 lines
2.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('CSSStyleDeclarationTest');
#import('../../lib/unittest/unittest.dart');
#import('../../lib/unittest/html_config.dart');
#import('dart:html');
main() {
useHtmlConfiguration();
createTestStyle() {
return new CSSStyleDeclaration.css("""
color: blue;
width: 2px !important;
-webkit-transform: rotate(90deg);
""");
};
test('default constructor is empty', () {
var style = new CSSStyleDeclaration();
expect(style.cssText, isEmpty);
expect(style.getPropertyPriority('color'), isEmpty);
expect(style.item(0), isEmpty);
expect(style, hasLength(0));
// These assertions throw a NotImplementedException in dartium:
// Expect.isNull(style.parentRule);
// Expect.isNull(style.getPropertyCSSValue('color'));
// Expect.isNull(style.getPropertyShorthand('color'));
});
test('cssText is wrapped', () {
var style = createTestStyle();
expect(style.cssText,
equals("color: blue; width: 2px !important; "
"-webkit-transform: rotate(90deg); "));
style.cssText = "color: red";
expect(style.cssText, equals("color: red; "));
});
test('length is wrapped', () {
expect(createTestStyle(), hasLength(3));
});
test('getPropertyPriority is wrapped', () {
var style = createTestStyle();
expect(style.getPropertyPriority("color"), isEmpty);
expect(style.getPropertyPriority("width"), equals("important"));
});
test('item is wrapped', () {
var style = createTestStyle();
expect(style.item(0), equals("color"));
expect(style.item(1), equals("width"));
expect(style.item(2), equals("-webkit-transform"));
});
test('removeProperty is wrapped', () {
var style = createTestStyle();
style.removeProperty("width");
expect(style.cssText,
equals("color: blue; -webkit-transform: rotate(90deg); "));
});
test('CSS property getters and setters', () {
var style = createTestStyle();
expect(style.color, equals("blue"));
expect(style.width, equals("2px"));
expect(style.transform, equals("rotate(90deg)"));
style.color = "red";
style.transform = "translate(10px, 20px)";
expect(style.cssText,
equals("color: red; width: 2px !important;"
" -webkit-transform: translate(10px, 20px); "));
});
}