Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(616)

Unified Diff: chrome/test/data/extensions/tray_cast/background.js

Issue 1224643008: Add a fake cast extension for testing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/extensions/tray_cast/background.js
diff --git a/chrome/test/data/extensions/tray_cast/background.js b/chrome/test/data/extensions/tray_cast/background.js
new file mode 100644
index 0000000000000000000000000000000000000000..a80f5c2255cdd031b67fa81af21d86441107962e
--- /dev/null
+++ b/chrome/test/data/extensions/tray_cast/background.js
@@ -0,0 +1,72 @@
+var backgroundSetup = {}
+
+tryCreateActivity = function(id, title, tabId) {
+ if (id === undefined || title === undefined || tabId === undefined)
+ return null;
+
+ return {
+ "id": id,
+ "title": title,
+ "tabId": tabId
+ };
+}
+
+var receiversActivities = [];
+// Add a new receiver. |activityTitle| and |activityTabId| are optional
+// parameters.
+addReceiver = function(id, receiverName, activityTitle, activityTabId) {
+ receiversActivities.push({
+ "activity": tryCreateActivity(id, activityTitle, activityTabId),
+ "receiver": {
+ "id": id,
+ "name": receiverName
+ }
+ });
+}
+// Required API method.
+getMirrorCapableReceiversAndActivities = function() {
+ if (this !== backgroundSetup)
+ throw 'this !== backgroundSetup';
+
+ return receiversActivities;
+}
+
+var stopMirroringReason = "";
+var stopMirroringCalled = false;
+wasStopMirroringCalledWithUserStop = function() {
+ return stopMirroringCalled && stopMirroringReason == 'user-stop';
+}
+// Required API method.
+stopMirroring = function(reason) {
+ if (this !== backgroundSetup)
+ throw 'this !== backgroundSetup';
+
+ stopMirroringReason = reason;
+ stopMirroringCalled = true;
+ for (item of receiversActivities) {
+ if (item.activity != null)
+ item.activity = null;
+ }
+}
+
+var launchTabId = 1;
+var launchTabTitle = "Fake Cast";
+var launchDesktopMirroringReceiverId = "";
+getLaunchDesktopMirroringReceiverId = function() {
+ return launchDesktopMirroringReceiverId;
+}
+// Required API method.
+launchDesktopMirroring = function(receiverId) {
+ if (this !== backgroundSetup)
+ throw 'this !== backgroundSetup';
+
+ launchDesktopMirroringReceiverId = receiverId;
+
+ for (item of receiversActivities) {
+ if (item.receiver.id == receiverId) {
+ item.activity =
+ tryCreateActivity(receiverId, launchTabId, launchTabTitle);
+ break;
+ }
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698