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

Unified Diff: chrome/test/data/extensions/api_test/system_indicator/test.js

Issue 11361189: Initial skeleton for System Indicator API (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Add manifest parsing and integrate with extension action api handlers. Created 8 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/extensions/api_test/system_indicator/test.js
diff --git a/chrome/test/data/extensions/api_test/system_indicator/test.js b/chrome/test/data/extensions/api_test/system_indicator/test.js
new file mode 100644
index 0000000000000000000000000000000000000000..067b34c8f4ee4eca08364a8c5d1a31dfa282176e
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/system_indicator/test.js
@@ -0,0 +1,76 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// System indicator test for Chrome.
+// browser_tests.exe --gtest_filter=ExtensionApiTest.SystemIndicator
+
+var callback = function() {
+ if (chrome.runtime.lastError) {
+ console.log('Error detected:' + chrome.runtime.lastError);
+ chrome.test.fail();
+ } else {
+ chrome.test.succeed();
+ }
+};
+
not at google - send to devlin 2012/11/21 23:39:23 I'm not really sure what the added value of these
dewittj 2012/11/26 18:32:58 Okay, I'll simplify the tests so that it just trie
+chrome.test.runTests([
+ function enableAndDisableNonexistentIcon() {
+ // Disable before enable, just in case.
+ chrome.systemIndicator.disable();
+ chrome.systemIndicator.enable();
+ chrome.systemIndicator.disable();
+ chrome.test.succeed();
+ },
+
+ // TODO(dewittj) Add binary files and enable these tests.
+ // function setUrl() {
+ // chrome.systemIndicator.setIcon({path: 'sample-19.png'}, callback);
+ // },
+ // function setMultiUrl() {
+ // var multiUrl = { '19': 'sample-19.png', '38': 'sample-38.png'};
+ // chrome.systemIndicator.setIcon({path: multiUrl}, callback);
+ // },
+
+ function setImageData() {
+ // Create a canvas, then set the icon using it.
+ var canvas = document.createElement('canvas');
+ canvas.width = 20;
+ canvas.height = 20;
+
+ var canvas_context = canvas.getContext('2d');
+ canvas_context.clearRect(0, 0, 20, 20);
+ canvas_context.fillStyle = '#00FF00';
+ canvas_context.fillRect(5, 5, 15, 15);
+ var data = canvas_context.getImageData(0, 0, 19, 19);
+ chrome.systemIndicator.setIcon({ imageData: data }, callback);
+ },
+ function setMultiImageData() {
+ // Create a canvas, then set the icon using it, and pass in multiple scales.
+ var canvas = document.createElement('canvas');
+ canvas.width = 20;
+ canvas.height = 20;
+
+ var canvas_context = canvas.getContext('2d');
+ canvas_context.clearRect(0, 0, 40, 40);
+ canvas_context.fillStyle = '#00FF00';
+ canvas_context.fillRect(5, 5, 15, 15);
+ var data = canvas_context.getImageData(0, 0, 19, 19);
+ var data2x = canvas_context.getImageData(0, 0, 38, 38);
+ var multiImageData = {
+ '19': data,
+ '38': data2x
+ };
+ chrome.systemIndicator.setIcon({ imageData: multiImageData }, callback);
+ },
+ function setEmptyImageData() {
+ var ok = false;
+ try {
+ chrome.systemIndicator.setIcon({});
+ } catch (e) {
+ chrome.test.succeed();
+ return;
+ }
+ chrome.test.fail();
+ }
+]);

Powered by Google App Engine
This is Rietveld 408576698