Chromium Code Reviews| Index: chrome/test/data/extensions/api_test/clipboard/set_image_data/test.js |
| diff --git a/chrome/test/data/extensions/api_test/clipboard/set_image_data/test.js b/chrome/test/data/extensions/api_test/clipboard/set_image_data/test.js |
| index fc587c58b0cd0ed718ab8e130eaf8e063221626f..b2f0edc75daf9339f2b31ef181a06d97212b8088 100644 |
| --- a/chrome/test/data/extensions/api_test/clipboard/set_image_data/test.js |
| +++ b/chrome/test/data/extensions/api_test/clipboard/set_image_data/test.js |
| @@ -6,7 +6,8 @@ |
| var testSuccessCount = 0; |
| -function testSetImageDataClipboard(imageUrl, imageType, expectSucceed) { |
| +function testSetImageDataClipboard(imageUrl, imageType, additional_items, |
| + expectSucceed) { |
|
Devlin
2017/04/26 18:20:15
We should expand this to take some kind of expecte
jennyz
2017/05/16 18:22:03
Done.
|
| var oReq = new XMLHttpRequest(); |
| oReq.open('GET', imageUrl, true); |
| oReq.responseType = 'arraybuffer'; |
| @@ -16,7 +17,8 @@ function testSetImageDataClipboard(imageUrl, imageType, expectSucceed) { |
| var binaryString = ''; |
| if (arrayBuffer) { |
| - chrome.clipboard.setImageData(arrayBuffer, imageType, function() { |
| + chrome.clipboard.setImageData(arrayBuffer, imageType, |
| + additional_items, function() { |
| chrome.test.assertEq(expectSucceed, !chrome.runtime.lastError); |
| chrome.test.succeed(); |
| }); |
| @@ -29,15 +31,64 @@ function testSetImageDataClipboard(imageUrl, imageType, expectSucceed) { |
| } |
| function testSavePngImageToClipboard(baseUrl) { |
| - testSetImageDataClipboard(baseUrl + '/icon1.png', 'png', true); |
| + var additional_items = []; |
| + testSetImageDataClipboard( |
| + baseUrl + '/icon1.png', 'png', additional_items, true); |
| } |
| function testSaveJpegImageToClipboard(baseUrl) { |
| - testSetImageDataClipboard(baseUrl + '/test.jpg', 'jpeg', true); |
| + var additional_items = []; |
| + testSetImageDataClipboard( |
| + baseUrl + '/test.jpg', 'jpeg', additional_items, true); |
| } |
| function testSaveBadImageData(baseUrl) { |
| - testSetImageDataClipboard(baseUrl + '/redirect_target.gif', 'jpeg', false); |
| + var additional_items = []; |
| + testSetImageDataClipboard( |
| + baseUrl + '/redirect_target.gif', 'jpeg', additional_items, false); |
| +} |
| + |
| +function testSavePngImageWithAdditionalDataToClipboard(baseUrl) { |
| + var additional_items = []; |
| + var text_item = { |
| + type: 'text/plain', |
| + data: 'Hello, world' |
| + } |
| + var html_item = { |
| + type: 'text/html', |
| + data: '<b>This is an html markup</b>' |
| + } |
| + additional_items.push(text_item); |
| + additional_items.push(html_item); |
| + testSetImageDataClipboard( |
| + baseUrl + '/icon1.png', 'png', additional_items, true); |
| +} |
| + |
| +function testSavePngImageWithAdditionalDataToClipboardInvalidType(baseUrl) { |
| + var additional_items = []; |
| + var text_item = { |
| + type: 'text/css', |
| + data: 'Hello, world' |
| + } |
| + additional_items.push(text_item); |
| + testSetImageDataClipboard( |
| + baseUrl + '/icon1.png', 'png', additional_items, false); |
| +} |
| + |
| +function testSavePngImageWithAdditionalDataToClipboardDuplicateTypeItems(baseUrl) { |
| + var additional_items = []; |
| + var text_item1 = { |
| + type: 'text/plain', |
| + data: 'Hello, world' |
| + } |
| + var text_item2 = { |
| + type: 'text/plain', |
| + data: 'Another text item' |
| + } |
| + additional_items.push(text_item1); |
| + additional_items.push(text_item2); |
| + testSetImageDataClipboard( |
| + baseUrl + '/icon1.png', 'png', additional_items, false); |
| } |
| function bindTest(test, param) { |
| @@ -51,6 +102,10 @@ chrome.test.getConfig(function(config) { |
| chrome.test.runTests([ |
| bindTest(testSavePngImageToClipboard, baseUrl), |
| bindTest(testSaveJpegImageToClipboard, baseUrl), |
| - bindTest(testSaveBadImageData, baseUrl) |
| + bindTest(testSaveBadImageData, baseUrl), |
| + bindTest(testSavePngImageWithAdditionalDataToClipboard, baseUrl), |
| + bindTest(testSavePngImageWithAdditionalDataToClipboardInvalidType, baseUrl), |
| + bindTest(testSavePngImageWithAdditionalDataToClipboardDuplicateTypeItems, |
| + baseUrl) |
| ]); |
| }) |