2015-05-13 23:42:35 +00:00
|
|
|
/*****************************************************************************
|
2018-05-14 22:46:17 +00:00
|
|
|
* Open MCT, Copyright (c) 2014-2018, United States Government
|
2015-05-13 23:42:35 +00:00
|
|
|
* as represented by the Administrator of the National Aeronautics and Space
|
|
|
|
* Administration. All rights reserved.
|
|
|
|
*
|
2016-07-12 23:21:58 +00:00
|
|
|
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
2015-05-13 23:42:35 +00:00
|
|
|
* "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.
|
|
|
|
*
|
2016-07-12 23:21:58 +00:00
|
|
|
* Open MCT includes source code licensed under additional open source
|
2015-05-13 23:42:35 +00:00
|
|
|
* 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.
|
|
|
|
*****************************************************************************/
|
2014-12-05 23:39:07 +00:00
|
|
|
|
|
|
|
define(
|
2017-12-07 21:04:46 +00:00
|
|
|
[
|
|
|
|
"../src/LayoutController",
|
|
|
|
"zepto"
|
|
|
|
],
|
|
|
|
function (
|
|
|
|
LayoutController,
|
|
|
|
$
|
|
|
|
) {
|
2014-12-05 23:39:07 +00:00
|
|
|
|
|
|
|
describe("The Layout controller", function () {
|
2014-12-06 00:53:53 +00:00
|
|
|
var mockScope,
|
2015-06-25 18:35:18 +00:00
|
|
|
mockEvent,
|
2014-12-06 00:53:53 +00:00
|
|
|
testModel,
|
|
|
|
testConfiguration,
|
2015-11-24 21:05:00 +00:00
|
|
|
controller,
|
|
|
|
mockCompositionCapability,
|
2015-11-26 02:53:37 +00:00
|
|
|
mockComposition,
|
2017-12-07 21:04:46 +00:00
|
|
|
mockCompositionObjects,
|
|
|
|
mockOpenMCT,
|
|
|
|
mockSelection,
|
|
|
|
mockDomainObjectCapability,
|
2018-06-27 20:30:01 +00:00
|
|
|
mockObjects,
|
|
|
|
unlistenFunc,
|
2017-12-07 21:04:46 +00:00
|
|
|
$element = [],
|
|
|
|
selectable = [];
|
2015-11-24 21:05:00 +00:00
|
|
|
|
2016-05-19 18:29:13 +00:00
|
|
|
function mockPromise(value) {
|
2015-11-24 21:05:00 +00:00
|
|
|
return {
|
|
|
|
then: function (thenFunc) {
|
|
|
|
return mockPromise(thenFunc(value));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2016-05-19 18:29:13 +00:00
|
|
|
function mockDomainObject(id) {
|
2015-11-24 21:05:00 +00:00
|
|
|
return {
|
2016-05-19 18:29:13 +00:00
|
|
|
getId: function () {
|
2015-11-24 21:05:00 +00:00
|
|
|
return id;
|
|
|
|
},
|
2016-05-19 18:29:13 +00:00
|
|
|
useCapability: function () {
|
2015-11-24 21:05:00 +00:00
|
|
|
return mockCompositionCapability;
|
2017-08-18 23:28:41 +00:00
|
|
|
},
|
|
|
|
getModel: function () {
|
|
|
|
if (id === 'b') {
|
|
|
|
return {
|
|
|
|
type : 'hyperlink'
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
return {};
|
|
|
|
}
|
2017-12-07 21:04:46 +00:00
|
|
|
},
|
|
|
|
getCapability: function () {
|
|
|
|
return mockDomainObjectCapability;
|
|
|
|
},
|
|
|
|
hasCapability: function (param) {
|
|
|
|
if (param === 'composition') {
|
|
|
|
return id !== 'b';
|
|
|
|
}
|
2018-06-27 20:30:01 +00:00
|
|
|
},
|
|
|
|
type: "testType"
|
2015-11-24 21:05:00 +00:00
|
|
|
};
|
|
|
|
}
|
2014-12-06 00:53:53 +00:00
|
|
|
|
|
|
|
beforeEach(function () {
|
|
|
|
mockScope = jasmine.createSpyObj(
|
|
|
|
"$scope",
|
2018-06-27 20:30:01 +00:00
|
|
|
["$watch", "$watchCollection", "$on"]
|
2014-12-06 00:53:53 +00:00
|
|
|
);
|
2015-06-25 18:35:18 +00:00
|
|
|
mockEvent = jasmine.createSpyObj(
|
|
|
|
'event',
|
2017-08-18 23:28:41 +00:00
|
|
|
['preventDefault', 'stopPropagation']
|
2015-06-25 18:35:18 +00:00
|
|
|
);
|
2014-12-06 00:53:53 +00:00
|
|
|
|
2015-11-24 21:05:00 +00:00
|
|
|
testModel = {};
|
|
|
|
|
|
|
|
mockComposition = ["a", "b", "c"];
|
2015-11-26 02:53:37 +00:00
|
|
|
mockCompositionObjects = mockComposition.map(mockDomainObject);
|
2014-12-06 00:53:53 +00:00
|
|
|
|
|
|
|
testConfiguration = {
|
|
|
|
panels: {
|
|
|
|
a: {
|
|
|
|
position: [20, 10],
|
|
|
|
dimensions: [5, 5]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2018-06-27 20:30:01 +00:00
|
|
|
|
|
|
|
unlistenFunc = jasmine.createSpy("unlisten");
|
2017-12-07 21:04:46 +00:00
|
|
|
mockDomainObjectCapability = jasmine.createSpyObj('capability',
|
2018-06-27 20:30:01 +00:00
|
|
|
['inEditContext', 'listen']
|
2017-12-07 21:04:46 +00:00
|
|
|
);
|
2018-06-30 00:32:59 +00:00
|
|
|
mockDomainObjectCapability.listen.and.returnValue(unlistenFunc);
|
2018-06-27 20:30:01 +00:00
|
|
|
|
2015-11-26 02:53:37 +00:00
|
|
|
mockCompositionCapability = mockPromise(mockCompositionObjects);
|
2015-11-24 21:05:00 +00:00
|
|
|
|
|
|
|
mockScope.domainObject = mockDomainObject("mockDomainObject");
|
2014-12-06 00:53:53 +00:00
|
|
|
mockScope.model = testModel;
|
|
|
|
mockScope.configuration = testConfiguration;
|
2017-12-07 21:04:46 +00:00
|
|
|
|
|
|
|
selectable[0] = {
|
|
|
|
context: {
|
|
|
|
oldItem: mockScope.domainObject
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
mockSelection = jasmine.createSpyObj("selection", [
|
|
|
|
'select',
|
|
|
|
'on',
|
|
|
|
'off',
|
|
|
|
'get'
|
|
|
|
]);
|
2018-06-30 00:32:59 +00:00
|
|
|
mockSelection.get.and.returnValue(selectable);
|
2018-06-27 20:30:01 +00:00
|
|
|
|
|
|
|
mockObjects = jasmine.createSpyObj('objects', [
|
|
|
|
'get'
|
|
|
|
]);
|
2018-06-30 00:32:59 +00:00
|
|
|
mockObjects.get.and.returnValue(mockPromise(mockDomainObject("mockObject")));
|
2017-12-07 21:04:46 +00:00
|
|
|
mockOpenMCT = {
|
2018-06-27 20:30:01 +00:00
|
|
|
selection: mockSelection,
|
|
|
|
objects: mockObjects
|
2017-12-07 21:04:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
$element = $('<div></div>');
|
|
|
|
$(document).find('body').append($element);
|
|
|
|
spyOn($element[0], 'click');
|
2017-08-18 23:28:41 +00:00
|
|
|
|
2018-06-30 00:32:59 +00:00
|
|
|
spyOn(mockScope.domainObject, "useCapability").and.callThrough();
|
2014-12-06 00:53:53 +00:00
|
|
|
|
2017-12-07 21:04:46 +00:00
|
|
|
controller = new LayoutController(mockScope, $element, mockOpenMCT);
|
2018-06-30 00:32:59 +00:00
|
|
|
spyOn(controller, "layoutPanels").and.callThrough();
|
2018-06-27 20:30:01 +00:00
|
|
|
spyOn(controller, "commit");
|
2017-08-18 23:28:41 +00:00
|
|
|
|
2018-06-30 00:32:59 +00:00
|
|
|
jasmine.clock().install();
|
2014-12-06 00:53:53 +00:00
|
|
|
});
|
|
|
|
|
2017-12-07 21:04:46 +00:00
|
|
|
afterEach(function () {
|
|
|
|
$element.remove();
|
2018-06-30 00:32:59 +00:00
|
|
|
jasmine.clock().uninstall();
|
2017-12-07 21:04:46 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it("listens for selection change events", function () {
|
|
|
|
expect(mockOpenMCT.selection.on).toHaveBeenCalledWith(
|
|
|
|
'change',
|
|
|
|
jasmine.any(Function)
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("cleans up on scope destroy", function () {
|
|
|
|
expect(mockScope.$on).toHaveBeenCalledWith(
|
|
|
|
'$destroy',
|
|
|
|
jasmine.any(Function)
|
|
|
|
);
|
|
|
|
|
2018-06-30 00:32:59 +00:00
|
|
|
mockScope.$on.calls.all()[0].args[1]();
|
2017-12-07 21:04:46 +00:00
|
|
|
|
|
|
|
expect(mockOpenMCT.selection.off).toHaveBeenCalledWith(
|
|
|
|
'change',
|
|
|
|
jasmine.any(Function)
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2014-12-06 00:53:53 +00:00
|
|
|
// Model changes will indicate that panel positions
|
|
|
|
// may have changed, for instance.
|
2015-01-27 18:22:50 +00:00
|
|
|
it("watches for changes to composition", function () {
|
2015-11-24 21:05:00 +00:00
|
|
|
expect(mockScope.$watchCollection).toHaveBeenCalledWith(
|
2015-01-27 18:22:50 +00:00
|
|
|
"model.composition",
|
2014-12-06 00:53:53 +00:00
|
|
|
jasmine.any(Function)
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2015-11-24 21:05:00 +00:00
|
|
|
it("Retrieves updated composition from composition capability", function () {
|
2018-06-30 00:32:59 +00:00
|
|
|
mockScope.$watchCollection.calls.mostRecent().args[1]();
|
2015-11-24 21:05:00 +00:00
|
|
|
expect(mockScope.domainObject.useCapability).toHaveBeenCalledWith(
|
|
|
|
"composition"
|
|
|
|
);
|
|
|
|
expect(controller.layoutPanels).toHaveBeenCalledWith(
|
|
|
|
mockComposition
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2015-11-26 02:53:37 +00:00
|
|
|
it("Is robust to concurrent changes to composition", function () {
|
|
|
|
var secondMockComposition = ["a", "b", "c", "d"],
|
|
|
|
secondMockCompositionObjects = secondMockComposition.map(mockDomainObject),
|
|
|
|
firstCompositionCB,
|
|
|
|
secondCompositionCB;
|
|
|
|
|
|
|
|
spyOn(mockCompositionCapability, "then");
|
2018-06-30 00:32:59 +00:00
|
|
|
mockScope.$watchCollection.calls.mostRecent().args[1]();
|
|
|
|
mockScope.$watchCollection.calls.mostRecent().args[1]();
|
2015-11-26 02:53:37 +00:00
|
|
|
|
2018-06-30 00:32:59 +00:00
|
|
|
firstCompositionCB = mockCompositionCapability.then.calls.all()[0].args[0];
|
|
|
|
secondCompositionCB = mockCompositionCapability.then.calls.all()[1].args[0];
|
2015-11-26 02:53:37 +00:00
|
|
|
|
|
|
|
//Resolve promises in reverse order
|
|
|
|
secondCompositionCB(secondMockCompositionObjects);
|
|
|
|
firstCompositionCB(mockCompositionObjects);
|
|
|
|
|
|
|
|
//Expect the promise call that was initiated most recently to
|
|
|
|
// be the one used to populate scope, irrespective of order that
|
|
|
|
// it was eventually resolved
|
|
|
|
expect(mockScope.composition).toBe(secondMockCompositionObjects);
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2014-12-06 00:53:53 +00:00
|
|
|
it("provides styles for frames, from configuration", function () {
|
2018-06-30 00:32:59 +00:00
|
|
|
mockScope.$watchCollection.calls.mostRecent().args[1]();
|
2014-12-06 00:53:53 +00:00
|
|
|
expect(controller.getFrameStyle("a")).toEqual({
|
|
|
|
top: "320px",
|
|
|
|
left: "640px",
|
|
|
|
width: "160px",
|
2018-05-26 01:58:49 +00:00
|
|
|
height: "160px",
|
|
|
|
minWidth : '160px',
|
|
|
|
minHeight : '160px'
|
2014-12-06 00:53:53 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it("provides default styles for frames", function () {
|
|
|
|
var styleB, styleC;
|
|
|
|
|
|
|
|
// b and c do not have configured positions
|
2018-06-30 00:32:59 +00:00
|
|
|
mockScope.$watchCollection.calls.mostRecent().args[1]();
|
2014-12-06 00:53:53 +00:00
|
|
|
|
|
|
|
styleB = controller.getFrameStyle("b");
|
|
|
|
styleC = controller.getFrameStyle("c");
|
|
|
|
|
|
|
|
// Should have a position, but we don't care what
|
|
|
|
expect(styleB.left).toBeDefined();
|
|
|
|
expect(styleB.top).toBeDefined();
|
|
|
|
expect(styleC.left).toBeDefined();
|
|
|
|
expect(styleC.top).toBeDefined();
|
|
|
|
|
|
|
|
// Should have ensured some difference in position
|
|
|
|
expect(styleB).not.toEqual(styleC);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("allows panels to be dragged", function () {
|
|
|
|
// Populate scope
|
2018-06-30 00:32:59 +00:00
|
|
|
mockScope.$watchCollection.calls.mostRecent().args[1]();
|
2014-12-06 00:53:53 +00:00
|
|
|
|
2016-09-03 13:16:54 +00:00
|
|
|
// Verify precondition
|
2014-12-06 00:53:53 +00:00
|
|
|
expect(testConfiguration.panels.b).not.toBeDefined();
|
|
|
|
|
|
|
|
// Do a drag
|
|
|
|
controller.startDrag("b", [1, 1], [0, 0]);
|
|
|
|
controller.continueDrag([100, 100]);
|
|
|
|
controller.endDrag();
|
|
|
|
|
|
|
|
// We do not look closely at the details here;
|
|
|
|
// that is tested in LayoutDragSpec. Just make sure
|
|
|
|
// that a configuration for b has been defined.
|
|
|
|
expect(testConfiguration.panels.b).toBeDefined();
|
|
|
|
});
|
2014-12-06 17:45:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
it("invokes commit after drag", function () {
|
|
|
|
// Populate scope
|
2018-06-30 00:32:59 +00:00
|
|
|
mockScope.$watchCollection.calls.mostRecent().args[1]();
|
2014-12-06 17:45:41 +00:00
|
|
|
|
|
|
|
// Do a drag
|
|
|
|
controller.startDrag("b", [1, 1], [0, 0]);
|
|
|
|
controller.continueDrag([100, 100]);
|
|
|
|
controller.endDrag();
|
|
|
|
|
2018-06-27 20:30:01 +00:00
|
|
|
expect(controller.commit).toHaveBeenCalled();
|
2014-12-06 17:45:41 +00:00
|
|
|
});
|
2015-02-17 18:50:02 +00:00
|
|
|
|
|
|
|
it("listens for drop events", function () {
|
|
|
|
// Layout should position panels according to
|
|
|
|
// where the user dropped them, so it needs to
|
|
|
|
// listen for drop events.
|
|
|
|
expect(mockScope.$on).toHaveBeenCalledWith(
|
|
|
|
'mctDrop',
|
|
|
|
jasmine.any(Function)
|
|
|
|
);
|
|
|
|
|
|
|
|
// Verify precondition
|
|
|
|
expect(testConfiguration.panels.d).not.toBeDefined();
|
|
|
|
|
|
|
|
// Notify that a drop occurred
|
2018-06-30 00:32:59 +00:00
|
|
|
mockScope.$on.calls.mostRecent().args[1](
|
2015-06-25 18:35:18 +00:00
|
|
|
mockEvent,
|
2015-02-17 18:50:02 +00:00
|
|
|
'd',
|
|
|
|
{ x: 300, y: 100 }
|
|
|
|
);
|
|
|
|
expect(testConfiguration.panels.d).toBeDefined();
|
2015-06-25 18:35:18 +00:00
|
|
|
expect(mockEvent.preventDefault).toHaveBeenCalled();
|
2018-06-27 20:30:01 +00:00
|
|
|
expect(controller.commit).toHaveBeenCalled();
|
2015-02-17 18:50:02 +00:00
|
|
|
});
|
2015-06-25 18:35:18 +00:00
|
|
|
|
|
|
|
it("ignores drops when default has been prevented", function () {
|
|
|
|
// Avoids redundant drop-handling, WTD-1233
|
2015-06-26 18:53:45 +00:00
|
|
|
mockEvent.defaultPrevented = true;
|
2015-06-25 18:35:18 +00:00
|
|
|
|
|
|
|
// Notify that a drop occurred
|
2018-06-30 00:32:59 +00:00
|
|
|
mockScope.$on.calls.mostRecent().args[1](
|
2015-06-25 18:35:18 +00:00
|
|
|
mockEvent,
|
|
|
|
'd',
|
|
|
|
{ x: 300, y: 100 }
|
|
|
|
);
|
|
|
|
expect(testConfiguration.panels.d).not.toBeDefined();
|
|
|
|
});
|
2015-08-03 19:18:49 +00:00
|
|
|
|
|
|
|
it("ensures a minimum frame size", function () {
|
2016-03-04 20:56:14 +00:00
|
|
|
var styleB;
|
2015-08-03 19:18:49 +00:00
|
|
|
|
|
|
|
// Start with a very small frame size
|
2016-05-19 18:29:13 +00:00
|
|
|
testModel.layoutGrid = [1, 1];
|
2015-08-03 19:18:49 +00:00
|
|
|
|
|
|
|
// White-boxy; we know which watch is which
|
2018-06-30 00:32:59 +00:00
|
|
|
mockScope.$watch.calls.all()[0].args[1](testModel.layoutGrid);
|
|
|
|
mockScope.$watchCollection.calls.all()[0].args[1](testModel.composition);
|
2015-08-03 19:18:49 +00:00
|
|
|
|
|
|
|
styleB = controller.getFrameStyle("b");
|
|
|
|
|
|
|
|
// Resulting size should still be reasonably large pixel-size
|
|
|
|
expect(parseInt(styleB.width, 10)).toBeGreaterThan(63);
|
|
|
|
expect(parseInt(styleB.width, 10)).toBeGreaterThan(31);
|
|
|
|
});
|
2015-11-10 01:48:58 +00:00
|
|
|
|
|
|
|
it("ensures a minimum frame size on drop", function () {
|
|
|
|
var style;
|
|
|
|
|
|
|
|
// Start with a very small frame size
|
2016-05-19 18:29:13 +00:00
|
|
|
testModel.layoutGrid = [1, 1];
|
2018-06-30 00:32:59 +00:00
|
|
|
mockScope.$watch.calls.all()[0].args[1](testModel.layoutGrid);
|
2015-11-10 01:48:58 +00:00
|
|
|
|
2018-06-27 20:30:01 +00:00
|
|
|
// Add a new object to the composition
|
|
|
|
mockComposition = ["a", "b", "c", "d"];
|
|
|
|
mockCompositionObjects = mockComposition.map(mockDomainObject);
|
|
|
|
mockCompositionCapability = mockPromise(mockCompositionObjects);
|
|
|
|
|
2015-11-10 01:48:58 +00:00
|
|
|
// Notify that a drop occurred
|
2018-06-30 00:32:59 +00:00
|
|
|
mockScope.$on.calls.mostRecent().args[1](
|
2015-11-10 01:48:58 +00:00
|
|
|
mockEvent,
|
|
|
|
'd',
|
|
|
|
{ x: 300, y: 100 }
|
|
|
|
);
|
|
|
|
|
|
|
|
style = controller.getFrameStyle("d");
|
|
|
|
|
|
|
|
// Resulting size should still be reasonably large pixel-size
|
|
|
|
expect(parseInt(style.width, 10)).toBeGreaterThan(63);
|
|
|
|
expect(parseInt(style.height, 10)).toBeGreaterThan(31);
|
|
|
|
});
|
2015-12-08 23:04:34 +00:00
|
|
|
|
|
|
|
it("updates positions of existing objects on a drop", function () {
|
|
|
|
var oldStyle;
|
|
|
|
|
2018-06-30 00:32:59 +00:00
|
|
|
mockScope.$watchCollection.calls.mostRecent().args[1]();
|
2015-12-08 23:04:34 +00:00
|
|
|
|
|
|
|
oldStyle = controller.getFrameStyle("b");
|
|
|
|
|
|
|
|
expect(oldStyle).toBeDefined();
|
|
|
|
|
|
|
|
// ...drop event...
|
2018-06-30 00:32:59 +00:00
|
|
|
mockScope.$on.calls.mostRecent()
|
2015-12-08 23:04:34 +00:00
|
|
|
.args[1](mockEvent, 'b', { x: 300, y: 100 });
|
|
|
|
|
|
|
|
expect(controller.getFrameStyle("b"))
|
|
|
|
.not.toEqual(oldStyle);
|
|
|
|
});
|
2017-08-18 23:28:41 +00:00
|
|
|
|
2017-12-07 21:04:46 +00:00
|
|
|
it("allows objects to be selected", function () {
|
2018-06-30 00:32:59 +00:00
|
|
|
mockScope.$watchCollection.calls.mostRecent().args[1]();
|
2017-08-18 23:28:41 +00:00
|
|
|
var childObj = mockCompositionObjects[0];
|
2017-12-07 21:04:46 +00:00
|
|
|
selectable[0].context.oldItem = childObj;
|
2018-06-30 00:32:59 +00:00
|
|
|
mockOpenMCT.selection.on.calls.mostRecent().args[1](selectable);
|
2017-08-18 23:28:41 +00:00
|
|
|
|
|
|
|
expect(controller.selected(childObj)).toBe(true);
|
|
|
|
});
|
|
|
|
|
2017-12-07 21:04:46 +00:00
|
|
|
it("prevents event bubbling while drag is in progress", function () {
|
2018-06-30 00:32:59 +00:00
|
|
|
mockScope.$watchCollection.calls.mostRecent().args[1]();
|
2017-08-18 23:28:41 +00:00
|
|
|
var childObj = mockCompositionObjects[0];
|
|
|
|
|
|
|
|
// Do a drag
|
2017-12-07 21:04:46 +00:00
|
|
|
controller.startDrag(childObj.getId(), [1, 1], [0, 0]);
|
2017-08-18 23:28:41 +00:00
|
|
|
controller.continueDrag([100, 100]);
|
|
|
|
controller.endDrag();
|
|
|
|
|
2017-12-07 21:04:46 +00:00
|
|
|
// Because mouse position could cause the parent object to be selected, this should be ignored.
|
|
|
|
controller.bypassSelection(mockEvent);
|
2017-08-18 23:28:41 +00:00
|
|
|
|
2017-12-07 21:04:46 +00:00
|
|
|
expect(mockEvent.stopPropagation).toHaveBeenCalled();
|
2017-08-18 23:28:41 +00:00
|
|
|
|
2017-12-07 21:04:46 +00:00
|
|
|
// Shoud be able to select another object when dragging is done.
|
2018-06-30 00:32:59 +00:00
|
|
|
jasmine.clock().tick(0);
|
|
|
|
mockEvent.stopPropagation.calls.reset();
|
2017-12-07 21:04:46 +00:00
|
|
|
controller.bypassSelection(mockEvent);
|
2017-08-18 23:28:41 +00:00
|
|
|
|
2017-12-07 21:04:46 +00:00
|
|
|
expect(mockEvent.stopPropagation).not.toHaveBeenCalled();
|
2017-08-18 23:28:41 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it("shows frames by default", function () {
|
2018-06-30 00:32:59 +00:00
|
|
|
mockScope.$watchCollection.calls.mostRecent().args[1]();
|
2017-08-18 23:28:41 +00:00
|
|
|
|
|
|
|
expect(controller.hasFrame(mockCompositionObjects[0])).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("hyperlinks hide frame by default", function () {
|
2018-06-30 00:32:59 +00:00
|
|
|
mockScope.$watchCollection.calls.mostRecent().args[1]();
|
2017-08-18 23:28:41 +00:00
|
|
|
|
|
|
|
expect(controller.hasFrame(mockCompositionObjects[1])).toBe(false);
|
|
|
|
});
|
|
|
|
|
2017-12-07 21:04:46 +00:00
|
|
|
it("selects the parent object when selected object is removed", function () {
|
2018-06-30 00:32:59 +00:00
|
|
|
mockScope.$watchCollection.calls.mostRecent().args[1]();
|
2017-10-02 20:49:12 +00:00
|
|
|
var childObj = mockCompositionObjects[0];
|
2017-12-07 21:04:46 +00:00
|
|
|
selectable[0].context.oldItem = childObj;
|
2018-06-30 00:32:59 +00:00
|
|
|
mockOpenMCT.selection.on.calls.mostRecent().args[1](selectable);
|
2017-10-02 20:49:12 +00:00
|
|
|
|
|
|
|
var composition = ["b", "c"];
|
2018-06-30 00:32:59 +00:00
|
|
|
mockScope.$watchCollection.calls.mostRecent().args[1](composition);
|
2017-10-02 20:49:12 +00:00
|
|
|
|
2017-12-07 21:04:46 +00:00
|
|
|
expect($element[0].click).toHaveBeenCalled();
|
2017-10-02 20:49:12 +00:00
|
|
|
});
|
|
|
|
|
2017-12-07 21:04:46 +00:00
|
|
|
it("allows objects to be drilled-in only when editing", function () {
|
2018-06-30 00:32:59 +00:00
|
|
|
mockScope.$watchCollection.calls.mostRecent().args[1]();
|
2017-12-07 21:04:46 +00:00
|
|
|
var childObj = mockCompositionObjects[0];
|
2018-06-30 00:32:59 +00:00
|
|
|
childObj.getCapability().inEditContext.and.returnValue(false);
|
2017-12-07 21:04:46 +00:00
|
|
|
controller.drill(mockEvent, childObj);
|
|
|
|
|
|
|
|
expect(controller.isDrilledIn(childObj)).toBe(false);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("allows objects to be drilled-in only if it has sub objects", function () {
|
2018-06-30 00:32:59 +00:00
|
|
|
mockScope.$watchCollection.calls.mostRecent().args[1]();
|
2017-12-07 21:04:46 +00:00
|
|
|
var childObj = mockCompositionObjects[1];
|
2018-06-30 00:32:59 +00:00
|
|
|
childObj.getCapability().inEditContext.and.returnValue(true);
|
2017-12-07 21:04:46 +00:00
|
|
|
controller.drill(mockEvent, childObj);
|
|
|
|
|
|
|
|
expect(controller.isDrilledIn(childObj)).toBe(false);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("selects a newly-dropped object", function () {
|
2018-06-30 00:32:59 +00:00
|
|
|
mockScope.$on.calls.mostRecent().args[1](
|
2017-12-07 21:04:46 +00:00
|
|
|
mockEvent,
|
|
|
|
'd',
|
|
|
|
{ x: 300, y: 100 }
|
|
|
|
);
|
|
|
|
|
|
|
|
var childObj = mockDomainObject("d");
|
2017-12-20 21:32:07 +00:00
|
|
|
var testElement = $("<div data-layout-id='some-id'></div>");
|
2017-12-07 21:04:46 +00:00
|
|
|
$element.append(testElement);
|
|
|
|
spyOn(testElement[0], 'click');
|
|
|
|
|
2017-12-20 21:32:07 +00:00
|
|
|
controller.selectIfNew('some-id', childObj);
|
2018-06-30 00:32:59 +00:00
|
|
|
jasmine.clock().tick(0);
|
2017-12-07 21:04:46 +00:00
|
|
|
|
|
|
|
expect(testElement[0].click).toHaveBeenCalled();
|
|
|
|
});
|
2014-12-05 23:39:07 +00:00
|
|
|
});
|
|
|
|
}
|
2015-06-25 18:35:18 +00:00
|
|
|
);
|