diff --git a/ext/src/shim/cast/classes/ApiConfig.js b/ext/src/shim/cast/classes/ApiConfig.js index 39f686a..057c73e 100755 --- a/ext/src/shim/cast/classes/ApiConfig.js +++ b/ext/src/shim/cast/classes/ApiConfig.js @@ -16,5 +16,9 @@ export default class ApiConfig { this.receiverListener = receiverListener; this.sessionListener = sessionListener; this.sessionRequest = sessionRequest; + + this.additionalSessionRequests = []; + this.customDialLaunchCallback = null; + this.invisibleSender = false; } }; diff --git a/ext/src/shim/cast/classes/Receiver.js b/ext/src/shim/cast/classes/Receiver.js index d29f868..cfb1419 100755 --- a/ext/src/shim/cast/classes/Receiver.js +++ b/ext/src/shim/cast/classes/Receiver.js @@ -8,9 +8,7 @@ export default class Receiver { constructor ( label , friendlyName - , opt_capabilities = [ - Capability.VIDEO_OUT - , Capability.AUDIO_OUT ] + , opt_capabilities = [] , opt_volume = null) { this.capabilities = opt_capabilities; diff --git a/jasmine.json b/jasmine.json index 7ca7bdd..30d1d77 100644 --- a/jasmine.json +++ b/jasmine.json @@ -1,5 +1,5 @@ { - "spec_dir": "test/spec", + "spec_dir": "test/spec/**", "spec_files": [ "*.spec.js" ], diff --git a/test/driver.js b/test/driver.js index f7fbbde..cf0d97c 100644 --- a/test/driver.js +++ b/test/driver.js @@ -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 = { diff --git a/test/spec/shim/cast/ApiConfig.spec.js b/test/spec/shim/cast/ApiConfig.spec.js new file mode 100644 index 0000000..fe8346d --- /dev/null +++ b/test/spec/shim/cast/ApiConfig.spec.js @@ -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"); + }); +}); diff --git a/test/spec/shim/cast/DialRequest.spec.js b/test/spec/shim/cast/DialRequest.spec.js new file mode 100644 index 0000000..d119775 --- /dev/null +++ b/test/spec/shim/cast/DialRequest.spec.js @@ -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"); + }); +}); diff --git a/test/spec/shim/cast/Error.spec.js b/test/spec/shim/cast/Error.spec.js new file mode 100644 index 0000000..3bd4989 --- /dev/null +++ b/test/spec/shim/cast/Error.spec.js @@ -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" }); + }); +}); diff --git a/test/spec/shim/cast/Image.spec.js b/test/spec/shim/cast/Image.spec.js new file mode 100644 index 0000000..c07c2d1 --- /dev/null +++ b/test/spec/shim/cast/Image.spec.js @@ -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"); + }); +}); diff --git a/test/spec/shim/cast/Receiver.spec.js b/test/spec/shim/cast/Receiver.spec.js new file mode 100644 index 0000000..2ac09e5 --- /dev/null +++ b/test/spec/shim/cast/Receiver.spec.js @@ -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 }); + }); +}); diff --git a/test/spec/shim/cast/ReceiverDisplayStatus.spec.js b/test/spec/shim/cast/ReceiverDisplayStatus.spec.js new file mode 100644 index 0000000..bca5218 --- /dev/null +++ b/test/spec/shim/cast/ReceiverDisplayStatus.spec.js @@ -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 } + ]); + }); +}); diff --git a/test/spec/shim/cast/SenderApplication.spec.js b/test/spec/shim/cast/SenderApplication.spec.js new file mode 100644 index 0000000..e69de29 diff --git a/test/spec/shim/cast/Session.spec.js b/test/spec/shim/cast/Session.spec.js new file mode 100644 index 0000000..e69de29 diff --git a/test/spec/shim/cast/SessionRequest.spec.js b/test/spec/shim/cast/SessionRequest.spec.js new file mode 100644 index 0000000..e69de29 diff --git a/test/spec/shim/cast/Timeout.spec.js b/test/spec/shim/cast/Timeout.spec.js new file mode 100644 index 0000000..e69de29 diff --git a/test/spec/shim/cast/Volume.spec.js b/test/spec/shim/cast/Volume.spec.js new file mode 100644 index 0000000..e69de29 diff --git a/test/spec/chrome.spec.js b/test/spec/shim/chrome.spec.js similarity index 99% rename from test/spec/chrome.spec.js rename to test/spec/shim/chrome.spec.js index 05095a6..6ade3a5 100644 --- a/test/spec/chrome.spec.js +++ b/test/spec/shim/chrome.spec.js @@ -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(); });