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

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

Issue 2379573008: Add SetImageData api to chrome.clipboard. (Closed)
Patch Set: Address code review comments and add test cases. Created 4 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
OLDNEW
(Empty)
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Test clipboard extension api chrome.clipboard.onClipboardDataChanged event.
6
7 var testSuccessCount = 0;
8
9 function testSetImageDataClipboard(imageUrl, imageType, expectSucceed) {
10 var oReq = new XMLHttpRequest();
11 oReq.open("GET", imageUrl, true);
12 oReq.responseType = "arraybuffer";
13
14 oReq.onload = function (oEvent) {
15 var arrayBuffer = oReq.response;
16 var binaryString = '';
17
18 if (arrayBuffer) {
19 chrome.clipboard.setImageData(arrayBuffer, imageType, function() {
20 if (!chrome.runtime.lastError) {
Devlin 2016/12/09 15:23:51 Can't this big chunk just be chrome.test.assertEq(
jennyz 2016/12/14 01:15:36 Done.
21 if (expectSucceed)
22 chrome.test.succeed();
23 else
24 chrome.test.fail();
25 } else {
26 if (expectSucceed)
27 chrome.test.fail();
28 else
29 chrome.test.succeed();
30 }
31 testSuccessCount++;
32 chrome.test.sendMessage('test success ' + testSuccessCount);
Devlin 2016/12/09 15:23:51 why do we need these messages? The test system wi
jennyz 2016/12/14 01:15:36 Done.
33 });
34 } else {
35 chrome.test.fail('Failed to load the png image file');
36 }
37 };
38
39 oReq.send(null);
40 }
41
42 function testSavePngImageToClipboard(baseUrl) {
43 testSetImageDataClipboard(baseUrl + '/penguin.png', 'png', true);
Devlin 2016/12/09 15:23:52 Rietveld won't let me comment on the pictures, so
jennyz 2016/12/14 01:15:36 Good point. Changed to use the existing image file
Devlin 2016/12/16 02:26:15 I see we're still adding the other images, though?
jennyz 2016/12/19 07:01:36 The other images from copied from existing image f
Devlin 2016/12/19 23:08:22 Latest patch set: https://codereview.chromium.org/
jennyz 2016/12/20 22:16:54 I have removed the previously added image files.
44 }
45
46 function testSaveJpegImageToClipboard(baseUrl) {
47 testSetImageDataClipboard(baseUrl + '/panda.jpg', 'jpeg', true);
48 }
49
50 function testSaveBadImageData(baseUrl) {
51 testSetImageDataClipboard(baseUrl + '/star.gif', 'jpeg', false);
52 }
53
54 function bindTest(test, param) {
55 var result = test.bind(null, param);
56 result.generatedName = test.name;
57 return result;
58 }
59
60 chrome.test.getConfig(function(config) {
61 var baseUrl = 'http://localhost:' + config.testServer.port + '/extensions';
62 chrome.test.runTests([
63 bindTest(testSavePngImageToClipboard, baseUrl),
64 bindTest(testSaveJpegImageToClipboard, baseUrl),
65 bindTest(testSaveBadImageData, baseUrl)
66 ]);
67 })
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698