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

Unified Diff: chrome/test/data/extensions/api_test/chromeos_info_private/background.js

Issue 8725019: Move another bunch of extension API tests to manifest_version 2. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 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/chromeos_info_private/background.js
===================================================================
--- chrome/test/data/extensions/api_test/chromeos_info_private/background.js (revision 0)
+++ chrome/test/data/extensions/api_test/chromeos_info_private/background.js (revision 0)
@@ -0,0 +1,60 @@
+// Copyright (c) 2011 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.
+
+var pass = chrome.test.callbackPass;
+var fail = chrome.test.callbackFail;
+
+function getTestFunctionFor(keys, fails) {
+ return function generatedTest () {
+ // Debug.
+ console.log("keys: " + keys + "; fails: " + fails);
+
+ chrome.chromeosInfoPrivate.get(
+ keys,
+ pass(
+ function(values) {
+ for (var i = 0; i < keys.length; ++i) {
+ // Debug
+ if (keys[i] in values) {
+ console.log(" values['" + keys[i] + "'] = " +
+ values[keys[i]]);
+ } else {
+ console.log(" " + keys[i] + " is missing in values");
+ }
+
+ chrome.test.assertEq(fails.indexOf(keys[i]) == -1,
+ keys[i] in values);
+ }
+ }
+ )
+ );
+ }
+}
+
+// Automatically generates tests for the given possible keys. Note, this
+// tests do not check return value, only the fact that it is presented.
+function generateTestsForKeys(keys) {
+ var tests = [];
+ // Test with all the keys at one.
+ tests.push(getTestFunctionFor(keys, []));
+ // Tests with key which hasn't corresponding value.
+ var noValueKey = "noValueForThisKey";
+ tests.push(getTestFunctionFor([noValueKey], [noValueKey]));
+
+ if (keys.length > 1) {
+ // Tests with the separate keys.
+ for (var i = 0; i < keys.length; ++i) {
+ tests.push(getTestFunctionFor([keys[i]], []));
+ }
+ }
+ if (keys.length >= 2) {
+ tests.push(getTestFunctionFor([keys[0], keys[1]], []));
+ tests.push(getTestFunctionFor([keys[0], noValueKey, keys[1]],
+ [noValueKey]));
+ }
+ return tests;
+}
+
+var tests = generateTestsForKeys(["hwid", "homeProvider", "initialLocale"])
+chrome.test.runTests(tests);

Powered by Google App Engine
This is Rietveld 408576698