diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /devtools/client/memory/test/unit/test_action_diffing_04.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'devtools/client/memory/test/unit/test_action_diffing_04.js')
-rw-r--r-- | devtools/client/memory/test/unit/test_action_diffing_04.js | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/devtools/client/memory/test/unit/test_action_diffing_04.js b/devtools/client/memory/test/unit/test_action_diffing_04.js new file mode 100644 index 000000000..2c3cd098b --- /dev/null +++ b/devtools/client/memory/test/unit/test_action_diffing_04.js @@ -0,0 +1,78 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +// Test that we compute census diffs. + +const { + diffingState, + snapshotState, + viewState +} = require("devtools/client/memory/constants"); +const { + toggleDiffing, + selectSnapshotForDiffingAndRefresh +} = require("devtools/client/memory/actions/diffing"); +const { + takeSnapshot, + readSnapshot +} = require("devtools/client/memory/actions/snapshot"); +const { changeView } = require("devtools/client/memory/actions/view"); + +function run_test() { + run_next_test(); +} + +add_task(function* () { + let front = new StubbedMemoryFront(); + let heapWorker = new HeapAnalysesClient(); + yield front.attach(); + let store = Store(); + const { getState, dispatch } = store; + dispatch(changeView(viewState.CENSUS)); + + equal(getState().diffing, null, "not diffing by default"); + + const s1 = yield dispatch(takeSnapshot(front, heapWorker)); + const s2 = yield dispatch(takeSnapshot(front, heapWorker)); + const s3 = yield dispatch(takeSnapshot(front, heapWorker)); + dispatch(readSnapshot(heapWorker, s1)); + dispatch(readSnapshot(heapWorker, s2)); + dispatch(readSnapshot(heapWorker, s3)); + yield waitUntilSnapshotState(store, [snapshotState.READ, + snapshotState.READ, + snapshotState.READ]); + + dispatch(toggleDiffing()); + dispatch(selectSnapshotForDiffingAndRefresh(heapWorker, + getState().snapshots[0])); + dispatch(selectSnapshotForDiffingAndRefresh(heapWorker, + getState().snapshots[1])); + + ok(getState().diffing, "We should be diffing."); + equal(getState().diffing.firstSnapshotId, getState().snapshots[0].id, + "First snapshot selected."); + equal(getState().diffing.secondSnapshotId, getState().snapshots[1].id, + "Second snapshot selected."); + + yield waitUntilState(store, + state => + state.diffing.state === diffingState.TAKING_DIFF); + ok(true, + "Selecting two snapshots for diffing should trigger computing a diff."); + + yield waitUntilState(store, + state => state.diffing.state === diffingState.TOOK_DIFF); + ok(true, "And then the diff should complete."); + ok(getState().diffing.census, "And we should have a census."); + ok(getState().diffing.census.report, "And that census should have a report."); + equal(getState().diffing.census.display, getState().censusDisplay, + "And that census should have the correct display"); + equal(getState().diffing.census.filter, getState().filter, + "And that census should have the correct filter"); + equal(getState().diffing.census.display.inverted, + getState().censusDisplay.inverted, + "And that census should have the correct inversion"); + + heapWorker.destroy(); + yield front.detach(); +}); |