mirror of
https://github.com/nasa/openmct.git
synced 2025-06-17 06:38:17 +00:00
[Mobile] AgentService & Tests
Adjusted the getOrientation of agentService to inject the window instead of calling for it in agentService. Also adjusted treeNodeController for this. Added tests for the agentService's getOrientation function.
This commit is contained in:
@ -182,7 +182,7 @@ define(
|
|||||||
// and in portrait mode, than, hide the tree menu
|
// and in portrait mode, than, hide the tree menu
|
||||||
TreeNodeController.prototype.setObject = function (ngModel, domainObject) {
|
TreeNodeController.prototype.setObject = function (ngModel, domainObject) {
|
||||||
ngModel.selectedObject = domainObject;
|
ngModel.selectedObject = domainObject;
|
||||||
if (this.agentService.getOrientation() === "portrait" &&
|
if (this.agentService.getOrientation(window.innerWidth, window.innerHeight) === "portrait" &&
|
||||||
this.agentService.isPhone(navigator.userAgent)) {
|
this.agentService.isPhone(navigator.userAgent)) {
|
||||||
this.$scope.$emit('select-obj');
|
this.$scope.$emit('select-obj');
|
||||||
}
|
}
|
||||||
|
@ -67,11 +67,12 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Returns the orientation of the device based on the
|
// Returns the orientation of the device based on the
|
||||||
// device's window dimensions
|
// device's window dimensions, pass in the innerWidth
|
||||||
function getOrientation() {
|
// and innerheight of the current window
|
||||||
if (window.innerWidth > window.innerHeight) {
|
function getOrientation(innerWidth, innerHeight) {
|
||||||
|
if (innerWidth > innerHeight) {
|
||||||
return "landscape";
|
return "landscape";
|
||||||
} else if (window.innerWidth < window.innerHeight) {
|
} else if (innerWidth < innerHeight) {
|
||||||
return "portrait";
|
return "portrait";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,8 +38,8 @@ define(
|
|||||||
// Creates a mockLocation, used to
|
// Creates a mockLocation, used to
|
||||||
// do the view search
|
// do the view search
|
||||||
mockWindow = jasmine.createSpyObj(
|
mockWindow = jasmine.createSpyObj(
|
||||||
"$window",
|
"window",
|
||||||
[ "outerWidth", "outerHeight" ]
|
[ "innerWidth", "innerHeight" ]
|
||||||
);
|
);
|
||||||
|
|
||||||
mockNavigator = jasmine.createSpyObj(
|
mockNavigator = jasmine.createSpyObj(
|
||||||
@ -47,7 +47,7 @@ define(
|
|||||||
[ "userAgent" ]
|
[ "userAgent" ]
|
||||||
);
|
);
|
||||||
|
|
||||||
agentService = new AgentService(mockWindow);
|
agentService = new AgentService();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("get current device user agent", function () {
|
it("get current device user agent", function () {
|
||||||
@ -61,13 +61,8 @@ define(
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("get orientation of the current device", function () {
|
it("get orientation of the current device", function () {
|
||||||
mockWindow.outerWidth = 768;
|
agentService.getOrientation(1024, 768);
|
||||||
mockWindow.outerHeight = 1024;
|
agentService.getOrientation(768, 1024);
|
||||||
agentService.getOrientation();
|
|
||||||
|
|
||||||
mockWindow.outerWidth = 1024;
|
|
||||||
mockWindow.outerHeight = 768;
|
|
||||||
agentService.getOrientation();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user