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