mirror of
https://github.com/nasa/openmct.git
synced 2025-06-17 22:58:14 +00:00
[Plot] Complete specs related to stacked mode
Add specs for SubPlot, which was introduced to support presenting multiple plot areas within a single plot view (stacked plots, WTD-625.)
This commit is contained in:
@ -127,6 +127,11 @@ define(
|
|||||||
updateTicks();
|
updateTicks();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Start with the right initial drawing bounds,
|
||||||
|
// tick marks
|
||||||
|
updateDrawingBounds();
|
||||||
|
updateTicks();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
getTelemetryObjects: function () {
|
getTelemetryObjects: function () {
|
||||||
return telemetryObjects;
|
return telemetryObjects;
|
||||||
|
@ -9,17 +9,124 @@ define(
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
describe("A sub-plot", function () {
|
describe("A sub-plot", function () {
|
||||||
var subplot;
|
var mockDomainObject,
|
||||||
|
mockPanZoomStack,
|
||||||
|
mockElement,
|
||||||
|
testDomainObjects,
|
||||||
|
testOrigin,
|
||||||
|
testDimensions,
|
||||||
|
subplot;
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
|
mockDomainObject = jasmine.createSpyObj(
|
||||||
|
"domainObject",
|
||||||
|
[ "getId", "getModel", "getCapability" ]
|
||||||
|
);
|
||||||
|
mockPanZoomStack = jasmine.createSpyObj(
|
||||||
|
"panZoomStack",
|
||||||
|
[
|
||||||
|
"getDepth",
|
||||||
|
"pushPanZoom",
|
||||||
|
"popPanZoom",
|
||||||
|
"setBasePanZoom",
|
||||||
|
"clearPanZoom",
|
||||||
|
"getPanZoom",
|
||||||
|
"getOrigin",
|
||||||
|
"getDimensions"
|
||||||
|
]
|
||||||
|
);
|
||||||
|
mockElement = jasmine.createSpyObj(
|
||||||
|
"element",
|
||||||
|
[ "getBoundingClientRect" ]
|
||||||
|
);
|
||||||
|
|
||||||
it("provides coordinates on hover", function () {
|
testOrigin = [ 5, 10 ];
|
||||||
// expect(subplot.getHoverCoordinates().length).toEqual(0);
|
testDimensions = [ 3000, 1000 ];
|
||||||
//
|
testDomainObjects = [ mockDomainObject, mockDomainObject ];
|
||||||
// subplot.hover({ target: mockElement });
|
|
||||||
//
|
mockPanZoomStack.getOrigin.andReturn(testOrigin);
|
||||||
// expect(subplot.getHoverCoordinates().length).toEqual(2);
|
mockPanZoomStack.getDimensions.andReturn(testDimensions);
|
||||||
|
mockPanZoomStack.getPanZoom.andReturn(
|
||||||
|
{ origin: testOrigin, dimensions: testDimensions }
|
||||||
|
);
|
||||||
|
mockElement.getBoundingClientRect.andReturn(
|
||||||
|
{ left: 10, top: 20, width: 100, height: 100 }
|
||||||
|
);
|
||||||
|
|
||||||
|
subplot = new SubPlot(
|
||||||
|
testDomainObjects,
|
||||||
|
mockPanZoomStack
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
it("provides a getter for its plotted objects", function () {
|
||||||
|
expect(subplot.getTelemetryObjects())
|
||||||
|
.toEqual(testDomainObjects);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("exposes tick marks", function () {
|
||||||
|
// Just test availability; details are tested
|
||||||
|
// in PlotTickFormatter
|
||||||
|
expect(Array.isArray(subplot.getDomainTicks()))
|
||||||
|
.toBeTruthy();
|
||||||
|
expect(Array.isArray(subplot.getRangeTicks()))
|
||||||
|
.toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("allows hovering state to be tracked", function () {
|
||||||
|
expect(subplot.isHovering()).toBeFalsy();
|
||||||
|
expect(subplot.isHovering(true)).toBeTruthy();
|
||||||
|
expect(subplot.isHovering()).toBeTruthy();
|
||||||
|
expect(subplot.isHovering(false)).toBeFalsy();
|
||||||
|
expect(subplot.isHovering()).toBeFalsy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("provides hovering coordinates", function () {
|
||||||
|
// Should be empty when not hovering
|
||||||
|
expect(subplot.getHoverCoordinates()).toEqual([]);
|
||||||
|
|
||||||
|
// Start hovering
|
||||||
|
subplot.hover({ target: mockElement });
|
||||||
|
|
||||||
|
// Should now have coordinates to display
|
||||||
|
expect(subplot.getHoverCoordinates().length).toEqual(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("supports marquee zoom", function () {
|
||||||
|
expect(mockPanZoomStack.pushPanZoom).not.toHaveBeenCalled();
|
||||||
|
|
||||||
|
// Simulate a marquee zoom. Note that the mockElement
|
||||||
|
// is 100 by 100 and starts at 10,20
|
||||||
|
subplot.startMarquee({
|
||||||
|
target: mockElement,
|
||||||
|
clientX: 60,
|
||||||
|
clientY: 45
|
||||||
|
});
|
||||||
|
subplot.hover({
|
||||||
|
target: mockElement,
|
||||||
|
clientX: 75,
|
||||||
|
clientY: 85
|
||||||
|
});
|
||||||
|
subplot.endMarquee({
|
||||||
|
target: mockElement,
|
||||||
|
clientX: 80,
|
||||||
|
clientY: 95
|
||||||
|
});
|
||||||
|
// ... so the origin should be 50%,25% into current dimensions,
|
||||||
|
// and new dimensions should be 20%,50% thereof
|
||||||
|
|
||||||
|
expect(mockPanZoomStack.pushPanZoom).toHaveBeenCalledWith(
|
||||||
|
[
|
||||||
|
testOrigin[0] + testDimensions[0] * 0.50,
|
||||||
|
testOrigin[1] + testDimensions[1] * 0.25
|
||||||
|
],
|
||||||
|
[
|
||||||
|
testDimensions[0] * 0.20,
|
||||||
|
testDimensions[1] * 0.50
|
||||||
|
]
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
Reference in New Issue
Block a user