| OLD | NEW |
| 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 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 fail('Only custom wallpaper can change layout.')); | 46 fail('Only custom wallpaper can change layout.')); |
| 47 })); | 47 })); |
| 48 } else { | 48 } else { |
| 49 chrome.test.fail('Failed to load test.jpg from local server.'); | 49 chrome.test.fail('Failed to load test.jpg from local server.'); |
| 50 } | 50 } |
| 51 }); | 51 }); |
| 52 }, | 52 }, |
| 53 function setCustomJpegWallpaper() { | 53 function setCustomJpegWallpaper() { |
| 54 chrome.wallpaperPrivate.setCustomWallpaper(wallpaper, | 54 chrome.wallpaperPrivate.setCustomWallpaper(wallpaper, |
| 55 'CENTER_CROPPED', | 55 'CENTER_CROPPED', |
| 56 pass(function(fileName) { | 56 true, |
| 57 '123', |
| 58 pass(function(thumbnail) { |
| 57 chrome.wallpaperPrivate.setCustomWallpaperLayout('CENTER', | 59 chrome.wallpaperPrivate.setCustomWallpaperLayout('CENTER', |
| 58 pass(function() { | 60 pass(function() { |
| 59 chrome.wallpaperPrivate.setCustomWallpaperLayout('STRETCH', pass()); | 61 chrome.wallpaperPrivate.setCustomWallpaperLayout('STRETCH', pass()); |
| 60 })); | 62 })); |
| 61 })); | 63 })); |
| 62 }, | 64 }, |
| 63 function getCustomWallpaperThumbnail() { | 65 function getCustomWallpaperThumbnail() { |
| 64 chrome.wallpaperPrivate.getOfflineWallpaperList('CUSTOM', | 66 chrome.wallpaperPrivate.getOfflineWallpaperList('CUSTOM', |
| 65 pass(function(lists) { | 67 pass(function(lists) { |
| 66 chrome.test.assertEq(1, lists.length); | 68 chrome.test.assertEq(1, lists.length); |
| 67 chrome.wallpaperPrivate.getThumbnail(lists[0], 'CUSTOM', | 69 chrome.wallpaperPrivate.getThumbnail(lists[0], 'CUSTOM', |
| 68 pass(function(data) { | 70 pass(function(data) { |
| 69 chrome.test.assertNoLastError(); | 71 chrome.test.assertNoLastError(); |
| 70 })); | 72 })); |
| 71 })); | 73 })); |
| 72 }, | 74 }, |
| 73 function setCustomJepgBadWallpaper() { | 75 function setCustomJepgBadWallpaper() { |
| 74 var url = "http://a.com:PORT/files/extensions/api_test" + | 76 var url = "http://a.com:PORT/files/extensions/api_test" + |
| 75 "/wallpaper_manager/test_bad.jpg"; | 77 "/wallpaper_manager/test_bad.jpg"; |
| 76 url = url.replace(/PORT/, config.testServer.port); | 78 url = url.replace(/PORT/, config.testServer.port); |
| 77 requestImage(url, function(requestStatus, response) { | 79 requestImage(url, function(requestStatus, response) { |
| 78 if (requestStatus === 200) { | 80 if (requestStatus === 200) { |
| 79 var badWallpaper = response; | 81 var badWallpaper = response; |
| 80 chrome.wallpaperPrivate.setCustomWallpaper(badWallpaper, | 82 chrome.wallpaperPrivate.setCustomWallpaper(badWallpaper, |
| 81 'CENTER_CROPPED', fail(wallpaperStrings.invalidWallpaper)); | 83 'CENTER_CROPPED', false, '123', |
| 84 fail(wallpaperStrings.invalidWallpaper)); |
| 82 } else { | 85 } else { |
| 83 chrome.test.fail('Failed to load test_bad.jpg from local server.'); | 86 chrome.test.fail('Failed to load test_bad.jpg from local server.'); |
| 84 } | 87 } |
| 85 }); | 88 }); |
| 86 }, | 89 }, |
| 87 function setWallpaperFromFileSystem() { | 90 function setWallpaperFromFileSystem() { |
| 88 var url = "http://a.com:PORT/files/extensions/api_test" + | 91 var url = "http://a.com:PORT/files/extensions/api_test" + |
| 89 "/wallpaper_manager/test.jpg"; | 92 "/wallpaper_manager/test.jpg"; |
| 90 url = url.replace(/PORT/, config.testServer.port); | 93 url = url.replace(/PORT/, config.testServer.port); |
| 91 chrome.wallpaperPrivate.setWallpaperIfExist(url, 'CENTER_CROPPED', | 94 chrome.wallpaperPrivate.setWallpaperIfExist(url, 'CENTER_CROPPED', |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 chrome.wallpaperPrivate.getOfflineWallpaperList('ONLINE', | 134 chrome.wallpaperPrivate.getOfflineWallpaperList('ONLINE', |
| 132 pass(function(list) { | 135 pass(function(list) { |
| 133 chrome.test.assertEq('test.jpg', list[0]); | 136 chrome.test.assertEq('test.jpg', list[0]); |
| 134 chrome.test.assertEq('test1.jpg', list[1]); | 137 chrome.test.assertEq('test1.jpg', list[1]); |
| 135 })); | 138 })); |
| 136 })); | 139 })); |
| 137 })); | 140 })); |
| 138 } | 141 } |
| 139 ]); | 142 ]); |
| 140 }); | 143 }); |
| OLD | NEW |