Port remaining Sky tests to the new world
These tests now run in the DOM-less world. R=ianh@google.com Review URL: https://codereview.chromium.org/1212163009.
This commit is contained in:
parent
fbef1235e0
commit
280945c6b9
@ -1,2 +1,2 @@
|
||||
# This test depends on events.md being implemented
|
||||
crbug.com/1 events/dispatcher.sky [ Skip ]
|
||||
crbug.com/1 events/dispatcher.dart [ Skip ]
|
||||
|
@ -1,6 +1,4 @@
|
||||
<sky>
|
||||
<import src="../resources/dom-utils.sky" as="DomUtils" />
|
||||
<script>
|
||||
import "../resources/dom_utils.dart";
|
||||
import "../resources/third_party/unittest/unittest.dart";
|
||||
import "../resources/unit.dart";
|
||||
|
||||
@ -9,8 +7,7 @@ import "dart:sky";
|
||||
void main() {
|
||||
initUnit();
|
||||
|
||||
var childElementCount = DomUtils.childElementCount;
|
||||
var childNodeCount = DomUtils.childNodeCount;
|
||||
Document document = new Document();
|
||||
|
||||
test("should throw with invalid arguments", () {
|
||||
var parent = document.createElement("div");
|
||||
@ -28,8 +25,8 @@ void main() {
|
||||
test("should insert children", () {
|
||||
var parent = document.createElement("div");
|
||||
var child1 = parent.appendChild(document.createElement("div"));
|
||||
var child2 = parent.appendChild(new Text(" text "));
|
||||
var child3 = parent.appendChild(new Text(" "));
|
||||
var child2 = parent.appendChild(document.createText(" text "));
|
||||
var child3 = parent.appendChild(document.createText(" "));
|
||||
var child4 = parent.appendChild(document.createElement("div"));
|
||||
expect(child1.parentNode, equals(parent));
|
||||
expect(child2.parentNode, equals(parent));
|
||||
@ -42,8 +39,8 @@ void main() {
|
||||
test("should insert children with a fragment", () {
|
||||
var fragment = document.createDocumentFragment();
|
||||
var child1 = fragment.appendChild(document.createElement("div"));
|
||||
var child2 = fragment.appendChild(new Text(" text "));
|
||||
var child3 = fragment.appendChild(new Text(" "));
|
||||
var child2 = fragment.appendChild(document.createText(" text "));
|
||||
var child3 = fragment.appendChild(document.createText(" "));
|
||||
var child4 = fragment.appendChild(document.createElement("div"));
|
||||
var parent = document.createElement("div");
|
||||
parent.appendChild(fragment);
|
||||
@ -79,5 +76,3 @@ void main() {
|
||||
// }, throws);
|
||||
// });
|
||||
}
|
||||
</script>
|
||||
</sky>
|
@ -1,5 +1,3 @@
|
||||
<html>
|
||||
<script>
|
||||
import "../resources/third_party/unittest/unittest.dart";
|
||||
import "../resources/unit.dart";
|
||||
|
||||
@ -10,6 +8,7 @@ void main() {
|
||||
|
||||
var div;
|
||||
setUp(() {
|
||||
var document = new Document();
|
||||
div = document.createElement("div");
|
||||
});
|
||||
|
||||
@ -63,5 +62,3 @@ void main() {
|
||||
expect(oldAttributes[2].value, equals("2"));
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</html>
|
@ -1,6 +1,4 @@
|
||||
<sky>
|
||||
<import src="../resources/dom-utils.sky" as="DomUtils" />
|
||||
<script>
|
||||
import "../resources/dom_utils.dart";
|
||||
import "../resources/third_party/unittest/unittest.dart";
|
||||
import "../resources/unit.dart";
|
||||
|
||||
@ -11,9 +9,6 @@ void main() {
|
||||
|
||||
var doc;
|
||||
|
||||
var childElementCount = DomUtils.childElementCount;
|
||||
var childNodeCount = DomUtils.childNodeCount;
|
||||
|
||||
setUp(() {
|
||||
doc = new Document();
|
||||
});
|
||||
@ -29,7 +24,7 @@ void main() {
|
||||
});
|
||||
|
||||
test("should allow replacing a text child with an element", () {
|
||||
var oldChild = doc.appendChild(new Text("text here"));
|
||||
var oldChild = doc.appendChild(doc.createText("text here"));
|
||||
expect(childElementCount(doc), equals(0));
|
||||
expect(childNodeCount(doc), equals(1));
|
||||
var newChild = doc.createElement("div");
|
||||
@ -43,7 +38,7 @@ void main() {
|
||||
test("should allow replacing the document element with text", () {
|
||||
var oldChild = doc.appendChild(doc.createElement("div"));
|
||||
expect(childElementCount(doc), equals(1));
|
||||
var newChild = new Text(" text ");
|
||||
var newChild = doc.createText(" text ");
|
||||
oldChild.replaceWith([newChild]);
|
||||
expect(childElementCount(doc), equals(0));
|
||||
expect(childNodeCount(doc), equals(1));
|
||||
@ -53,8 +48,8 @@ void main() {
|
||||
|
||||
test("should allow inserting text with a fragment", () {
|
||||
var fragment = doc.createDocumentFragment();
|
||||
fragment.appendChild(new Text(" text "));
|
||||
fragment.appendChild(new Text(" text "));
|
||||
fragment.appendChild(doc.createText(" text "));
|
||||
fragment.appendChild(doc.createText(" text "));
|
||||
expect(childNodeCount(doc), equals(0));
|
||||
doc.appendChild(fragment);
|
||||
expect(childElementCount(doc), equals(0));
|
||||
@ -65,9 +60,9 @@ void main() {
|
||||
var oldChild = doc.appendChild(doc.createElement("div"));
|
||||
expect(childElementCount(doc), equals(1));
|
||||
var fragment = doc.createDocumentFragment();
|
||||
fragment.appendChild(new Text(" text "));
|
||||
fragment.appendChild(doc.createText(" text "));
|
||||
var newChild = fragment.appendChild(doc.createElement("div"));
|
||||
fragment.appendChild(new Text(" "));
|
||||
fragment.appendChild(doc.createText(" "));
|
||||
oldChild.replaceWith([fragment]);
|
||||
expect(childElementCount(doc), equals(1));
|
||||
expect(childNodeCount(doc), equals(3));
|
||||
@ -77,7 +72,7 @@ void main() {
|
||||
|
||||
test("should throw when inserting multiple elements", () {
|
||||
doc.appendChild(doc.createElement("div"));
|
||||
var oldChild = doc.appendChild(new Text(" text "));
|
||||
var oldChild = doc.appendChild(doc.createText(" text "));
|
||||
expect(childElementCount(doc), equals(1));
|
||||
var newChild = doc.createElement("div");
|
||||
// expect(() {
|
||||
@ -92,10 +87,10 @@ void main() {
|
||||
var oldChild = doc.appendChild(doc.createElement("div"));
|
||||
expect(childElementCount(doc), equals(1));
|
||||
var fragment = doc.createDocumentFragment();
|
||||
fragment.appendChild(new Text(" text "));
|
||||
fragment.appendChild(doc.createText(" text "));
|
||||
fragment.appendChild(doc.createElement("div"));
|
||||
fragment.appendChild(doc.createElement("div"));
|
||||
fragment.appendChild(new Text(" "));
|
||||
fragment.appendChild(doc.createText(" "));
|
||||
// expect(() {
|
||||
// doc.replaceChild(fragment, 0);
|
||||
// }, throws);
|
||||
@ -104,5 +99,3 @@ void main() {
|
||||
// }, throws);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</sky>
|
26
engine/src/flutter/tests/dom/getChildElements.dart
Normal file
26
engine/src/flutter/tests/dom/getChildElements.dart
Normal file
@ -0,0 +1,26 @@
|
||||
import "../resources/third_party/unittest/unittest.dart";
|
||||
import "../resources/unit.dart";
|
||||
|
||||
import "dart:sky";
|
||||
|
||||
void main() {
|
||||
initUnit();
|
||||
|
||||
test("getChildElements should only include immediate children", () {
|
||||
var doc = new Document();
|
||||
var parent = doc.createElement('parent');
|
||||
var child1 = doc.createElement('child1');
|
||||
var child2 = doc.createElement('child1');
|
||||
var grandchild = doc.createElement('grandchild');
|
||||
|
||||
doc.appendChild(parent);
|
||||
parent.appendChild(child1);
|
||||
parent.appendChild(child2);
|
||||
child1.appendChild(grandchild);
|
||||
|
||||
var children = parent.getChildElements();
|
||||
expect(children.length, equals(2));
|
||||
expect(children[0], equals(child1));
|
||||
expect(children[1], equals(child2));
|
||||
});
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
<parent>
|
||||
<child1>
|
||||
<grandchild />
|
||||
</child1>
|
||||
<child2 />
|
||||
</parent>
|
||||
|
||||
<script>
|
||||
import "../resources/third_party/unittest/unittest.dart";
|
||||
import "../resources/unit.dart";
|
||||
|
||||
import "dart:sky";
|
||||
|
||||
void main() {
|
||||
initUnit();
|
||||
|
||||
test("getChildElements should only include immediate children", () {
|
||||
var parent = document.querySelector('parent');
|
||||
var children = parent.getChildElements();
|
||||
expect(children.length, equals(2));
|
||||
expect(children[0], equals(document.querySelector('child1')));
|
||||
expect(children[1], equals(document.querySelector('child2')));
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</sky>
|
@ -1,6 +0,0 @@
|
||||
CONSOLE: unittest-suite-wait-for-done
|
||||
CONSOLE: PASS: should be able to insert in DOM
|
||||
CONSOLE:
|
||||
CONSOLE: All 1 tests passed.
|
||||
CONSOLE: unittest-suite-success
|
||||
DONE
|
@ -1,31 +0,0 @@
|
||||
<sky>
|
||||
<script>
|
||||
import "../resources/third_party/unittest/unittest.dart";
|
||||
import "../resources/unit.dart";
|
||||
|
||||
import "dart:sky";
|
||||
|
||||
class CustomText extends Text {
|
||||
CustomText() : super("awesome");
|
||||
|
||||
bool get isCustom => true;
|
||||
}
|
||||
|
||||
void main() {
|
||||
initUnit();
|
||||
|
||||
test("should be able to insert in DOM", () {
|
||||
var child = new CustomText();
|
||||
expect(child.isCustom, isTrue);
|
||||
expect(child.parentNode, isNull);
|
||||
expect(child.data, equals("awesome"));
|
||||
|
||||
var parent = document.createElement("div");
|
||||
parent.appendChild(child);
|
||||
expect(child.parentNode, equals(parent));
|
||||
expect(parent.firstChild, equals(child));
|
||||
expect(parent.firstChild.isCustom, isTrue);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</sky>
|
@ -1,5 +1,3 @@
|
||||
<sky>
|
||||
<script>
|
||||
import "../resources/third_party/unittest/unittest.dart";
|
||||
import "../resources/unit.dart";
|
||||
|
||||
@ -47,5 +45,3 @@ void main() {
|
||||
expect(child.owner, isNull);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</sky>
|
@ -1,6 +1,4 @@
|
||||
<sky>
|
||||
<import src="../resources/dom-utils.sky" as="DomUtils" />
|
||||
<script>
|
||||
import "../resources/dom_utils.dart";
|
||||
import "../resources/third_party/unittest/unittest.dart";
|
||||
import "../resources/unit.dart";
|
||||
|
||||
@ -9,8 +7,7 @@ import "dart:sky";
|
||||
void main() {
|
||||
initUnit();
|
||||
|
||||
var childElementCount = DomUtils.childElementCount;
|
||||
var childNodeCount = DomUtils.childNodeCount;
|
||||
var document = new Document();
|
||||
|
||||
test("should replace elements", () {
|
||||
var parent = document.createElement("div");
|
||||
@ -23,7 +20,7 @@ void main() {
|
||||
|
||||
test("should replace text", () {
|
||||
var parent = document.createElement("div");
|
||||
var oldChild = parent.appendChild(new Text(" it's a text "));
|
||||
var oldChild = parent.appendChild(document.createText(" it's a text "));
|
||||
var newChild = document.createElement("div");
|
||||
oldChild.replaceWith([newChild]);
|
||||
expect(oldChild.parentNode, isNull);
|
||||
@ -33,8 +30,8 @@ void main() {
|
||||
test("should replace children with a fragment", () {
|
||||
var fragment = document.createDocumentFragment();
|
||||
var child1 = fragment.appendChild(document.createElement("div"));
|
||||
var child2 = fragment.appendChild(new Text(" text "));
|
||||
var child3 = fragment.appendChild(new Text(" "));
|
||||
var child2 = fragment.appendChild(document.createText(" text "));
|
||||
var child3 = fragment.appendChild(document.createText(" "));
|
||||
var child4 = fragment.appendChild(document.createElement("div"));
|
||||
var parent = document.createElement("div");
|
||||
var oldChild = parent.appendChild(document.createElement("div"));
|
||||
@ -72,5 +69,3 @@ void main() {
|
||||
// }, throws);
|
||||
// });
|
||||
}
|
||||
</script>
|
||||
</sky>
|
@ -1,4 +1,3 @@
|
||||
<script>
|
||||
import "../resources/third_party/unittest/unittest.dart";
|
||||
import "../resources/unit.dart";
|
||||
import "dart:sky";
|
||||
@ -100,4 +99,3 @@ void main() {
|
||||
|
||||
});
|
||||
}
|
||||
</script>
|
@ -1,6 +0,0 @@
|
||||
CONSOLE: unittest-suite-wait-for-done
|
||||
CONSOLE: PASS: should have a constructor
|
||||
CONSOLE:
|
||||
CONSOLE: All 1 tests passed.
|
||||
CONSOLE: unittest-suite-success
|
||||
DONE
|
@ -1,20 +0,0 @@
|
||||
<html>
|
||||
<script>
|
||||
import "../resources/third_party/unittest/unittest.dart";
|
||||
import "../resources/unit.dart";
|
||||
|
||||
import "dart:sky";
|
||||
|
||||
main() {
|
||||
initUnit();
|
||||
|
||||
test('should have a constructor', () {
|
||||
var doc = new Document();
|
||||
expect(doc, isNotNull);
|
||||
// assert.doesNotThrow(function() {
|
||||
// doc.registerElement('x-foo');
|
||||
// }, 'new document should have a registration context');
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</html>
|
@ -1,7 +1,5 @@
|
||||
<script>
|
||||
import "dart:sky.internals" as internals;
|
||||
|
||||
void main() {
|
||||
internals.notifyTestComplete("PASS");
|
||||
}
|
||||
</script>>
|
@ -1,4 +1,3 @@
|
||||
<script>
|
||||
import "../resources/third_party/unittest/unittest.dart";
|
||||
import "../resources/unit.dart";
|
||||
|
||||
@ -10,4 +9,3 @@ void main() {
|
||||
expect(x, equals(5));
|
||||
});
|
||||
}
|
||||
</script>>
|
@ -1,6 +1,3 @@
|
||||
#!mojo mojo:sky_viewer
|
||||
<sky>
|
||||
<script>
|
||||
import 'dart:async';
|
||||
import 'dart:typed_data';
|
||||
import "dart:sky.internals" as internals;
|
||||
@ -45,5 +42,3 @@ main() async {
|
||||
var result = await run(url);
|
||||
internals.notifyTestComplete(result);
|
||||
}
|
||||
</script>
|
||||
</sky>
|
@ -1,6 +1,3 @@
|
||||
<html>
|
||||
<foo />
|
||||
<script>
|
||||
import "../resources/third_party/unittest/unittest.dart";
|
||||
import "../resources/unit.dart";
|
||||
|
||||
@ -10,14 +7,14 @@ void main() {
|
||||
initUnit();
|
||||
|
||||
test('should be settable using "style" attribute', () {
|
||||
var foo = document.querySelector('foo');
|
||||
foo.setAttribute('style', 'color: red');
|
||||
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)'));
|
||||
expect(window.getComputedStyle(foo)["color"], equals('rgb(255, 0, 0)'));
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</html>
|
@ -1,6 +1,3 @@
|
||||
<html>
|
||||
<foo />
|
||||
<script>
|
||||
import "../resources/third_party/unittest/unittest.dart";
|
||||
import "../resources/unit.dart";
|
||||
|
||||
@ -10,7 +7,11 @@ void main() {
|
||||
initUnit();
|
||||
|
||||
test('should not crash when setting style to null', () {
|
||||
var foo = document.querySelector('foo');
|
||||
LayoutRoot layoutRoot = new LayoutRoot();
|
||||
var document = new Document();
|
||||
var foo = document.createElement('foo');
|
||||
layoutRoot.rootElement = foo;
|
||||
|
||||
expect(foo.style['color'], isNull);
|
||||
foo.style["color"] = null; // This used to crash.
|
||||
expect(foo.style['color'], isNull);
|
||||
@ -22,7 +23,7 @@ void main() {
|
||||
expect(foo.style['color'], equals("rgb(0, 0, 255)"));
|
||||
foo.style.removeProperty("color");
|
||||
expect(foo.style['color'], isNull);
|
||||
|
||||
layoutRoot.layout();
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</html>
|
Loading…
x
Reference in New Issue
Block a user