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

Side by Side Diff: chrome/test/data/extensions/api_test/chromeos_info_private/background.html

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 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 <script> 1 <!--
2 var pass = chrome.test.callbackPass; 2 * Copyright (c) 2011 The Chromium Authors. All rights reserved. Use of this
3 var fail = chrome.test.callbackFail; 3 * source code is governed by a BSD-style license that can be found in the
4 4 * LICENSE file.
5 function getTestFunctionFor(keys, fails) { 5 -->
6 return function generatedTest () { 6 <script src="background.js"></script>
7 // Debug.
8 console.log("keys: " + keys + "; fails: " + fails);
9
10 chrome.chromeosInfoPrivate.get(
11 keys,
12 pass(
13 function(values) {
14 for (var i = 0; i < keys.length; ++i) {
15 // Debug
16 if (keys[i] in values) {
17 console.log(" values['" + keys[i] + "'] = " +
18 values[keys[i]]);
19 } else {
20 console.log(" " + keys[i] + " is missing in values");
21 }
22
23 chrome.test.assertEq(fails.indexOf(keys[i]) == -1,
24 keys[i] in values);
25 }
26 }
27 )
28 );
29 }
30 }
31
32 // Automatically generates tests for the given possible keys. Note, this
33 // tests do not check return value, only the fact that it is presented.
34 function generateTestsForKeys(keys) {
35 var tests = [];
36 // Test with all the keys at one.
37 tests.push(getTestFunctionFor(keys, []));
38 // Tests with key which hasn't corresponding value.
39 var noValueKey = "noValueForThisKey";
40 tests.push(getTestFunctionFor([noValueKey], [noValueKey]));
41
42 if (keys.length > 1) {
43 // Tests with the separate keys.
44 for (var i = 0; i < keys.length; ++i) {
45 tests.push(getTestFunctionFor([keys[i]], []));
46 }
47 }
48 if (keys.length >= 2) {
49 tests.push(getTestFunctionFor([keys[0], keys[1]], []));
50 tests.push(getTestFunctionFor([keys[0], noValueKey, keys[1]],
51 [noValueKey]));
52 }
53 return tests;
54 }
55
56 var tests = generateTestsForKeys(["hwid", "homeProvider", "initialLocale"])
57 chrome.test.runTests(tests);
58 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698