Implement blank file tests + fix shim

This commit is contained in:
hensm
2019-01-12 10:12:10 +00:00
parent 839ea81838
commit 45319fe771
8 changed files with 141 additions and 30 deletions

View File

@@ -32,7 +32,7 @@ export default class Session {
this._stopCallbacks = new Map();
this.sessionId = sessionId;
this.transportId = sessionId;
this.transportId = sessionId || "";
this.appId = appId;
this.appImages = appImages;
this.displayName = displayName;
@@ -41,16 +41,17 @@ export default class Session {
this.media = [];
this.namespaces = [];
this.senderApps = [];
this.status = SessionStatus.DISCONNECTED;
this.status = SessionStatus.CONNECTED;
this.statusText = null;
this._sendMessage("bridge:bridgesession/initialize", {
address: receiver._address
, port: receiver._port
, appId
, sessionId
});
if (receiver) {
this._sendMessage("bridge:bridgesession/initialize", {
address: receiver._address
, port: receiver._port
, appId
, sessionId
});
}
onMessage(message => {
// Filter other session messages

View File

@@ -1,20 +1,21 @@
"use strict";
import { Capability } from "../enums";
import { requestSession as requestSessionTimeout } from "../../timeout.js";
// https://developers.google.com/cast/docs/reference/chrome/chrome.cast.SessionRequest
export default class SessionRequest {
constructor (
appId
, opt_capabilities = [
Capability.VIDEO_OUT
, Capability.AUDIO_OUT ]
, opt_timeout = null) {
this.appId = appId;
this.capabilities = opt_capabilities;
this.language = null;
this.requestSessionTimeout = requestSessionTimeout;
}
};
"use strict";
import { Capability } from "../enums";
import { requestSession as requestSessionTimeout } from "../../timeout.js";
// https://developers.google.com/cast/docs/reference/chrome/chrome.cast.SessionRequest
export default class SessionRequest {
constructor (
appId
, opt_capabilities = [
Capability.VIDEO_OUT
, Capability.AUDIO_OUT ]
, opt_timeout = requestSessionTimeout) {
this.appId = appId;
this.capabilities = opt_capabilities;
this.dialRequest = null;
this.language = null;
this.requestSessionTimeout = opt_timeout;
}
};

View File

@@ -1,6 +1,6 @@
"use strict";
describe("chrome.cast.Receiver", () => {
describe("chrome.cast.ReceiverDisplayStatus", () => {
it("should have all properties", async () => {
const receiverDisplayStatus =
new chrome.cast.ReceiverDisplayStatus();

View File

@@ -0,0 +1,18 @@
"use strict";
describe("chrome.cast.SenderApplication", () => {
it("should have all properties", async () => {
const senderApplication = new chrome.cast.SenderApplication();
expect(senderApplication.platform).toBe(undefined);
expect(senderApplication.url).toBe(null);
expect(senderApplication.packageId).toBe(null);
});
it("should have expected assigned properties", async () => {
const senderApplication = new chrome.cast.SenderApplication(
chrome.cast.SenderPlatform.CHROME);
expect(senderApplication.platform).toBe("chrome");
});
});

View File

@@ -0,0 +1,36 @@
"use strict";
describe("chrome.cast.Session", () => {
it("should have all properties", async () => {
const session = new chrome.cast.Session();
expect(session.appId).toBe(undefined);
expect(session.appImages).toBe(undefined);
expect(session.displayName).toBe(undefined);
expect(session.media).toEqual([]);
expect(session.namespaces).toEqual([]);
expect(session.receiver).toBe(undefined);
expect(session.senderApps).toEqual([]);
expect(session.sessionId).toBe(undefined);
expect(session.status).toBe("connected");
expect(session.statusText).toBe(null);
expect(session.transportId).toBe("");
});
it("should have expected assigned properties", async () => {
const session = new chrome.cast.Session(
"__sessionId"
, "__appId"
, "__displayName"
, [ new chrome.cast.Image("http://example.com") ]
, new chrome.cast.Receiver("__label", "__friendlyName"));
expect(session.appId).toBe("__appId");
expect(session.appImages).toEqual(jasmine.arrayContaining([
jasmine.objectContaining({ url: "http://example.com" })
]));
expect(session.displayName).toBe("__displayName");
expect(session.receiver).toEqual(jasmine.any(chrome.cast.Receiver));
expect(session.sessionId).toBe("__sessionId");
});
});

View File

@@ -0,0 +1,25 @@
"use strict";
describe("chrome.cast.SessionRequest", () => {
it("should have all properties", async () => {
const sessionRequest = new chrome.cast.SessionRequest();
expect(sessionRequest.appId).toBe(undefined);
expect(sessionRequest.capabilities).toEqual([ "video_out", "audio_out" ]);
expect(sessionRequest.dialRequest).toBe(null);
expect(sessionRequest.language).toBe(null);
expect(sessionRequest.requestSessionTimeout).toBe(60000);
});
it("should have expected assigned properties", async () => {
const sessionRequest = new chrome.cast.SessionRequest(
"__appId"
, [ chrome.cast.Capability.VIDEO_OUT
, chrome.cast.Capability.AUDIO_IN ]
, 5000);
expect(sessionRequest.appId).toBe("__appId");
expect(sessionRequest.capabilities).toEqual([ "video_out", "audio_in" ]);
expect(sessionRequest.requestSessionTimeout).toBe(5000);
});
});

View File

@@ -0,0 +1,13 @@
"use strict";
describe("chrome.cast.Timeout", () => {
it("should have all properties", async () => {
const timeout = new chrome.cast.Timeout();
expect(timeout.leaveSession).toBe(3000);
expect(timeout.requestSession).toBe(60000);
expect(timeout.sendCustomMessage).toBe(3000);
expect(timeout.setReceiverVolume).toBe(3000);
expect(timeout.stopSession).toBe(3000);
});
});

View File

@@ -0,0 +1,17 @@
"use strict";
describe("chrome.cast.Volume", () => {
it("should have all properties", async () => {
const volume = new chrome.cast.Volume();
expect(volume.level).toBe(null);
expect(volume.muted).toBe(null);
});
it("should have expected assigned properties", async () => {
const volume = new chrome.cast.Volume(0.5, false);
expect(volume.level).toBe(0.5);
expect(volume.muted).toBe(false);
});
});