mirror of
https://github.com/nasa/openmct.git
synced 2025-04-09 20:31:26 +00:00
[Telemetry] Update plot specs
Update plot specs to reflect refactoring out of formatter for telemetry values, WTD-599.
This commit is contained in:
parent
f63038a83f
commit
78b636dafe
@ -20,6 +20,9 @@ define(
|
||||
* which will be plotted in this sub-plot
|
||||
* @param {PlotPanZoomStack} panZoomStack the stack of pan-zoom
|
||||
* states which is applicable to this sub-plot
|
||||
* @param {TelemetryFormatter} telemetryFormatter the telemetry
|
||||
* formatting service; used to convert domain/range values
|
||||
* from telemetry data sets to a human-readable form.
|
||||
*/
|
||||
function SubPlot(telemetryObjects, panZoomStack, telemetryFormatter) {
|
||||
// We are used from a template often, so maintain
|
||||
|
@ -10,6 +10,7 @@ define(
|
||||
|
||||
describe("The plot controller", function () {
|
||||
var mockScope,
|
||||
mockFormatter,
|
||||
mockTelemetry, // mock telemetry controller
|
||||
mockData,
|
||||
mockDomainObject,
|
||||
@ -22,6 +23,10 @@ define(
|
||||
"$scope",
|
||||
[ "$watch", "$on" ]
|
||||
);
|
||||
mockFormatter = jasmine.createSpyObj(
|
||||
"formatter",
|
||||
[ "formatDomainValue", "formatRangeValue" ]
|
||||
);
|
||||
mockTelemetry = jasmine.createSpyObj(
|
||||
"telemetry",
|
||||
[ "getResponse", "getMetadata" ]
|
||||
@ -41,7 +46,7 @@ define(
|
||||
mockData.getDomainValue.andCallFake(echo);
|
||||
mockData.getRangeValue.andCallFake(echo);
|
||||
|
||||
controller = new PlotController(mockScope);
|
||||
controller = new PlotController(mockScope, mockFormatter);
|
||||
});
|
||||
|
||||
it("listens for telemetry updates", function () {
|
||||
|
47
platform/features/plot/test/SubPlotFactorySpec.js
Normal file
47
platform/features/plot/test/SubPlotFactorySpec.js
Normal file
@ -0,0 +1,47 @@
|
||||
/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/
|
||||
|
||||
/**
|
||||
* MergeModelsSpec. Created by vwoeltje on 11/6/14.
|
||||
*/
|
||||
define(
|
||||
["../src/SubPlotFactory"],
|
||||
function (SubPlotFactory) {
|
||||
"use strict";
|
||||
|
||||
describe("The sub-plot factory", function () {
|
||||
var mockDomainObject,
|
||||
mockPanZoomStack,
|
||||
mockFormatter,
|
||||
factory;
|
||||
|
||||
beforeEach(function () {
|
||||
mockDomainObject = jasmine.createSpyObj(
|
||||
"domainObject",
|
||||
[ "getId", "getModel", "getCapability" ]
|
||||
);
|
||||
mockPanZoomStack = jasmine.createSpyObj(
|
||||
"panZoomStack",
|
||||
[ "getPanZoom" ]
|
||||
);
|
||||
mockFormatter = jasmine.createSpyObj(
|
||||
"formatter",
|
||||
[ "formatDomainValue", "formatRangeValue" ]
|
||||
);
|
||||
|
||||
mockPanZoomStack.getPanZoom.andReturn({
|
||||
origin: [ 0, 0 ],
|
||||
dimensions: [ 100, 100 ]
|
||||
});
|
||||
|
||||
factory = new SubPlotFactory(mockFormatter);
|
||||
});
|
||||
|
||||
it("creates sub-plots", function () {
|
||||
expect(factory.createSubPlot(
|
||||
[mockDomainObject],
|
||||
mockPanZoomStack
|
||||
).getTelemetryObjects()).toEqual([mockDomainObject]);
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
@ -11,6 +11,7 @@ define(
|
||||
describe("A sub-plot", function () {
|
||||
var mockDomainObject,
|
||||
mockPanZoomStack,
|
||||
mockFormatter,
|
||||
mockElement,
|
||||
testDomainObjects,
|
||||
testOrigin,
|
||||
@ -35,6 +36,10 @@ define(
|
||||
"getDimensions"
|
||||
]
|
||||
);
|
||||
mockFormatter = jasmine.createSpyObj(
|
||||
"formatter",
|
||||
[ "formatDomainValue", "formatRangeValue" ]
|
||||
);
|
||||
mockElement = jasmine.createSpyObj(
|
||||
"element",
|
||||
[ "getBoundingClientRect" ]
|
||||
@ -55,7 +60,8 @@ define(
|
||||
|
||||
subplot = new SubPlot(
|
||||
testDomainObjects,
|
||||
mockPanZoomStack
|
||||
mockPanZoomStack,
|
||||
mockFormatter
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -9,18 +9,23 @@ define(
|
||||
"use strict";
|
||||
|
||||
describe("Plot mode options", function () {
|
||||
var mockDomainObject;
|
||||
var mockDomainObject,
|
||||
mockSubPlotFactory;
|
||||
|
||||
beforeEach(function () {
|
||||
mockDomainObject = jasmine.createSpyObj(
|
||||
"domainObject",
|
||||
[ "getId", "getModel", "getCapability" ]
|
||||
);
|
||||
mockSubPlotFactory = jasmine.createSpyObj(
|
||||
"subPlotFactory",
|
||||
[ "createSubPlot" ]
|
||||
);
|
||||
});
|
||||
|
||||
it("offers only one option when one object is present", function () {
|
||||
expect(
|
||||
new PlotModeOptions([mockDomainObject])
|
||||
new PlotModeOptions([mockDomainObject], mockSubPlotFactory)
|
||||
.getModeOptions().length
|
||||
).toEqual(1);
|
||||
});
|
||||
@ -33,7 +38,7 @@ define(
|
||||
mockDomainObject
|
||||
];
|
||||
expect(
|
||||
new PlotModeOptions(objects)
|
||||
new PlotModeOptions(objects, mockSubPlotFactory)
|
||||
.getModeOptions().length
|
||||
).toEqual(2);
|
||||
});
|
||||
@ -44,7 +49,7 @@ define(
|
||||
mockDomainObject,
|
||||
mockDomainObject,
|
||||
mockDomainObject
|
||||
]),
|
||||
], mockSubPlotFactory),
|
||||
initialHandler = plotModeOptions.getModeHandler();
|
||||
|
||||
// Change the mode
|
||||
|
@ -10,8 +10,11 @@ define(
|
||||
|
||||
describe("Overlaid plot mode", function () {
|
||||
var mockDomainObject,
|
||||
mockSubPlotFactory,
|
||||
mockSubPlot,
|
||||
mockPrepared,
|
||||
testBuffers,
|
||||
testDrawingObjects,
|
||||
mode;
|
||||
|
||||
function mockElement(x, y, w, h) {
|
||||
@ -22,10 +25,24 @@ define(
|
||||
};
|
||||
}
|
||||
|
||||
function doZoom(subplot, i) {
|
||||
subplot.startMarquee({ target: mockElement() });
|
||||
subplot.hover({ target: mockElement() });
|
||||
subplot.endMarquee({ target: mockElement() });
|
||||
function createMockSubPlot() {
|
||||
var mockSubPlot = jasmine.createSpyObj(
|
||||
"subPlot",
|
||||
[
|
||||
"setDomainOffset",
|
||||
"hover",
|
||||
"startMarquee",
|
||||
"endMarquee",
|
||||
"getDrawingObject",
|
||||
"update"
|
||||
]
|
||||
),
|
||||
testDrawingObject = {};
|
||||
|
||||
// Track drawing objects in order of creation
|
||||
testDrawingObjects.push(testDrawingObject);
|
||||
mockSubPlot.getDrawingObject.andReturn(testDrawingObject);
|
||||
return mockSubPlot;
|
||||
}
|
||||
|
||||
beforeEach(function () {
|
||||
@ -33,12 +50,18 @@ define(
|
||||
"domainObject",
|
||||
[ "getId", "getModel", "getCapability" ]
|
||||
);
|
||||
mockSubPlotFactory = jasmine.createSpyObj(
|
||||
"subPlotFactory",
|
||||
[ "createSubPlot" ]
|
||||
);
|
||||
// Prepared telemetry data
|
||||
mockPrepared = jasmine.createSpyObj(
|
||||
"prepared",
|
||||
[ "getDomainOffset", "getOrigin", "getDimensions", "getBuffers" ]
|
||||
);
|
||||
|
||||
mockSubPlotFactory.createSubPlot.andCallFake(createMockSubPlot);
|
||||
|
||||
// Act as if we have three buffers full of data
|
||||
testBuffers = [["a"], ["b"], ["c"]];
|
||||
mockPrepared.getBuffers.andReturn(testBuffers);
|
||||
@ -46,11 +69,14 @@ define(
|
||||
mockPrepared.getOrigin.andReturn([10, 10]);
|
||||
mockPrepared.getDimensions.andReturn([500, 500]);
|
||||
|
||||
// Clear out drawing objects
|
||||
testDrawingObjects = [];
|
||||
|
||||
mode = new PlotOverlayMode([
|
||||
mockDomainObject,
|
||||
mockDomainObject,
|
||||
mockDomainObject
|
||||
]);
|
||||
], mockSubPlotFactory);
|
||||
});
|
||||
|
||||
it("creates one sub-plot for all domain objects", function () {
|
||||
@ -68,14 +94,15 @@ define(
|
||||
|
||||
mode.plotTelemetry(mockPrepared);
|
||||
|
||||
// Should all each have one line
|
||||
mode.getSubPlots().forEach(function (subplot, i) {
|
||||
// Should have one sub-plot with three lines
|
||||
testDrawingObjects.forEach(function (testDrawingObject, i) {
|
||||
// Either empty list or undefined is fine;
|
||||
// just want to make sure there are no lines.
|
||||
expect(subplot.getDrawingObject().lines.length)
|
||||
expect(testDrawingObject.lines.length)
|
||||
.toEqual(3);
|
||||
// Make sure all buffers were drawn, in order.
|
||||
subplot.getDrawingObject().lines.forEach(function (line, j) {
|
||||
// Make sure the right buffer was drawn to the
|
||||
// right subplot.
|
||||
testDrawingObject.lines.forEach(function (line, j) {
|
||||
expect(line.buffer).toEqual(testBuffers[j]);
|
||||
});
|
||||
});
|
||||
@ -86,7 +113,10 @@ define(
|
||||
expect(mode.isZoomed()).toBeFalsy();
|
||||
|
||||
// Trigger some zoom changes
|
||||
mode.getSubPlots().forEach(doZoom);
|
||||
mockSubPlotFactory.createSubPlot.calls.forEach(function (c) {
|
||||
// Second argument to the factory was pan-zoom stack
|
||||
c.args[1].pushPanZoom([1, 2], [3, 4]);
|
||||
});
|
||||
|
||||
// Should start out unzoomed
|
||||
expect(mode.isZoomed()).toBeTruthy();
|
||||
@ -94,8 +124,10 @@ define(
|
||||
|
||||
it("supports unzooming", function () {
|
||||
// Trigger some zoom changes
|
||||
mode.getSubPlots().forEach(doZoom);
|
||||
|
||||
mockSubPlotFactory.createSubPlot.calls.forEach(function (c) {
|
||||
// Second argument to the factory was pan-zoom stack
|
||||
c.args[1].pushPanZoom([1, 2], [3, 4]);
|
||||
});
|
||||
// Verify that we are indeed zoomed now
|
||||
expect(mode.isZoomed()).toBeTruthy();
|
||||
|
||||
@ -108,12 +140,16 @@ define(
|
||||
|
||||
it("supports stepping back through zoom states", function () {
|
||||
// Trigger some zoom changes
|
||||
mode.getSubPlots().forEach(doZoom);
|
||||
mockSubPlotFactory.createSubPlot.calls.forEach(function (c) {
|
||||
// Second argument to the factory was pan-zoom stack
|
||||
c.args[1].pushPanZoom([1, 2], [3, 4]);
|
||||
});
|
||||
|
||||
// Step back the same number of zoom changes
|
||||
mode.getSubPlots().forEach(function (subplot, i) {
|
||||
mockSubPlotFactory.createSubPlot.calls.forEach(function (c) {
|
||||
// Should still be zoomed at start of each iteration
|
||||
expect(mode.isZoomed()).toBeTruthy();
|
||||
// Step back one of the zoom changes.
|
||||
mode.stepBackPanZoom();
|
||||
});
|
||||
|
||||
|
@ -10,8 +10,11 @@ define(
|
||||
|
||||
describe("Stacked plot mode", function () {
|
||||
var mockDomainObject,
|
||||
mockSubPlotFactory,
|
||||
mockSubPlot,
|
||||
mockPrepared,
|
||||
testBuffers,
|
||||
testDrawingObjects,
|
||||
mode;
|
||||
|
||||
function mockElement(x, y, w, h) {
|
||||
@ -22,10 +25,24 @@ define(
|
||||
};
|
||||
}
|
||||
|
||||
function doZoom(subplot, i) {
|
||||
subplot.startMarquee({ target: mockElement() });
|
||||
subplot.hover({ target: mockElement() });
|
||||
subplot.endMarquee({ target: mockElement() });
|
||||
function createMockSubPlot() {
|
||||
var mockSubPlot = jasmine.createSpyObj(
|
||||
"subPlot",
|
||||
[
|
||||
"setDomainOffset",
|
||||
"hover",
|
||||
"startMarquee",
|
||||
"endMarquee",
|
||||
"getDrawingObject",
|
||||
"update"
|
||||
]
|
||||
),
|
||||
testDrawingObject = {};
|
||||
|
||||
// Track drawing objects in order of creation
|
||||
testDrawingObjects.push(testDrawingObject);
|
||||
mockSubPlot.getDrawingObject.andReturn(testDrawingObject);
|
||||
return mockSubPlot;
|
||||
}
|
||||
|
||||
beforeEach(function () {
|
||||
@ -33,12 +50,18 @@ define(
|
||||
"domainObject",
|
||||
[ "getId", "getModel", "getCapability" ]
|
||||
);
|
||||
mockSubPlotFactory = jasmine.createSpyObj(
|
||||
"subPlotFactory",
|
||||
[ "createSubPlot" ]
|
||||
);
|
||||
// Prepared telemetry data
|
||||
mockPrepared = jasmine.createSpyObj(
|
||||
"prepared",
|
||||
[ "getDomainOffset", "getOrigin", "getDimensions", "getBuffers" ]
|
||||
);
|
||||
|
||||
mockSubPlotFactory.createSubPlot.andCallFake(createMockSubPlot);
|
||||
|
||||
// Act as if we have three buffers full of data
|
||||
testBuffers = [["a"], ["b"], ["c"]];
|
||||
mockPrepared.getBuffers.andReturn(testBuffers);
|
||||
@ -46,11 +69,14 @@ define(
|
||||
mockPrepared.getOrigin.andReturn([10, 10]);
|
||||
mockPrepared.getDimensions.andReturn([500, 500]);
|
||||
|
||||
// Objects that will be drawn to in sub-plots
|
||||
testDrawingObjects = [];
|
||||
|
||||
mode = new PlotStackMode([
|
||||
mockDomainObject,
|
||||
mockDomainObject,
|
||||
mockDomainObject
|
||||
]);
|
||||
], mockSubPlotFactory);
|
||||
});
|
||||
|
||||
it("creates one sub-plot per domain object", function () {
|
||||
@ -69,14 +95,14 @@ define(
|
||||
mode.plotTelemetry(mockPrepared);
|
||||
|
||||
// Should all each have one line
|
||||
mode.getSubPlots().forEach(function (subplot, i) {
|
||||
testDrawingObjects.forEach(function (testDrawingObject, i) {
|
||||
// Either empty list or undefined is fine;
|
||||
// just want to make sure there are no lines.
|
||||
expect(subplot.getDrawingObject().lines.length)
|
||||
expect(testDrawingObject.lines.length)
|
||||
.toEqual(1);
|
||||
// Make sure the right buffer was drawn to the
|
||||
// right subplot.
|
||||
expect(subplot.getDrawingObject().lines[0].buffer)
|
||||
expect(testDrawingObject.lines[0].buffer)
|
||||
.toEqual(testBuffers[i]);
|
||||
});
|
||||
});
|
||||
@ -86,7 +112,10 @@ define(
|
||||
expect(mode.isZoomed()).toBeFalsy();
|
||||
|
||||
// Trigger some zoom changes
|
||||
mode.getSubPlots().forEach(doZoom);
|
||||
mockSubPlotFactory.createSubPlot.calls.forEach(function (c) {
|
||||
// Second argument to the factory was pan-zoom stack
|
||||
c.args[1].pushPanZoom([1, 2], [3, 4]);
|
||||
});
|
||||
|
||||
// Should start out unzoomed
|
||||
expect(mode.isZoomed()).toBeTruthy();
|
||||
@ -94,8 +123,10 @@ define(
|
||||
|
||||
it("supports unzooming", function () {
|
||||
// Trigger some zoom changes
|
||||
mode.getSubPlots().forEach(doZoom);
|
||||
|
||||
mockSubPlotFactory.createSubPlot.calls.forEach(function (c) {
|
||||
// Second argument to the factory was pan-zoom stack
|
||||
c.args[1].pushPanZoom([1, 2], [3, 4]);
|
||||
});
|
||||
// Verify that we are indeed zoomed now
|
||||
expect(mode.isZoomed()).toBeTruthy();
|
||||
|
||||
@ -108,12 +139,16 @@ define(
|
||||
|
||||
it("supports stepping back through zoom states", function () {
|
||||
// Trigger some zoom changes
|
||||
mode.getSubPlots().forEach(doZoom);
|
||||
mockSubPlotFactory.createSubPlot.calls.forEach(function (c) {
|
||||
// Second argument to the factory was pan-zoom stack
|
||||
c.args[1].pushPanZoom([1, 2], [3, 4]);
|
||||
});
|
||||
|
||||
// Step back the same number of zoom changes
|
||||
mode.getSubPlots().forEach(function (subplot, i) {
|
||||
mockSubPlotFactory.createSubPlot.calls.forEach(function (c) {
|
||||
// Should still be zoomed at start of each iteration
|
||||
expect(mode.isZoomed()).toBeTruthy();
|
||||
// Step back
|
||||
mode.stepBackPanZoom();
|
||||
});
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
"MCTChart",
|
||||
"PlotController",
|
||||
"SubPlot",
|
||||
"SubPlotFactory",
|
||||
"elements/PlotAxis",
|
||||
"elements/PlotPalette",
|
||||
"elements/PlotPanZoomStack",
|
||||
|
@ -11,6 +11,7 @@ define(
|
||||
describe("A domain column", function () {
|
||||
var mockDataSet,
|
||||
testMetadata,
|
||||
mockFormatter,
|
||||
column;
|
||||
|
||||
beforeEach(function () {
|
||||
@ -18,11 +19,15 @@ define(
|
||||
"data",
|
||||
[ "getDomainValue" ]
|
||||
);
|
||||
mockFormatter = jasmine.createSpyObj(
|
||||
"formatter",
|
||||
[ "formatDomainValue", "formatRangeValue" ]
|
||||
);
|
||||
testMetadata = {
|
||||
key: "testKey",
|
||||
name: "Test Name"
|
||||
};
|
||||
column = new DomainColumn(testMetadata);
|
||||
column = new DomainColumn(testMetadata, mockFormatter);
|
||||
});
|
||||
|
||||
it("reports a column header from domain metadata", function () {
|
||||
|
@ -11,6 +11,7 @@ define(
|
||||
describe("A range column", function () {
|
||||
var mockDataSet,
|
||||
testMetadata,
|
||||
mockFormatter,
|
||||
column;
|
||||
|
||||
beforeEach(function () {
|
||||
@ -18,11 +19,15 @@ define(
|
||||
"data",
|
||||
[ "getRangeValue" ]
|
||||
);
|
||||
mockFormatter = jasmine.createSpyObj(
|
||||
"formatter",
|
||||
[ "formatDomainValue", "formatRangeValue" ]
|
||||
);
|
||||
testMetadata = {
|
||||
key: "testKey",
|
||||
name: "Test Name"
|
||||
};
|
||||
column = new RangeColumn(testMetadata);
|
||||
column = new RangeColumn(testMetadata, mockFormatter);
|
||||
});
|
||||
|
||||
it("reports a column header from range metadata", function () {
|
||||
|
Loading…
x
Reference in New Issue
Block a user