mirror of
https://github.com/nasa/openmct.git
synced 2025-05-02 08:43:17 +00:00
[Plot] Update failing specs
Update failing specs after changes for WTD-806.
This commit is contained in:
parent
955c4209f0
commit
74b9d68dc8
@ -202,7 +202,7 @@ define(
|
|||||||
// Initially prepare state for these objects.
|
// Initially prepare state for these objects.
|
||||||
// Note that this may be an empty array at this time,
|
// Note that this may be an empty array at this time,
|
||||||
// so we also need to check during update cycles.
|
// so we also need to check during update cycles.
|
||||||
prepareLines(handle.getTelemetryObjects());
|
update();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
/**
|
/**
|
||||||
|
@ -11,8 +11,8 @@ define(
|
|||||||
describe("The plot controller", function () {
|
describe("The plot controller", function () {
|
||||||
var mockScope,
|
var mockScope,
|
||||||
mockFormatter,
|
mockFormatter,
|
||||||
mockSubscriber,
|
mockHandler,
|
||||||
mockSubscription,
|
mockHandle,
|
||||||
mockDomainObject,
|
mockDomainObject,
|
||||||
controller;
|
controller;
|
||||||
|
|
||||||
@ -30,28 +30,29 @@ define(
|
|||||||
"domainObject",
|
"domainObject",
|
||||||
[ "getId", "getModel", "getCapability" ]
|
[ "getId", "getModel", "getCapability" ]
|
||||||
);
|
);
|
||||||
mockSubscriber = jasmine.createSpyObj(
|
mockHandler = jasmine.createSpyObj(
|
||||||
"telemetrySubscriber",
|
"telemetrySubscriber",
|
||||||
["subscribe"]
|
["handle"]
|
||||||
);
|
);
|
||||||
mockSubscription = jasmine.createSpyObj(
|
mockHandle = jasmine.createSpyObj(
|
||||||
"subscription",
|
"subscription",
|
||||||
[
|
[
|
||||||
"unsubscribe",
|
"unsubscribe",
|
||||||
"getTelemetryObjects",
|
"getTelemetryObjects",
|
||||||
"getMetadata",
|
"getMetadata",
|
||||||
"getDomainValue",
|
"getDomainValue",
|
||||||
"getRangeValue"
|
"getRangeValue",
|
||||||
|
"request"
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
mockSubscriber.subscribe.andReturn(mockSubscription);
|
mockHandler.handle.andReturn(mockHandle);
|
||||||
mockSubscription.getTelemetryObjects.andReturn([mockDomainObject]);
|
mockHandle.getTelemetryObjects.andReturn([mockDomainObject]);
|
||||||
mockSubscription.getMetadata.andReturn([{}]);
|
mockHandle.getMetadata.andReturn([{}]);
|
||||||
mockSubscription.getDomainValue.andReturn(123);
|
mockHandle.getDomainValue.andReturn(123);
|
||||||
mockSubscription.getRangeValue.andReturn(42);
|
mockHandle.getRangeValue.andReturn(42);
|
||||||
|
|
||||||
controller = new PlotController(mockScope, mockFormatter, mockSubscriber);
|
controller = new PlotController(mockScope, mockFormatter, mockHandler);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("provides plot colors", function () {
|
it("provides plot colors", function () {
|
||||||
@ -71,7 +72,7 @@ define(
|
|||||||
// Make an object available
|
// Make an object available
|
||||||
mockScope.$watch.mostRecentCall.args[1](mockDomainObject);
|
mockScope.$watch.mostRecentCall.args[1](mockDomainObject);
|
||||||
// Should have subscribed
|
// Should have subscribed
|
||||||
expect(mockSubscriber.subscribe).toHaveBeenCalledWith(
|
expect(mockHandler.handle).toHaveBeenCalledWith(
|
||||||
mockDomainObject,
|
mockDomainObject,
|
||||||
jasmine.any(Function),
|
jasmine.any(Function),
|
||||||
true // Lossless
|
true // Lossless
|
||||||
@ -92,7 +93,7 @@ define(
|
|||||||
expect(controller.getSubPlots().length > 0).toBeTruthy();
|
expect(controller.getSubPlots().length > 0).toBeTruthy();
|
||||||
|
|
||||||
// Broadcast data
|
// Broadcast data
|
||||||
mockSubscriber.subscribe.mostRecentCall.args[1]();
|
mockHandler.handle.mostRecentCall.args[1]();
|
||||||
|
|
||||||
controller.getSubPlots().forEach(function (subplot) {
|
controller.getSubPlots().forEach(function (subplot) {
|
||||||
expect(subplot.getDrawingObject().lines)
|
expect(subplot.getDrawingObject().lines)
|
||||||
@ -104,17 +105,17 @@ define(
|
|||||||
// Make an object available
|
// Make an object available
|
||||||
mockScope.$watch.mostRecentCall.args[1](mockDomainObject);
|
mockScope.$watch.mostRecentCall.args[1](mockDomainObject);
|
||||||
// Verify precondition - shouldn't unsubscribe yet
|
// Verify precondition - shouldn't unsubscribe yet
|
||||||
expect(mockSubscription.unsubscribe).not.toHaveBeenCalled();
|
expect(mockHandle.unsubscribe).not.toHaveBeenCalled();
|
||||||
// Remove the domain object
|
// Remove the domain object
|
||||||
mockScope.$watch.mostRecentCall.args[1](undefined);
|
mockScope.$watch.mostRecentCall.args[1](undefined);
|
||||||
// Should have unsubscribed
|
// Should have unsubscribed
|
||||||
expect(mockSubscription.unsubscribe).toHaveBeenCalled();
|
expect(mockHandle.unsubscribe).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it("changes modes depending on number of objects", function () {
|
it("changes modes depending on number of objects", function () {
|
||||||
// Act like one object is available
|
// Act like one object is available
|
||||||
mockSubscription.getTelemetryObjects.andReturn([
|
mockHandle.getTelemetryObjects.andReturn([
|
||||||
mockDomainObject
|
mockDomainObject
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -124,7 +125,7 @@ define(
|
|||||||
expect(controller.getModeOptions().length).toEqual(1);
|
expect(controller.getModeOptions().length).toEqual(1);
|
||||||
|
|
||||||
// Act like one object is available
|
// Act like one object is available
|
||||||
mockSubscription.getTelemetryObjects.andReturn([
|
mockHandle.getTelemetryObjects.andReturn([
|
||||||
mockDomainObject,
|
mockDomainObject,
|
||||||
mockDomainObject,
|
mockDomainObject,
|
||||||
mockDomainObject
|
mockDomainObject
|
||||||
@ -180,11 +181,11 @@ define(
|
|||||||
// Make sure $destroy is what's listened for
|
// Make sure $destroy is what's listened for
|
||||||
expect(mockScope.$on.mostRecentCall.args[0]).toEqual('$destroy');
|
expect(mockScope.$on.mostRecentCall.args[0]).toEqual('$destroy');
|
||||||
// Also verify precondition
|
// Also verify precondition
|
||||||
expect(mockSubscription.unsubscribe).not.toHaveBeenCalled();
|
expect(mockHandle.unsubscribe).not.toHaveBeenCalled();
|
||||||
// Destroy the scope
|
// Destroy the scope
|
||||||
mockScope.$on.mostRecentCall.args[1]();
|
mockScope.$on.mostRecentCall.args[1]();
|
||||||
// Should have unsubscribed
|
// Should have unsubscribed
|
||||||
expect(mockSubscription.unsubscribe).toHaveBeenCalled();
|
expect(mockHandle.unsubscribe).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -55,57 +55,14 @@ define(
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("provides one buffer per telemetry object", function () {
|
it("provides one buffer per telemetry object", function () {
|
||||||
expect(updater.getBuffers().length).toEqual(3);
|
expect(updater.getLineBuffers().length).toEqual(3);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("changes buffer count if telemetry object counts change", function () {
|
it("changes buffer count if telemetry object counts change", function () {
|
||||||
mockSubscription.getTelemetryObjects
|
mockSubscription.getTelemetryObjects
|
||||||
.andReturn([makeMockDomainObject('a')]);
|
.andReturn([makeMockDomainObject('a')]);
|
||||||
updater.update();
|
updater.update();
|
||||||
expect(updater.getBuffers().length).toEqual(1);
|
expect(updater.getLineBuffers().length).toEqual(1);
|
||||||
});
|
|
||||||
|
|
||||||
it("maintains a buffer of received telemetry", function () {
|
|
||||||
// Count should be large enough to trigger a buffer resize
|
|
||||||
var count = 750,
|
|
||||||
i;
|
|
||||||
|
|
||||||
// Increment values exposed by subscription
|
|
||||||
function increment() {
|
|
||||||
Object.keys(testDomainValues).forEach(function (k) {
|
|
||||||
testDomainValues[k] += 1;
|
|
||||||
testRangeValues[k] += 1;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Simulate a lot of telemetry updates
|
|
||||||
for (i = 0; i < count; i += 1) {
|
|
||||||
updater.update();
|
|
||||||
expect(updater.getLength(0)).toEqual(i + 1);
|
|
||||||
expect(updater.getLength(1)).toEqual(i + 1);
|
|
||||||
expect(updater.getLength(2)).toEqual(i + 1);
|
|
||||||
increment();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Domain offset should be lowest domain value
|
|
||||||
expect(updater.getDomainOffset()).toEqual(3);
|
|
||||||
|
|
||||||
// Test against initial values, offset by count,
|
|
||||||
// as was the case during each update
|
|
||||||
for (i = 0; i < count; i += 1) {
|
|
||||||
expect(updater.getBuffers()[0][i * 2])
|
|
||||||
.toEqual(3 + i - 3);
|
|
||||||
expect(updater.getBuffers()[0][i * 2 + 1])
|
|
||||||
.toEqual(123 + i);
|
|
||||||
expect(updater.getBuffers()[1][i * 2])
|
|
||||||
.toEqual(7 + i - 3);
|
|
||||||
expect(updater.getBuffers()[1][i * 2 + 1])
|
|
||||||
.toEqual(456 + i);
|
|
||||||
expect(updater.getBuffers()[2][i * 2])
|
|
||||||
.toEqual(13 + i - 3);
|
|
||||||
expect(updater.getBuffers()[2][i * 2 + 1])
|
|
||||||
.toEqual(789 + i);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("can handle delayed telemetry object availability", function () {
|
it("can handle delayed telemetry object availability", function () {
|
||||||
@ -124,7 +81,7 @@ define(
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Should have 0 buffers for 0 objects
|
// Should have 0 buffers for 0 objects
|
||||||
expect(updater.getBuffers().length).toEqual(0);
|
expect(updater.getLineBuffers().length).toEqual(0);
|
||||||
|
|
||||||
// Restore the three objects the test subscription would
|
// Restore the three objects the test subscription would
|
||||||
// normally have.
|
// normally have.
|
||||||
@ -132,30 +89,9 @@ define(
|
|||||||
updater.update();
|
updater.update();
|
||||||
|
|
||||||
// Should have 3 buffers for 3 objects
|
// Should have 3 buffers for 3 objects
|
||||||
expect(updater.getBuffers().length).toEqual(3);
|
expect(updater.getLineBuffers().length).toEqual(3);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it("shifts buffer upon expansion", function () {
|
|
||||||
// Count should be large enough to hit buffer's max size
|
|
||||||
var count = 1400,
|
|
||||||
i;
|
|
||||||
|
|
||||||
// Initial update; should have 3 in first position
|
|
||||||
// (a's initial domain value)
|
|
||||||
updater.update();
|
|
||||||
expect(updater.getBuffers()[0][1]).toEqual(123);
|
|
||||||
|
|
||||||
// Simulate a lot of telemetry updates
|
|
||||||
for (i = 0; i < count; i += 1) {
|
|
||||||
testDomainValues.a += 1;
|
|
||||||
testRangeValues.a += 1;
|
|
||||||
updater.update();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Value at front of the buffer should have been pushed out
|
|
||||||
expect(updater.getBuffers()[0][1]).not.toEqual(123);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
@ -57,18 +57,30 @@ define(
|
|||||||
// Prepared telemetry data
|
// Prepared telemetry data
|
||||||
mockPrepared = jasmine.createSpyObj(
|
mockPrepared = jasmine.createSpyObj(
|
||||||
"prepared",
|
"prepared",
|
||||||
[ "getDomainOffset", "getOrigin", "getDimensions", "getBuffers", "getLength" ]
|
[
|
||||||
|
"getDomainOffset",
|
||||||
|
"getOrigin",
|
||||||
|
"getDimensions",
|
||||||
|
"getLineBuffers"
|
||||||
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
mockSubPlotFactory.createSubPlot.andCallFake(createMockSubPlot);
|
mockSubPlotFactory.createSubPlot.andCallFake(createMockSubPlot);
|
||||||
|
|
||||||
// Act as if we have three buffers full of data
|
// Act as if we have three buffers full of data
|
||||||
testBuffers = [["a"], ["b"], ["c"]];
|
testBuffers = ['a', 'b', 'c'].map(function (id) {
|
||||||
mockPrepared.getBuffers.andReturn(testBuffers);
|
var mockBuffer = jasmine.createSpyObj(
|
||||||
|
'buffer-' + id,
|
||||||
|
['getBuffer', 'getLength']
|
||||||
|
);
|
||||||
|
mockBuffer.getBuffer.andReturn([id]);
|
||||||
|
mockBuffer.getLength.andReturn(3);
|
||||||
|
return mockBuffer;
|
||||||
|
});
|
||||||
|
mockPrepared.getLineBuffers.andReturn(testBuffers);
|
||||||
mockPrepared.getDomainOffset.andReturn(1234);
|
mockPrepared.getDomainOffset.andReturn(1234);
|
||||||
mockPrepared.getOrigin.andReturn([10, 10]);
|
mockPrepared.getOrigin.andReturn([10, 10]);
|
||||||
mockPrepared.getDimensions.andReturn([500, 500]);
|
mockPrepared.getDimensions.andReturn([500, 500]);
|
||||||
mockPrepared.getLength.andReturn(3);
|
|
||||||
|
|
||||||
// Clear out drawing objects
|
// Clear out drawing objects
|
||||||
testDrawingObjects = [];
|
testDrawingObjects = [];
|
||||||
@ -104,7 +116,7 @@ define(
|
|||||||
// Make sure the right buffer was drawn to the
|
// Make sure the right buffer was drawn to the
|
||||||
// right subplot.
|
// right subplot.
|
||||||
testDrawingObject.lines.forEach(function (line, j) {
|
testDrawingObject.lines.forEach(function (line, j) {
|
||||||
expect(line.buffer).toEqual(testBuffers[j]);
|
expect(line.buffer).toEqual(testBuffers[j].getBuffer());
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -57,18 +57,25 @@ define(
|
|||||||
// Prepared telemetry data
|
// Prepared telemetry data
|
||||||
mockPrepared = jasmine.createSpyObj(
|
mockPrepared = jasmine.createSpyObj(
|
||||||
"prepared",
|
"prepared",
|
||||||
[ "getDomainOffset", "getOrigin", "getDimensions", "getBuffers", "getLength" ]
|
[ "getDomainOffset", "getOrigin", "getDimensions", "getLineBuffers" ]
|
||||||
);
|
);
|
||||||
|
|
||||||
mockSubPlotFactory.createSubPlot.andCallFake(createMockSubPlot);
|
mockSubPlotFactory.createSubPlot.andCallFake(createMockSubPlot);
|
||||||
|
|
||||||
// Act as if we have three buffers full of data
|
// Act as if we have three buffers full of data
|
||||||
testBuffers = [["a"], ["b"], ["c"]];
|
testBuffers = ['a', 'b', 'c'].map(function (id) {
|
||||||
mockPrepared.getBuffers.andReturn(testBuffers);
|
var mockBuffer = jasmine.createSpyObj(
|
||||||
|
'buffer-' + id,
|
||||||
|
['getBuffer', 'getLength']
|
||||||
|
);
|
||||||
|
mockBuffer.getBuffer.andReturn([id]);
|
||||||
|
mockBuffer.getLength.andReturn(3);
|
||||||
|
return mockBuffer;
|
||||||
|
});
|
||||||
|
mockPrepared.getLineBuffers.andReturn(testBuffers);
|
||||||
mockPrepared.getDomainOffset.andReturn(1234);
|
mockPrepared.getDomainOffset.andReturn(1234);
|
||||||
mockPrepared.getOrigin.andReturn([10, 10]);
|
mockPrepared.getOrigin.andReturn([10, 10]);
|
||||||
mockPrepared.getDimensions.andReturn([500, 500]);
|
mockPrepared.getDimensions.andReturn([500, 500]);
|
||||||
mockPrepared.getLength.andReturn(3);
|
|
||||||
|
|
||||||
// Objects that will be drawn to in sub-plots
|
// Objects that will be drawn to in sub-plots
|
||||||
testDrawingObjects = [];
|
testDrawingObjects = [];
|
||||||
@ -104,7 +111,7 @@ define(
|
|||||||
// Make sure the right buffer was drawn to the
|
// Make sure the right buffer was drawn to the
|
||||||
// right subplot.
|
// right subplot.
|
||||||
expect(testDrawingObject.lines[0].buffer)
|
expect(testDrawingObject.lines[0].buffer)
|
||||||
.toEqual(testBuffers[i]);
|
.toEqual(testBuffers[i].getBuffer());
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user