diff options
author | mihaip@chromium.org <mihaip@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-27 21:27:12 +0000 |
---|---|---|
committer | mihaip@chromium.org <mihaip@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-27 21:27:12 +0000 |
commit | 2ef31c6227eb4a045cf47079da59789ac4d4e6c0 (patch) | |
tree | d93abbd898edbd3a3e4f208c4003a5a72aaa635d | |
parent | 15c4b9d690064a9cc93e97474504370e28e07dce (diff) | |
download | chromium_src-2ef31c6227eb4a045cf47079da59789ac4d4e6c0.zip chromium_src-2ef31c6227eb4a045cf47079da59789ac4d4e6c0.tar.gz chromium_src-2ef31c6227eb4a045cf47079da59789ac4d4e6c0.tar.bz2 |
Fix CaptureVisibleTabRace to complete deterministically.
Since the test appears to time out on Leopard, leave in a FLAKY_ prefix for
the Mac, and add extra logging to see how far it gets on the bots.
Also fix expected/actual argument order in chrome.test.assertEq call and
the way we report kInternalVisibleTabCaptureError (we assign it to error_
directly in all places but one).
BUG=80212
TEST=ExtensionApiTest.CaptureVisibleTabRace
Review URL: http://codereview.chromium.org/6904054
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@83215 0039d316-1c4b-4281-b951-d872f2087c98
5 files changed, 42 insertions, 21 deletions
diff --git a/chrome/browser/extensions/extension_tabs_apitest.cc b/chrome/browser/extensions/extension_tabs_apitest.cc index d367f99..a6897a9 100644 --- a/chrome/browser/extensions/extension_tabs_apitest.cc +++ b/chrome/browser/extensions/extension_tabs_apitest.cc @@ -37,9 +37,9 @@ #define MAYBE_UpdateWindowSizeExitsFullscreen UpdateWindowSizeExitsFullscreen #endif -// Times out on Mac. http://crbug.com/80212 +// Times out on Mac (especially Leopard). http://crbug.com/80212 #if defined(OS_MACOSX) -#define MAYBE_CaptureVisibleTabRace DISABLED_CaptureVisibleTabRace +#define MAYBE_CaptureVisibleTabRace FLAKY_CaptureVisibleTabRace #else #define MAYBE_CaptureVisibleTabRace CaptureVisibleTabRace #endif diff --git a/chrome/browser/extensions/extension_tabs_module.cc b/chrome/browser/extensions/extension_tabs_module.cc index 459d794..9c636ac 100644 --- a/chrome/browser/extensions/extension_tabs_module.cc +++ b/chrome/browser/extensions/extension_tabs_module.cc @@ -1211,8 +1211,7 @@ void CaptureVisibleTabFunction::SendResultFromBitmap( } if (!encoded) { - error_ = ExtensionErrorUtils::FormatErrorMessage( - keys::kInternalVisibleTabCaptureError, ""); + error_ = keys::kInternalVisibleTabCaptureError; SendResponse(false); return; } diff --git a/chrome/renderer/resources/extension_apitest.js b/chrome/renderer/resources/extension_apitest.js index 4f5d94b6..16b2164 100644 --- a/chrome/renderer/resources/extension_apitest.js +++ b/chrome/renderer/resources/extension_apitest.js @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -75,7 +75,7 @@ var chrome = chrome || {}; }; chrome.test.runNextTest = function() { - chrome.test.assertEq(pendingCallbacks, 0); + chrome.test.assertEq(0, pendingCallbacks); lastTest = currentTest; currentTest = chrome.test.tests.shift(); if (!currentTest) { diff --git a/chrome/test/data/extensions/api_test/tabs/capture_visible_tab/common/tabs_util.js b/chrome/test/data/extensions/api_test/tabs/capture_visible_tab/common/tabs_util.js index 917cd03..c802955 100644 --- a/chrome/test/data/extensions/api_test/tabs/capture_visible_tab/common/tabs_util.js +++ b/chrome/test/data/extensions/api_test/tabs/capture_visible_tab/common/tabs_util.js @@ -1,3 +1,7 @@ +// Copyright (c) 2011 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. +// // Utility functions to help with tabs/windows testing. // Creates one window with tabs set to the urls in the array |tabUrls|. @@ -63,7 +67,7 @@ function getPixels(imgUrl, windowRect, callbackFn) { var context = canvas.getContext('2d'); context.drawImage( img, - 10, 10, 20, 20, // Source rect: Crop to x in 10..20, y in 10..20. + 10, 10, 10, 10, // Source rect: Crop to x in 10..20, y in 10..20. 0, 0, 10, 10); // Dest rect is 10x10. No resizing is done. var imageData = context.getImageData(0, 0, 10, 10).data; diff --git a/chrome/test/data/extensions/api_test/tabs/capture_visible_tab/test_race.js b/chrome/test/data/extensions/api_test/tabs/capture_visible_tab/test_race.js index 16fa7fe..8840d38 100644 --- a/chrome/test/data/extensions/api_test/tabs/capture_visible_tab/test_race.js +++ b/chrome/test/data/extensions/api_test/tabs/capture_visible_tab/test_race.js @@ -3,7 +3,7 @@ // found in the LICENSE file. // // API test for chrome.tabs.captureVisibleTab() that tests that concurrent -// capture requests end up with the expected data (by opening 10 windows with +// capture requests end up with the expected data (by opening 8 windows with // alternating black and white contents and asserting that the captured pixels // are of the expected colors). // browser_tests.exe --gtest_filter=ExtensionApiTest.CaptureVisibleTabRace @@ -20,8 +20,15 @@ var kWindowRect = { chrome.test.runTests([ function captureVisibleTabRace() { - var windowIdToExpectedColor = {}; - for (var i = 0; i < 10; i++) { + // Simulate a callback being added to make sure that the test isn't + // considered complete until all of the 8 windows are test (this happens + // in parallel, so the normal nesting of pass() call is not sufficient). + var callbackCompleted = chrome.test.callbackAdded(); + + console.log(new Date() + ' - creating windows'); + + var windowsAndColors = []; + for (var i = 0; i < 8; i++) { var colorName; var expectedColor; if (i % 2) { @@ -35,22 +42,33 @@ chrome.test.runTests([ createWindow( [url], kWindowRect, - pass((function(expectedColor, winId, tabIds) { - windowIdToExpectedColor[winId] = expectedColor; - }).bind(this, expectedColor))); + (function(expectedColor, winId, tabIds) { + console.log(new Date() + ' - created ' + winId); + windowsAndColors.push([winId, expectedColor]); + }).bind(this, expectedColor)); } - waitForAllTabs(pass(function() { - for (var windowId in windowIdToExpectedColor) { - var expectedColor = windowIdToExpectedColor[windowId]; - windowId = parseInt(windowId, 10); + waitForAllTabs(function() { + console.log(new Date() + ' - capturing contents'); + + var testedWindowCount = 0; + windowsAndColors.forEach(function(windowIdAndExpectedColor) { + var windowId = windowIdAndExpectedColor[0]; + var expectedColor = windowIdAndExpectedColor[1]; chrome.tabs.captureVisibleTab( windowId, - pass((function(expectedColor, imgDataUrl) { + {'format': 'png'}, + function(imgDataUrl) { + console.log(new Date() + ' - captured ' + windowId); testPixelsAreExpectedColor( imgDataUrl, kWindowRect, expectedColor); - }).bind(this, expectedColor))); - } - })); + console.log(new Date() + ' - tested pixels for ' + windowId); + testedWindowCount++; + if (testedWindowCount == windowsAndColors.length) { + callbackCompleted(); + } + }); + }); + }); } ]); |