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 15 matching lines...) Expand all Loading... |
26 chrome.test.fail('An error thrown when requesting wallpaper.'); | 26 chrome.test.fail('An error thrown when requesting wallpaper.'); |
27 }; | 27 }; |
28 }; | 28 }; |
29 chrome.test.runTests([ | 29 chrome.test.runTests([ |
30 function getWallpaperStrings() { | 30 function getWallpaperStrings() { |
31 chrome.wallpaperPrivate.getStrings(pass(function(strings) { | 31 chrome.wallpaperPrivate.getStrings(pass(function(strings) { |
32 wallpaperStrings = strings; | 32 wallpaperStrings = strings; |
33 })); | 33 })); |
34 }, | 34 }, |
35 function setOnlineJpegWallpaper() { | 35 function setOnlineJpegWallpaper() { |
36 var url = "http://a.com:PORT/files/extensions/api_test" + | 36 var url = "http://a.com:PORT/extensions/api_test" + |
37 "/wallpaper_manager/test.jpg"; | 37 "/wallpaper_manager/test.jpg"; |
38 url = url.replace(/PORT/, config.testServer.port); | 38 url = url.replace(/PORT/, config.testServer.port); |
39 requestImage(url, function(requestStatus, response) { | 39 requestImage(url, function(requestStatus, response) { |
40 if (requestStatus === 200) { | 40 if (requestStatus === 200) { |
41 wallpaperJpeg = response; | 41 wallpaperJpeg = response; |
42 chrome.wallpaperPrivate.setWallpaper(wallpaperJpeg, | 42 chrome.wallpaperPrivate.setWallpaper(wallpaperJpeg, |
43 'CENTER_CROPPED', | 43 'CENTER_CROPPED', |
44 url, | 44 url, |
45 pass(function() { | 45 pass(function() { |
46 chrome.wallpaperPrivate.setCustomWallpaperLayout('CENTER', | 46 chrome.wallpaperPrivate.setCustomWallpaperLayout('CENTER', |
(...skipping 10 matching lines...) Expand all Loading... |
57 true, | 57 true, |
58 '123', | 58 '123', |
59 pass(function(thumbnail) { | 59 pass(function(thumbnail) { |
60 chrome.wallpaperPrivate.setCustomWallpaperLayout('CENTER', | 60 chrome.wallpaperPrivate.setCustomWallpaperLayout('CENTER', |
61 pass(function() { | 61 pass(function() { |
62 chrome.wallpaperPrivate.setCustomWallpaperLayout('STRETCH', pass()); | 62 chrome.wallpaperPrivate.setCustomWallpaperLayout('STRETCH', pass()); |
63 })); | 63 })); |
64 })); | 64 })); |
65 }, | 65 }, |
66 function setCustomPngWallpaper() { | 66 function setCustomPngWallpaper() { |
67 var url = "http://a.com:PORT/files/extensions/api_test" + | 67 var url = "http://a.com:PORT/extensions/api_test" + |
68 "/wallpaper_manager/test.png"; | 68 "/wallpaper_manager/test.png"; |
69 url = url.replace(/PORT/, config.testServer.port); | 69 url = url.replace(/PORT/, config.testServer.port); |
70 requestImage(url, function(requestStatus, response) { | 70 requestImage(url, function(requestStatus, response) { |
71 if (requestStatus === 200) { | 71 if (requestStatus === 200) { |
72 wallpaperPng = response; | 72 wallpaperPng = response; |
73 chrome.wallpaperPrivate.setCustomWallpaper(wallpaperPng, | 73 chrome.wallpaperPrivate.setCustomWallpaper(wallpaperPng, |
74 'CENTER_CROPPED', | 74 'CENTER_CROPPED', |
75 true, | 75 true, |
76 '123', | 76 '123', |
77 pass(function(thumbnail) { | 77 pass(function(thumbnail) { |
78 chrome.wallpaperPrivate.setCustomWallpaperLayout('CENTER', | 78 chrome.wallpaperPrivate.setCustomWallpaperLayout('CENTER', |
79 pass(function() { | 79 pass(function() { |
80 chrome.wallpaperPrivate.setCustomWallpaperLayout('STRETCH', | 80 chrome.wallpaperPrivate.setCustomWallpaperLayout('STRETCH', |
81 pass()); | 81 pass()); |
82 })); | 82 })); |
83 })); | 83 })); |
84 } else { | 84 } else { |
85 chrome.test.fail('Failed to load test.png from local server.'); | 85 chrome.test.fail('Failed to load test.png from local server.'); |
86 } | 86 } |
87 }); | 87 }); |
88 }, | 88 }, |
89 function setCustomJepgBadWallpaper() { | 89 function setCustomJepgBadWallpaper() { |
90 var url = "http://a.com:PORT/files/extensions/api_test" + | 90 var url = "http://a.com:PORT/extensions/api_test" + |
91 "/wallpaper_manager/test_bad.jpg"; | 91 "/wallpaper_manager/test_bad.jpg"; |
92 url = url.replace(/PORT/, config.testServer.port); | 92 url = url.replace(/PORT/, config.testServer.port); |
93 requestImage(url, function(requestStatus, response) { | 93 requestImage(url, function(requestStatus, response) { |
94 if (requestStatus === 200) { | 94 if (requestStatus === 200) { |
95 var badWallpaper = response; | 95 var badWallpaper = response; |
96 chrome.wallpaperPrivate.setCustomWallpaper(badWallpaper, | 96 chrome.wallpaperPrivate.setCustomWallpaper(badWallpaper, |
97 'CENTER_CROPPED', false, '123', | 97 'CENTER_CROPPED', false, '123', |
98 fail(wallpaperStrings.invalidWallpaper)); | 98 fail(wallpaperStrings.invalidWallpaper)); |
99 } else { | 99 } else { |
100 chrome.test.fail('Failed to load test_bad.jpg from local server.'); | 100 chrome.test.fail('Failed to load test_bad.jpg from local server.'); |
101 } | 101 } |
102 }); | 102 }); |
103 }, | 103 }, |
104 function setWallpaperFromFileSystem() { | 104 function setWallpaperFromFileSystem() { |
105 var url = "http://a.com:PORT/files/extensions/api_test" + | 105 var url = "http://a.com:PORT/extensions/api_test" + |
106 "/wallpaper_manager/test.jpg"; | 106 "/wallpaper_manager/test.jpg"; |
107 url = url.replace(/PORT/, config.testServer.port); | 107 url = url.replace(/PORT/, config.testServer.port); |
108 chrome.wallpaperPrivate.setWallpaperIfExists(url, 'CENTER_CROPPED', | 108 chrome.wallpaperPrivate.setWallpaperIfExists(url, 'CENTER_CROPPED', |
109 'ONLINE', | 109 'ONLINE', |
110 pass(function(exists) { | 110 pass(function(exists) { |
111 chrome.test.assertTrue(exists); | 111 chrome.test.assertTrue(exists); |
112 chrome.wallpaperPrivate.setWallpaperIfExists( | 112 chrome.wallpaperPrivate.setWallpaperIfExists( |
113 'http://dummyurl/test1.jpg', 'CENTER_CROPPED', 'ONLINE', | 113 'http://dummyurl/test1.jpg', 'CENTER_CROPPED', 'ONLINE', |
114 fail('Failed to set wallpaper test1.jpg from file system.')); | 114 fail('Failed to set wallpaper test1.jpg from file system.')); |
115 })); | 115 })); |
116 }, | 116 }, |
117 function getAndSetThumbnail() { | 117 function getAndSetThumbnail() { |
118 var url = "http://a.com:PORT/files/extensions/api_test" + | 118 var url = "http://a.com:PORT/extensions/api_test" + |
119 "/wallpaper_manager/test.jpg"; | 119 "/wallpaper_manager/test.jpg"; |
120 url = url.replace(/PORT/, config.testServer.port); | 120 url = url.replace(/PORT/, config.testServer.port); |
121 chrome.wallpaperPrivate.getThumbnail(url, 'ONLINE', pass(function(data) { | 121 chrome.wallpaperPrivate.getThumbnail(url, 'ONLINE', pass(function(data) { |
122 chrome.test.assertNoLastError(); | 122 chrome.test.assertNoLastError(); |
123 if (data) { | 123 if (data) { |
124 chrome.test.fail('Thumbnail is not found. getThumbnail should not ' + | 124 chrome.test.fail('Thumbnail is not found. getThumbnail should not ' + |
125 'return any data.'); | 125 'return any data.'); |
126 } | 126 } |
127 chrome.wallpaperPrivate.saveThumbnail(url, wallpaperJpeg, | 127 chrome.wallpaperPrivate.saveThumbnail(url, wallpaperJpeg, |
128 pass(function() { | 128 pass(function() { |
(...skipping 21 matching lines...) Expand all Loading... |
150 chrome.wallpaperPrivate.getOfflineWallpaperList('ONLINE', | 150 chrome.wallpaperPrivate.getOfflineWallpaperList('ONLINE', |
151 pass(function(list) { | 151 pass(function(list) { |
152 chrome.test.assertEq('test.jpg', list[0]); | 152 chrome.test.assertEq('test.jpg', list[0]); |
153 chrome.test.assertEq('test1.jpg', list[1]); | 153 chrome.test.assertEq('test1.jpg', list[1]); |
154 })); | 154 })); |
155 })); | 155 })); |
156 })); | 156 })); |
157 } | 157 } |
158 ]); | 158 ]); |
159 }); | 159 }); |
OLD | NEW |