Commit 4d1da77c authored by tommycli@chromium.org's avatar tommycli@chromium.org

Media Galleries API: Fix CopyTo test flaky timeout on Windows.

TBR=asargent
BUG=268481

Review URL: https://chromiumcodereview.appspot.com/22895002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@217066 0039d316-1c4b-4281-b951-d872f2087c98
parent 038cbd2d
...@@ -133,9 +133,8 @@ IN_PROC_BROWSER_TEST_F(MediaGalleriesPlatformAppBrowserTest, ...@@ -133,9 +133,8 @@ IN_PROC_BROWSER_TEST_F(MediaGalleriesPlatformAppBrowserTest,
kTestGalleries, media_directories.num_galleries()))); kTestGalleries, media_directories.num_galleries())));
} }
// Flakily times out: http://crbug.com/268481
IN_PROC_BROWSER_TEST_F(MediaGalleriesPlatformAppBrowserTest, IN_PROC_BROWSER_TEST_F(MediaGalleriesPlatformAppBrowserTest,
DISABLED_MediaGalleriesCopyTo) { MediaGalleriesCopyTo) {
chrome::EnsureMediaDirectoriesExists media_directories; chrome::EnsureMediaDirectoriesExists media_directories;
base::ScopedTempDir temp_dir; base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
......
...@@ -4,18 +4,24 @@ ...@@ -4,18 +4,24 @@
var mediaGalleries = chrome.mediaGalleries; var mediaGalleries = chrome.mediaGalleries;
function getOnwriteendCallbackExpectFailure(testImageFileEntry, galleries) { function getOnwriteendCallbackExpectFailure(testImageFileEntry, galleries,
filename) {
return function() { return function() {
testImageFileEntry.copyTo(galleries[0].root, this.filename, testImageFileEntry.copyTo(
galleries[0].root,
filename,
chrome.test.fail, chrome.test.fail,
chrome.test.callbackPass(function() {})); chrome.test.succeed);
}; };
} }
function getOnwriteendCallbackExpectSuccess(testImageFileEntry, galleries) { function getOnwriteendCallbackExpectSuccess(testImageFileEntry, galleries,
filename) {
return function() { return function() {
testImageFileEntry.copyTo(galleries[0].root, this.filename, testImageFileEntry.copyTo(
chrome.test.callbackPass(function() {}), galleries[0].root,
filename,
chrome.test.succeed,
chrome.test.fail); chrome.test.fail);
}; };
} }
...@@ -39,8 +45,7 @@ function runTest(testCase, getOnwriteendCallback) { ...@@ -39,8 +45,7 @@ function runTest(testCase, getOnwriteendCallback) {
var testImageFileEntry; var testImageFileEntry;
function getMediaFileSystemsList() { function getMediaFileSystemsList() {
mediaGalleries.getMediaFileSystems( mediaGalleries.getMediaFileSystems(testGalleries);
chrome.test.callbackPass(testGalleries));
} }
function testGalleries(results) { function testGalleries(results) {
...@@ -50,21 +55,19 @@ function runTest(testCase, getOnwriteendCallback) { ...@@ -50,21 +55,19 @@ function runTest(testCase, getOnwriteendCallback) {
// Create a temporary file system and an image for copying-into test. // Create a temporary file system and an image for copying-into test.
window.webkitRequestFileSystem(window.TEMPORARY, 1024*1024, window.webkitRequestFileSystem(window.TEMPORARY, 1024*1024,
chrome.test.callbackPass(temporaryFileSystemCallback), temporaryFileSystemCallback,
chrome.test.fail); chrome.test.fail);
} }
function temporaryFileSystemCallback(filesystem) { function temporaryFileSystemCallback(filesystem) {
filesystem.root.getFile(testCase.filename, {create:true, exclusive: false}, filesystem.root.getFile(testCase.filename, {create:true, exclusive: false},
chrome.test.callbackPass(temporaryImageCallback), temporaryImageCallback,
chrome.test.fail); chrome.test.fail);
} }
function temporaryImageCallback(entry) { function temporaryImageCallback(entry) {
testImageFileEntry = entry; testImageFileEntry = entry;
entry.createWriter( entry.createWriter(imageWriterCallback, chrome.test.fail);
chrome.test.callbackPass(imageWriterCallback),
chrome.test.fail);
} }
function imageWriterCallback(writer) { function imageWriterCallback(writer) {
...@@ -79,8 +82,8 @@ function runTest(testCase, getOnwriteendCallback) { ...@@ -79,8 +82,8 @@ function runTest(testCase, getOnwriteendCallback) {
chrome.test.fail("Unable to write test image: " + e.toString()); chrome.test.fail("Unable to write test image: " + e.toString());
} }
writer.onwriteend = chrome.test.callbackPass( writer.onwriteend = getOnwriteendCallback(testImageFileEntry, galleries,
getOnwriteendCallback(testImageFileEntry, galleries)); testCase.filename);
writer.write(blob); writer.write(blob);
} }
...@@ -93,3 +96,19 @@ function createTest(testCase, getOnwriteendCallback) { ...@@ -93,3 +96,19 @@ function createTest(testCase, getOnwriteendCallback) {
runTest(testCase, getOnwriteendCallback); 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
});
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment