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. |
| 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'; |
| 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 |