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

Unified Diff: chrome/test/data/extensions/api_test/media_galleries_private/gallerywatch/test.js

Issue 11535008: Implement mediaGalleriesPrivate api to notify extensions about gallery changed events. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Disable SetupGalleryWatch browser test on ChromeOS Created 7 years, 12 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/test/data/extensions/api_test/media_galleries_private/gallerywatch/manifest.json ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/extensions/api_test/media_galleries_private/gallerywatch/test.js
diff --git a/chrome/test/data/extensions/api_test/media_galleries_private/gallerywatch/test.js b/chrome/test/data/extensions/api_test/media_galleries_private/gallerywatch/test.js
new file mode 100644
index 0000000000000000000000000000000000000000..da98dabc167a5c426b17f3ec431776ad255a41d5
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/media_galleries_private/gallerywatch/test.js
@@ -0,0 +1,66 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+var galleries;
+var invalidGalleryId = 11000;
+
+// chrome.mediaGalleries.getMediaFileSystems callback.
+var mediaFileSystemsListCallback = function (results) {
+ galleries = results;
+ chrome.test.sendMessage('get_media_file_systems_callback_ok');
+};
+
+// Gallery changed event handler.
+var onGalleryChangedCallback = function (details) {
+ chrome.test.sendMessage('gallery_changed_event_received');
+};
+
+// Add watch request callback.
+var onAddWatchRequestCallback = function (details) {
+ if (!details || !details.success)
+ chrome.test.sendMessage('add_watch_request_failed');
+ else
+ chrome.test.sendMessage('add_watch_request_succeeded');
+};
+
+// Helpers to add and remove event listeners.
+function addGalleryChangedListener() {
+ chrome.mediaGalleriesPrivate.onGalleryChanged.addListener(
+ onGalleryChangedCallback);
+ chrome.test.sendMessage('add_gallery_changed_listener_ok');
+};
+
+function setupWatchOnValidGalleries() {
+ for (var i = 0; i < galleries.length; ++i) {
+ var info = JSON.parse(galleries[i].name);
+ chrome.mediaGalleriesPrivate.addGalleryWatch(info.galleryId,
+ onAddWatchRequestCallback);
+ }
+ chrome.test.sendMessage('add_gallery_watch_ok');
+};
+
+function setupWatchOnInvalidGallery() {
+ chrome.mediaGalleriesPrivate.addGalleryWatch(invalidGalleryId,
+ onAddWatchRequestCallback);
+ chrome.test.sendMessage('add_gallery_watch_ok');
+}
+
+function getMediaFileSystems() {
+ chrome.mediaGalleries.getMediaFileSystems(mediaFileSystemsListCallback);
+ chrome.test.sendMessage('get_media_file_systems_ok');
+};
+
+function removeGalleryWatch() {
+ for (var i = 0; i < galleries.length; ++i) {
+ var info = JSON.parse(galleries[i].name);
+ chrome.mediaGalleriesPrivate.removeGalleryWatch(info.galleryId);
+ }
+ chrome.test.sendMessage('remove_gallery_watch_ok');
+};
+
+function removeGalleryChangedListener() {
+ chrome.mediaGalleriesPrivate.onGalleryChanged.removeListener(
+ onGalleryChangedCallback);
+ chrome.test.sendMessage('remove_gallery_changed_listener_ok');
+};
« no previous file with comments | « chrome/test/data/extensions/api_test/media_galleries_private/gallerywatch/manifest.json ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698