OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // This just tests the interface. It does not test for specific results, only | 5 // This just tests the interface. It does not test for specific results, only |
6 // that callbacks are correctly invoked, expected parameters are correct, | 6 // that callbacks are correctly invoked, expected parameters are correct, |
7 // and failures are detected. | 7 // and failures are detected. |
8 | 8 |
9 var kTestPrefName = 'download.default_directory'; | 9 var kTestPrefName = 'download.default_directory'; |
10 var kTestPrefValue = '/Downloads'; | 10 var kTestPrefValue = '/Downloads'; |
(...skipping 10 matching lines...) Expand all Loading... |
21 function setPref() { | 21 function setPref() { |
22 chrome.settingsPrivate.setPref( | 22 chrome.settingsPrivate.setPref( |
23 kTestPrefName, | 23 kTestPrefName, |
24 kTestPrefValue, | 24 kTestPrefValue, |
25 kTestPageId, | 25 kTestPageId, |
26 function(success) { | 26 function(success) { |
27 callbackResult(success); | 27 callbackResult(success); |
28 chrome.test.succeed(); | 28 chrome.test.succeed(); |
29 }); | 29 }); |
30 }, | 30 }, |
| 31 function setPref_CrOSSetting() { |
| 32 chrome.settingsPrivate.setPref( |
| 33 'cros.accounts.allowBWSI', |
| 34 false, |
| 35 kTestPageId, |
| 36 function(success) { |
| 37 callbackResult(success); |
| 38 chrome.test.succeed(); |
| 39 }); |
| 40 }, |
31 function getPref() { | 41 function getPref() { |
32 chrome.settingsPrivate.getPref( | 42 chrome.settingsPrivate.getPref( |
33 kTestPrefName, | 43 kTestPrefName, |
34 function(value) { | 44 function(value) { |
35 chrome.test.assertTrue(value !== null); | 45 chrome.test.assertTrue(value !== null); |
36 callbackResult(true); | 46 callbackResult(true); |
37 chrome.test.succeed(); | 47 chrome.test.succeed(); |
38 }); | 48 }); |
39 }, | 49 }, |
| 50 function getPref_CrOSSetting() { |
| 51 chrome.settingsPrivate.getPref( |
| 52 'cros.accounts.allowBWSI', |
| 53 function(value) { |
| 54 chrome.test.assertTrue(value !== null); |
| 55 callbackResult(true); |
| 56 chrome.test.succeed(); |
| 57 }); |
| 58 }, |
40 function getAllPrefs() { | 59 function getAllPrefs() { |
41 chrome.settingsPrivate.getAllPrefs( | 60 chrome.settingsPrivate.getAllPrefs( |
42 function(prefs) { | 61 function(prefs) { |
43 chrome.test.assertTrue(prefs.length > 0); | 62 chrome.test.assertTrue(prefs.length > 0); |
44 callbackResult(true); | 63 callbackResult(true); |
45 chrome.test.succeed(); | 64 chrome.test.succeed(); |
46 }); | 65 }); |
47 }, | 66 }, |
48 function onPrefsChanged() { | 67 function onPrefsChanged() { |
49 chrome.settingsPrivate.onPrefsChanged.addListener(function(prefs) { | 68 chrome.settingsPrivate.onPrefsChanged.addListener(function(prefs) { |
50 chrome.test.assertTrue(prefs.length > 0); | 69 chrome.test.assertTrue(prefs.length > 0); |
51 chrome.test.assertEq(kTestPrefName, prefs[0].key); | 70 chrome.test.assertEq(kTestPrefName, prefs[0].key); |
52 chrome.test.assertEq(kTestPrefValue, prefs[0].value); | 71 chrome.test.assertEq(kTestPrefValue, prefs[0].value); |
53 callbackResult(true); | 72 callbackResult(true); |
54 chrome.test.succeed(); | 73 chrome.test.succeed(); |
55 }); | 74 }); |
56 | 75 |
57 chrome.settingsPrivate.setPref( | 76 chrome.settingsPrivate.setPref( |
58 kTestPrefName, | 77 kTestPrefName, |
59 kTestPrefValue, | 78 kTestPrefValue, |
60 kTestPageId, | 79 kTestPageId, |
61 function() {}); | 80 function() {}); |
62 }, | 81 }, |
| 82 function onPrefsChanged_CrOSSetting() { |
| 83 chrome.settingsPrivate.onPrefsChanged.addListener(function(prefs) { |
| 84 chrome.test.assertTrue(prefs.length > 0); |
| 85 chrome.test.assertEq('cros.accounts.allowBWSI', prefs[0].key); |
| 86 chrome.test.assertEq(false, prefs[0].value); |
| 87 callbackResult(true); |
| 88 chrome.test.succeed(); |
| 89 }); |
| 90 |
| 91 chrome.settingsPrivate.setPref( |
| 92 'cros.accounts.allowBWSI', |
| 93 false, |
| 94 kTestPageId, |
| 95 function() {}); |
| 96 }, |
63 ]; | 97 ]; |
64 | 98 |
65 var testToRun = window.location.search.substring(1); | 99 var testToRun = window.location.search.substring(1); |
66 chrome.test.runTests(availableTests.filter(function(op) { | 100 chrome.test.runTests(availableTests.filter(function(op) { |
67 return op.name == testToRun; | 101 return op.name == testToRun; |
68 })); | 102 })); |
69 | 103 |
OLD | NEW |