Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2010 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 // Idle api test for Chrome. | |
|
dcheng
2012/11/13 00:52:19
This comment should probably be updated =)
dewittj
2012/11/13 06:58:54
Done
| |
| 6 // browser_tests.exe --gtest_filter=ExtensionApiTest.SystemIndicator | |
| 7 | |
| 8 // Due to the fact that browser tests are run in many different environments it | |
| 9 // is not simple to be able to set the user input value before testing. For | |
| 10 // these bvts we have chosen the minimal consistent tests. | |
| 11 | |
| 12 chrome.test.runTests([ | |
| 13 function showAndHideNonexistentIcon() { | |
| 14 // Hide before show, just in case | |
| 15 chrome.experimental.systemIndicator.hide(); | |
| 16 chrome.experimental.systemIndicator.show(); | |
| 17 chrome.experimental.systemIndicator.hide(); | |
| 18 chrome.test.succeed(); | |
| 19 }, | |
| 20 function setUrl() { | |
| 21 // Success in showing the icon? | |
| 22 chrome.experimental.systemIndicator.setURL('128.png'); | |
| 23 chrome.test.succeed(); | |
| 24 }, | |
| 25 function setImageData() { | |
| 26 // create an image, turn it into a canvas, then set the icon. | |
| 27 var img = new Image(), | |
| 28 path = '128.png'; | |
|
dcheng
2012/11/13 00:52:19
Nit: I'd probably just say var path = here as well
dewittj
2012/11/13 06:58:54
I've found that in JS, the "single var statement a
| |
| 29 img.onerror = function() { | |
| 30 console.error('Could not load icon \'' + path + '\'.'); | |
| 31 chrome.test.fail(); | |
| 32 }; | |
| 33 img.onload = function() { | |
| 34 var canvas = document.createElement('canvas'); | |
| 35 canvas.width = img.width; | |
| 36 canvas.height = img.height; | |
| 37 | |
| 38 var canvas_context = canvas.getContext('2d'); | |
| 39 canvas_context.clearRect(0, 0, canvas.width, canvas.height); | |
| 40 canvas_context.drawImage(img, 0, 0, canvas.width, canvas.height); | |
| 41 var imageData = canvas_context.getImageData(0, 0, canvas.width, | |
| 42 canvas.height); | |
| 43 chrome.experimental.systemIndicator.setImageData(imageData); | |
| 44 chrome.test.succeed(); | |
| 45 }; | |
| 46 img.src = path; | |
| 47 } | |
| 48 ]); | |
| OLD | NEW |