mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 748517 - add tests for async load/store; r=taras
This commit is contained in:
parent
7645c7010f
commit
95d662770d
@ -527,7 +527,7 @@ TelemetryPing.prototype = {
|
|||||||
if (success && file.exists()) {
|
if (success && file.exists()) {
|
||||||
file.remove(true);
|
file.remove(true);
|
||||||
}
|
}
|
||||||
if (slug == "test-ping")
|
if (slug == "test-ping" && recordSuccess)
|
||||||
Services.obs.notifyObservers(null, "telemetry-test-xhr-complete", null);
|
Services.obs.notifyObservers(null, "telemetry-test-xhr-complete", null);
|
||||||
}
|
}
|
||||||
request.addEventListener("error", function(aEvent) finishRequest(request.channel), false);
|
request.addEventListener("error", function(aEvent) finishRequest(request.channel), false);
|
||||||
@ -776,10 +776,10 @@ TelemetryPing.prototype = {
|
|||||||
aSubject.QueryInterface(Ci.nsISupportsString).data = data.payload;
|
aSubject.QueryInterface(Ci.nsISupportsString).data = data.payload;
|
||||||
break;
|
break;
|
||||||
case "test-save-histograms":
|
case "test-save-histograms":
|
||||||
this.saveHistograms(aSubject.QueryInterface(Ci.nsIFile), true);
|
this.saveHistograms(aSubject.QueryInterface(Ci.nsIFile), aData != "async");
|
||||||
break;
|
break;
|
||||||
case "test-load-histograms":
|
case "test-load-histograms":
|
||||||
this.loadHistograms(aSubject.QueryInterface(Ci.nsIFile), true);
|
this.loadHistograms(aSubject.QueryInterface(Ci.nsIFile), aData != "async");
|
||||||
break;
|
break;
|
||||||
case "test-enable-load-save-notifications":
|
case "test-enable-load-save-notifications":
|
||||||
this._doLoadSaveNotifications = true;
|
this._doLoadSaveNotifications = true;
|
||||||
|
@ -33,6 +33,7 @@ function telemetry_ping () {
|
|||||||
const TelemetryPing = Cc["@mozilla.org/base/telemetry-ping;1"].getService(Ci.nsIObserver);
|
const TelemetryPing = Cc["@mozilla.org/base/telemetry-ping;1"].getService(Ci.nsIObserver);
|
||||||
TelemetryPing.observe(null, "test-gather-startup", null);
|
TelemetryPing.observe(null, "test-gather-startup", null);
|
||||||
TelemetryPing.observe(null, "test-enable-persistent-telemetry-send", null);
|
TelemetryPing.observe(null, "test-enable-persistent-telemetry-send", null);
|
||||||
|
TelemetryPing.observe(null, "test-enable-load-save-notifications", null);
|
||||||
TelemetryPing.observe(null, "test-ping", SERVER);
|
TelemetryPing.observe(null, "test-ping", SERVER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +77,7 @@ function getSavedHistogramsFile(basename) {
|
|||||||
|
|
||||||
function telemetryObserver(aSubject, aTopic, aData) {
|
function telemetryObserver(aSubject, aTopic, aData) {
|
||||||
Services.obs.removeObserver(telemetryObserver, aTopic);
|
Services.obs.removeObserver(telemetryObserver, aTopic);
|
||||||
httpserver.registerPathHandler(PATH, checkPersistedHistograms);
|
httpserver.registerPathHandler(PATH, checkPersistedHistogramsSync);
|
||||||
let histogramsFile = getSavedHistogramsFile("saved-histograms.dat");
|
let histogramsFile = getSavedHistogramsFile("saved-histograms.dat");
|
||||||
setupTestData();
|
setupTestData();
|
||||||
|
|
||||||
@ -152,7 +153,7 @@ function checkPayloadInfo(payload, reason) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkPayload(request, reason) {
|
function checkPayload(request, reason, successfulPings) {
|
||||||
let payload = decodeRequestPayload(request);
|
let payload = decodeRequestPayload(request);
|
||||||
|
|
||||||
checkPayloadInfo(payload, reason);
|
checkPayloadInfo(payload, reason);
|
||||||
@ -189,8 +190,8 @@ function checkPayload(request, reason) {
|
|||||||
range: [1, 2],
|
range: [1, 2],
|
||||||
bucket_count: 3,
|
bucket_count: 3,
|
||||||
histogram_type: 2,
|
histogram_type: 2,
|
||||||
values: {0:1, 1:1, 2:0},
|
values: {0:1, 1:successfulPings, 2:0},
|
||||||
sum: 1
|
sum: successfulPings
|
||||||
};
|
};
|
||||||
let tc = payload.histograms[TELEMETRY_SUCCESS];
|
let tc = payload.histograms[TELEMETRY_SUCCESS];
|
||||||
do_check_eq(uneval(tc), uneval(expected_tc));
|
do_check_eq(uneval(tc), uneval(expected_tc));
|
||||||
@ -217,15 +218,45 @@ function checkPayload(request, reason) {
|
|||||||
("otherThreads" in payload.slowSQL));
|
("otherThreads" in payload.slowSQL));
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkPersistedHistograms(request, response) {
|
function checkPersistedHistogramsSync(request, response) {
|
||||||
httpserver.registerPathHandler(PATH, checkHistograms);
|
httpserver.registerPathHandler(PATH, checkHistogramsSync);
|
||||||
checkPayload(request, "saved-session");
|
checkPayload(request, "saved-session", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkHistograms(request, response) {
|
function checkHistogramsSync(request, response) {
|
||||||
|
checkPayload(request, "test-ping", 1);
|
||||||
|
|
||||||
|
Services.obs.addObserver(runAsyncTestObserver, "telemetry-test-xhr-complete", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
function runAsyncTestObserver(aSubject, aTopic, aData) {
|
||||||
|
Services.obs.removeObserver(runAsyncTestObserver, aTopic);
|
||||||
|
httpserver.registerPathHandler(PATH, checkPersistedHistogramsAsync);
|
||||||
|
let histogramsFile = getSavedHistogramsFile("saved-histograms2.dat");
|
||||||
|
|
||||||
|
const TelemetryPing = Cc["@mozilla.org/base/telemetry-ping;1"].getService(Ci.nsIObserver);
|
||||||
|
Services.obs.addObserver(function(aSubject, aTopic, aData) {
|
||||||
|
Services.obs.removeObserver(arguments.callee, aTopic);
|
||||||
|
|
||||||
|
Services.obs.addObserver(function(aSubject, aTopic, aData) {
|
||||||
|
Services.obs.removeObserver(arguments.callee, aTopic);
|
||||||
|
telemetry_ping();
|
||||||
|
}, "telemetry-test-load-complete", false);
|
||||||
|
|
||||||
|
TelemetryPing.observe(histogramsFile, "test-load-histograms", "async");
|
||||||
|
}, "telemetry-test-save-complete", false);
|
||||||
|
TelemetryPing.observe(histogramsFile, "test-save-histograms", "async");
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkPersistedHistogramsAsync(request, response) {
|
||||||
|
httpserver.registerPathHandler(PATH, checkHistogramsAsync);
|
||||||
|
checkPayload(request, "saved-session", 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkHistogramsAsync(request, response) {
|
||||||
// do not need the http server anymore
|
// do not need the http server anymore
|
||||||
httpserver.stop(do_test_finished);
|
httpserver.stop(do_test_finished);
|
||||||
checkPayload(request, "test-ping");
|
checkPayload(request, "test-ping", 2);
|
||||||
|
|
||||||
gFinished = true;
|
gFinished = true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user