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

Unified Diff: chrome/test/data/extensions/api_test/wallpaper_manager/test.js

Issue 11348215: Make wallpaper picker manifest and thumbnails available when offline. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove success paramter and add a todo Created 8 years 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
Index: chrome/test/data/extensions/api_test/wallpaper_manager/test.js
diff --git a/chrome/test/data/extensions/api_test/wallpaper_manager/test.js b/chrome/test/data/extensions/api_test/wallpaper_manager/test.js
index efda128659afbbbac9b35f67d604935c40bc0f3e..645a59046c5d79be6d8a088b006449a6d536921f 100644
--- a/chrome/test/data/extensions/api_test/wallpaper_manager/test.js
+++ b/chrome/test/data/extensions/api_test/wallpaper_manager/test.js
@@ -11,6 +11,20 @@ var fail = chrome.test.callbackFail;
chrome.test.getConfig(function(config) {
var wallpaper;
var wallpaperStrings;
+ var requestImage = function(url, onLoadCallback) {
+ var wallpaperRequest = new XMLHttpRequest();
+ wallpaperRequest.open('GET', url, true);
+ wallpaperRequest.responseType = 'arraybuffer';
+ try {
+ wallpaperRequest.send(null);
+ wallpaperRequest.onloadend = function(e) {
+ onLoadCallback(wallpaperRequest.status, wallpaperRequest.response);
+ };
+ } catch (e) {
+ console.error(e);
+ chrome.test.fail('An error thrown when requesting wallpaper.');
+ };
+ };
chrome.test.runTests([
function getWallpaperStrings() {
chrome.wallpaperPrivate.getStrings(pass(function(strings) {
@@ -18,29 +32,20 @@ chrome.test.getConfig(function(config) {
}));
},
function setOnlineJpegWallpaper() {
- var wallpaperRequest = new XMLHttpRequest();
var url = "http://a.com:PORT/files/extensions/api_test" +
"/wallpaper_manager/test.jpg";
url = url.replace(/PORT/, config.testServer.port);
- wallpaperRequest.open('GET', url, true);
- wallpaperRequest.responseType = 'arraybuffer';
- try {
- wallpaperRequest.send(null);
- wallpaperRequest.onload = function (e) {
- if (wallpaperRequest.status === 200) {
- wallpaper = wallpaperRequest.response;
- chrome.wallpaperPrivate.setWallpaper(wallpaper,
- 'CENTER_CROPPED',
- url,
- pass());
- } else {
- chrome.test.fail('Failed to load test.jpg from local server.');
- }
- };
- } catch (e) {
- console.error(e);
- chrome.test.fail('An error thrown when requesting wallpaper.');
- };
+ requestImage(url, function(requestStatus, response) {
+ if (requestStatus === 200) {
+ wallpaper = response;
+ chrome.wallpaperPrivate.setWallpaper(wallpaper,
+ 'CENTER_CROPPED',
+ url,
+ pass());
+ } else {
+ chrome.test.fail('Failed to load test.jpg from local server.');
+ }
+ });
},
function setCustomJpegWallpaper() {
chrome.wallpaperPrivate.setCustomWallpaper(wallpaper,
@@ -48,27 +53,37 @@ chrome.test.getConfig(function(config) {
pass());
},
function setCustomJepgBadWallpaper() {
- var wallpaperRequest = new XMLHttpRequest();
var url = "http://a.com:PORT/files/extensions/api_test" +
"/wallpaper_manager/test_bad.jpg";
url = url.replace(/PORT/, config.testServer.port);
- wallpaperRequest.open('GET', url, true);
- wallpaperRequest.responseType = 'arraybuffer';
- try {
- wallpaperRequest.send(null);
- wallpaperRequest.onload = function (e) {
- if (wallpaperRequest.status === 200) {
- var badWallpaper = wallpaperRequest.response;
- chrome.wallpaperPrivate.setCustomWallpaper(badWallpaper,
- 'CENTER_CROPPED', fail(wallpaperStrings.invalidWallpaper));
- } else {
- chrome.test.fail('Failed to load test_bad.jpg from local server.');
- }
- };
- } catch (e) {
- console.error(e);
- chrome.test.fail('An error thrown when requesting wallpaper.');
- };
+ requestImage(url, function(requestStatus, response) {
+ if (requestStatus === 200) {
+ var badWallpaper = response;
+ chrome.wallpaperPrivate.setCustomWallpaper(badWallpaper,
+ 'CENTER_CROPPED', fail(wallpaperStrings.invalidWallpaper));
+ } else {
+ chrome.test.fail('Failed to load test_bad.jpg from local server.');
+ }
+ });
+ },
+ function getAndSetThumbnail() {
+ var url = "http://a.com:PORT/files/extensions/api_test" +
+ "/wallpaper_manager/test.jpg";
+ url = url.replace(/PORT/, config.testServer.port);
+ chrome.wallpaperPrivate.getThumbnail(url, pass(function(data) {
+ chrome.test.assertNoLastError();
+ if (data)
+ chrome.test.fail('Thumbnail is not found. getThumbnail should not ' +
+ 'return any data.');
+ chrome.wallpaperPrivate.saveThumbnail(url, wallpaper, pass(function() {
+ chrome.test.assertNoLastError();
+ chrome.wallpaperPrivate.getThumbnail(url, pass(function(data) {
+ chrome.test.assertNoLastError();
+ // Thumbnail should already be saved to thumbnail directory.
+ chrome.test.assertEq(wallpaper, data);
+ }));
+ }));
+ }));
}
]);
});

Powered by Google App Engine
This is Rietveld 408576698