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

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

Issue 2314313002: Add sessionType and playStoreStatus to chromeosInfoPrivate. (Closed)
Patch Set: Created 4 years, 3 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
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
Devlin 2016/09/06 23:04:53 Where did these tests go?
Rahul Chaturvedi 2016/09/06 23:19:35 Uploaded the missing test files.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 var pass = chrome.test.callbackPass;
6 var fail = chrome.test.callbackFail;
7
8 function getTestFunctionFor(keys, fails) {
9 return function generatedTest () {
10 // Debug.
11 console.warn('keys: ' + keys + '; fails: ' + fails);
12
13 chrome.chromeosInfoPrivate.get(
14 keys,
15 pass(
16 function(values) {
17 for (var i = 0; i < keys.length; ++i) {
18 // Debug
19 if (keys[i] in values) {
20 console.log(' values["' + keys[i] + '"] = ' +
21 values[keys[i]]);
22 } else {
23 console.log(' ' + keys[i] + ' is missing in values');
24 }
25
26 chrome.test.assertEq(fails.indexOf(keys[i]) == -1,
27 keys[i] in values);
28 }
29 }
30 )
31 );
32 }
33 }
34
35 // Automatically generates tests for the given possible keys. Note, this
36 // tests do not check return value, only the fact that it is presented.
37 function generateTestsForKeys(keys) {
38 var tests = [];
39 // Test with all the keys at one.
40 tests.push(getTestFunctionFor(keys, []));
41 // Tests with key which hasn't corresponding value.
42 var noValueKey = 'noValueForThisKey';
43 tests.push(getTestFunctionFor([noValueKey], [noValueKey]));
44
45 if (keys.length > 1) {
46 // Tests with the separate keys.
47 for (var i = 0; i < keys.length; ++i) {
48 tests.push(getTestFunctionFor([keys[i]], []));
49 }
50 }
51 if (keys.length >= 2) {
52 tests.push(getTestFunctionFor([keys[0], keys[1]], []));
53 tests.push(getTestFunctionFor([keys[0], noValueKey, keys[1]],
54 [noValueKey]));
55 }
56 return tests;
57 }
58
59 function timezoneSetTest() {
60 chrome.chromeosInfoPrivate.set('timezone', 'Pacific/Kiritimati');
61 chrome.chromeosInfoPrivate.get(
62 ['timezone'],
63 pass(
64 function(values) {
65 chrome.test.assertEq(values['timezone'],
66 'Pacific/Kiritimati');
67 }
68 ));
69 }
70
71 function prefsTest() {
72 chrome.chromeosInfoPrivate.set('a11yLargeCursorEnabled', true);
73 chrome.chromeosInfoPrivate.set('a11yStickyKeysEnabled', true);
74 chrome.chromeosInfoPrivate.set('a11ySpokenFeedbackEnabled', true);
75 chrome.chromeosInfoPrivate.set('a11yHighContrastEnabled', true);
76 chrome.chromeosInfoPrivate.set('a11yScreenMagnifierEnabled', true);
77 chrome.chromeosInfoPrivate.set('a11yAutoClickEnabled', true);
78 chrome.chromeosInfoPrivate.set('a11yVirtualKeyboardEnabled', true);
79 chrome.chromeosInfoPrivate.set('sendFunctionKeys', true);
80 chrome.chromeosInfoPrivate.get(
81 ['a11yLargeCursorEnabled',
82 'a11yStickyKeysEnabled',
83 'a11ySpokenFeedbackEnabled',
84 'a11yHighContrastEnabled',
85 'a11yScreenMagnifierEnabled',
86 'a11yAutoClickEnabled',
87 'a11yVirtualKeyboardEnabled',
88 'sendFunctionKeys'],
89 pass(
90 function(values) {
91 chrome.test.assertEq(values['a11yLargeCursorEnabled'], true);
92 chrome.test.assertEq(values['a11yStickyKeysEnabled'], true);
93 chrome.test.assertEq(values['a11ySpokenFeedbackEnabled'], true);
94 chrome.test.assertEq(values['a11yHighContrastEnabled'], true);
95 chrome.test.assertEq(values['a11yScreenMagnifierEnabled'], true);
96 chrome.test.assertEq(values['a11yAutoClickEnabled'], true);
97 chrome.test.assertEq(values['a11yVirtualKeyboardEnabled'], true);
98 chrome.test.assertEq(values['sendFunctionKeys'], true);
99 }
100 ));
101 }
102
103 // Run generated chrome.chromeosInfoPrivate.get() tests.
104 var tests = generateTestsForKeys(['hwid',
105 'customizationId',
106 'homeProvider',
107 'initialLocale',
108 'board',
109 'isOwner',
110 'clientId',
111 'a11yLargeCursorEnabled',
112 'a11yStickyKeysEnabled',
113 'a11ySpokenFeedbackEnabled',
114 'a11yHighContrastEnabled',
115 'a11yScreenMagnifierEnabled',
116 'a11yAutoClickEnabled',
117 'a11yVirtualKeyboardEnabled',
118 'sendFunctionKeys',
119 'timezone',
120 'supportedTimezones'])
121
122 // Add chrome.chromeosInfoPrivate.set() test.
123 tests.push(timezoneSetTest);
124 tests.push(prefsTest);
125
126 chrome.test.runTests(tests);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698