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

Side by Side Diff: chrome/test/data/extensions/api_test/wallpaper_manager/test.js

Issue 11280300: Revert 171011 - Broke Linux ChromiumOS Tests (dbg)(2) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/common/extensions/api/wallpaper_private.json ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Deleted: svn:mime-type
- text/javascript
Deleted: svn:eol-style
- LF
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // wallpaperPrivate api test 5 // wallpaperPrivate api test
6 // browser_tests --gtest_filter=ExtensionApiTest.wallpaperPrivate 6 // browser_tests --gtest_filter=ExtensionApiTest.wallpaperPrivate
7 7
8 var pass = chrome.test.callbackPass; 8 var pass = chrome.test.callbackPass;
9 var fail = chrome.test.callbackFail; 9 var fail = chrome.test.callbackFail;
10 10
11 chrome.test.getConfig(function(config) { 11 chrome.test.getConfig(function(config) {
12 var wallpaper; 12 var wallpaper;
13 var wallpaperStrings; 13 var wallpaperStrings;
14 var requestImage = function(url, onLoadCallback) {
15 var wallpaperRequest = new XMLHttpRequest();
16 wallpaperRequest.open('GET', url, true);
17 wallpaperRequest.responseType = 'arraybuffer';
18 try {
19 wallpaperRequest.send(null);
20 wallpaperRequest.onloadend = function(e) {
21 onLoadCallback(wallpaperRequest.status, wallpaperRequest.response);
22 };
23 } catch (e) {
24 console.error(e);
25 chrome.test.fail('An error thrown when requesting wallpaper.');
26 };
27 };
28 chrome.test.runTests([ 14 chrome.test.runTests([
29 function getWallpaperStrings() { 15 function getWallpaperStrings() {
30 chrome.wallpaperPrivate.getStrings(pass(function(strings) { 16 chrome.wallpaperPrivate.getStrings(pass(function(strings) {
31 wallpaperStrings = strings; 17 wallpaperStrings = strings;
32 })); 18 }));
33 }, 19 },
34 function setOnlineJpegWallpaper() { 20 function setOnlineJpegWallpaper() {
21 var wallpaperRequest = new XMLHttpRequest();
35 var url = "http://a.com:PORT/files/extensions/api_test" + 22 var url = "http://a.com:PORT/files/extensions/api_test" +
36 "/wallpaper_manager/test.jpg"; 23 "/wallpaper_manager/test.jpg";
37 url = url.replace(/PORT/, config.testServer.port); 24 url = url.replace(/PORT/, config.testServer.port);
38 requestImage(url, function(requestStatus, response) { 25 wallpaperRequest.open('GET', url, true);
39 if (requestStatus === 200) { 26 wallpaperRequest.responseType = 'arraybuffer';
40 wallpaper = response; 27 try {
41 chrome.wallpaperPrivate.setWallpaper(wallpaper, 28 wallpaperRequest.send(null);
42 'CENTER_CROPPED', 29 wallpaperRequest.onload = function (e) {
43 url, 30 if (wallpaperRequest.status === 200) {
44 pass()); 31 wallpaper = wallpaperRequest.response;
45 } else { 32 chrome.wallpaperPrivate.setWallpaper(wallpaper,
46 chrome.test.fail('Failed to load test.jpg from local server.'); 33 'CENTER_CROPPED',
47 } 34 url,
48 }); 35 pass());
36 } else {
37 chrome.test.fail('Failed to load test.jpg from local server.');
38 }
39 };
40 } catch (e) {
41 console.error(e);
42 chrome.test.fail('An error thrown when requesting wallpaper.');
43 };
49 }, 44 },
50 function setCustomJpegWallpaper() { 45 function setCustomJpegWallpaper() {
51 chrome.wallpaperPrivate.setCustomWallpaper(wallpaper, 46 chrome.wallpaperPrivate.setCustomWallpaper(wallpaper,
52 'CENTER_CROPPED', 47 'CENTER_CROPPED',
53 pass()); 48 pass());
54 }, 49 },
55 function setCustomJepgBadWallpaper() { 50 function setCustomJepgBadWallpaper() {
51 var wallpaperRequest = new XMLHttpRequest();
56 var url = "http://a.com:PORT/files/extensions/api_test" + 52 var url = "http://a.com:PORT/files/extensions/api_test" +
57 "/wallpaper_manager/test_bad.jpg"; 53 "/wallpaper_manager/test_bad.jpg";
58 url = url.replace(/PORT/, config.testServer.port); 54 url = url.replace(/PORT/, config.testServer.port);
59 requestImage(url, function(requestStatus, response) { 55 wallpaperRequest.open('GET', url, true);
60 if (requestStatus === 200) { 56 wallpaperRequest.responseType = 'arraybuffer';
61 var badWallpaper = response; 57 try {
62 chrome.wallpaperPrivate.setCustomWallpaper(badWallpaper, 58 wallpaperRequest.send(null);
63 'CENTER_CROPPED', fail(wallpaperStrings.invalidWallpaper)); 59 wallpaperRequest.onload = function (e) {
64 } else { 60 if (wallpaperRequest.status === 200) {
65 chrome.test.fail('Failed to load test_bad.jpg from local server.'); 61 var badWallpaper = wallpaperRequest.response;
66 } 62 chrome.wallpaperPrivate.setCustomWallpaper(badWallpaper,
67 }); 63 'CENTER_CROPPED', fail(wallpaperStrings.invalidWallpaper));
68 }, 64 } else {
69 function getAndSetThumbnail() { 65 chrome.test.fail('Failed to load test_bad.jpg from local server.');
70 var url = "http://a.com:PORT/files/extensions/api_test" + 66 }
71 "/wallpaper_manager/test.jpg"; 67 };
72 url = url.replace(/PORT/, config.testServer.port); 68 } catch (e) {
73 chrome.wallpaperPrivate.getThumbnail(url, pass(function(data) { 69 console.error(e);
74 chrome.test.assertNoLastError(); 70 chrome.test.fail('An error thrown when requesting wallpaper.');
75 if (data) 71 };
76 chrome.test.fail('Thumbnail is not found. getThumbnail should not ' +
77 'return any data.');
78 chrome.wallpaperPrivate.saveThumbnail(url, wallpaper, pass(function() {
79 chrome.test.assertNoLastError();
80 chrome.wallpaperPrivate.getThumbnail(url, pass(function(data) {
81 chrome.test.assertNoLastError();
82 // Thumbnail should already be saved to thumbnail directory.
83 chrome.test.assertEq(wallpaper, data);
84 }));
85 }));
86 }));
87 } 72 }
88 ]); 73 ]);
89 }); 74 });
OLDNEW
« no previous file with comments | « chrome/common/extensions/api/wallpaper_private.json ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698