mirror of
https://github.com/nasa/openmct.git
synced 2025-01-18 18:57:01 +00:00
Merge pull request #30 from slhale/open26
[Events] Create tests for real time version
This commit is contained in:
commit
0b4aa730f4
@ -47,6 +47,8 @@ define(
|
||||
* @returns {string} the title to display
|
||||
*/
|
||||
getTitle: function () {
|
||||
// At the moment there does not appear to be a way to get the
|
||||
// column's title through metadata for real time telemetry
|
||||
return "Time";
|
||||
},
|
||||
/**
|
||||
|
@ -46,6 +46,7 @@ define(
|
||||
rows = [];
|
||||
|
||||
function getTelemetryObjects() {
|
||||
//console.log("handle.getTelemetryObjects() ", handle.getTelemetryObjects());
|
||||
return handle ? handle.getTelemetryObjects() : [];
|
||||
}
|
||||
|
||||
@ -92,7 +93,6 @@ define(
|
||||
return column.getValue(telemetryObject, handle).text;
|
||||
}));
|
||||
// Remove first rows when adding past the max rows limit
|
||||
//rows.splice(ROW_COUNT, Number.MAX_VALUE);
|
||||
rows.splice(0, rows.length - ROW_COUNT);
|
||||
lastUpdated[id] = domainValue;
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ define(
|
||||
|
||||
/**
|
||||
* A column which will report telemetry range values
|
||||
* (typically, measurements.) Used by the RTScrollingListController.
|
||||
* (typically, measurements.) Used by the RTEventListController.
|
||||
*
|
||||
* @constructor
|
||||
* @param rangeMetadata an object with the machine- and human-
|
||||
|
@ -30,7 +30,7 @@ define(
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Policy controlling when the Messages view should be avaliable.
|
||||
* Policy controlling when the real time Messages view should be avaliable.
|
||||
* @constructor
|
||||
*/
|
||||
function RTMessagesViewPolicy() {
|
||||
@ -39,7 +39,6 @@ define(
|
||||
var telemetry = domainObject &&
|
||||
domainObject.getCapability('telemetry'),
|
||||
metadata = telemetry ? telemetry.getMetadata() : {},
|
||||
data = telemetry ? telemetry.requestData() : {},
|
||||
ranges = metadata.ranges || [];
|
||||
|
||||
return ranges.some(function (range) {
|
||||
|
@ -0,0 +1,88 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT Web, Copyright (c) 2014-2015, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT Web includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
/*global define,describe,it,expect,beforeEach,waitsFor,jasmine*/
|
||||
|
||||
/**
|
||||
* RTEventSpec. Created by vwoeltje on 11/6/14. Modified by shale on 06/25/2015.
|
||||
*/
|
||||
define(
|
||||
["../src/DomainColumn"],
|
||||
function (DomainColumn) {
|
||||
"use strict";
|
||||
|
||||
var TEST_DOMAIN_VALUE = "some formatted domain value";
|
||||
|
||||
describe("A real time event list domain column", function () {
|
||||
var mockDomainObject,
|
||||
mockTelemetryHandler,
|
||||
mockHandle,
|
||||
mockFormatter,
|
||||
column;
|
||||
|
||||
beforeEach(function () {
|
||||
mockDomainObject = jasmine.createSpyObj(
|
||||
"domainObject",
|
||||
["getModel", "getCapability"]
|
||||
);
|
||||
mockTelemetryHandler = jasmine.createSpyObj(
|
||||
"telemetryHandler",
|
||||
["handle"]
|
||||
);
|
||||
mockHandle = jasmine.createSpyObj(
|
||||
"handle",
|
||||
["getDomainValue", "getRangeValue"]
|
||||
);
|
||||
mockFormatter = jasmine.createSpyObj(
|
||||
"formatter",
|
||||
["formatDomainValue", "formatRangeValue"]
|
||||
);
|
||||
mockFormatter.formatDomainValue.andReturn(TEST_DOMAIN_VALUE);
|
||||
|
||||
column = new DomainColumn(mockFormatter);
|
||||
});
|
||||
|
||||
it("reports the domain column header as 'Time'", function () {
|
||||
expect(column.getTitle()).toEqual("Time");
|
||||
});
|
||||
|
||||
it("retrives data from a telemetry provider", function () {
|
||||
column.getValue(mockDomainObject, mockHandle);
|
||||
expect(mockHandle.getDomainValue).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("formats domain values as time", function () {
|
||||
mockHandle.getDomainValue.andReturn(402513731000);
|
||||
|
||||
// Should have just given the value the formatter gave
|
||||
expect(column.getValue(mockDomainObject, mockHandle).text)
|
||||
.toEqual(TEST_DOMAIN_VALUE);
|
||||
|
||||
// Make sure that service interactions were as expected
|
||||
expect(mockFormatter.formatDomainValue)
|
||||
.toHaveBeenCalledWith(402513731000);
|
||||
expect(mockFormatter.formatRangeValue)
|
||||
.not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
);
|
@ -0,0 +1,130 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT Web, Copyright (c) 2014-2015, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT Web includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
/*global define,describe,it,expect,beforeEach,waitsFor,jasmine*/
|
||||
|
||||
/**
|
||||
* RTEventSpec. Created by shale on 06/25/2015.
|
||||
*/
|
||||
define(
|
||||
["../src/RTEventListController"],
|
||||
function (RTEventListController) {
|
||||
"use strict";
|
||||
|
||||
describe("The real time event list controller", function () {
|
||||
var mockDomainObject,
|
||||
mockScope,
|
||||
mockTelemetryHandler,
|
||||
mockHandle,
|
||||
mockTelemetryFormatter,
|
||||
controller;
|
||||
|
||||
beforeEach(function () {
|
||||
mockDomainObject = jasmine.createSpyObj(
|
||||
"domainObject",
|
||||
[ "getId", "getModel", "getCapability" ]
|
||||
);
|
||||
mockScope = jasmine.createSpyObj(
|
||||
"$scope",
|
||||
[ "$on", "$watch" ]
|
||||
);
|
||||
mockTelemetryHandler = jasmine.createSpyObj(
|
||||
"telemetryHandler",
|
||||
["handle"]
|
||||
);
|
||||
mockHandle = jasmine.createSpyObj(
|
||||
"handle",
|
||||
["getDomainValue", "getRangeValue", "getTelemetryObjects", "unsubscribe"]
|
||||
);
|
||||
mockTelemetryFormatter = jasmine.createSpyObj(
|
||||
"formatter",
|
||||
["formatDomainValue", "formatRangeValue"]
|
||||
);
|
||||
|
||||
controller = new RTEventListController(mockScope, mockTelemetryHandler, mockTelemetryFormatter);
|
||||
|
||||
mockHandle.getDomainValue.andReturn("domain value");
|
||||
mockHandle.getRangeValue.andReturn("range value");
|
||||
|
||||
mockTelemetryHandler.handle.andReturn(mockHandle);
|
||||
mockHandle.getTelemetryObjects.andReturn([mockDomainObject]);
|
||||
|
||||
// Subscribe to the RT telemetry
|
||||
// second argument of: $scope.$watch("domainObject", makeSubscription);
|
||||
mockScope.$watch.calls.forEach(function (c) {
|
||||
// There are two possible calls of $watch, so we need to filter
|
||||
// through the calls to get the correct kind
|
||||
if (c.args[0] === 'domainObject') {
|
||||
c.args[1]();
|
||||
}
|
||||
});
|
||||
|
||||
// callback, passed into telemetry handler
|
||||
mockTelemetryHandler.handle.mostRecentCall.args[1]();
|
||||
|
||||
// Update the telemetry objects
|
||||
// second argument of: $scope.$watch(getTelemetryObjects, updateObjects);
|
||||
mockScope.$watch.calls.forEach(function (c) {
|
||||
// There are two possible calls of $watch, so we need to filter
|
||||
// through the calls to get the correct kind
|
||||
if (c.args[0] !== 'domainObject') {
|
||||
c.args[1]([mockDomainObject]);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
it("provides a domain and a range column", function () {
|
||||
// Should have two columns with these headers
|
||||
expect(controller.headers()).toEqual(["Time", "Message"]);
|
||||
});
|
||||
|
||||
it("listens for telemetry data updates", function () {
|
||||
// Of the two possible $watch calls, this corresponds to
|
||||
// $scope.$watch(getTelemetryObjects, updateObjects);
|
||||
expect(mockScope.$watch).toHaveBeenCalledWith(
|
||||
jasmine.any(Function),
|
||||
jasmine.any(Function)
|
||||
);
|
||||
});
|
||||
|
||||
it("makes telemetry subscriptions", function () {
|
||||
// Of the two possible $watch calls, this corresponds to
|
||||
// $scope.$watch("domainObject", makeSubscription);
|
||||
expect(mockScope.$watch).toHaveBeenCalledWith(
|
||||
"domainObject",
|
||||
jasmine.any(Function)
|
||||
);
|
||||
});
|
||||
|
||||
it("releases telemetry subscriptions on destruction", function () {
|
||||
// Call the second argument of
|
||||
// $scope.$on("$destroy", releaseSubscription);
|
||||
mockScope.$on.mostRecentCall.args[1]();
|
||||
|
||||
expect(mockScope.$on).toHaveBeenCalledWith(
|
||||
"$destroy",
|
||||
jasmine.any(Function)
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
@ -0,0 +1,84 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT Web, Copyright (c) 2014-2015, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT Web includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
/*global define,describe,it,expect,beforeEach,waitsFor,jasmine*/
|
||||
|
||||
/**
|
||||
* RTEventSpec. Created by vwoeltje on 11/6/14. Modified by shale on 06/25/2015.
|
||||
*/
|
||||
define(
|
||||
["../src/RangeColumn"],
|
||||
function (RangeColumn) {
|
||||
"use strict";
|
||||
|
||||
var TEST_RANGE_VALUE = "some formatted range value";
|
||||
|
||||
describe("A real time event list range column", function () {
|
||||
var mockDomainObject,
|
||||
mockTelemetryHandler,
|
||||
mockHandle,
|
||||
mockFormatter,
|
||||
column;
|
||||
|
||||
beforeEach(function () {
|
||||
mockDomainObject = jasmine.createSpyObj(
|
||||
"domainObject",
|
||||
["getModel", "getCapability"]
|
||||
);
|
||||
mockTelemetryHandler = jasmine.createSpyObj(
|
||||
"telemetryHandler",
|
||||
["handle"]
|
||||
);
|
||||
mockHandle = jasmine.createSpyObj(
|
||||
"handle",
|
||||
["getDomainValue", "getRangeValue"]
|
||||
);
|
||||
mockFormatter = jasmine.createSpyObj(
|
||||
"formatter",
|
||||
["formatDomainValue", "formatRangeValue"]
|
||||
);
|
||||
mockFormatter.formatRangeValue.andReturn(TEST_RANGE_VALUE);
|
||||
|
||||
column = new RangeColumn();
|
||||
});
|
||||
|
||||
it("reports a range column header as 'Message'", function () {
|
||||
expect(column.getTitle()).toEqual("Message");
|
||||
});
|
||||
|
||||
it("retrives data from a telemetry provider", function () {
|
||||
column.getValue(mockDomainObject, mockHandle);
|
||||
expect(mockHandle.getRangeValue).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("does not format range values", function () {
|
||||
mockHandle.getRangeValue.andReturn(123.45678);
|
||||
// Does not format range value as time
|
||||
expect(column.getValue(mockDomainObject, mockHandle).text)
|
||||
.not.toEqual(TEST_RANGE_VALUE);
|
||||
// There should be no additional formatting
|
||||
// i.e. the message string stays a string
|
||||
expect(column.getValue(mockDomainObject, mockHandle).text)
|
||||
.toEqual(123.45678);
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
@ -0,0 +1,82 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT Web, Copyright (c) 2014-2015, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT Web includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
/*global define,describe,it,expect,beforeEach,jasmine*/
|
||||
|
||||
/**
|
||||
* RTEventSpec. Created by shale on 06/25/2015.
|
||||
*/
|
||||
define(
|
||||
["../../src/policies/RTMessagesViewPolicy"],
|
||||
function (RTMessagesViewPolicy) {
|
||||
"use strict";
|
||||
|
||||
describe("The real time Messages view policy", function () {
|
||||
var testView,
|
||||
mockDomainObject,
|
||||
mockTelemetry,
|
||||
testMetadata,
|
||||
policy;
|
||||
|
||||
beforeEach(function () {
|
||||
testView = { key: "rtmessages" };
|
||||
testMetadata = {};
|
||||
mockDomainObject = jasmine.createSpyObj(
|
||||
'domainObject',
|
||||
['getId', 'getModel', 'getCapability']
|
||||
);
|
||||
mockTelemetry = jasmine.createSpyObj(
|
||||
'telemetry',
|
||||
['getMetadata']
|
||||
);
|
||||
mockDomainObject.getCapability.andCallFake(function (c) {
|
||||
return c === 'telemetry' ? mockTelemetry : undefined;
|
||||
});
|
||||
mockTelemetry.getMetadata.andReturn(testMetadata);
|
||||
|
||||
policy = new RTMessagesViewPolicy();
|
||||
});
|
||||
|
||||
it("allows the real time messages view for domain objects with string telemetry", function () {
|
||||
testMetadata.ranges = [ { key: "foo", format: "string" } ];
|
||||
expect(policy.allow(testView, mockDomainObject)).toBeTruthy();
|
||||
});
|
||||
|
||||
it("disallows the real time messages view for domain objects without string telemetry", function () {
|
||||
testMetadata.ranges = [ { key: "foo", format: "somethingElse" } ];
|
||||
expect(policy.allow(testView, mockDomainObject)).toBeFalsy();
|
||||
});
|
||||
|
||||
it("disallows the real time messages view for domain objects without telemetry", function () {
|
||||
testMetadata.ranges = [ { key: "foo", format: "string" } ];
|
||||
mockDomainObject.getCapability.andReturn(undefined);
|
||||
expect(policy.allow(testView, mockDomainObject)).toBeFalsy();
|
||||
});
|
||||
|
||||
it("allows other views", function () {
|
||||
testView.key = "somethingElse";
|
||||
testMetadata.ranges = [ { key: "foo", format: "somethingElse" } ];
|
||||
expect(policy.allow(testView, mockDomainObject)).toBeTruthy();
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
);
|
6
platform/features/rtevents/test/suite.json
Normal file
6
platform/features/rtevents/test/suite.json
Normal file
@ -0,0 +1,6 @@
|
||||
[
|
||||
"DomainColumn",
|
||||
"policies/RTMessagesViewPolicy",
|
||||
"RangeColumn",
|
||||
"RTEventListController"
|
||||
]
|
Loading…
Reference in New Issue
Block a user