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

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

Issue 1287023010: Browser tests for the ChromeOS chromecast system tray item. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Fix compile error on CrOS bot Created 5 years, 4 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
« no previous file with comments | « chrome/chrome_tests.gypi ('k') | chrome/test/data/extensions/tray_cast/manifest.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 51a4732bc1d4952265ca14b483bb02cc81cdc539..2ea871a1ea412cff62369b1db7a9705e3a0eb713 100644
--- a/chrome/test/data/extensions/tray_cast/background.js
+++ b/chrome/test/data/extensions/tray_cast/background.js
@@ -12,47 +12,36 @@ tryCreateActivity_ = function(id, title, tabId) {
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.
-addReceiver = function(id, receiverName, activityTitle, activityTabId) {
+var addReceiver = function(id, receiverName, activityTitle, activityTabId) {
receiversActivities.push({
- "activity": tryCreateActivity_(id, activityTitle, activityTabId),
- "receiver": {
- "id": id,
- "name": receiverName
- }
+ 'receiver': {
+ 'id': id,
+ 'name': receiverName
+ },
+ 'activity': tryCreateActivity_(id, activityTitle, activityTabId)
});
-}
-// 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';
- return receiversActivities;
+ sendDevices();
}
-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;
+chrome.cast.devicesPrivate.stopCast.addListener(function(reason) {
+ if (reason !== 'user-stop')
+ throw 'expected reason to be "user-stop"';
var foundActivity = false;
for (item of receiversActivities) {
@@ -63,26 +52,25 @@ stopMirroring = function(reason) {
}
if (foundActivity === false)
throw 'stopMirroring called when there was nothing being mirrored'
-}
-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';
+ stopMirroringCalled = true;
+ sendDevices();
+});
+
+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, launchTabId, launchTabTitle);
+ item.activity = tryCreateActivity_(receiverId, tabTitle, tabId);
break;
}
}
-}
+
+ sendDevices();
+});
« no previous file with comments | « chrome/chrome_tests.gypi ('k') | chrome/test/data/extensions/tray_cast/manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698