OLD | NEW |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 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 // Content settings API test | 5 // Content settings API test |
6 // Run with browser_tests --gtest_filter=ExtensionApiTest.DataReductionProxy | 6 // Run with browser_tests --gtest_filter=ExtensionApiTest.DataReductionProxy |
7 | 7 |
8 var drp = chrome.dataReductionProxy; | 8 var dataReductionProxy = chrome.dataReductionProxy; |
| 9 var privatePreferences = chrome.preferencesPrivate; |
9 chrome.test.runTests([ | 10 chrome.test.runTests([ |
10 function getDrpPrefs() { | 11 function getDrpPrefs() { |
11 drp.spdyProxyEnabled.get({}, chrome.test.callbackPass( | 12 dataReductionProxy.spdyProxyEnabled.get({}, chrome.test.callbackPass( |
12 function(result) { | 13 function(result) { |
13 chrome.test.assertEq( | 14 chrome.test.assertEq( |
14 { | 15 { |
15 'value': false, | 16 'value': false, |
16 'levelOfControl': 'controllable_by_this_extension' | 17 'levelOfControl': 'controllable_by_this_extension' |
17 }, | 18 }, |
18 result); | 19 result); |
19 })); | 20 })); |
20 drp.dataReductionDailyContentLength.get({}, chrome.test.callbackPass( | 21 dataReductionProxy.dataReductionDailyContentLength.get({}, |
21 function(result) { | 22 chrome.test.callbackPass(function(result) { |
22 chrome.test.assertEq( | 23 chrome.test.assertEq( |
23 { | 24 { |
24 'value': [], | 25 'value': [], |
25 'levelOfControl': 'controllable_by_this_extension' | 26 'levelOfControl': 'controllable_by_this_extension' |
26 }, | 27 }, |
27 result); | 28 result); |
28 })); | 29 })); |
29 drp.dataReductionDailyReceivedLength.get({}, chrome.test.callbackPass( | 30 dataReductionProxy.dataReductionDailyReceivedLength.get({}, |
30 function(result) { | 31 chrome.test.callbackPass(function(result) { |
31 chrome.test.assertEq( | 32 chrome.test.assertEq( |
32 { | 33 { |
33 'value': [], | 34 'value': [], |
34 'levelOfControl': 'controllable_by_this_extension' | 35 'levelOfControl': 'controllable_by_this_extension' |
35 }, | 36 }, |
36 result); | 37 result); |
37 })); | 38 })); |
38 drp.dataReductionUpdateDailyLengths.get({}, chrome.test.callbackPass( | 39 privatePreferences.dataReductionUpdateDailyLengths.get({}, |
39 function(result) { | 40 chrome.test.callbackPass(function(result) { |
40 chrome.test.assertEq( | 41 chrome.test.assertEq( |
41 { | 42 { |
42 'value': false, | 43 'value': false |
43 'levelOfControl': 'controllable_by_this_extension' | |
44 }, | 44 }, |
45 result); | 45 result); |
46 })); | 46 })); |
47 }, | 47 }, |
48 function updateDailyLengths() { | 48 function updateDailyLengths() { |
49 drp.dataReductionDailyContentLength.onChange.addListener( | 49 dataReductionProxy.dataReductionDailyContentLength.onChange.addListener( |
50 confirmDailyContentLength); | 50 confirmDailyContentLength); |
51 drp.dataReductionDailyReceivedLength.onChange.addListener( | 51 dataReductionProxy.dataReductionDailyReceivedLength.onChange.addListener( |
52 confirmRecievedLength); | 52 confirmRecievedLength); |
53 | 53 |
54 // Trigger calls to confirmDailyContentLength.onChange and | 54 // Trigger calls to confirmDailyContentLength.onChange and |
55 // dataReductionDailyReceivedLength.onChange listeners. | 55 // dataReductionDailyReceivedLength.onChange listeners. |
56 drp.spdyProxyEnabled.set({ 'value': true }); | 56 dataReductionProxy.spdyProxyEnabled.set({ 'value': true }); |
57 drp.dataReductionUpdateDailyLengths.set({'value': true}); | 57 privatePreferences.dataReductionUpdateDailyLengths.set({'value': true}); |
58 | 58 |
59 // Helper methods. | 59 // Helper methods. |
60 var expectedDailyLengths = []; | 60 var expectedDailyLengths = []; |
61 for (var i = 0; i < 60; i++) { | 61 for (var i = 0; i < 60; i++) { |
62 expectedDailyLengths[i] = '0'; | 62 expectedDailyLengths[i] = '0'; |
63 } | 63 } |
64 function confirmRecievedLength() { | 64 function confirmRecievedLength() { |
65 drp.dataReductionDailyReceivedLength.get({}, | 65 dataReductionProxy.dataReductionDailyReceivedLength.get({}, |
66 chrome.test.callbackPass(function(result) { | 66 chrome.test.callbackPass(function(result) { |
67 chrome.test.assertEq( | 67 chrome.test.assertEq( |
68 { | 68 { |
69 'value': expectedDailyLengths , | 69 'value': expectedDailyLengths , |
70 'levelOfControl': 'controllable_by_this_extension' | 70 'levelOfControl': 'controllable_by_this_extension' |
71 }, | 71 }, |
72 result); | 72 result); |
73 })); | 73 })); |
74 } | 74 privatePreferences.dataReductionUpdateDailyLengths.get({}, |
75 function confirmDailyContentLength() { | |
76 drp.dataReductionDailyContentLength.get({}, | |
77 chrome.test.callbackPass(function(result) { | 75 chrome.test.callbackPass(function(result) { |
78 chrome.test.assertEq( | 76 chrome.test.assertEq( |
79 { | 77 { |
| 78 'value': false |
| 79 }, |
| 80 result); |
| 81 })); |
| 82 } |
| 83 function confirmDailyContentLength() { |
| 84 dataReductionProxy.dataReductionDailyContentLength.get({}, |
| 85 chrome.test.callbackPass(function(result) { |
| 86 chrome.test.assertEq( |
| 87 { |
80 'value': expectedDailyLengths , | 88 'value': expectedDailyLengths , |
81 'levelOfControl': 'controllable_by_this_extension' | 89 'levelOfControl': 'controllable_by_this_extension' |
82 }, | 90 }, |
83 result); | 91 result); |
84 })); | 92 })); |
| 93 privatePreferences.dataReductionUpdateDailyLengths.get({}, |
| 94 chrome.test.callbackPass(function(result) { |
| 95 chrome.test.assertEq( |
| 96 { |
| 97 'value': false |
| 98 }, |
| 99 result); |
| 100 })); |
85 } | 101 } |
86 } | 102 } |
87 ]); | 103 ]); |
OLD | NEW |