|
1 | 1 | 'use strict'; |
2 | 2 |
|
3 | | -requireApp('communications/ftu/test/unit/mock_icc_helper.js'); |
4 | | -requireApp('communications/ftu/test/unit/mock_settings.js'); |
5 | | -requireApp('system/test/unit/mock_settings_listener.js'); |
| 3 | +requireApp('communications/shared/test/unit/mocks/mock_navigator_moz_settings.js'); |
6 | 4 | requireApp('communications/ftu/js/data_mobile.js'); |
7 | 5 |
|
8 | | -var mocksHelperForNavigation = new MocksHelper(['IccHelper']); |
9 | | -mocksHelperForNavigation.init(); |
10 | | - |
11 | 6 | suite('mobile data >', function() { |
12 | 7 | var realSettings, |
13 | | - settingKey = 'ril.data.enabled'; |
| 8 | + settingToggleKey = 'ril.data.enabled', |
| 9 | + settingApnKey = 'ril.data.apnSettings'; |
14 | 10 | var mocksHelper = mocksHelperForNavigation; |
15 | 11 |
|
16 | 12 | suiteSetup(function() { |
17 | 13 | realSettings = navigator.mozSettings; |
18 | | - navigator.mozSettings = MockNavigatorSettings; |
| 14 | + navigator.mozSettings = window.MockNavigatorSettings; |
19 | 15 |
|
20 | | - mocksHelper.suiteSetup(); |
21 | 16 | DataMobile.init(); |
22 | 17 | }); |
23 | 18 |
|
24 | 19 | suiteTeardown(function() { |
25 | 20 | navigator.mozSettings = realSettings; |
26 | 21 | realSettings = null; |
27 | | - |
28 | | - mocksHelper.suiteTeardown(); |
29 | 22 | }); |
30 | 23 |
|
31 | | - test('load APN values from file', function(done) { |
32 | | - var settingList = ['ril.data.apn', |
33 | | - 'ril.data.user', |
34 | | - 'ril.data.passwd', |
35 | | - 'ril.data.httpProxyHost', |
36 | | - 'ril.data.httpProxyPort']; |
37 | | - // real values taken from /shared/resources/apn.json, careful if changed |
38 | | - IccHelper.setProperty('iccInfo', {mcc: '214', mnc: '07'}); |
39 | | - for (var settingName in settingList) { |
40 | | - MockNavigatorSettings.mSettings[settingList[settingName]] = null; |
41 | | - } |
42 | | - |
43 | | - DataMobile.getAPN(function() { |
44 | | - for (var settingName in settingList) { |
45 | | - assert.isNotNull( |
46 | | - MockNavigatorSettings.mSettings[settingList[settingName]]); |
47 | | - } |
48 | | - done(); |
| 24 | + suite('Load APN values from database', function() { |
| 25 | + var result; |
| 26 | + |
| 27 | + setup(function(done) { |
| 28 | + window.MockNavigatorSettings.mSettings[settingApnKey] = '[[]]'; |
| 29 | + DataMobile.getAPN(function(response) { |
| 30 | + result = response; |
| 31 | + done(); |
| 32 | + }); |
| 33 | + }); |
| 34 | + |
| 35 | + test('Values are loaded', function() { |
| 36 | + assert.isNotNull(result); |
| 37 | + }); |
| 38 | + |
| 39 | + test('Observer is added before', function() { |
| 40 | + assert.isNotNull(window.MockNavigatorSettings.mObservers); |
| 41 | + }); |
| 42 | + |
| 43 | + test('Observer is removed after', function() { |
| 44 | + assert.isNotNull(window.MockNavigatorSettings.mRemovedObservers); |
49 | 45 | }); |
50 | 46 | }); |
51 | 47 |
|
52 | | - test('toggle status of mobile data', function(done) { |
53 | | - // real values taken from /shared/resources/apn.json, careful if changed |
54 | | - IccHelper.setProperty('iccInfo', {mcc: '214', mnc: '07'}); |
55 | | - DataMobile.toggle(false, function() { |
56 | | - assert.isFalse(MockNavigatorSettings.mSettings[settingKey]); |
57 | | - done(); |
| 48 | + suite('Toggle status of mobile data', function() { |
| 49 | + test('toggle status of mobile data', function(done) { |
| 50 | + DataMobile.toggle(true, function() { |
| 51 | + assert.isTrue(window.MockNavigatorSettings.mSettings[settingToggleKey]); |
| 52 | + done(); |
| 53 | + }); |
| 54 | + }); |
| 55 | + |
| 56 | + test('toggle status of mobile data', function(done) { |
| 57 | + DataMobile.toggle(false, function() { |
| 58 | + assert.isFalse( |
| 59 | + window.MockNavigatorSettings.mSettings[settingToggleKey] |
| 60 | + ); |
| 61 | + done(); |
| 62 | + }); |
58 | 63 | }); |
59 | 64 | }); |
60 | 65 |
|
|
0 commit comments