Merge pull request #737 from abarth/migrate_tests

Migrate three tests to sky/unit/test
This commit is contained in:
Adam Barth 2015-08-21 09:14:06 -07:00
commit f82c55488e
29 changed files with 106 additions and 238 deletions

View File

@ -1,8 +0,0 @@
unittest-suite-wait-for-done
PASS: should throw with invalid arguments
PASS: should insert children
PASS: should insert children with a fragment
All 3 tests passed.
unittest-suite-success
DONE

View File

@ -1,9 +0,0 @@
unittest-suite-wait-for-done
PASS: should get by index
PASS: should set by name
PASS: should be case sensitive
PASS: should not live update
All 4 tests passed.
unittest-suite-success
DONE

View File

@ -1,12 +0,0 @@
unittest-suite-wait-for-done
PASS: should allow replacing the document element
PASS: should allow replacing a text child with an element
PASS: should allow replacing the document element with text
PASS: should allow inserting text with a fragment
PASS: should allow replacing the document element with a fragment
PASS: should throw when inserting multiple elements
PASS: should throw when inserting multiple elements with a fragment
All 7 tests passed.
unittest-suite-success
DONE

View File

@ -1,6 +0,0 @@
unittest-suite-wait-for-done
PASS: getChildElements should only include immediate children
All 1 tests passed.
unittest-suite-success
DONE

View File

@ -1,6 +0,0 @@
unittest-suite-wait-for-done
PASS: should throw with invalid arguments
All 1 tests passed.
unittest-suite-success
DONE

View File

@ -1,7 +0,0 @@
unittest-suite-wait-for-done
PASS: should return null for elements not a child of a scope
PASS: should return the document for elements in the document scope
All 2 tests passed.
unittest-suite-success
DONE

View File

@ -1,8 +0,0 @@
unittest-suite-wait-for-done
PASS: should replace elements
PASS: should replace text
PASS: should replace children with a fragment
All 3 tests passed.
unittest-suite-success
DONE

View File

@ -1,6 +0,0 @@
unittest-suite-wait-for-done
PASS: color accessors should work
All 1 tests passed.
unittest-suite-success
DONE

View File

@ -1,19 +0,0 @@
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:sky';
import '../resources/third_party/unittest/unittest.dart';
import '../resources/unit.dart';
void main() {
initUnit();
test("color accessors should work", () {
Color foo = new Color(0x12345678);
expect(foo.alpha, equals(0x12));
expect(foo.red, equals(0x34));
expect(foo.green, equals(0x56));
expect(foo.blue, equals(0x78));
});
}

View File

@ -1,6 +0,0 @@
unittest-suite-wait-for-done
PASS: matrix access should work
All 1 tests passed.
unittest-suite-success
DONE

View File

@ -1,8 +0,0 @@
unittest-suite-wait-for-done
PASS: paint set to black
PASS: color created with out of bounds value
PASS: color created with wildly out of bounds value
All 3 tests passed.
unittest-suite-success
DONE

View File

@ -1,35 +0,0 @@
import 'dart:sky' as sky;
import '../resources/third_party/unittest/unittest.dart';
import '../resources/unit.dart';
void main() {
initUnit();
test("paint set to black", () {
sky.Color c = new sky.Color(0x00000000);
sky.Paint p = new sky.Paint();
p.color = c;
expect(c.toString(), equals('Color(0x00000000)'));
});
test("color created with out of bounds value", () {
try {
sky.Color c = new sky.Color(0x100 << 24);
sky.Paint p = new sky.Paint();
p.color = c;
} catch (e) {
expect(e != null, equals(true));
}
});
test("color created with wildly out of bounds value", () {
try {
sky.Color c = new sky.Color(1 << 1000000);
sky.Paint p = new sky.Paint();
p.color = c;
} catch (e) {
expect(e != null, equals(true));
}
});
}

View File

@ -1,6 +0,0 @@
unittest-suite-wait-for-done
PASS: createText(null) shouldn't crash
All 1 tests passed.
unittest-suite-success
DONE

View File

@ -1,17 +0,0 @@
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:sky' as sky;
import '../resources/third_party/unittest/unittest.dart';
import '../resources/unit.dart';
void main() {
initUnit();
test("createText(null) shouldn't crash", () {
var doc = new sky.Document();
doc.createText(null);
});
}

View File

@ -1,6 +0,0 @@
unittest-suite-wait-for-done
PASS: should be settable using "style" attribute
All 1 tests passed.
unittest-suite-success
DONE

View File

@ -1,20 +0,0 @@
import "../resources/third_party/unittest/unittest.dart";
import "../resources/unit.dart";
import "dart:sky";
void main() {
initUnit();
test('should be settable using "style" attribute', () {
LayoutRoot layoutRoot = new LayoutRoot();
var document = new Document();
var foo = document.createElement('foo');
layoutRoot.rootElement = foo;
foo.setAttribute('style', 'color: red');
expect(foo.getAttribute('style'), equals('color: red'));
expect(foo.style["color"], equals('rgb(255, 0, 0)'));
});
}

View File

@ -1,6 +0,0 @@
unittest-suite-wait-for-done
PASS: should not crash when setting style to null
All 1 tests passed.
unittest-suite-success
DONE

View File

@ -1,12 +1,10 @@
import "../resources/dom_utils.dart";
import "../resources/third_party/unittest/unittest.dart";
import "../resources/unit.dart";
import 'dart:sky';
import "dart:sky";
import 'package:test/test.dart';
import 'dom_utils.dart';
void main() {
initUnit();
Document document = new Document();
test("should throw with invalid arguments", () {
@ -18,7 +16,7 @@ void main() {
parent.appendChild(null);
}, throws);
expect(() {
parent.appendChild({tagName: "div"});
parent.appendChild({"tagName": "div"});
}, throws);
});

View File

@ -1,11 +1,8 @@
import "../resources/third_party/unittest/unittest.dart";
import "../resources/unit.dart";
import 'dart:sky';
import "dart:sky";
import 'package:test/test.dart';
void main() {
initUnit();
var div;
setUp(() {
var document = new Document();

View File

@ -1,15 +1,13 @@
import "../resources/dom_utils.dart";
import "../resources/third_party/unittest/unittest.dart";
import "../resources/unit.dart";
import 'dart:sky' as sky;
import 'dart:sky' show Rect, Color, Paint;
import "dart:sky";
import 'package:test/test.dart';
import 'package:vector_math/vector_math.dart';
void main() {
initUnit();
PictureRecorder recorder = new PictureRecorder();
Canvas canvas = new Canvas(recorder, new Rect.fromLTRB(0.0, 0.0, 100.0, 100.0));
sky.PictureRecorder recorder = new sky.PictureRecorder();
sky.Canvas canvas = new sky.Canvas(recorder, new Rect.fromLTRB(0.0, 0.0, 100.0, 100.0));
test("matrix access should work", () {
// Matrix equality doesn't work!

View File

@ -0,0 +1,40 @@
import 'dart:sky';
import 'package:test/test.dart';
void main() {
test("color accessors should work", () {
Color foo = new Color(0x12345678);
expect(foo.alpha, equals(0x12));
expect(foo.red, equals(0x34));
expect(foo.green, equals(0x56));
expect(foo.blue, equals(0x78));
});
test("paint set to black", () {
Color c = new Color(0x00000000);
Paint p = new Paint();
p.color = c;
expect(c.toString(), equals('Color(0x00000000)'));
});
test("color created with out of bounds value", () {
try {
Color c = new Color(0x100 << 24);
Paint p = new Paint();
p.color = c;
} catch (e) {
expect(e != null, equals(true));
}
});
test("color created with wildly out of bounds value", () {
try {
Color c = new Color(1 << 1000000);
Paint p = new Paint();
p.color = c;
} catch (e) {
expect(e != null, equals(true));
}
});
}

View File

@ -1,12 +1,10 @@
import "../resources/dom_utils.dart";
import "../resources/third_party/unittest/unittest.dart";
import "../resources/unit.dart";
import 'dart:sky';
import "dart:sky";
import 'package:test/test.dart';
import 'dom_utils.dart';
void main() {
initUnit();
var doc;
setUp(() {

View File

@ -0,0 +1,15 @@
import 'dart:sky';
int childNodeCount(parent) {
int count = 0;
for (Node node = parent.firstChild; node != null; node = node.nextSibling)
++count;
return count;
}
int childElementCount(parent) {
int count = 0;
for (Element element = parent.firstElementChild; element != null; element = element.nextElementSibling)
++count;
return count;
}

View File

@ -1,11 +1,8 @@
import "../resources/third_party/unittest/unittest.dart";
import "../resources/unit.dart";
import 'dart:sky';
import "dart:sky";
import 'package:test/test.dart';
void main() {
initUnit();
test("getChildElements should only include immediate children", () {
var doc = new Document();
var parent = doc.createElement('parent');

View File

@ -1,14 +1,23 @@
import "../resources/third_party/unittest/unittest.dart";
import "../resources/unit.dart";
import 'dart:sky' as sky;
import "dart:sky";
import 'package:test/test.dart';
void main() {
initUnit();
test('should be settable using "style" attribute', () {
sky.LayoutRoot layoutRoot = new sky.LayoutRoot();
var document = new sky.Document();
var foo = document.createElement('foo');
layoutRoot.rootElement = foo;
foo.setAttribute('style', 'color: red');
expect(foo.getAttribute('style'), equals('color: red'));
expect(foo.style["color"], equals('rgb(255, 0, 0)'));
});
test('should not crash when setting style to null', () {
LayoutRoot layoutRoot = new LayoutRoot();
var document = new Document();
sky.LayoutRoot layoutRoot = new sky.LayoutRoot();
var document = new sky.Document();
var foo = document.createElement('foo');
layoutRoot.rootElement = foo;

View File

@ -1,12 +1,8 @@
import "../resources/dom_utils.dart";
import "../resources/third_party/unittest/unittest.dart";
import "../resources/unit.dart";
import 'dart:sky';
import "dart:sky";
import 'package:test/test.dart';
void main() {
initUnit();
Document document = new Document();
test("should throw with invalid arguments", () {

View File

@ -1,11 +1,8 @@
import "../resources/third_party/unittest/unittest.dart";
import "../resources/unit.dart";
import 'dart:sky';
import "dart:sky";
import 'package:test/test.dart';
void main() {
initUnit();
test("should return null for elements not a child of a scope", () {
var doc = new Document();
var element = doc.createElement("div");

View File

@ -1,12 +1,10 @@
import "../resources/dom_utils.dart";
import "../resources/third_party/unittest/unittest.dart";
import "../resources/unit.dart";
import 'dart:sky';
import "dart:sky";
import 'package:test/test.dart';
import 'dom_utils.dart';
void main() {
initUnit();
var document = new Document();
test("should replace elements", () {

View File

@ -0,0 +1,10 @@
import 'dart:sky' as sky;
import 'package:test/test.dart';
void main() {
test("createText(null) shouldn't crash", () {
var doc = new sky.Document();
doc.createText(null);
});
}