mirror of
https://github.com/nasa/openmct.git
synced 2025-05-09 12:03:21 +00:00
[Mobile] Tests
Completed tests for AgentService, InfoService, and ContextMenuAction. ContextMenu and InfoButton Gesture tests remain. Also resized info button icon.
This commit is contained in:
parent
66408eeec8
commit
6b65ae77e7
@ -378,7 +378,7 @@
|
|||||||
width: 50px;
|
width: 50px;
|
||||||
right: 0px;
|
right: 0px;
|
||||||
left: auto;
|
left: auto;
|
||||||
font-size: 1.5em; }
|
font-size: 1.3em; }
|
||||||
/* line 47, ../sass/mobile/_item.scss */
|
/* line 47, ../sass/mobile/_item.scss */
|
||||||
.items-holder .item.grid-item .bar.bottom-bar.abs {
|
.items-holder .item.grid-item .bar.bottom-bar.abs {
|
||||||
top: 0px;
|
top: 0px;
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
width: 50px;
|
width: 50px;
|
||||||
right: 0px;
|
right: 0px;
|
||||||
left: auto;
|
left: auto;
|
||||||
font-size: 1.5em;
|
font-size: 1.3em;
|
||||||
}
|
}
|
||||||
.bar {
|
.bar {
|
||||||
&.bottom-bar.abs {
|
&.bottom-bar.abs {
|
||||||
|
@ -53,8 +53,11 @@ define(
|
|||||||
it("get current device user agent", function () {
|
it("get current device user agent", function () {
|
||||||
mockNavigator.userAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.89 Safari/537.36";
|
mockNavigator.userAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.89 Safari/537.36";
|
||||||
agentService.isMobile(mockNavigator.userAgent);
|
agentService.isMobile(mockNavigator.userAgent);
|
||||||
|
agentService.isPhone(mockNavigator.userAgent);
|
||||||
mockNavigator.userAgent = "Mozilla/5.0 (iPad; CPU OS 7_0 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53";
|
mockNavigator.userAgent = "Mozilla/5.0 (iPad; CPU OS 7_0 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53";
|
||||||
agentService.isMobile(mockNavigator.userAgent);
|
agentService.isMobile(mockNavigator.userAgent);
|
||||||
|
mockNavigator.userAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 7_0 like Mac OS X; en-us) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53";
|
||||||
|
agentService.isPhone(mockNavigator.userAgent);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("get orientation of the current device", function () {
|
it("get orientation of the current device", function () {
|
||||||
|
102
platform/commonUI/inspect/test/gestures/InfoButtonGestureSpec.js
Normal file
102
platform/commonUI/inspect/test/gestures/InfoButtonGestureSpec.js
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* 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,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/
|
||||||
|
|
||||||
|
define(
|
||||||
|
['../../src/gestures/InfoButtonGesture'],
|
||||||
|
function (InfoButtonGesture) {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
describe("The info button gesture", function () {
|
||||||
|
var mockDocument,
|
||||||
|
mockAgentService,
|
||||||
|
mockInfoService,
|
||||||
|
testDelay = 12321,
|
||||||
|
mockElement,
|
||||||
|
mockDomainObject,
|
||||||
|
mockScope,
|
||||||
|
mockOff,
|
||||||
|
testMetadata,
|
||||||
|
mockPromise,
|
||||||
|
mockHide,
|
||||||
|
gesture;
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
|
mockDocument = jasmine.createSpyObj('$document', ['find']);
|
||||||
|
mockAgentService = jasmine.createSpyObj('agentService', ['isMobile', 'isPhone']);
|
||||||
|
mockInfoService = jasmine.createSpyObj(
|
||||||
|
'infoService',
|
||||||
|
[ 'display' ]
|
||||||
|
);
|
||||||
|
mockElement = jasmine.createSpyObj(
|
||||||
|
'element',
|
||||||
|
[ 'on', 'off', 'scope', 'css' ]
|
||||||
|
);
|
||||||
|
mockDomainObject = jasmine.createSpyObj(
|
||||||
|
'domainObject',
|
||||||
|
[ 'getId', 'getCapability', 'useCapability', 'getModel' ]
|
||||||
|
);
|
||||||
|
mockDocument = jasmine.createSpyObj('$document', ['find']);
|
||||||
|
mockAgentService = jasmine.createSpyObj('agentService', ['isMobile']);
|
||||||
|
mockInfoService = jasmine.createSpyObj(
|
||||||
|
'infoService',
|
||||||
|
[ 'display' ]
|
||||||
|
);
|
||||||
|
mockElement = jasmine.createSpyObj(
|
||||||
|
'element',
|
||||||
|
[ 'on', 'off', 'scope', 'css' ]
|
||||||
|
);
|
||||||
|
mockDomainObject = jasmine.createSpyObj(
|
||||||
|
'domainObject',
|
||||||
|
[ 'getId', 'getCapability', 'useCapability', 'getModel' ]
|
||||||
|
);
|
||||||
|
|
||||||
|
mockScope = jasmine.createSpyObj('$scope', [ '$on' ]);
|
||||||
|
mockOff = jasmine.createSpy('$off');
|
||||||
|
testMetadata = [ { name: "Test name", value: "Test value" } ];
|
||||||
|
mockHide = jasmine.createSpy('hide');
|
||||||
|
|
||||||
|
mockDomainObject.getModel.andReturn({ name: "Test Object" });
|
||||||
|
mockDomainObject.useCapability.andCallFake(function (c) {
|
||||||
|
return (c === 'metadata') ? testMetadata : undefined;
|
||||||
|
});
|
||||||
|
mockElement.scope.andReturn(mockScope);
|
||||||
|
mockScope.$on.andReturn(mockOff);
|
||||||
|
mockInfoService.display.andReturn(mockHide);
|
||||||
|
mockAgentService.isMobile.andReturn(true);
|
||||||
|
gesture = new InfoButtonGesture(
|
||||||
|
mockDocument,
|
||||||
|
mockAgentService,
|
||||||
|
mockInfoService,
|
||||||
|
mockElement,
|
||||||
|
mockDomainObject
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("listens for click on the representation", function () {
|
||||||
|
expect(mockElement.on)
|
||||||
|
.toHaveBeenCalledWith('click', jasmine.any(Function));
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
@ -31,6 +31,7 @@ define(
|
|||||||
mockDocument,
|
mockDocument,
|
||||||
testWindow,
|
testWindow,
|
||||||
mockRootScope,
|
mockRootScope,
|
||||||
|
mockAgentService,
|
||||||
mockCompiledTemplate,
|
mockCompiledTemplate,
|
||||||
testScope,
|
testScope,
|
||||||
mockBody,
|
mockBody,
|
||||||
@ -42,6 +43,7 @@ define(
|
|||||||
mockDocument = jasmine.createSpyObj('$document', ['find']);
|
mockDocument = jasmine.createSpyObj('$document', ['find']);
|
||||||
testWindow = { innerWidth: 1000, innerHeight: 100 };
|
testWindow = { innerWidth: 1000, innerHeight: 100 };
|
||||||
mockRootScope = jasmine.createSpyObj('$rootScope', ['$new']);
|
mockRootScope = jasmine.createSpyObj('$rootScope', ['$new']);
|
||||||
|
mockAgentService = jasmine.createSpyObj('agentService', ['isMobile', 'isPhone']);
|
||||||
mockCompiledTemplate = jasmine.createSpy('template');
|
mockCompiledTemplate = jasmine.createSpy('template');
|
||||||
testScope = {};
|
testScope = {};
|
||||||
mockBody = jasmine.createSpyObj('body', ['append']);
|
mockBody = jasmine.createSpyObj('body', ['append']);
|
||||||
@ -58,7 +60,8 @@ define(
|
|||||||
mockCompile,
|
mockCompile,
|
||||||
mockDocument,
|
mockDocument,
|
||||||
testWindow,
|
testWindow,
|
||||||
mockRootScope
|
mockRootScope,
|
||||||
|
mockAgentService
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -124,6 +127,18 @@ define(
|
|||||||
(40 + InfoConstants.BUBBLE_OFFSET[1]) + 'px'
|
(40 + InfoConstants.BUBBLE_OFFSET[1]) + 'px'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("when on phone device, positioning is always on bottom", function () {
|
||||||
|
mockAgentService.isPhone.andReturn(true);
|
||||||
|
service = new InfoService(
|
||||||
|
mockCompile,
|
||||||
|
mockDocument,
|
||||||
|
testWindow,
|
||||||
|
mockRootScope,
|
||||||
|
mockAgentService
|
||||||
|
);
|
||||||
|
service.display('', '', {}, [0, 0]);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
[
|
[
|
||||||
"gestures/InfoGesture",
|
"gestures/InfoGesture",
|
||||||
|
"gestures/InfoButtonGesture",
|
||||||
"services/InfoService"
|
"services/InfoService"
|
||||||
]
|
]
|
||||||
|
@ -53,6 +53,14 @@ define(
|
|||||||
mockStopPropagation,
|
mockStopPropagation,
|
||||||
action;
|
action;
|
||||||
|
|
||||||
|
function fireEvent(evt, value) {
|
||||||
|
mockElement.on.calls.forEach(function (call) {
|
||||||
|
if (call.args[0] === evt) {
|
||||||
|
call.args[1](value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
mockCompile = jasmine.createSpy("$compile");
|
mockCompile = jasmine.createSpy("$compile");
|
||||||
mockCompiledTemplate = jasmine.createSpy("template");
|
mockCompiledTemplate = jasmine.createSpy("template");
|
||||||
@ -144,13 +152,12 @@ define(
|
|||||||
it("keeps a menu when menu is clicked", function () {
|
it("keeps a menu when menu is clicked", function () {
|
||||||
// Show the menu
|
// Show the menu
|
||||||
action.perform();
|
action.perform();
|
||||||
|
|
||||||
// Find and fire body's mousedown listener
|
// Find and fire body's mousedown listener
|
||||||
// mockMenu.on.calls.forEach(function (call) {
|
mockMenu.on.calls.forEach(function (call) {
|
||||||
// if (call.args[0] === 'mousedown') {
|
if (call.args[0] === 'mousedown') {
|
||||||
// call.args[1]();
|
call.args[1](mockEvent);
|
||||||
// }
|
}
|
||||||
// });
|
});
|
||||||
|
|
||||||
// Menu should have been removed
|
// Menu should have been removed
|
||||||
expect(mockMenu.remove).not.toHaveBeenCalled();
|
expect(mockMenu.remove).not.toHaveBeenCalled();
|
||||||
@ -171,11 +178,11 @@ define(
|
|||||||
);
|
);
|
||||||
action.perform();
|
action.perform();
|
||||||
|
|
||||||
// mockMenu.on.calls.forEach(function (call) {
|
mockMenu.on.calls.forEach(function (call) {
|
||||||
// if (call.args[0] === 'touchstart') {
|
if (call.args[0] === 'touchstart') {
|
||||||
// call.args[1]();
|
call.args[1](mockEvent);
|
||||||
// }
|
}
|
||||||
// });
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -82,10 +82,11 @@ define(
|
|||||||
// Capture the contextmenu callback
|
// Capture the contextmenu callback
|
||||||
fireGesture = mockElement.on.mostRecentCall.args[1];
|
fireGesture = mockElement.on.mostRecentCall.args[1];
|
||||||
|
|
||||||
expect(mockElement.on).toHaveBeenCalledWith(
|
mockMenu.on.calls.forEach(function (call) {
|
||||||
"touchstart",
|
if (call.args[0] === 'touchstart') {
|
||||||
jasmine.any(Function)
|
call.args[1](mockEvent);
|
||||||
);
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user