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-take-snapshot-and-census.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-take-snapshot-and-census.js')
-rw-r--r-- | devtools/client/memory/test/unit/test_action-take-snapshot-and-census.js | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/devtools/client/memory/test/unit/test_action-take-snapshot-and-census.js b/devtools/client/memory/test/unit/test_action-take-snapshot-and-census.js new file mode 100644 index 000000000..77c3b8e38 --- /dev/null +++ b/devtools/client/memory/test/unit/test_action-take-snapshot-and-census.js @@ -0,0 +1,58 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +/** + * Tests the task creator `takeSnapshotAndCensus()` for the whole flow of + * taking a snapshot, and its sub-actions. + */ + +let { snapshotState: states, treeMapState } = require("devtools/client/memory/constants"); +let actions = require("devtools/client/memory/actions/snapshot"); + +function run_test() { + run_next_test(); +} + +add_task(function* () { + let front = new StubbedMemoryFront(); + let heapWorker = new HeapAnalysesClient(); + yield front.attach(); + let store = Store(); + + let snapshotI = 0; + let censusI = 0; + let snapshotStates = ["SAVING", "SAVED", "READING", "READ"]; + let censusStates = ["SAVING", "SAVED"]; + let expectStates = () => { + let snapshot = store.getState().snapshots[0]; + if (!snapshot) { + return; + } + if (snapshotI < snapshotStates.length) { + let isCorrectState = snapshot.state === states[snapshotStates[snapshotI]]; + if (isCorrectState) { + ok(true, `Found expected snapshot state ${snapshotStates[snapshotI]}`); + snapshotI++; + } + } + if (snapshot.treeMap && censusI < censusStates.length) { + if (snapshot.treeMap.state === treeMapState[censusStates[censusI]]) { + ok(true, `Found expected census state ${censusStates[censusI]}`); + censusI++; + } + } + }; + + + let unsubscribe = store.subscribe(expectStates); + store.dispatch(actions.takeSnapshotAndCensus(front, heapWorker)); + + yield waitUntilState(store, () => { return snapshotI === snapshotStates.length && + censusI === censusStates.length; }); + unsubscribe(); + + ok(true, "takeSnapshotAndCensus() produces the correct sequence of states in a snapshot"); + let snapshot = store.getState().snapshots[0]; + ok(snapshot.treeMap, "snapshot has tree map census data"); + ok(snapshot.selected, "snapshot is selected"); +}); |