Publish Vulpes Preview 15 sources for desktop, Android and Tundra

Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
This commit is contained in:
OverSu 2026-09-30 23:13:03 +02:00
commit b38dea0597
25901 changed files with 9982925 additions and 369 deletions

View file

@ -0,0 +1,335 @@
'use strict';
suite('ApnList', function() {
var FAKE_APN_LIST_KEY = 'fakeKey';
var mockAsyncStorage;
var map = {
'*': {
'modules/async_storage': 'MockAsyncStorage',
'modules/apn/apn_utils': 'MockApnUtils'
}
};
var modules = [
'modules/apn/apn_list',
'modules/apn/apn_item',
'modules/async_storage',
'modules/apn/apn_utils'
];
setup(function(done) {
var requireCtx = testRequire([], map, function() {});
mockAsyncStorage = {};
define('MockAsyncStorage', function() {
return {
setItem: function() {
return Promise.resolve();
},
getItem: function(key) {
return Promise.resolve(mockAsyncStorage[key]);
}
};
});
define('MockApnUtils', function() {
return {
generateId: function() {},
clone: function() {}
};
});
requireCtx(modules,
function(ApnList, ApnItem, MockAsyncStorage, MockApnUtils) {
this.ApnList = ApnList;
this.ApnItem = ApnItem;
this.MockAsyncStorage = MockAsyncStorage;
this.MockApnUtils = MockApnUtils;
// Create mock apn items.
this.mockApnItems = [
{
id: '0',
category: 'category0'
},
{
id: '1',
category: 'category1'
}
];
this.apnList = new this.ApnList(FAKE_APN_LIST_KEY);
mockAsyncStorage = {};
mockAsyncStorage[FAKE_APN_LIST_KEY] = this.mockApnItems;
done();
}.bind(this));
});
suite('_add', function() {
test('add with category specified', function(done) {
var apn = {};
var category = 'category';
var randomId = 'randomId';
mockAsyncStorage = {};
this.sinon.stub(this.MockApnUtils, 'generateId', function() {
return randomId;
});
this.apnList._add(apn, category)
.then(function(apnId) {
var addedApnItem = this.apnList._apnItems[0];
assert.deepEqual(addedApnItem.apn, apn);
assert.equal(addedApnItem.id, randomId);
assert.equal(addedApnItem.category, category);
assert.equal(apnId, randomId);
}.bind(this), function() {
// This function does not reject.
assert.isTrue(false);
}).then(done, done);
});
test('add without category specified', function(done) {
var apn = {};
var randomId = 'randomId';
mockAsyncStorage = {};
this.sinon.stub(this.MockApnUtils, 'generateId', function() {
return randomId;
});
this.apnList._add(apn)
.then(function(apnId) {
var addedApnItem = this.apnList._apnItems[0];
assert.deepEqual(addedApnItem.apn, apn);
assert.equal(addedApnItem.id, randomId);
assert.equal(addedApnItem.category, this.ApnItem.APN_CATEGORY.CUSTOM);
assert.equal(apnId, randomId);
}.bind(this), function() {
// This function does not reject.
assert.isTrue(false);
}).then(done, done);
});
});
suite('_remove', function() {
test('no existing apn items', function(done) {
mockAsyncStorage = {};
this.apnList._remove('000')
.then(function() {
// Should not resolve.
assert.isTrue(false);
}.bind(this), function(err) {
assert.equal(err, 'no apn items');
}).then(done, done);
});
test('remove with valid id', function(done) {
var removedApnId = this.mockApnItems[0].id;
this.apnList._remove(removedApnId)
.then(function() {
assert.ok(!this.apnList._apnItems.some(
(apnItem) => apnItem.id === removedApnId));
}.bind(this), function() {
// This function does not reject.
assert.isTrue(false);
}).then(done, done);
});
test('remove with invalid id', function(done) {
var removedApnId = 'invalidId';
this.apnList._remove(removedApnId)
.then(function() {
// Should not resolve.
assert.isTrue(false);
}.bind(this), function(err) {
assert.equal(err, 'apn not found');
}).then(done, done);
});
});
suite('_update', function() {
test('no existing apn items', function(done) {
mockAsyncStorage = {};
this.apnList._update('000', {})
.then(function() {
// Should not resolve.
assert.isTrue(false);
}.bind(this), function(err) {
assert.equal(err, 'no apn items');
}).then(done, done);
});
test('update with valid id', function(done) {
var updatedApnId = this.mockApnItems[0].id;
var apn = {
fakeKey: 'fakeValue'
};
this.apnList._update(updatedApnId, apn)
.then(function() {
assert.equal(this.apnList._apnItems[0].apn.fakeKey, apn.fakeKey);
}.bind(this), function() {
// This function does not reject.
assert.isTrue(false);
}).then(done, done);
});
test('update with invalid id', function(done) {
var updatedApnId = 'invalidId';
this.apnList._update(updatedApnId, {})
.then(function() {
// Should not resolve.
assert.isTrue(false);
}.bind(this), function(err) {
assert.equal(err, 'apn not found');
}).then(done, done);
});
});
suite('items', function() {
test('with cached apn items', function(done) {
var that = this;
this.apnList._apnItems = this.mockApnItems;
this.apnList.items()
.then(function(result) {
assert.equal(result, that.mockApnItems);
}, function() {
// This function does not reject.
assert.isTrue(false);
}).then(done, done);
});
test('without cached apn items', function(done) {
var that = this;
this.apnList._apnItems = null;
mockAsyncStorage = {};
mockAsyncStorage[FAKE_APN_LIST_KEY] = this.mockApnItems;
this.apnList.items()
.then(function(apnItems) {
apnItems.forEach(function(apnItem, index) {
var mockApnItem = that.mockApnItems[index];
assert.equal(apnItem.id, mockApnItem.id);
assert.equal(apnItem.category, mockApnItem.category);
assert.equal(apnItem.apn, mockApnItem);
});
assert.equal(apnItems, that.apnList._apnItems);
}, function() {
// This function does not reject.
assert.isTrue(false);
}).then(done, done);
});
});
suite('item', function() {
test('without id specified', function(done) {
this.apnList.item()
.then(function(apnItem) {
assert.isNull(apnItem);
}, function() {
// This function does not reject.
assert.isTrue(false);
}).then(done, done);
});
test('without existing apn items', function(done) {
mockAsyncStorage = {};
this.apnList.item('1')
.then(function(apnItem) {
assert.isNull(apnItem);
}, function() {
// This function does not reject.
assert.isTrue(false);
}).then(done, done);
});
test('with existing apn items', function(done) {
this.apnList._apnItems = this.mockApnItems;
this.apnList.item('1')
.then(function(apnItem) {
assert.equal(apnItem.id, '1');
}, function() {
// This function does not reject.
assert.isTrue(false);
}).then(done, done);
});
});
suite('add', function() {
test('should call to _schedule and _add correctly', function(done) {
var apn = {};
var category = 'category';
var apnClone = {};
this.sinon.stub(this.MockApnUtils, 'clone', function() {
return apnClone;
});
this.sinon.stub(this.apnList, '_add', function() {
return Promise.resolve();
});
this.sinon.spy(this.apnList, '_schedule');
this.apnList.add(apn, category)
.then(function() {
sinon.assert.calledWith(this.MockApnUtils.clone, apn);
sinon.assert.called(this.apnList._schedule);
sinon.assert.calledWith(this.apnList._add, apnClone, category);
}.bind(this), function() {
// This function does not reject.
assert.isTrue(false);
}).then(done, done);
});
});
suite('remove', function() {
test('should call to _schedule and _remove correctly', function(done) {
var apnId = '000';
this.sinon.stub(this.apnList, '_remove', function() {
return Promise.resolve();
});
this.sinon.spy(this.apnList, '_schedule');
this.apnList.remove(apnId)
.then(function() {
sinon.assert.called(this.apnList._schedule);
sinon.assert.calledWith(this.apnList._remove, apnId);
}.bind(this), function() {
// This function does not reject.
assert.isTrue(false);
}).then(done, done);
});
});
suite('update', function() {
test('should call to _schedule and _update correctly', function(done) {
var apnId = '000';
var apn = {};
var apnClone = {};
this.sinon.stub(this.MockApnUtils, 'clone', function() {
return apnClone;
});
this.sinon.stub(this.apnList, '_update', function() {
return Promise.resolve();
});
this.sinon.spy(this.apnList, '_schedule');
this.apnList.update(apnId, apn)
.then(function() {
sinon.assert.calledWith(this.MockApnUtils.clone, apn);
sinon.assert.called(this.apnList._schedule);
sinon.assert.calledWith(this.apnList._update, apnId, apnClone);
}.bind(this), function() {
// This function does not reject.
assert.isTrue(false);
}).then(done, done);
});
});
});

View file

@ -0,0 +1,186 @@
'use strict';
suite('ApnSelections', function() {
var map = {
'*': {
'modules/settings_cache': 'MockSettingsCache'
}
};
var modules = [
'modules/apn/apn_selections',
'modules/apn/apn_const',
'modules/settings_cache'
];
var realMozSettings;
var mockMozSettings;
var realMobileConnections;
var mockMobileConnections;
function createMockApnSelections(apnTypes) {
var mockApnSelections = [];
function addMockApnSelection(apnType, i) {
mockApnSelection[apnType] = apnType + '_' + i + '_id';
}
for (var i = 0; i < mockMobileConnections.length; i++) {
var mockApnSelection = {};
apnTypes.forEach(addMockApnSelection);
mockApnSelections.push(mockApnSelection);
}
return mockApnSelections;
}
suiteSetup(function() {
mockMozSettings = {
_mObservers: {},
createLock: function() {
return {
set: function() {
var obj = {};
setTimeout(function() {
obj.onsuccess();
});
return obj;
}
};
},
addObserver: function(name, callback) {
this._mObservers[name] = this._mObservers[name] || [];
this._mObservers[name].push(callback);
},
mTriggerObservers: function(name, value) {
this._mObservers[name].forEach(function(callback) {
callback({
settingValue: value
});
});
}
};
realMozSettings = navigator.mozSettings;
navigator.mozSettings = mockMozSettings;
mockMobileConnections = [{}, {}];
realMobileConnections = navigator.mozMobileConnections;
navigator.mozMobileConnections = mockMobileConnections;
});
suiteTeardown(function() {
navigator.mozSettings = realMozSettings;
navigator.mozMobileConnections = realMobileConnections;
});
setup(function(done) {
var that = this;
var requireCtx = testRequire([], map, function() {});
this.mockSettingsDB = {};
define('MockSettingsCache', function() {
return {
getSettings: function(callback) {
callback(that.mockSettingsDB);
}
};
});
requireCtx(modules,
function(ApnSelections, ApnConst, MockSettingsCache) {
this.ApnSelections = ApnSelections;
this.ApnConst = ApnConst;
this.MockSettingsCache = MockSettingsCache;
this.apnSelections = new this.ApnSelections();
this.mockApnSelections =
createMockApnSelections(this.ApnConst.APN_TYPES);
this.mockSettingsDB[this.ApnConst.APN_SELECTIONS_KEY] =
this.mockApnSelections;
done();
}.bind(this));
});
suite('get', function() {
test('should get correct apn selections', function(done) {
var isTheSameSelection = (function(selection1, selection2) {
return this.ApnConst.APN_TYPES.every(function(apnType) {
return selection1[apnType] === selection2[apnType];
});
}).bind(this);
var promises = [];
for (var i = 0; i < mockMobileConnections.length; i++) {
promises.push(this.apnSelections.get(i));
}
Promise.all(promises).then(function(results) {
results.forEach(function(result, index) {
assert.ok(isTheSameSelection(result, this.mockApnSelections[index]));
}, this);
}.bind(this), function() {
// This function does not reject.
assert.isTrue(false);
}).then(done, done);
});
test('should get empty apn selections when apn selections is unavailable',
function(done) {
this.mockSettingsDB[this.ApnConst.APN_SELECTIONS_KEY] = null;
var isEmptySelection = (function(selection) {
return this.ApnConst.APN_TYPES.every(function(apnType) {
return selection[apnType] == null;
});
}).bind(this);
var promises = [];
for (var i = 0; i < mockMobileConnections.length; i++) {
promises.push(this.apnSelections.get(i));
}
Promise.all(promises).then(function(results) {
results.forEach(function(result) {
assert.ok(isEmptySelection(result));
}, this);
}.bind(this), function() {
// This function does not reject.
assert.isTrue(false);
}).then(done, done);
});
test('should commit when the selection is changed', function(done) {
var FAKE_ACTIVE_APN_ID = '000';
this.sinon.spy(this.apnSelections, '_commit');
this.apnSelections.get(0).then(function(apnSelection) {
apnSelection['default'] = FAKE_ACTIVE_APN_ID;
sinon.assert.called(this.apnSelections._commit);
}.bind(this), function() {
// This function does not reject.
assert.isTrue(false);
}).then(done, done);
});
});
suite('clear', function() {
test('should clear selection correctly', function(done) {
this.apnSelections.clear(0).then(function() {
this.ApnConst.APN_TYPES.forEach(function(apnType) {
assert.isTrue(this.mockApnSelections[apnType] == null);
}, this);
}.bind(this), function() {
// This function does not reject.
assert.isTrue(false);
}).then(done, done);
});
});
test('The ready promise should be set to null when the field of ' +
'apn.selections is cleared', function(done) {
this.apnSelections._ready().then(function() {
mockMozSettings
.mTriggerObservers(this.ApnConst.APN_SELECTIONS_KEY, null);
assert.equal(this._readyPromise, null);
}.bind(this), function() {
// This function does not reject.
assert.isTrue(false);
}).then(done, done);
});
});

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,205 @@
'use strict';
suite('ApnSettings', function() {
var map = {
'*': {
'modules/apn/apn_utils': 'MockApnUtils',
'modules/settings_cache': 'MockSettingsCache'
}
};
var modules = [
'modules/apn/apn_settings',
'modules/apn/apn_const',
'modules/apn/apn_utils',
'modules/settings_cache'
];
var findTargetSettings = function(apnSettings, serviceId, apnType) {
return apnSettings._apnSettings[serviceId].find(function(apn) {
return apn.types.some((type) => apnType === type);
});
};
setup(function(done) {
var that = this;
var requireCtx = testRequire([], map, function() {});
this.mockSettingsDB = {};
define('MockSettingsCache', function() {
return {
getSettings: function(callback) {
callback(that.mockSettingsDB);
}
};
});
define('MockApnUtils', function() {
return {
clone: function() {},
isMatchedApn: function() {}
};
});
requireCtx(modules,
function(ApnSettings, ApnConst, MockApnUtils, MockSettingsCache) {
this.ApnSettings = ApnSettings;
this.ApnConst = ApnConst;
this.MockApnUtils = MockApnUtils;
this.MockSettingsCache = MockSettingsCache;
this.apnSettings = new this.ApnSettings();
this.mockApnSettings = [
[{ carrier: 'fakeCarrier1', types: ['default'] }],
[{ carrier: 'fakeCarrier2', types: ['mms'] }]
];
this.mockSettingsDB = {};
this.mockSettingsDB[this.ApnConst.APN_SETTINGS_KEY] =
this.mockApnSettings;
done();
}.bind(this));
});
suite('_ready', function() {
test('should init the settings correctly', function(done) {
this.sinon.stub(this.apnSettings, '_addObservers');
this.apnSettings._ready()
.then(function() {
assert.ok(this.apnSettings._isReady);
assert.deepEqual(this.apnSettings._apnSettings, this.mockApnSettings);
sinon.assert.called(this.apnSettings._addObservers);
}.bind(this), function() {
// This function does not reject.
assert.isTrue(false);
}).then(done, done);
});
});
suite('_update', function() {
var serviceId = 0;
var apnType = 'default';
test('update with apn', function(done) {
this.sinon.stub(this.MockApnUtils, 'isMatchedApn', function() {
return false;
});
var newApnSetting = { carrier: 'newCarrier', types: [apnType] };
this.apnSettings._update(serviceId, apnType, newApnSetting)
.then(function() {
var targetApnSettings =
findTargetSettings(this.apnSettings, serviceId, apnType);
assert.deepEqual(targetApnSettings, newApnSetting);
}.bind(this), function() {
// This function does not reject.
assert.isTrue(false);
}).then(done, done);
});
test('update with null', function(done) {
this.apnSettings._update(serviceId, apnType, null)
.then(function() {
var targetApnSettings =
findTargetSettings(this.apnSettings, serviceId, apnType);
assert.ok(targetApnSettings === undefined);
}.bind(this), function() {
// This function does not reject.
assert.isTrue(false);
}).then(done, done);
});
});
suite('getAll', function() {
var serviceId = 0;
test('should return correct apn setting', function(done) {
this.apnSettings.getAll(serviceId)
.then(function(apnSetting) {
assert.deepEqual(apnSetting, this.mockApnSettings[serviceId]);
}.bind(this), function() {
// This function does not reject.
assert.isTrue(false);
}).then(done, done);
});
});
suite('get', function() {
var serviceId = 0;
var apnType = 'default';
test('should return correct apn setting', function(done) {
this.apnSettings.get(serviceId, apnType)
.then(function(apnSetting) {
var targetApnSettings =
findTargetSettings(this.apnSettings, serviceId, apnType);
assert.deepEqual(targetApnSettings, apnSetting);
}.bind(this), function() {
// This function does not reject.
assert.isTrue(false);
}).then(done, done);
});
test('should return null if no existing setting', function(done) {
this.mockSettingsDB[this.ApnConst.APN_SETTINGS_KEY] = {};
this.apnSettings.get(serviceId, apnType)
.then(function(apnSetting) {
assert.isNull(apnSetting);
}.bind(this), function() {
// This function does not reject.
assert.isTrue(false);
}).then(done, done);
});
});
suite('update', function() {
var serviceId = 0;
var apnType = 'default';
test('should call to _schedule and _update correctly', function(done) {
var apn = {};
var apnClone = {};
this.sinon.stub(this.MockApnUtils, 'clone', function() {
return apnClone;
});
this.sinon.stub(this.apnSettings, '_commit', function() {
return Promise.resolve();
});
this.sinon.stub(this.apnSettings, '_update', function() {
return Promise.resolve();
});
this.sinon.spy(this.apnSettings, '_schedule');
this.apnSettings.update(serviceId, apnType, apn)
.then(function(apnSetting) {
sinon.assert.calledWith(this.MockApnUtils.clone, apn);
sinon.assert.called(this.apnSettings._schedule);
sinon.assert.calledWith(this.apnSettings._update, serviceId, apnType,
apnClone);
}.bind(this), function() {
// This function does not reject.
assert.isTrue(false);
}).then(done, done);
});
});
suite('restore', function() {
var serviceId = 0;
setup(function() {
this.sinon.stub(this.apnSettings, '_schedule', function() {
return Promise.resolve();
});
});
test('should restore to default apn settings correctly', function(done) {
this.apnSettings._apnSettings = [];
this.apnSettings.restore(serviceId)
.then(function() {
assert.deepEqual(this.apnSettings._apnSettings, this.mockApnSettings);
}.bind(this), function() {
// This function does not reject.
assert.isTrue(false);
}).then(done, done);
});
});
});