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

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

Issue 6995105: Expose initial_locale via chrome.chromeosInfoPrivate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use initial locale from settings Created 9 years, 6 months 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
« no previous file with comments | « chrome/common/extensions/api/extension_api.json ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <script> 1 <script>
2 var pass = chrome.test.callbackPass; 2 var pass = chrome.test.callbackPass;
3 var fail = chrome.test.callbackFail; 3 var fail = chrome.test.callbackFail;
4 4
5 function getTestFunctionFor(keys, fails) { 5 function getTestFunctionFor(keys, fails) {
6 return function generatedTest () { 6 return function generatedTest () {
7 // Debug. 7 // Debug.
8 console.log("keys: " + keys + ", fails: " + fails); 8 console.log("keys: " + keys + "; fails: " + fails);
9 9
10 chrome.chromeosInfoPrivate.get( 10 chrome.chromeosInfoPrivate.get(
11 keys, 11 keys,
12 pass(function(values) { 12 pass(
13 // Debug 13 function(values) {
14 console.log("values: ", values); 14 for (var i = 0; i < keys.length; ++i) {
15 for (var i = 0; i < keys.length; ++i) 15 // Debug
16 chrome.test.assertEq(!(i in fails), keys[i] in values); 16 if (keys[i] in values) {
17 })); 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 );
18 } 29 }
19 } 30 }
20 31
21 // Automatically generates tests for the given possible keys. Note, this 32 // Automatically generates tests for the given possible keys. Note, this
22 // tests do not check return value, only the fact that it is presented. 33 // tests do not check return value, only the fact that it is presented.
23 function generateTestsForKeys(keys) { 34 function generateTestsForKeys(keys) {
24 var tests = []; 35 var tests = [];
25 // Test with all the keys at one. 36 // Test with all the keys at one.
26 tests.push(getTestFunctionFor(keys, [])); 37 tests.push(getTestFunctionFor(keys, []));
27 // Tests with key which hasn't corresponding value. 38 // Tests with key which hasn't corresponding value.
28 var noValueKey = "no-value-for-this-key"; 39 var noValueKey = "noValueForThisKey";
29 tests.push(getTestFunctionFor([noValueKey], [0])); 40 tests.push(getTestFunctionFor([noValueKey], [noValueKey]));
30 41
31 if (keys.length > 1) { 42 if (keys.length > 1) {
32 // Tests with the separate keys. 43 // Tests with the separate keys.
33 for (var i = 0; i < keys.length; ++i) { 44 for (var i = 0; i < keys.length; ++i) {
34 tests.push(getTestFunctionFor([keys[i]], [])); 45 tests.push(getTestFunctionFor([keys[i]], []));
35 } 46 }
36 } 47 }
37 if (keys.length > 2) { 48 if (keys.length >= 2) {
38 tests.push(getTestFunctionFor([keys[0], keys[1]], [])); 49 tests.push(getTestFunctionFor([keys[0], keys[1]], []));
39 tests.push(getTestFunctionFor([keys[0], noValueKey, keys[1]], [1])); 50 tests.push(getTestFunctionFor([keys[0], noValueKey, keys[1]],
51 [noValueKey]));
40 } 52 }
41 return tests; 53 return tests;
42 } 54 }
43 55
44 var tests = generateTestsForKeys(["hwid", "homeProvider"]) 56 var tests = generateTestsForKeys(["hwid", "homeProvider", "initialLocale"])
45 chrome.test.runTests(tests); 57 chrome.test.runTests(tests);
46 </script> 58 </script>
OLDNEW
« no previous file with comments | « chrome/common/extensions/api/extension_api.json ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698