mirror of
https://github.com/hensm/fx_cast.git
synced 2026-06-08 08:39:59 +00:00
Implement blank file tests + fix shim
This commit is contained in:
@@ -32,7 +32,7 @@ export default class Session {
|
|||||||
this._stopCallbacks = new Map();
|
this._stopCallbacks = new Map();
|
||||||
|
|
||||||
this.sessionId = sessionId;
|
this.sessionId = sessionId;
|
||||||
this.transportId = sessionId;
|
this.transportId = sessionId || "";
|
||||||
this.appId = appId;
|
this.appId = appId;
|
||||||
this.appImages = appImages;
|
this.appImages = appImages;
|
||||||
this.displayName = displayName;
|
this.displayName = displayName;
|
||||||
@@ -41,16 +41,17 @@ export default class Session {
|
|||||||
this.media = [];
|
this.media = [];
|
||||||
this.namespaces = [];
|
this.namespaces = [];
|
||||||
this.senderApps = [];
|
this.senderApps = [];
|
||||||
this.status = SessionStatus.DISCONNECTED;
|
this.status = SessionStatus.CONNECTED;
|
||||||
this.statusText = null;
|
this.statusText = null;
|
||||||
|
|
||||||
this._sendMessage("bridge:bridgesession/initialize", {
|
if (receiver) {
|
||||||
address: receiver._address
|
this._sendMessage("bridge:bridgesession/initialize", {
|
||||||
, port: receiver._port
|
address: receiver._address
|
||||||
, appId
|
, port: receiver._port
|
||||||
, sessionId
|
, appId
|
||||||
});
|
, sessionId
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
onMessage(message => {
|
onMessage(message => {
|
||||||
// Filter other session messages
|
// Filter other session messages
|
||||||
|
|||||||
@@ -1,20 +1,21 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
import { Capability } from "../enums";
|
import { Capability } from "../enums";
|
||||||
import { requestSession as requestSessionTimeout } from "../../timeout.js";
|
import { requestSession as requestSessionTimeout } from "../../timeout.js";
|
||||||
|
|
||||||
// https://developers.google.com/cast/docs/reference/chrome/chrome.cast.SessionRequest
|
// https://developers.google.com/cast/docs/reference/chrome/chrome.cast.SessionRequest
|
||||||
export default class SessionRequest {
|
export default class SessionRequest {
|
||||||
constructor (
|
constructor (
|
||||||
appId
|
appId
|
||||||
, opt_capabilities = [
|
, opt_capabilities = [
|
||||||
Capability.VIDEO_OUT
|
Capability.VIDEO_OUT
|
||||||
, Capability.AUDIO_OUT ]
|
, Capability.AUDIO_OUT ]
|
||||||
, opt_timeout = null) {
|
, opt_timeout = requestSessionTimeout) {
|
||||||
|
|
||||||
this.appId = appId;
|
this.appId = appId;
|
||||||
this.capabilities = opt_capabilities;
|
this.capabilities = opt_capabilities;
|
||||||
this.language = null;
|
this.dialRequest = null;
|
||||||
this.requestSessionTimeout = requestSessionTimeout;
|
this.language = null;
|
||||||
}
|
this.requestSessionTimeout = opt_timeout;
|
||||||
};
|
}
|
||||||
|
};
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
describe("chrome.cast.Receiver", () => {
|
describe("chrome.cast.ReceiverDisplayStatus", () => {
|
||||||
it("should have all properties", async () => {
|
it("should have all properties", async () => {
|
||||||
const receiverDisplayStatus =
|
const receiverDisplayStatus =
|
||||||
new chrome.cast.ReceiverDisplayStatus();
|
new chrome.cast.ReceiverDisplayStatus();
|
||||||
|
|||||||
@@ -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");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
@@ -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");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
@@ -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);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
@@ -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);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
@@ -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);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user