test-electron: wait to run tests until protos are ready
This commit is contained in:
parent
8e598688e7
commit
618c0fce1e
4 changed files with 54 additions and 28 deletions
|
@ -5,11 +5,40 @@
|
||||||
|
|
||||||
// eslint-disable-next-line func-names
|
// eslint-disable-next-line func-names
|
||||||
(function() {
|
(function() {
|
||||||
window.textsecure = window.textsecure || {};
|
const FILES_TO_LOAD = [
|
||||||
window.textsecure.protobuf = {};
|
'SignalService.proto',
|
||||||
|
'SignalStorage.proto',
|
||||||
|
'SubProtocol.proto',
|
||||||
|
'DeviceMessages.proto',
|
||||||
|
'Stickers.proto',
|
||||||
|
|
||||||
function loadProtoBufs(filename) {
|
// Just for encrypting device names
|
||||||
return dcodeIO.ProtoBuf.loadProtoFile(
|
'DeviceName.proto',
|
||||||
|
|
||||||
|
// Metadata-specific protos
|
||||||
|
'UnidentifiedDelivery.proto',
|
||||||
|
|
||||||
|
// Groups
|
||||||
|
'Groups.proto',
|
||||||
|
];
|
||||||
|
|
||||||
|
let remainingFilesToLoad = FILES_TO_LOAD.length;
|
||||||
|
const hasFinishedLoading = () => remainingFilesToLoad <= 0;
|
||||||
|
let onLoadCallbacks = [];
|
||||||
|
|
||||||
|
window.textsecure = window.textsecure || {};
|
||||||
|
window.textsecure.protobuf = {
|
||||||
|
onLoad: callback => {
|
||||||
|
if (hasFinishedLoading()) {
|
||||||
|
setTimeout(callback, 0);
|
||||||
|
} else {
|
||||||
|
onLoadCallbacks.push(callback);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
FILES_TO_LOAD.forEach(filename => {
|
||||||
|
dcodeIO.ProtoBuf.loadProtoFile(
|
||||||
{ root: window.PROTO_ROOT, file: filename },
|
{ root: window.PROTO_ROOT, file: filename },
|
||||||
(error, result) => {
|
(error, result) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
|
@ -29,22 +58,13 @@
|
||||||
for (const protoName in protos) {
|
for (const protoName in protos) {
|
||||||
textsecure.protobuf[protoName] = protos[protoName];
|
textsecure.protobuf[protoName] = protos[protoName];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
remainingFilesToLoad -= 1;
|
||||||
|
if (hasFinishedLoading()) {
|
||||||
|
onLoadCallbacks.forEach(callback => callback());
|
||||||
|
onLoadCallbacks = [];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
});
|
||||||
|
|
||||||
loadProtoBufs('SignalService.proto');
|
|
||||||
loadProtoBufs('SignalStorage.proto');
|
|
||||||
loadProtoBufs('SubProtocol.proto');
|
|
||||||
loadProtoBufs('DeviceMessages.proto');
|
|
||||||
loadProtoBufs('Stickers.proto');
|
|
||||||
|
|
||||||
// Just for encrypting device names
|
|
||||||
loadProtoBufs('DeviceName.proto');
|
|
||||||
|
|
||||||
// Metadata-specific protos
|
|
||||||
loadProtoBufs('UnidentifiedDelivery.proto');
|
|
||||||
|
|
||||||
// Groups
|
|
||||||
loadProtoBufs('Groups.proto');
|
|
||||||
})();
|
})();
|
||||||
|
|
|
@ -52,8 +52,10 @@
|
||||||
|
|
||||||
<!-- Uncomment to start tests without code coverage enabled -->
|
<!-- Uncomment to start tests without code coverage enabled -->
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
window.textsecure.protobuf.onLoad(() => {
|
||||||
mocha.run();
|
mocha.run();
|
||||||
window.Signal.conversationControllerStart();
|
window.Signal.conversationControllerStart();
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -397,6 +397,7 @@
|
||||||
|
|
||||||
<!-- Uncomment to start tests without code coverage enabled -->
|
<!-- Uncomment to start tests without code coverage enabled -->
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
window.textsecure.protobuf.onLoad(() => {
|
||||||
window.Signal.conversationControllerStart();
|
window.Signal.conversationControllerStart();
|
||||||
|
|
||||||
window.test.pendingDescribeCalls.forEach(args => {
|
window.test.pendingDescribeCalls.forEach(args => {
|
||||||
|
@ -404,6 +405,7 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
mocha.run();
|
mocha.run();
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
4
ts/textsecure.d.ts
vendored
4
ts/textsecure.d.ts
vendored
|
@ -212,7 +212,9 @@ type SubProtocolProtobufTypes = {
|
||||||
WebSocketResponseMessage: typeof WebSocketResponseMessageClass;
|
WebSocketResponseMessage: typeof WebSocketResponseMessageClass;
|
||||||
};
|
};
|
||||||
|
|
||||||
type ProtobufCollectionType = DeviceMessagesProtobufTypes &
|
type ProtobufCollectionType = {
|
||||||
|
onLoad: (callback: () => unknown) => void;
|
||||||
|
} & DeviceMessagesProtobufTypes &
|
||||||
DeviceNameProtobufTypes &
|
DeviceNameProtobufTypes &
|
||||||
GroupsProtobufTypes &
|
GroupsProtobufTypes &
|
||||||
SignalServiceProtobufTypes &
|
SignalServiceProtobufTypes &
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue