xmpp: Communicate stream closure from the buffer
This commit is contained in:
@@ -54,4 +54,37 @@ void main() {
|
||||
expect(childb, true);
|
||||
});
|
||||
});
|
||||
|
||||
test("Test closing the stream", () async {
|
||||
bool childa = false;
|
||||
bool childb = false;
|
||||
bool closed = false;
|
||||
|
||||
final buffer = XmlStreamBuffer();
|
||||
final controller = StreamController<String>();
|
||||
|
||||
controller
|
||||
.stream
|
||||
.transform(buffer)
|
||||
.forEach((node) {
|
||||
if (node.tag == "childa") {
|
||||
childa = true;
|
||||
} else if (node.tag == "childb") {
|
||||
childb = true;
|
||||
} else if (node.tag == "stream:stream" && node.children.isEmpty) {
|
||||
assert (childa);
|
||||
assert (childb);
|
||||
closed = true;
|
||||
}
|
||||
});
|
||||
controller.add("<childa");
|
||||
controller.add(" /><childb />");
|
||||
controller.add("</stream:stream>");
|
||||
|
||||
await Future.delayed(const Duration(seconds: 2), () {
|
||||
expect(childa, true);
|
||||
expect(childb, true);
|
||||
expect(closed, true);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user