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

Unified Diff: chrome/test/data/extensions/api_test/media_galleries/copy_to_access/no_access/copy_to_common.js

Issue 24356005: Simplify the MediaGalleriesPlatformAppBrowserTest copyTo tests. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 3 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 | « no previous file | chrome/test/data/extensions/api_test/media_galleries/copy_to_access/no_access/test.js » ('j') | 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/copy_to_access/no_access/copy_to_common.js
===================================================================
--- chrome/test/data/extensions/api_test/media_galleries/copy_to_access/no_access/copy_to_common.js (revision 224775)
+++ chrome/test/data/extensions/api_test/media_galleries/copy_to_access/no_access/copy_to_common.js (working copy)
@@ -2,32 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-var mediaGalleries = chrome.mediaGalleries;
-
-function getOnwriteendCallbackExpectFailure(testImageFileEntry, galleries,
- filename) {
- return function() {
- testImageFileEntry.copyTo(
- galleries[0].root,
- filename,
- chrome.test.fail,
- chrome.test.succeed);
- };
-}
-
-function getOnwriteendCallbackExpectSuccess(testImageFileEntry, galleries,
- filename) {
- return function() {
- testImageFileEntry.copyTo(
- galleries[0].root,
- filename,
- chrome.test.succeed,
- chrome.test.fail);
- };
-}
-
// Valid WEBP image.
-var validCase = {
+// TODO(thestig) Maybe copy these files to a media gallery in the C++ setup
+// phase to avoid having this and webkitRequestFileSystem() below.
+var validWEBPImageCase = {
filename: "valid.webp",
blobString: "RIFF0\0\0\0WEBPVP8 $\0\0\0\xB2\x02\0\x9D\x01\x2A" +
"\x01\0\x01\0\x2F\x9D\xCE\xE7s\xA8((((\x01\x9CK(\0" +
@@ -35,18 +13,16 @@
}
// Write an invalid test image and expect failure.
-var invalidCase = {
+var invalidWEBPImageCase = {
filename: "invalid.webp",
blobString: "abc123"
}
-function runTest(testCase, getOnwriteendCallback) {
+function runCopyToTest(testCase, expectSucceed) {
var galleries;
var testImageFileEntry;
- function getMediaFileSystemsList() {
- mediaGalleries.getMediaFileSystems(testGalleries);
- }
+ chrome.mediaGalleries.getMediaFileSystems(testGalleries);
function testGalleries(results) {
galleries = results;
@@ -82,33 +58,42 @@
chrome.test.fail("Unable to write test image: " + e.toString());
}
- writer.onwriteend = getOnwriteendCallback(testImageFileEntry, galleries,
- testCase.filename);
+ writer.onwriteend = testCopyTo(testImageFileEntry, galleries[0],
+ testCase.filename, expectSucceed);
writer.write(blob);
}
- getMediaFileSystemsList();
+ function testCopyTo(testImageFileEntry, gallery, filename, expectSucceed) {
+ var onSuccess;
+ var onFailure;
+ if (expectSucceed) {
+ onSuccess = chrome.test.succeed;
+ onFailure = chrome.test.fail;
+ } else {
+ onSuccess = chrome.test.fail;
+ onFailure = chrome.test.succeed;
+ }
+ return function() {
+ testImageFileEntry.copyTo(gallery.root, filename, onSuccess, onFailure);
+ };
+ }
}
-function createTest(testCase, getOnwriteendCallback) {
- return function() {
- runTest(testCase, getOnwriteendCallback);
- };
-}
-
// Create a dummy window to prevent the ExtensionProcessManager from suspending
// the chrome-test app. Needed because the writer.onerror and writer.onwriteend
// events do not qualify as pending callbacks, so the app looks dormant.
-chrome.app.runtime.onLaunched.addListener(function() {
- chrome.app.window.create('dummy.html', {
- bounds: {
- width: 800,
- height: 600,
- left: 100,
- top: 100
- },
- minWidth: 800,
- minHeight: 600
+function CreateDummyWindowToPreventSleep() {
+ chrome.app.runtime.onLaunched.addListener(function() {
+ chrome.app.window.create('dummy.html', {
+ bounds: {
+ width: 800,
+ height: 600,
+ left: 100,
+ top: 100
+ },
+ minWidth: 800,
+ minHeight: 600
+ });
});
-});
+}
« no previous file with comments | « no previous file | chrome/test/data/extensions/api_test/media_galleries/copy_to_access/no_access/test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698