зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1049704 - Add a "type" parameter to Simulator configurations in WebIDE. r=jryans
This commit is contained in:
Родитель
620cb198ae
Коммит
829951a43f
|
@ -44,7 +44,7 @@ var SimulatorEditor = {
|
|||
Simulators.on("configure", (e, simulator) => { this.edit(simulator) });
|
||||
// Extract the list of device simulation options we'll support.
|
||||
let deviceFields = form.querySelectorAll("*[data-device]");
|
||||
this._deviceOptions = [].map.call(deviceFields, field => field.name);
|
||||
this._deviceOptions = Array.map(deviceFields, field => field.name);
|
||||
}
|
||||
|
||||
// Append a new <option> to a <select> (or <optgroup>) element.
|
||||
|
@ -172,7 +172,7 @@ var SimulatorEditor = {
|
|||
// TODO (Bug 1146531) Indicate that a custom profile is now required.
|
||||
}
|
||||
// If `form.name` contains the old version, update its last occurrence.
|
||||
if (form.name.value.contains(oldVer) && simulator.version !== oldVer) {
|
||||
if (form.name.value.includes(oldVer) && simulator.version !== oldVer) {
|
||||
let regex = new RegExp("(.*)" + oldVer);
|
||||
let name = form.name.value.replace(regex, "$1" + simulator.version);
|
||||
simulator.options.name = form.name.value = Simulators.uniqueName(name);
|
||||
|
|
|
@ -139,8 +139,16 @@ var Simulators = {
|
|||
if (matching.length > 0) {
|
||||
return promise.resolve();
|
||||
}
|
||||
let name = addon.name.replace(" Simulator", "");
|
||||
return this.add(new Simulator({name}, addon), silently);
|
||||
let options = {};
|
||||
options.name = addon.name.replace(" Simulator", "");
|
||||
// Some addons specify a simulator type at the end of their version string,
|
||||
// e.g. "2_5_tv".
|
||||
let type = this.simulatorAddonVersion(addon).split("_")[2];
|
||||
if (type) {
|
||||
// "tv" is shorthand for type "television".
|
||||
options.type = (type === "tv" ? "television" : type);
|
||||
}
|
||||
return this.add(new Simulator(options, addon), silently);
|
||||
},
|
||||
|
||||
// TODO (Bug 1146521) Maybe find a better way to deal with removed addons?
|
||||
|
@ -199,11 +207,28 @@ var Simulators = {
|
|||
return unique;
|
||||
},
|
||||
|
||||
/**
|
||||
* Compare an addon's ID against the expected form of a simulator addon ID,
|
||||
* and try to extract its version if there is a match.
|
||||
*
|
||||
* Note: If a simulator addon is recognized, but no version can be extracted
|
||||
* (e.g. custom RegExp pref value), we return "Unknown" to keep the returned
|
||||
* value 'truthy'.
|
||||
*/
|
||||
simulatorAddonVersion(addon) {
|
||||
let match = SimulatorRegExp.exec(addon.id);
|
||||
if (!match) {
|
||||
return null;
|
||||
}
|
||||
let version = match[1];
|
||||
return version || "Unknown";
|
||||
},
|
||||
|
||||
/**
|
||||
* Detect simulator addons, including "unofficial" ones.
|
||||
*/
|
||||
isSimulatorAddon(addon) {
|
||||
return SimulatorRegExp.exec(addon.id);
|
||||
return !!this.simulatorAddonVersion(addon);
|
||||
},
|
||||
|
||||
emitUpdated() {
|
||||
|
@ -250,7 +275,7 @@ function Simulator(options = {}, addon = null) {
|
|||
this.options = options;
|
||||
|
||||
// Fill `this.options` with default values where needed.
|
||||
let defaults = this._defaults;
|
||||
let defaults = this.defaults;
|
||||
for (let option in defaults) {
|
||||
if (this.options[option] == null) {
|
||||
this.options[option] = defaults[option];
|
||||
|
@ -259,16 +284,26 @@ function Simulator(options = {}, addon = null) {
|
|||
}
|
||||
Simulator.prototype = {
|
||||
|
||||
// Default simulation options, based on the Firefox OS Flame.
|
||||
// Default simulation options.
|
||||
_defaults: {
|
||||
width: 320,
|
||||
height: 570,
|
||||
pixelRatio: 1.5
|
||||
// Based on the Firefox OS Flame.
|
||||
phone: {
|
||||
width: 320,
|
||||
height: 570,
|
||||
pixelRatio: 1.5
|
||||
},
|
||||
// Based on a 720p HD TV.
|
||||
television: {
|
||||
width: 1280,
|
||||
height: 720,
|
||||
pixelRatio: 1,
|
||||
}
|
||||
},
|
||||
_defaultType: "phone",
|
||||
|
||||
restoreDefaults() {
|
||||
let defaults = this.defaults;
|
||||
let options = this.options;
|
||||
let defaults = this._defaults;
|
||||
for (let option in defaults) {
|
||||
options[option] = defaults[option];
|
||||
}
|
||||
|
@ -307,6 +342,11 @@ Simulator.prototype = {
|
|||
return process.kill();
|
||||
},
|
||||
|
||||
get defaults() {
|
||||
let defaults = this._defaults;
|
||||
return defaults[this.type] || defaults[this._defaultType];
|
||||
},
|
||||
|
||||
get id() {
|
||||
return this.name;
|
||||
},
|
||||
|
@ -315,6 +355,10 @@ Simulator.prototype = {
|
|||
return this.options.name;
|
||||
},
|
||||
|
||||
get type() {
|
||||
return this.options.type || this._defaultType;
|
||||
},
|
||||
|
||||
get version() {
|
||||
return this.options.b2gBinary ? "Custom" : this.addon.name.match(/\d+\.\d+/)[0];
|
||||
},
|
||||
|
|
Двоичный файл не отображается.
Двоичный файл не отображается.
Двоичный файл не отображается.
Двоичный файл не отображается.
|
@ -1,4 +1,4 @@
|
|||
{
|
||||
"stable": ["1.0", "2.0"],
|
||||
"unstable": ["3.0"]
|
||||
"unstable": ["3.0", "3.0_tv"]
|
||||
}
|
||||
|
|
|
@ -18,6 +18,10 @@ support-files =
|
|||
addons/fxos_3_0_simulator-linux64.xpi
|
||||
addons/fxos_3_0_simulator-win32.xpi
|
||||
addons/fxos_3_0_simulator-mac64.xpi
|
||||
addons/fxos_3_0_tv_simulator-linux.xpi
|
||||
addons/fxos_3_0_tv_simulator-linux64.xpi
|
||||
addons/fxos_3_0_tv_simulator-win32.xpi
|
||||
addons/fxos_3_0_tv_simulator-mac64.xpi
|
||||
addons/adbhelper-linux.xpi
|
||||
addons/adbhelper-linux64.xpi
|
||||
addons/adbhelper-win32.xpi
|
||||
|
|
|
@ -101,13 +101,13 @@
|
|||
|
||||
let params = yield runSimulator(0);
|
||||
|
||||
ok(params.path.contains(sim10.addonID) && params.path.contains("b2g-bin"), "Simulator binary path looks right");
|
||||
ok(params.path.includes(sim10.addonID) && params.path.includes("b2g-bin"), "Simulator binary path looks right");
|
||||
|
||||
let pid = params.args.indexOf("-profile");
|
||||
ok(pid > -1, "Simulator process arguments have --profile");
|
||||
|
||||
let profilePath = params.args[pid + 1];
|
||||
ok(profilePath.contains(sim10.addonID) && profilePath.contains("profile"), "Simulator profile path looks right");
|
||||
ok(profilePath.includes(sim10.addonID) && profilePath.includes("profile"), "Simulator profile path looks right");
|
||||
|
||||
ok(params.args.indexOf("-dbgport") > -1 || params.args.indexOf("-start-debugger-server") > -1, "Simulator process arguments have a debugger port");
|
||||
|
||||
|
@ -234,8 +234,8 @@
|
|||
|
||||
let defaults = Simulator.prototype._defaults;
|
||||
|
||||
for (let param in defaults) {
|
||||
is(form[param].value, String(defaults[param]), "Default value for device " + param);
|
||||
for (let param in defaults.phone) {
|
||||
is(form[param].value, String(defaults.phone[param]), "Default phone value for device " + param);
|
||||
}
|
||||
|
||||
let width = 5000, height = 4000;
|
||||
|
@ -248,7 +248,7 @@
|
|||
|
||||
let sid = params.args.indexOf("-screen");
|
||||
ok(sid > -1, "Simulator process arguments have --screen");
|
||||
ok(params.args[sid + 1].contains(width + "x" + height), "Simulator screen resolution looks right");
|
||||
ok(params.args[sid + 1].includes(width + "x" + height), "Simulator screen resolution looks right");
|
||||
|
||||
yield set(form.version, sim10.addonID);
|
||||
|
||||
|
@ -277,8 +277,8 @@
|
|||
|
||||
// Test `device`.
|
||||
|
||||
for (let param in defaults) {
|
||||
is(form[param].value, String(defaults[param]), "Default value for device " + param);
|
||||
for (let param in defaults.phone) {
|
||||
is(form[param].value, String(defaults.phone[param]), "Default phone value for device " + param);
|
||||
}
|
||||
|
||||
let devices = yield GetDevices();
|
||||
|
@ -294,15 +294,32 @@
|
|||
params = yield runSimulator(1);
|
||||
|
||||
sid = params.args.indexOf("-screen");
|
||||
ok(params.args[sid + 1].contains(device.width + "x" + device.height), "Simulator screen resolution looks right");
|
||||
ok(params.args[sid + 1].includes(device.width + "x" + device.height), "Simulator screen resolution looks right");
|
||||
|
||||
// Restore default simulator options.
|
||||
|
||||
doc.querySelector("#reset").click();
|
||||
yield nextTick();
|
||||
|
||||
for (let param in defaults) {
|
||||
is(form[param].value, String(defaults[param]), "Default value for device " + param);
|
||||
for (let param in defaults.phone) {
|
||||
is(form[param].value, String(defaults.phone[param]), "Default phone value for device " + param);
|
||||
}
|
||||
|
||||
// Install and configure the fake "Firefox OS 3.0 TV" simulator addon.
|
||||
|
||||
let sim30tv = addons.simulators.filter(a => a.version == "3.0_tv")[0];
|
||||
|
||||
sim30tv.install();
|
||||
|
||||
yield addonStatus(sim30tv, "installed");
|
||||
|
||||
is(findAll(".runtime-panel-item-simulator").length, 3, "Three simulators in runtime panel");
|
||||
|
||||
simulatorList.querySelectorAll(".configure-button")[2].click();
|
||||
yield nextTick();
|
||||
|
||||
for (let param in defaults.television) {
|
||||
is(form[param].value, String(defaults.television[param]), "Default TV value for device " + param);
|
||||
}
|
||||
|
||||
// Force reload the list of simulators.
|
||||
|
@ -312,9 +329,15 @@
|
|||
yield Simulators._load();
|
||||
yield nextTick();
|
||||
|
||||
is(findAll(".runtime-panel-item-simulator").length, 2, "Two simulators saved and reloaded " + Simulators._simulators.map(s => s.name).join(','));
|
||||
is(findAll(".runtime-panel-item-simulator").length, 3, "Three simulators saved and reloaded " + Simulators._simulators.map(s => s.name).join(','));
|
||||
|
||||
// Uninstall the 2.0 addon and watch its Simulator object disappear.
|
||||
// Uninstall the 3.0 TV and 2.0 addons, and watch their Simulator objects disappear.
|
||||
|
||||
sim30tv.uninstall();
|
||||
|
||||
yield addonStatus(sim30tv, "uninstalled");
|
||||
|
||||
is(findAll(".runtime-panel-item-simulator").length, 2, "Two simulators left in runtime panel");
|
||||
|
||||
sim20.uninstall();
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче