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 |
index 2ea871a1ea412cff62369b1db7a9705e3a0eb713..51a4732bc1d4952265ca14b483bb02cc81cdc539 100644 |
--- a/chrome/test/data/extensions/tray_cast/background.js |
+++ b/chrome/test/data/extensions/tray_cast/background.js |
@@ -12,36 +12,47 @@ |
return null; |
return { |
- 'id': id, |
- 'title': title, |
- 'tabId': tabId |
+ "id": id, |
+ "title": title, |
+ "tabId": tabId |
}; |
} |
var receiversActivities = []; |
-var sendDevices = function() { |
- chrome.cast.devicesPrivate.updateDevices(receiversActivities); |
-} |
-chrome.cast.devicesPrivate.updateDevicesRequested.addListener(sendDevices); |
- |
// Add a new receiver. |activityTitle| and |activityTabId| are optional |
// parameters. |
-var addReceiver = function(id, receiverName, activityTitle, activityTabId) { |
+addReceiver = function(id, receiverName, activityTitle, activityTabId) { |
receiversActivities.push({ |
- 'receiver': { |
- 'id': id, |
- 'name': receiverName |
- }, |
- 'activity': tryCreateActivity_(id, activityTitle, activityTabId) |
+ "activity": tryCreateActivity_(id, activityTitle, activityTabId), |
+ "receiver": { |
+ "id": id, |
+ "name": receiverName |
+ } |
}); |
+} |
+// Required API method. |
+getMirrorCapableReceiversAndActivities = function() { |
+ // For all of the API methods, we verify that |this| points to |
+ // backgroundSetup. In the actual extension, the API methods are |
+ // also free-standing but they are really class methods on backgroundSetup. |
+ if (this !== backgroundSetup) |
+ throw 'this !== backgroundSetup'; |
- sendDevices(); |
+ return receiversActivities; |
} |
+var stopMirroringReason = ""; |
var stopMirroringCalled = false; |
-chrome.cast.devicesPrivate.stopCast.addListener(function(reason) { |
- if (reason !== 'user-stop') |
- throw 'expected reason to be "user-stop"'; |
+wasStopMirroringCalledWithUserStop = function() { |
+ return stopMirroringCalled && stopMirroringReason == 'user-stop'; |
+} |
+// Required API method. |
+stopMirroring = function(reason) { |
+ if (this !== backgroundSetup) |
+ throw 'this !== backgroundSetup'; |
+ |
+ stopMirroringReason = reason; |
+ stopMirroringCalled = true; |
var foundActivity = false; |
for (item of receiversActivities) { |
@@ -52,25 +63,26 @@ |
} |
if (foundActivity === false) |
throw 'stopMirroring called when there was nothing being mirrored' |
+} |
- stopMirroringCalled = true; |
- sendDevices(); |
-}); |
+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'; |
- |
-var launchDesktopMirroringReceiverId = ''; |
-chrome.cast.devicesPrivate.startCast.addListener(function(receiverId) { |
launchDesktopMirroringReceiverId = receiverId; |
- |
- var tabTitle = 'Tab Title'; |
- var tabId = 1; |
for (item of receiversActivities) { |
if (item.receiver.id == receiverId) { |
- item.activity = tryCreateActivity_(receiverId, tabTitle, tabId); |
+ item.activity = |
+ tryCreateActivity_(receiverId, launchTabId, launchTabTitle); |
break; |
} |
} |
- |
- sendDevices(); |
-}); |
+} |