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

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: IDL Capitalization Nit fixed 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..a68b47217f40b225f06cd083afce42ed1ff89ad9
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/system_indicator/test.js
@@ -0,0 +1,48 @@
+// 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.
+
+// 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
+// browser_tests.exe --gtest_filter=ExtensionApiTest.SystemIndicator
+
+// Due to the fact that browser tests are run in many different environments it
+// is not simple to be able to set the user input value before testing. For
+// these bvts we have chosen the minimal consistent tests.
+
+chrome.test.runTests([
+ function showAndHideNonexistentIcon() {
+ // Hide before show, just in case
+ chrome.experimental.systemIndicator.hide();
+ chrome.experimental.systemIndicator.show();
+ chrome.experimental.systemIndicator.hide();
+ chrome.test.succeed();
+ },
+ function setUrl() {
+ // Success in showing the icon?
+ chrome.experimental.systemIndicator.setURL('128.png');
+ chrome.test.succeed();
+ },
+ function setImageData() {
+ // create an image, turn it into a canvas, then set the icon.
+ var img = new Image(),
+ 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
+ img.onerror = function() {
+ console.error('Could not load icon \'' + path + '\'.');
+ chrome.test.fail();
+ };
+ img.onload = function() {
+ var canvas = document.createElement('canvas');
+ canvas.width = img.width;
+ canvas.height = img.height;
+
+ var canvas_context = canvas.getContext('2d');
+ canvas_context.clearRect(0, 0, canvas.width, canvas.height);
+ canvas_context.drawImage(img, 0, 0, canvas.width, canvas.height);
+ var imageData = canvas_context.getImageData(0, 0, canvas.width,
+ canvas.height);
+ chrome.experimental.systemIndicator.setImageData(imageData);
+ chrome.test.succeed();
+ };
+ img.src = path;
+ }
+]);

Powered by Google App Engine
This is Rietveld 408576698