mirror of
https://github.com/hensm/fx_cast.git
synced 2026-06-08 08:39:59 +00:00
chrome.cast class tests
This commit is contained in:
@@ -37,8 +37,8 @@ async function create () {
|
||||
return driver;
|
||||
}
|
||||
|
||||
async function destroy () {
|
||||
await this.driver.quit();
|
||||
function destroy (driver = this.driver) {
|
||||
driver.quit();
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
72
test/spec/shim/cast/ApiConfig.spec.js
Normal file
72
test/spec/shim/cast/ApiConfig.spec.js
Normal file
@@ -0,0 +1,72 @@
|
||||
"use strict";
|
||||
|
||||
const { create } = require("../../../driver");
|
||||
|
||||
describe("chrome.cast.ApiConfig", () => {
|
||||
let driver;
|
||||
|
||||
beforeAll(async () => {
|
||||
driver = await create();
|
||||
});
|
||||
afterAll(() => {
|
||||
driver.quit();
|
||||
})
|
||||
|
||||
|
||||
it("should have all properties", async () => {
|
||||
const [ typeof_receiverListener
|
||||
, typeof_sessionListener
|
||||
, typeof_sessionRequest
|
||||
, apiConfig ] = await driver.executeScript(() => {
|
||||
|
||||
const apiConfig = new chrome.cast.ApiConfig();
|
||||
|
||||
return [
|
||||
typeof apiConfig.receiverListener
|
||||
, typeof apiConfig.sessionListener
|
||||
, typeof apiConfig.sessionRequest
|
||||
, apiConfig
|
||||
];
|
||||
});
|
||||
|
||||
expect(apiConfig.additionalSessionRequests).toEqual([]);
|
||||
expect(apiConfig.autoJoinPolicy).toBe("tab_and_origin_scoped");
|
||||
expect(apiConfig.customDialLaunchCallback).toBe(null);
|
||||
expect(apiConfig.defaultActionPolicy).toBe("create_session");
|
||||
expect(apiConfig.invisibleSender).toBe(false);
|
||||
expect(typeof_receiverListener).toBe("undefined");
|
||||
expect(typeof_sessionListener).toBe("undefined");
|
||||
expect(typeof_sessionRequest).toBe("undefined");
|
||||
});
|
||||
|
||||
it("should have expected assigned properties", async () => {
|
||||
const [ typeof_sessionListener
|
||||
, typeof_receiverListener
|
||||
, apiConfig ] = await driver.executeScript(() => {
|
||||
|
||||
const sessionRequest = new chrome.cast.SessionRequest(
|
||||
chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID);
|
||||
|
||||
function sessionListener () {}
|
||||
function receiverListener () {}
|
||||
|
||||
const apiConfig = new chrome.cast.ApiConfig(
|
||||
sessionRequest
|
||||
, sessionListener
|
||||
, receiverListener
|
||||
, chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED
|
||||
, chrome.cast.DefaultActionPolicy.CAST_THIS_TAB);
|
||||
|
||||
return [
|
||||
typeof sessionListener
|
||||
, typeof receiverListener
|
||||
, apiConfig
|
||||
];
|
||||
});
|
||||
|
||||
expect(typeof_sessionListener).toBe("function");
|
||||
expect(typeof_receiverListener).toBe("function");
|
||||
expect(apiConfig.autoJoinPolicy).toBe("origin_scoped");
|
||||
expect(apiConfig.defaultActionPolicy).toBe("cast_this_tab");
|
||||
});
|
||||
});
|
||||
42
test/spec/shim/cast/DialRequest.spec.js
Normal file
42
test/spec/shim/cast/DialRequest.spec.js
Normal file
@@ -0,0 +1,42 @@
|
||||
"use strict";
|
||||
|
||||
const { create } = require("../../../driver");
|
||||
|
||||
describe("chrome.cast.DialRequest", () => {
|
||||
let driver;
|
||||
|
||||
beforeAll(async () => {
|
||||
driver = await create();
|
||||
});
|
||||
afterAll(() => {
|
||||
driver.quit();
|
||||
})
|
||||
|
||||
|
||||
it("should have all properties", async () => {
|
||||
const [ typeof_appName
|
||||
, dialRequest ] = await driver.executeScript(() => {
|
||||
|
||||
const dialRequest = new chrome.cast.DialRequest();
|
||||
|
||||
return [
|
||||
typeof dialRequest.appName
|
||||
, dialRequest
|
||||
];
|
||||
});
|
||||
|
||||
expect(typeof_appName).toBe("undefined");
|
||||
expect(dialRequest.launchParameter).toBe(null);
|
||||
});
|
||||
|
||||
it("should have expected assigned properties", async () => {
|
||||
const dialRequest = await driver.executeScript(() => {
|
||||
return new chrome.cast.DialRequest(
|
||||
"testAppName"
|
||||
, "testLaunchParameter");
|
||||
});
|
||||
|
||||
expect(dialRequest.appName).toBe("testAppName");
|
||||
expect(dialRequest.launchParameter).toBe("testLaunchParameter");
|
||||
});
|
||||
});
|
||||
46
test/spec/shim/cast/Error.spec.js
Normal file
46
test/spec/shim/cast/Error.spec.js
Normal file
@@ -0,0 +1,46 @@
|
||||
"use strict";
|
||||
|
||||
const { create } = require("../../../driver");
|
||||
|
||||
describe("chrome.cast.Error", () => {
|
||||
let driver;
|
||||
|
||||
beforeAll(async () => {
|
||||
driver = await create();
|
||||
});
|
||||
afterAll(() => {
|
||||
driver.quit();
|
||||
})
|
||||
|
||||
|
||||
it("should have all properties", async () => {
|
||||
const [ typeof_code
|
||||
, error ] = await driver.executeScript(() => {
|
||||
|
||||
const error = new chrome.cast.Error();
|
||||
|
||||
return [
|
||||
typeof error.code
|
||||
, error
|
||||
];
|
||||
});
|
||||
|
||||
expect(typeof_code).toBe("undefined");
|
||||
expect(error.description).toBe(null);
|
||||
expect(error.details).toBe(null);
|
||||
});
|
||||
|
||||
it("should have expected assigned properties", async () => {
|
||||
const error = await driver.executeScript(() => {
|
||||
return new chrome.cast.Error(
|
||||
chrome.cast.ErrorCode.CANCEL
|
||||
, "testErrorDescription"
|
||||
, { testErrorDetails: "testErrorDetails" });
|
||||
});
|
||||
|
||||
expect(error.code).toBe("cancel");
|
||||
expect(error.description).toBe("testErrorDescription");
|
||||
expect(error.details).toEqual(
|
||||
{ testErrorDetails: "testErrorDetails" });
|
||||
});
|
||||
});
|
||||
40
test/spec/shim/cast/Image.spec.js
Normal file
40
test/spec/shim/cast/Image.spec.js
Normal file
@@ -0,0 +1,40 @@
|
||||
"use strict";
|
||||
|
||||
const { create } = require("../../../driver");
|
||||
|
||||
describe("chrome.cast.Image", () => {
|
||||
let driver;
|
||||
|
||||
beforeAll(async () => {
|
||||
driver = await create();
|
||||
});
|
||||
afterAll(() => {
|
||||
driver.quit();
|
||||
})
|
||||
|
||||
|
||||
it("should have all properties", async () => {
|
||||
const [ typeof_url
|
||||
, image ] = await driver.executeScript(() => {
|
||||
|
||||
const image = new chrome.cast.Image();
|
||||
|
||||
return [
|
||||
typeof image.url
|
||||
, image
|
||||
];
|
||||
});
|
||||
|
||||
expect(typeof_url).toBe("undefined");
|
||||
expect(image.height).toBe(null);
|
||||
expect(image.width).toBe(null);
|
||||
});
|
||||
|
||||
it("should have expected assigned properties", async () => {
|
||||
const image = await driver.executeScript(() => {
|
||||
return new chrome.cast.Image("http://example.com");
|
||||
});
|
||||
|
||||
expect(image.url).toBe("http://example.com");
|
||||
});
|
||||
});
|
||||
54
test/spec/shim/cast/Receiver.spec.js
Normal file
54
test/spec/shim/cast/Receiver.spec.js
Normal file
@@ -0,0 +1,54 @@
|
||||
"use strict";
|
||||
|
||||
const { create } = require("../../../driver");
|
||||
|
||||
describe("chrome.cast.Receiver", () => {
|
||||
let driver;
|
||||
|
||||
beforeAll(async () => {
|
||||
driver = await create();
|
||||
});
|
||||
afterAll(() => {
|
||||
driver.quit();
|
||||
})
|
||||
|
||||
|
||||
it("should have all properties", async () => {
|
||||
const [ typeof_friendlyName
|
||||
, typeof_label
|
||||
, receiver ] = await driver.executeScript(() => {
|
||||
|
||||
const receiver = new chrome.cast.Receiver();
|
||||
|
||||
return [
|
||||
typeof receiver.friendlyName
|
||||
, typeof receiver.label
|
||||
, receiver
|
||||
];
|
||||
});
|
||||
|
||||
expect(typeof_friendlyName).toBe("undefined");
|
||||
expect(typeof_label).toBe("undefined");
|
||||
expect(receiver.capabilities).toEqual([]);
|
||||
expect(receiver.displayStatus).toBe(null);
|
||||
expect(receiver.isActiveInput).toBe(null);
|
||||
expect(receiver.receiverType).toBe("cast");
|
||||
expect(receiver.volume).toBe(null);
|
||||
});
|
||||
|
||||
it("should have expected assigned properties", async () => {
|
||||
const error = await driver.executeScript(() => {
|
||||
return new chrome.cast.Receiver(
|
||||
"testLabel"
|
||||
, "testFriendlyName"
|
||||
, [ chrome.cast.Capability.VIDEO_OUT
|
||||
, chrome.cast.Capability.AUDIO_OUT ]
|
||||
, new chrome.cast.Volume(1, false));
|
||||
});
|
||||
|
||||
expect(error.capabilities).toEqual([ "video_out", "audio_out" ]);
|
||||
expect(error.friendlyName).toBe("testFriendlyName");
|
||||
expect(error.label).toBe("testLabel");
|
||||
expect(error.volume).toEqual({ level: 1, muted: false });
|
||||
});
|
||||
});
|
||||
52
test/spec/shim/cast/ReceiverDisplayStatus.spec.js
Normal file
52
test/spec/shim/cast/ReceiverDisplayStatus.spec.js
Normal file
@@ -0,0 +1,52 @@
|
||||
"use strict";
|
||||
|
||||
const { create } = require("../../../driver");
|
||||
|
||||
describe("chrome.cast.Receiver", () => {
|
||||
let driver;
|
||||
|
||||
beforeAll(async () => {
|
||||
driver = await create();
|
||||
});
|
||||
afterAll(() => {
|
||||
driver.quit();
|
||||
})
|
||||
|
||||
|
||||
it("should have all properties", async () => {
|
||||
const [ typeof_appImages
|
||||
, typeof_statusText
|
||||
, receiverDisplayStatus ] = await driver.executeScript(() => {
|
||||
|
||||
const receiverDisplayStatus =
|
||||
new chrome.cast.ReceiverDisplayStatus();
|
||||
|
||||
return [
|
||||
typeof receiverDisplayStatus.appImages
|
||||
, typeof receiverDisplayStatus.statusText
|
||||
, receiverDisplayStatus
|
||||
];
|
||||
});
|
||||
|
||||
expect(typeof_appImages).toBe("undefined");
|
||||
expect(typeof_statusText).toBe("undefined");
|
||||
expect(receiverDisplayStatus.showStop).toBe(null);
|
||||
});
|
||||
|
||||
it("should have expected assigned properties", async () => {
|
||||
const receiverDisplayStatus = await driver.executeScript(() => {
|
||||
return new chrome.cast.ReceiverDisplayStatus(
|
||||
"testStatusText"
|
||||
, [
|
||||
new chrome.cast.Image("http://example.com/1")
|
||||
, new chrome.cast.Image("http://example.com/2")
|
||||
]);
|
||||
});
|
||||
|
||||
expect(receiverDisplayStatus.statusText).toBe("testStatusText");
|
||||
expect(receiverDisplayStatus.appImages).toEqual([
|
||||
{ url: "http://example.com/1", height: null, width: null }
|
||||
, { url: "http://example.com/2", height: null, width: null }
|
||||
]);
|
||||
});
|
||||
});
|
||||
0
test/spec/shim/cast/SenderApplication.spec.js
Normal file
0
test/spec/shim/cast/SenderApplication.spec.js
Normal file
0
test/spec/shim/cast/Session.spec.js
Normal file
0
test/spec/shim/cast/Session.spec.js
Normal file
0
test/spec/shim/cast/SessionRequest.spec.js
Normal file
0
test/spec/shim/cast/SessionRequest.spec.js
Normal file
0
test/spec/shim/cast/Timeout.spec.js
Normal file
0
test/spec/shim/cast/Timeout.spec.js
Normal file
0
test/spec/shim/cast/Volume.spec.js
Normal file
0
test/spec/shim/cast/Volume.spec.js
Normal file
@@ -1,18 +1,17 @@
|
||||
"use strict";
|
||||
|
||||
const sharedDriver = require("../sharedDriver");
|
||||
const { create, destroy } = require("../../driver");
|
||||
|
||||
describe("chrome", () => {
|
||||
let driver;
|
||||
let chrome;
|
||||
|
||||
beforeAll(async () => {
|
||||
driver = await sharedDriver();
|
||||
driver = await create();
|
||||
chrome = await driver.executeScript(() => {
|
||||
return chrome;
|
||||
});
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
driver.quit();
|
||||
});
|
||||
Reference in New Issue
Block a user