mirror of
https://github.com/nasa/openmct.git
synced 2024-12-21 22:17:49 +00:00
Merge remote-tracking branch 'origin/missing-time-conductor-957'
This commit is contained in:
commit
37a417051d
@ -97,6 +97,8 @@ define(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$scope.$watch("configuration", swimlanePopulator.configure);
|
||||||
|
|
||||||
// Recalculate swimlane state on changes
|
// Recalculate swimlane state on changes
|
||||||
$scope.$watch("domainObject", swimlanePopulator.populate);
|
$scope.$watch("domainObject", swimlanePopulator.populate);
|
||||||
|
|
||||||
|
@ -43,8 +43,7 @@ define(
|
|||||||
var swimlanes = [],
|
var swimlanes = [],
|
||||||
start = Number.POSITIVE_INFINITY,
|
start = Number.POSITIVE_INFINITY,
|
||||||
end = Number.NEGATIVE_INFINITY,
|
end = Number.NEGATIVE_INFINITY,
|
||||||
colors = (configuration.colors || {}),
|
assigner,
|
||||||
assigner = new TimelineColorAssigner(colors),
|
|
||||||
lastDomainObject;
|
lastDomainObject;
|
||||||
|
|
||||||
// Track extremes of start/end times
|
// Track extremes of start/end times
|
||||||
@ -152,8 +151,15 @@ define(
|
|||||||
recalculateSwimlanes(lastDomainObject);
|
recalculateSwimlanes(lastDomainObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure colors are exposed in configuration
|
function initialize() {
|
||||||
|
var colors = (configuration.colors || {});
|
||||||
|
assigner = new TimelineColorAssigner(colors);
|
||||||
configuration.colors = colors;
|
configuration.colors = colors;
|
||||||
|
recalculateSwimlanes(lastDomainObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure colors are exposed in configuration
|
||||||
|
initialize();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
/**
|
/**
|
||||||
@ -188,6 +194,15 @@ define(
|
|||||||
*/
|
*/
|
||||||
end: function () {
|
end: function () {
|
||||||
return end;
|
return end;
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* Pass a new configuration object (to retrieve and store
|
||||||
|
* swimlane configuration)
|
||||||
|
* @param newConfig
|
||||||
|
*/
|
||||||
|
configure: function (newConfig) {
|
||||||
|
configuration = newConfig;
|
||||||
|
initialize();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -68,6 +68,14 @@ define(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function fireWatch(expr, value) {
|
||||||
|
mockScope.$watch.calls.forEach(function (call) {
|
||||||
|
if (call.args[0] === expr) {
|
||||||
|
call.args[1](value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
var mockA, mockB, mockUtilization, mockPromise, mockGraph, testCapabilities;
|
var mockA, mockB, mockUtilization, mockPromise, mockGraph, testCapabilities;
|
||||||
@ -141,9 +149,15 @@ define(
|
|||||||
expect(mockScope.scroll.y).toEqual(0);
|
expect(mockScope.scroll.y).toEqual(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("watches for a configuration object", function () {
|
||||||
|
expect(mockScope.$watch).toHaveBeenCalledWith(
|
||||||
|
"configuration",
|
||||||
|
jasmine.any(Function)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it("repopulates when modifications are made", function () {
|
it("repopulates when modifications are made", function () {
|
||||||
var fnWatchCall,
|
var fnWatchCall;
|
||||||
strWatchCall;
|
|
||||||
|
|
||||||
// Find the $watch that was given a function
|
// Find the $watch that was given a function
|
||||||
mockScope.$watch.calls.forEach(function (call) {
|
mockScope.$watch.calls.forEach(function (call) {
|
||||||
@ -151,16 +165,11 @@ define(
|
|||||||
// white-box: we know the first call is
|
// white-box: we know the first call is
|
||||||
// the one we're looking for
|
// the one we're looking for
|
||||||
fnWatchCall = fnWatchCall || call;
|
fnWatchCall = fnWatchCall || call;
|
||||||
} else if (typeof call.args[0] === 'string') {
|
|
||||||
strWatchCall = strWatchCall || call;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Make sure string watch was for domainObject
|
// Make sure string watch was for domainObject
|
||||||
expect(strWatchCall.args[0]).toEqual('domainObject');
|
fireWatch('domainObject', mockDomainObject);
|
||||||
// Initially populate
|
|
||||||
strWatchCall.args[1](mockDomainObject);
|
|
||||||
|
|
||||||
// There should be to swimlanes
|
// There should be to swimlanes
|
||||||
expect(controller.swimlanes().length).toEqual(2);
|
expect(controller.swimlanes().length).toEqual(2);
|
||||||
|
|
||||||
@ -182,23 +191,23 @@ define(
|
|||||||
// order of $watch calls in TimelineController.
|
// order of $watch calls in TimelineController.
|
||||||
|
|
||||||
// Initially populate
|
// Initially populate
|
||||||
mockScope.$watch.calls[0].args[1](mockDomainObject);
|
fireWatch('domainObject', mockDomainObject);
|
||||||
|
|
||||||
// Verify precondition - no graphs
|
// Verify precondition - no graphs
|
||||||
expect(controller.graphs().length).toEqual(0);
|
expect(controller.graphs().length).toEqual(0);
|
||||||
|
|
||||||
// Execute the watch function for graph state
|
// Execute the watch function for graph state
|
||||||
tmp = mockScope.$watch.calls[2].args[0]();
|
tmp = mockScope.$watch.calls[3].args[0]();
|
||||||
|
|
||||||
// Change graph state
|
// Change graph state
|
||||||
testConfiguration.graph = { a: true, b: true };
|
testConfiguration.graph = { a: true, b: true };
|
||||||
|
|
||||||
// Verify that this would have triggered a watch
|
// Verify that this would have triggered a watch
|
||||||
expect(mockScope.$watch.calls[2].args[0]())
|
expect(mockScope.$watch.calls[3].args[0]())
|
||||||
.not.toEqual(tmp);
|
.not.toEqual(tmp);
|
||||||
|
|
||||||
// Run the function the watch would have triggered
|
// Run the function the watch would have triggered
|
||||||
mockScope.$watch.calls[2].args[1]();
|
mockScope.$watch.calls[3].args[1]();
|
||||||
|
|
||||||
// Should have some graphs now
|
// Should have some graphs now
|
||||||
expect(controller.graphs().length).toEqual(2);
|
expect(controller.graphs().length).toEqual(2);
|
||||||
@ -211,7 +220,7 @@ define(
|
|||||||
mockZoom.duration.andReturn(12345);
|
mockZoom.duration.andReturn(12345);
|
||||||
|
|
||||||
// Initially populate
|
// Initially populate
|
||||||
mockScope.$watch.calls[0].args[1](mockDomainObject);
|
fireWatch('domainObject', mockDomainObject);
|
||||||
|
|
||||||
expect(controller.width(mockZoom)).toEqual(54321);
|
expect(controller.width(mockZoom)).toEqual(54321);
|
||||||
// Verify interactions; we took zoom's duration for our start/end,
|
// Verify interactions; we took zoom's duration for our start/end,
|
||||||
|
@ -177,6 +177,10 @@ define(
|
|||||||
// representation to store local variables into.
|
// representation to store local variables into.
|
||||||
$scope.representation = {};
|
$scope.representation = {};
|
||||||
|
|
||||||
|
// Change templates (passing in undefined to clear
|
||||||
|
// if we don't have enough info to show a template.)
|
||||||
|
changeTemplate(canRepresent ? representation : undefined);
|
||||||
|
|
||||||
// Any existing representers are no longer valid; release them.
|
// Any existing representers are no longer valid; release them.
|
||||||
destroyRepresenters();
|
destroyRepresenters();
|
||||||
|
|
||||||
@ -222,10 +226,6 @@ define(
|
|||||||
// next change object/key pair changes
|
// next change object/key pair changes
|
||||||
toClear = uses.concat(['model']);
|
toClear = uses.concat(['model']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change templates (passing in undefined to clear
|
|
||||||
// if we don't have enough info to show a template.)
|
|
||||||
changeTemplate(canRepresent ? representation : undefined);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the representation when the key changes (e.g. if a
|
// Update the representation when the key changes (e.g. if a
|
||||||
|
@ -194,21 +194,6 @@ define(
|
|||||||
.toHaveBeenCalledWith(testViews[1]);
|
.toHaveBeenCalledWith(testViews[1]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("exposes configuration before changing templates", function () {
|
|
||||||
var observedConfiguration;
|
|
||||||
|
|
||||||
mockChangeTemplate.andCallFake(function () {
|
|
||||||
observedConfiguration = mockScope.configuration;
|
|
||||||
});
|
|
||||||
|
|
||||||
mockScope.key = "xyz";
|
|
||||||
mockScope.domainObject = mockDomainObject;
|
|
||||||
fireWatch('key', mockScope.key);
|
|
||||||
fireWatch('domainObject', mockDomainObject);
|
|
||||||
|
|
||||||
expect(observedConfiguration).toBeDefined();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("does not load templates until there is an object", function () {
|
it("does not load templates until there is an object", function () {
|
||||||
mockScope.key = "xyz";
|
mockScope.key = "xyz";
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user