diff --git a/apps/costcontrol/index.html b/apps/costcontrol/index.html index 9942aefa8e97..201c19165895 100644 --- a/apps/costcontrol/index.html +++ b/apps/costcontrol/index.html @@ -76,13 +76,6 @@ - - - - - - - diff --git a/apps/costcontrol/js/common.js b/apps/costcontrol/js/common.js index 22b9fe322079..a6f5a43d1c90 100755 --- a/apps/costcontrol/js/common.js +++ b/apps/costcontrol/js/common.js @@ -71,23 +71,6 @@ var Common = { 'app://search.gaiamobile.org/manifest.webapp' ], - SYSTEM_MANIFEST: 'app://system.gaiamobile.org/manifest.webapp', - - BROWSER_APP: { - manifestURL: 'app://browser.gaiamobile.org/manifest.webapp', - origin: '', - manifest: { - icons: { - '84': '/shared/resources/branding/browser_84.png', - '126': '/shared/resources/branding/browser_126.png', - '142': '/shared/resources/branding/browser_142.png', - '189': '/shared/resources/branding/browser_189.png', - '284': '/shared/resources/branding/browser_284.png' - }, - name: 'browser' - } - }, - startFTE: function(mode) { var iframe = document.getElementById('fte_view'); @@ -219,7 +202,6 @@ var Common = { Common.allApps = appList.filter(function(app) { return Common.specialApps.indexOf(app.manifestURL) === -1; }); - Common.allApps.push(Common.BROWSER_APP); Common.allAppsLoaded = true; resolve(Common.allApps); }; @@ -260,14 +242,6 @@ var Common = { }, getLocalizedAppName: function(app) { - // If is System App returns label others - if (app.manifestURL === Common.SYSTEM_MANIFEST) { - return _('data-usage-other-apps'); - } - // Browser app does not exist, we have to provide the localized app name - if (app.manifestURL === Common.BROWSER_APP.manifestURL) { - return _('data-usage-browser-app'); - } var manifest = this.getAppManifest(app); var userLang = document.documentElement.lang; var locales = manifest.locales; diff --git a/apps/costcontrol/js/costcontrol.js b/apps/costcontrol/js/costcontrol.js index 55b4e24003ed..85d88fc24518 100644 --- a/apps/costcontrol/js/costcontrol.js +++ b/apps/costcontrol/js/costcontrol.js @@ -588,11 +588,6 @@ var CostControl = (function() { var manifestURL = request.result.appManifestURL; // ignore the 'null' manifestURL if (manifestURL && manifestURL !== 'null') { - var isBrowser = request.result.browsingTrafficOnly && - manifestURL === Common.SYSTEM_MANIFEST; - if (isBrowser) { - manifestURL = Common.BROWSER_APP.manifestURL; - } network.apps[manifestURL] = { samples: data[0], total: data[1] @@ -648,17 +643,7 @@ var CostControl = (function() { if (apps && apps.length > 0) { requests = []; apps.forEach(function(manifestURL) { - // Ignoring the system app because of the system traffic is going to - // be calculated (Front-end workaround for Bug 1083680) - if (manifestURL !== Common.SYSTEM_MANIFEST) { - var options = { appManifestURL: manifestURL }; - // Browser app is included on System app - if (manifestURL === Common.BROWSER_APP.manifestURL) { - options.appManifestURL = Common.SYSTEM_MANIFEST; - options.browsingTrafficOnly = true; - } - requests.push(requestSamples(options)); - } + requests.push(requestSamples({ appManifestURL: manifestURL })); }); } else { requests = [requestSamples()]; diff --git a/apps/costcontrol/js/views/datausage.js b/apps/costcontrol/js/views/datausage.js index 227b707a467d..24abd036fe99 100644 --- a/apps/costcontrol/js/views/datausage.js +++ b/apps/costcontrol/js/views/datausage.js @@ -1,4 +1,4 @@ -/* global debug, ConfigManager, CostControl, Formatting, +/* global _, debug, ConfigManager, CostControl, Formatting, SimManager, Common, ChartUtils */ /* jshint -W120 */ @@ -19,6 +19,8 @@ var DataUsageTab = (function() { var costcontrol, initialized, model; + var SYSTEM_MANIFEST = 'app://system.gaiamobile.org/manifest.webapp'; + function setupTab() { if (initialized) { return; @@ -343,7 +345,7 @@ var DataUsageTab = (function() { function drawApps(model) { function createAppItem(app) { - var isSystem = app.manifestURL === Common.SYSTEM_MANIFEST; + var isSystem = app.manifestURL === SYSTEM_MANIFEST; var appElement = document.createElement('li'); appElement.className = 'app-item'; @@ -369,7 +371,9 @@ var DataUsageTab = (function() { var nameElement = document.createElement('div'); nameElement.className = 'app-info-row app-name'; - nameElement.textContent = Common.getLocalizedAppName(app); + nameElement.textContent = isSystem ? + _('data-usage-other-apps') : + Common.getLocalizedAppName(app); appInfoElement.appendChild(nameElement); var barElement = document.createElement('div'); @@ -412,7 +416,6 @@ var DataUsageTab = (function() { // allocated to an app) to the System application. function fixResidualTraffic() { var breakdownTotal = 0; - mobileApps[Common.SYSTEM_MANIFEST] = {total: 0}; if (manifests.length > 0) { breakdownTotal = manifests.reduce(function(accumulatedTraffic, appManifest) { @@ -420,11 +423,14 @@ var DataUsageTab = (function() { }, 0); } var residualTraffic = mobileTotal - breakdownTotal; - // System traffic is the residual traffic + // Updating System traffic to add the residual traffic if (residualTraffic > 0) { - mobileApps[Common.SYSTEM_MANIFEST].total = residualTraffic; - if (!manifests[Common.SYSTEM_MANIFEST]) { - manifests.push(Common.SYSTEM_MANIFEST); + // Ensure system app exists + mobileApps[SYSTEM_MANIFEST] = mobileApps[SYSTEM_MANIFEST] || {total: 0}; + var systemTraffic = mobileApps[SYSTEM_MANIFEST].total + residualTraffic; + mobileApps[SYSTEM_MANIFEST].total = systemTraffic; + if (!manifests[SYSTEM_MANIFEST]) { + manifests.push(SYSTEM_MANIFEST); } } } diff --git a/apps/costcontrol/locales/costcontrol.en-US.properties b/apps/costcontrol/locales/costcontrol.en-US.properties index 0a1bc62b9e6e..f943e0ab728a 100644 --- a/apps/costcontrol/locales/costcontrol.en-US.properties +++ b/apps/costcontrol/locales/costcontrol.en-US.properties @@ -215,7 +215,6 @@ data-used-since = {{amount}} of data used since {{start-date}} data-used-this-week = {{amount}} of data used this week data-used-this-month = {{amount}} of data used this month data-usage-other-apps = Others -data-usage-browser-app = Browser # LOCALIZATION NOTE: For charts the following labels are used to describe # various layers drawn. The following strings are spoken by screen readers and diff --git a/apps/costcontrol/test/unit/common_test.js b/apps/costcontrol/test/unit/common_test.js index f8bfe500bdf7..028169db57fd 100644 --- a/apps/costcontrol/test/unit/common_test.js +++ b/apps/costcontrol/test/unit/common_test.js @@ -121,7 +121,7 @@ suite('Cost Control Common >', function() { Common.loadApps().then(function(apps) { done(function() { assert.isTrue(Common.allAppsLoaded); - assert.equal(apps.length, 2); + assert.equal(apps.length, 1); assert.equal(apps[0].manifestURL, 'url2'); }); }); @@ -133,24 +133,13 @@ suite('Cost Control Common >', function() { Common.loadApps().then(function(apps) { done(function() { assert.isTrue(Common.allAppsLoaded); - assert.equal(apps.length, 3); + assert.equal(apps.length, 2); assert.equal(apps[0].manifestURL, 'url1'); assert.equal(apps[1].manifestURL, 'url2'); }); }); }); - test('loadApps load Browser App', function(done) { - Common.specialApps = []; - Common.allAppsLoaded = false; - Common.loadApps().then(function(apps) { - done(function() { - assert.isTrue(Common.allAppsLoaded); - assert.isTrue(apps.includes(Common.BROWSER_APP)); - }); - }); - }); - test('getApp by manifestURL correctly', function() { var app1 = Common.getApp('url1'); var app2 = Common.getApp('url2'); diff --git a/apps/costcontrol/test/unit/cost_control_test.js b/apps/costcontrol/test/unit/cost_control_test.js index b31073cc632c..f8a52cb559c3 100644 --- a/apps/costcontrol/test/unit/cost_control_test.js +++ b/apps/costcontrol/test/unit/cost_control_test.js @@ -499,50 +499,6 @@ suite('Cost Control Service Hub Suite >', function() { } ); - test( - 'Get datausage per app shows browser App', - function(done) { - var expectedLastDataUsage = { - mobile: { total: 10000, apps: {} }, - wifi: { total: 20000, apps: {} } - }; - - var fakeSettings = { lastDataUsage: expectedLastDataUsage }; - - this.sinon.stub(SimManager, 'requestDataSimIcc', function (callback) { - (typeof callback === 'function') && callback({iccId:'12345'}); - }); - - window.ConfigManager = new MockConfigManager({ - fakeSettings: fakeSettings - }); - - CostControl.getInstance(function(service) { - var manifests = [MockMozNetworkStats.APP_MANIFEST_1, - Common.BROWSER_APP.manifestURL]; - service.request({type: 'datausage', apps: manifests}, function(result) { - assert.equal(result.status, 'success'); - assert.equal(Object.keys(result.data.mobile.apps).length, 2); - - var apps = result.data.mobile.apps; - var app1 = apps[MockMozNetworkStats.APP_MANIFEST_1]; - var browserApp = apps[Common.BROWSER_APP.manifestURL]; - - assert.equal(app1.total, 1047); - assert.equal(browserApp.total, 595); - assert.equal(result.data.mobile.total, app1.total + browserApp.total); - - assert.equal( - fakeSettings.lastDataUsage.mobile.total, - expectedLastDataUsage.mobile.total - ); - - done(); - }); - }); - } - ); - test('Querying data usage globally caches the result', function(done) { this.sinon.stub(SimManager, 'requestDataSimIcc').yields({iccId: '12345'}); diff --git a/apps/costcontrol/test/unit/mock_common.js b/apps/costcontrol/test/unit/mock_common.js index 54d2c01045b4..693ff6a99f67 100644 --- a/apps/costcontrol/test/unit/mock_common.js +++ b/apps/costcontrol/test/unit/mock_common.js @@ -12,20 +12,6 @@ var MockCommon = function(config) { return { COST_CONTROL_APP: 'app://costcontrol.gaiamobile.org', - - BROWSER_APP: { - manifestURL: 'app://browser.gaiamobile.org/manifest.webapp', - origin: '', - manifest: { - icons: { - '84': '/shared/resources/branding/browser_84.png' - }, - name: 'browser' - } - }, - - SYSTEM_MANIFEST: 'app://system.gaiamobile.org/manifest.webapp', - allNetworkInterfaces: {}, localize: function (element, label, args) { element.textContent = label; diff --git a/apps/costcontrol/test/unit/mock_moz_network_stats.js b/apps/costcontrol/test/unit/mock_moz_network_stats.js index 1e067d0b1bad..f86e07cbf419 100644 --- a/apps/costcontrol/test/unit/mock_moz_network_stats.js +++ b/apps/costcontrol/test/unit/mock_moz_network_stats.js @@ -7,7 +7,7 @@ var MockMozNetworkStats; requireApp('costcontrol/test/unit/mock_all_network_interfaces.js', function() { MockMozNetworkStats = (function() { - var system_manifest = 'app://system.gaiamobile.org/manifest.webapp'; + var samples1 = { 'manifestURL': null, 'network': {'type': 0, 'id': '0'}, @@ -76,19 +76,6 @@ requireApp('costcontrol/test/unit/mock_all_network_interfaces.js', function() { {'rxBytes': 567, 'txBytes': 678, 'date': {'__date__': '2014-08-15T05:00:00.000Z'}}, ] - }, - 'app://system.gaiamobile.org/manifest.webapp': { - browsingTrafficOnly: true, - 'appManifestURL': system_manifest, - 'network': {'type': 1, 'id': '45678'}, - 'start': {'__date__': '2014-08-14T05:00:00.000Z'}, - 'end': {'__date__': '2014-08-31T05:00:00.000Z'}, - 'data': [ - {'rxBytes': 121, 'txBytes': 111, - 'date': {'__date__': '2014-08-14T05:00:00.000Z'}}, - {'rxBytes': 141, 'txBytes': 222, - 'date': {'__date__': '2014-08-15T05:00:00.000Z'}}, - ] } };