Bug 1339906 - pt 6 - add tests for RTCIceCandidatePairStats. r=drno draft
authorMichael Froman <mfroman@mozilla.com>
Tue, 13 Jun 2017 12:49:50 -0500
changeset 593516 596276a082d57f246aedd6fc0942e925754ef5df
parent 593515 36677deb573f561a7f1ae866f5899c50636f2e0f
child 633140 e94aeb4deec7c18492429c604ef1e7aa409be5f8
push id63727
push userbmo:mfroman@nostrum.com
push dateTue, 13 Jun 2017 20:45:01 +0000
reviewersdrno
bugs1339906
milestone56.0a1
Bug 1339906 - pt 6 - add tests for RTCIceCandidatePairStats. r=drno MozReview-Commit-ID: 5S296RRUvy0
dom/media/tests/mochitest/test_peerConnection_stats.html
--- a/dom/media/tests/mochitest/test_peerConnection_stats.html
+++ b/dom/media/tests/mochitest/test_peerConnection_stats.html
@@ -36,17 +36,30 @@ var statsExpectedByType = {
     deprecated: [],
   },
   "csrc": { skip: true },
   "codec": { skip: true },
   "peer-connection": { skip: true },
   "data-channel": { skip: true },
   "track": { skip: true },
   "transport": { skip: true },
-  "candidate-pair": { skip : true },
+  "candidate-pair": {
+    expected: ["id", "timestamp", "type",
+      "transportId", "localCandidateId", "remoteCandidateId", "state",
+      "priority", "nominated", "writable", "readable",
+      "bytesSent", "bytesReceived",
+      "lastPacketSentTimestamp", "lastPacketReceivedTimestamp",],
+    optional: ["selected",],
+    unimplemented: ["totalRoundTripTime", "currentRoundTripTime",
+      "availableOutgoingBitrate", "availableIncomingBitrate",
+      "requestsReceived", "requestsSent", "responsesReceived",
+      "responsesSent", "retransmissionsReceived", "retransmissionsSent",
+      "consentRequestsSent",],
+    deprecated: [],
+  },
   "local-candidate": { skip: true },
   "remote-candidate": { skip: true },
   "certificate": { skip: true },
 };
 ["in", "out"].forEach(pre => {
   let s = statsExpectedByType[pre + "bound-rtp"];
   s.optional = [...s.optional, ...s.localVideoOnly];
 });
@@ -355,16 +368,89 @@ var pedanticChecks = report => {
           stat.type + ".droppedFrames is not negative. value="
           + stat.droppedFrames);
 
         // framesEncoded
         ok(stat.framesEncoded >= 0 && stat.framesEncoded < 100000, stat.type
           + ".framesEncoded is a sane number for a short test. value="
           + stat.framesEncoded);
       }
+    } else if (stat.type == "candidate-pair") {
+      //
+      // Required fields
+      //
+
+      // transportId
+      ok(stat.transportId,
+        stat.type + ".transportId has a value. value="
+        + stat.transportId);
+
+      // localCandidateId
+      ok(stat.localCandidateId,
+        stat.type + ".localCandidateId has a value. value="
+        + stat.localCandidateId);
+
+      // remoteCandidateId
+      ok(stat.remoteCandidateId,
+        stat.type + ".remoteCandidateId has a value. value="
+        + stat.remoteCandidateId);
+
+      // state
+      ok(stat.state == "succeeded",
+        stat.type + ".state is succeeded. value="
+        + stat.state);
+
+      // priority
+      ok(stat.priority,
+        stat.type + ".priority has a value. value="
+        + stat.priority);
+
+      // nominated
+      ok(stat.nominated,
+        stat.type + ".nominated is true. value="
+        + stat.nominated);
+
+      // readable
+      ok(stat.readable,
+        stat.type + ".readable is true. value="
+        + stat.readable);
+
+      // writable
+      ok(stat.writable,
+        stat.type + ".writable is true. value="
+        + stat.writable);
+
+      // bytesSent
+      ok(stat.bytesSent > 20000 && stat.bytesSent < 800000,
+        stat.type + ".bytesSent is a sane number (20,000<>800,000)for a short test. value="
+        + stat.bytesSent);
+
+      // bytesReceived
+      ok(stat.bytesReceived > 20000 && stat.bytesReceived < 800000,
+        stat.type + ".bytesReceived is a sane number (20,000<>800,000) for a short test. value="
+        + stat.bytesReceived);
+
+      // lastPacketSentTimestamp
+      ok(stat.lastPacketSentTimestamp,
+        stat.type + ".lastPacketSentTimestamp has a value. value="
+        + stat.lastPacketSentTimestamp);
+
+      // lastPacketReceivedTimestamp
+      ok(stat.lastPacketReceivedTimestamp,
+        stat.type + ".lastPacketReceivedTimestamp has a value. value="
+        + stat.lastPacketReceivedTimestamp);
+
+      //
+      // Optional fields
+      //
+      // selected
+      ok(stat.selected === undefined || stat.selected == true,
+        stat.type + ".selected is undefined or true. value="
+        + stat.selected);
+
     }
 
     //
     // Ensure everything was tested
     //
     [...expectations.expected, ...expectations.optional].forEach(field => {
       ok(Object.keys(tested).includes(field), stat.type + "." + field
         + " was tested.");