Skip to content
This repository was archived by the owner on Oct 25, 2024. It is now read-only.

Commit ebf2aef

Browse files
author
zhangyihui1
committed
add publish eachOther cases
1 parent 1e5a586 commit ebf2aef

File tree

2 files changed

+232
-24
lines changed

2 files changed

+232
-24
lines changed

test/p2ptest/js/test.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -265,17 +265,6 @@ TestClient.prototype = {
265265
document.body.appendChild(para);
266266
video.srcObject = stream.mediaStream
267267
},
268-
269-
removeVideo: function(stream) {
270-
var videos = document.getElementsByClassName("video");
271-
if (stream) {
272-
videos = [document.getElementById("stream" + stream.id)]
273-
};
274-
for (var i = 0; i < videos.length; i++) {
275-
document.body.removeChild(videos[i]);
276-
};
277-
},
278-
279268
};
280269

281270
TestClient.prototype.constructor = TestClient;

test/p2ptest/test-ci.js

Lines changed: 232 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ describe('P2P JS SDK', function () {
5858
console.log(type, msg);
5959
}
6060

61+
function removeVideo() {
62+
var videos = document.getElementsByClassName("video");
63+
for (var i = 0; i < videos.length; i++) {
64+
document.body.removeChild(videos[i]);
65+
};
66+
}
67+
6168
var videoDetection = function (streamId) {
6269
window.setTimeout(function () {
6370
var framechecker = new VideoFrameChecker(
@@ -93,7 +100,7 @@ describe('P2P JS SDK', function () {
93100

94101
afterEach(function () {
95102
actorUser.close();
96-
actorUser.removeVideo(actorUser.localStream);
103+
removeVideo()
97104
detection = '';
98105
});
99106

@@ -342,7 +349,6 @@ describe('P2P JS SDK', function () {
342349
})
343350
});
344351

345-
346352
it('conncetWithSymolName', function (done) {
347353
Q('conncetWithSymolName')
348354
.then(function () {
@@ -532,8 +538,6 @@ describe('P2P JS SDK', function () {
532538
actorUser1_datasender = e.origin;
533539
actorUser1_data = e.message;
534540
});
535-
})
536-
.then(function () {
537541
actorUser2 = new TestClient(userName2, serverIP);
538542
actorUser2.bindListener("serverdisconnected", function (e) {
539543
actorUser2.request["server-disconnected_success"]++;
@@ -560,10 +564,9 @@ describe('P2P JS SDK', function () {
560564
afterEach(function () {
561565
Q('afterEach')
562566
.then(function () {
567+
removeVideo()
563568
actorUser1.disconnect();
564569
actorUser1 = undefined
565-
})
566-
.then(function () {
567570
actorUser2.disconnect();
568571
actorUser2 = undefined
569572
})
@@ -650,8 +653,6 @@ describe('P2P JS SDK', function () {
650653
})
651654
.then(function () {
652655
actorUser1.close();
653-
actorUser1.removeVideo(actorUser1.localStream);
654-
actorUser2.removeVideo(User2RemoteStream)
655656
detection = '';
656657
})
657658
.then(function () {
@@ -748,8 +749,6 @@ describe('P2P JS SDK', function () {
748749
})
749750
.then(function () {
750751
actorUser1.close();
751-
actorUser1.removeVideo(actorUser1.localStream);
752-
actorUser2.removeVideo(User2RemoteStream)
753752
detection = '';
754753
})
755754
.then(function () {
@@ -823,8 +822,6 @@ describe('P2P JS SDK', function () {
823822
})
824823
.then(function () {
825824
actorUser1.close();
826-
actorUser1.removeVideo(actorUser1.localStream);
827-
actorUser2.removeVideo(User2RemoteStream)
828825
detection = '';
829826
})
830827
.then(function () {
@@ -999,6 +996,10 @@ describe('P2P JS SDK', function () {
999996
return actorUser2.request["streamended_success"] === 1;
1000997
}, userName2 + "check wait: streamended_success", waitInterval)
1001998
})
999+
.then(function () {
1000+
actorUser1.close();
1001+
detection = '';
1002+
})
10021003
.then(function () {
10031004
console.log('test end');
10041005
done();
@@ -1100,11 +1101,229 @@ describe('P2P JS SDK', function () {
11001101
return actorUser2.request["streamended_success"] === 1;
11011102
}, userName2 + "check wait: streamended_success", waitInterval)
11021103
})
1104+
.then(function () {
1105+
actorUser1.close();
1106+
detection = '';
1107+
})
11031108
.then(function () {
11041109
console.log('test end');
11051110
done();
11061111
})
11071112
});
11081113
});
1109-
});
11101114

1115+
describe('publish Test', function () {
1116+
var actorUser1 = undefined;
1117+
var actorUser2 = undefined;
1118+
var User1RemoteId = "";
1119+
var User1RemoteStream = undefined;
1120+
var User2RemoteId = "";
1121+
var User2RemoteStream = undefined;
1122+
var actorUser1_datasender = undefined;
1123+
var actorUser1_data = undefined;
1124+
var actorUser2_datasender = undefined;
1125+
var actorUser2_data = undefined;
1126+
1127+
afterEach(function () {
1128+
Q('afterEach')
1129+
.then(function () {
1130+
actorUser2.close();
1131+
actorUser1.close();
1132+
removeVideo()
1133+
detection = '';
1134+
actorUser1.disconnect();
1135+
actorUser2.disconnect();
1136+
actorUser1 = undefined
1137+
actorUser2 = undefined
1138+
})
1139+
});
1140+
1141+
var videoCodecList = ["vp8", "h264"];
1142+
for (i = 0; i < videoCodecList.length; i++) {
1143+
it('publishEachOther', function (done) {
1144+
Q('publishEachOther')
1145+
.then(function () {
1146+
// action
1147+
config ={
1148+
videoEncodings:[{
1149+
codec:{
1150+
name:videoCodecList[i]
1151+
},
1152+
maxBitrate:1000
1153+
}]
1154+
}
1155+
actorUser1 = new TestClient(userName1, serverIP, config);
1156+
actorUser1.bindListener("serverdisconnected", function (e) {
1157+
actorUser1.request["server-disconnected_success"]++;
1158+
});
1159+
actorUser1.bindListener('streamadded', function (e) {
1160+
console.log("trigger streamadded ")
1161+
actorUser1.request["streamadded_success"]++;
1162+
actorUser1.showInPage(e.stream);
1163+
e.stream.addEventListener('ended', () => {
1164+
console.log("stream is ended ")
1165+
actorUser1.request["streamended_success"]++;
1166+
})
1167+
User1RemoteId = e.stream.id;
1168+
User1RemoteStream = e.stream;
1169+
});
1170+
actorUser1.bindListener("messagereceived", function (e) {
1171+
actorUser1.request["data-received_success"]++;
1172+
actorUser1_datasender = e.origin;
1173+
actorUser1_data = e.message;
1174+
});
1175+
actorUser2 = new TestClient(userName2, serverIP, config);
1176+
actorUser2.bindListener("serverdisconnected", function (e) {
1177+
actorUser2.request["server-disconnected_success"]++;
1178+
});
1179+
actorUser2.bindListener('streamadded', function (e) {
1180+
console.log("trigger streamadded ")
1181+
actorUser2.request["streamadded_success"]++;
1182+
actorUser2.showInPage(e.stream);
1183+
e.stream.addEventListener('ended', () => {
1184+
console.log("stream is ended ")
1185+
actorUser2.request["streamended_success"]++;
1186+
})
1187+
User2RemoteId = e.stream.id;
1188+
User2RemoteStream = e.stream;
1189+
});
1190+
actorUser2.bindListener("messagereceived", function (e) {
1191+
actorUser2.request["data-received_success"]++;
1192+
actorUser2_datasender = e.origin;
1193+
actorUser2_data = e.message;
1194+
});
1195+
})
1196+
// 1. User1Connect
1197+
.then(function () {
1198+
// action
1199+
actorUser1.connect();
1200+
})
1201+
.then(function () {
1202+
// action
1203+
actorUser2.connect();
1204+
})
1205+
.then(function () {
1206+
return waitsFor(function () {
1207+
//check action
1208+
return actorUser1.request["connect_success"] === 1;
1209+
}, userName1 + " check action: login ", waitInterval)
1210+
})
1211+
.then(function () {
1212+
return waitsFor(function () {
1213+
//check action
1214+
return actorUser2.request["connect_success"] === 1;
1215+
}, userName2 + " check action: login ", waitInterval)
1216+
})
1217+
.then(function () {
1218+
// action
1219+
actorUser1.replaceAllowedRemoteIds(userName2);
1220+
})
1221+
.then(function () {
1222+
// action
1223+
actorUser2.replaceAllowedRemoteIds(userName1);
1224+
})
1225+
.then(function () {
1226+
// action
1227+
actorUser1.createLocalStream();
1228+
})
1229+
.then(function () {
1230+
return waitsFor(function () {
1231+
// check action
1232+
return actorUser1.request["createLocal_success"] === 1
1233+
}, userName1 + " check action: create localStream ", waitInterval)
1234+
})
1235+
.then(function () {
1236+
// action
1237+
detection = "";
1238+
videoDetection("stream" + actorUser1.request["localStreamId"]);
1239+
})
1240+
.then(function () {
1241+
return waitsFor(function () {
1242+
//wait lock
1243+
return detection === true;
1244+
}, userName1 + " create localstream is fail", waitInterval)
1245+
})
1246+
.then(function () {
1247+
//TODO change wrapper of publish
1248+
actorUser1.publish(userName2);
1249+
})
1250+
.then(function () {
1251+
return waitsFor(function () {
1252+
//check action
1253+
return actorUser1.request["publish_success"] === 1;
1254+
}, userName1 + "check action: publish", waitInterval)
1255+
})
1256+
.then(function () {
1257+
return waitsFor(function () {
1258+
//check wait
1259+
return actorUser2.request["streamadded_success"] === 1;
1260+
}, userName2 + "check wait: stream-added", waitInterval)
1261+
})
1262+
.then(function () {
1263+
// action
1264+
detection = "";
1265+
videoDetection("stream" + User2RemoteId);
1266+
})
1267+
.then(function () {
1268+
return waitsFor(function () {
1269+
//wait lock
1270+
return detection === true;
1271+
}, userName2 + " remote stream is good", waitInterval)
1272+
})
1273+
1274+
.then(function () {
1275+
// action
1276+
actorUser2.createLocalStream();
1277+
})
1278+
.then(function () {
1279+
return waitsFor(function () {
1280+
// check action
1281+
return actorUser2.request["createLocal_success"] === 1
1282+
}, userName2 + " check action: create localStream ", waitInterval)
1283+
})
1284+
.then(function () {
1285+
// action
1286+
detection = "";
1287+
videoDetection("stream" + actorUser2.request["localStreamId"]);
1288+
})
1289+
.then(function () {
1290+
return waitsFor(function () {
1291+
//wait lock
1292+
return detection === true;
1293+
}, userName2 + " create localstream is fail", waitInterval)
1294+
})
1295+
.then(function () {
1296+
//TODO change wrapper of publish
1297+
actorUser2.publish(userName1);
1298+
})
1299+
.then(function () {
1300+
return waitsFor(function () {
1301+
//check action
1302+
return actorUser2.request["publish_success"] === 1;
1303+
}, userName2 + "check action: publish", waitInterval)
1304+
})
1305+
.then(function () {
1306+
return waitsFor(function () {
1307+
//check wait
1308+
return actorUser1.request["streamadded_success"] === 1;
1309+
}, userName1 + "check wait: stream-added", waitInterval)
1310+
})
1311+
.then(function () {
1312+
// action
1313+
detection = "";
1314+
videoDetection("stream" + User2RemoteId);
1315+
})
1316+
.then(function () {
1317+
return waitsFor(function () {
1318+
//wait lock
1319+
return detection === true;
1320+
}, userName1 + " remote stream is good", waitInterval)
1321+
})
1322+
.then(function () {
1323+
console.log('test end');
1324+
done();
1325+
})
1326+
});
1327+
}
1328+
});
1329+
});

0 commit comments

Comments
 (0)