Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Revert "Bug 1125791 - [Cost Control][Usage] Show browser traffic in i…
Browse files Browse the repository at this point in the history
…ts own category inside the application breakdown"

This reverts commit 3953d7d.
  • Loading branch information
rvandermeulen committed Feb 24, 2015
1 parent 401ecde commit 8e98fe6
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 143 deletions.
7 changes: 0 additions & 7 deletions apps/costcontrol/index.html
Expand Up @@ -76,13 +76,6 @@
<link rel="import" href="/elements/topup-dialog.html">
<link rel="import" href="/elements/datausage-tab.html">
<link rel="import" href="/elements/appdetail-view.html">

<!-- Include the app icon in the application.zip -->
<link rel="resource" type="image/png" href="shared/resources/branding/browser_84.png"/>
<link rel="resource" type="image/png" href="shared/resources/branding/browser_126.png"/>
<link rel="resource" type="image/png" href="shared/resources/branding/browser_142.png"/>
<link rel="resource" type="image/png" href="shared/resources/branding/browser_189.png"/>
<link rel="resource" type="image/png" href="shared/resources/branding/browser_284.png"/>
</head>
<body role="application" class="theme-settings">

Expand Down
26 changes: 0 additions & 26 deletions apps/costcontrol/js/common.js
Expand Up @@ -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');

Expand Down Expand Up @@ -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);
};
Expand Down Expand Up @@ -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;
Expand Down
17 changes: 1 addition & 16 deletions apps/costcontrol/js/costcontrol.js
Expand Up @@ -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]
Expand Down Expand Up @@ -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()];
Expand Down
22 changes: 14 additions & 8 deletions 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 */

Expand All @@ -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;
Expand Down Expand Up @@ -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';

Expand All @@ -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');
Expand Down Expand Up @@ -412,19 +416,21 @@ 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) {
return accumulatedTraffic + mobileApps[appManifest].total;
}, 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);
}
}
}
Expand Down
1 change: 0 additions & 1 deletion apps/costcontrol/locales/costcontrol.en-US.properties
Expand Up @@ -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
Expand Down
15 changes: 2 additions & 13 deletions apps/costcontrol/test/unit/common_test.js
Expand Up @@ -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');
});
});
Expand All @@ -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');
Expand Down
44 changes: 0 additions & 44 deletions apps/costcontrol/test/unit/cost_control_test.js
Expand Up @@ -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'});

Expand Down
14 changes: 0 additions & 14 deletions apps/costcontrol/test/unit/mock_common.js
Expand Up @@ -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;
Expand Down
15 changes: 1 addition & 14 deletions apps/costcontrol/test/unit/mock_moz_network_stats.js
Expand Up @@ -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'},
Expand Down Expand Up @@ -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'}},
]
}
};

Expand Down

0 comments on commit 8e98fe6

Please sign in to comment.