Bug 1208371 - Simplify track disabling test code. r=jib

MozReview-Commit-ID: 1xMIosdYTW4

--HG--
extra : rebase_source : 21593a6c08128e90e2983b08a6a6470af97121de
This commit is contained in:
Andreas Pehrson 2016-01-05 10:16:30 +08:00
Родитель f17fbe75df
Коммит 65dc16a300
1 изменённых файлов: 14 добавлений и 9 удалений

Просмотреть файл

@ -39,23 +39,28 @@ runNetworkTest(() => {
const offsetX = 50;
const offsetY = 50;
const threshold = 128;
// We're regarding black as disabled here, and we're setting the alpha
// channel of the pixel to 255 to disregard alpha when testing.
var checkVideoEnabled = video =>
h.waitForPixel(video, offsetX, offsetY,
px => (px[3] = 255, h.isPixelNot(px, h.black, threshold)));
var checkVideoDisabled = video =>
h.waitForPixel(video, offsetX, offsetY,
px => (px[3] = 255, h.isPixel(px, h.black, threshold, offsetX*2, offsetY*2)));
return Promise.resolve()
.then(() => info("Checking local video enabled"))
.then(() => h.waitForPixel(localVideo, offsetX, offsetY,
px => h.isPixelNot(px, h.black, 128)))
.then(() => checkVideoEnabled(localVideo))
.then(() => info("Checking remote video enabled"))
.then(() => h.waitForPixel(remoteVideo, offsetX, offsetY,
px => h.isPixelNot(px, h.black, 128)))
.then(() => checkVideoEnabled(remoteVideo))
.then(() => info("Disabling original"))
.then(() => test.pcLocal.streams[0].getVideoTracks()[0].enabled = false)
.then(() => info("Checking local video disabled"))
.then(() => h.waitForPixel(localVideo, offsetX, offsetY,
px => h.isPixel(px, h.blackTransparent,
128), offsetX*2, offsetY*2))
.then(() => checkVideoDisabled(localVideo))
.then(() => info("Checking remote video disabled"))
.then(() => h.waitForPixel(remoteVideo, offsetX, offsetY,
px => h.isPixel(px, h.black, 128), offsetX*2, offsetY*2))
.then(() => checkVideoDisabled(remoteVideo))
},
function CHECK_AUDIO() {
var ac = new AudioContext();