Skip to content

Commit

Permalink
Merge pull request #1021 from zebrunner/develop
Browse files Browse the repository at this point in the history
3.0 rc
  • Loading branch information
dhreben authored Oct 8, 2024
2 parents 605a7ef + 6e44541 commit f2a96aa
Show file tree
Hide file tree
Showing 26 changed files with 198 additions and 59 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
SmartTestFarm
==================

Feel free to support the development with a [**donation**](https://www.paypal.com/donate?hosted_button_id=JLQ4U468TWQPS) for the next improvements.
Feel free to support the development with a [**donation**](https://www.paypal.com/donate/?hosted_button_id=MNHYYCYHAKUVA) for the next improvements.

<p align="center">
<a href="https://zebrunner.com/"><img alt="Zebrunner" src="https://github.com/zebrunner/zebrunner/raw/master/docs/img/zebrunner_intro.png"></a>
Expand Down
7 changes: 6 additions & 1 deletion lib/units/api/controllers/devices.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ const wirerouter = require('../../../wire/router')
function filterGenericDevices(req, res, devices) {
apiutil.respond(res, 200, 'Devices Information', {
devices: devices.map(function(device) {
return apiutil.filterDevice(req, device)
const filteredDevice = apiutil.filterDevice(req, device)
filteredDevice.name = device.model
return filteredDevice
})
})
}
Expand Down Expand Up @@ -221,6 +223,7 @@ function getDeviceBySerial(req, res) {

dbapi.loadDevice(req.user.groups.subscribed, serial)
.then(function(cursor) {
const deviceName = cursor._responses[0].r[0].model
cursor.next(function(err, device) {
if (err) {
return res.status(404).json({
Expand All @@ -230,6 +233,8 @@ function getDeviceBySerial(req, res) {
}
let responseDevice = apiutil.publishDevice(device, req.user)

responseDevice.name = deviceName

if (fields) {
responseDevice = _.pick(device, fields.split(','))
}
Expand Down
19 changes: 19 additions & 0 deletions lib/units/ios-device/plugins/util/iosutil.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,25 @@ let iosutil = {
}
},
swipe: function(orientation, params, deviceSize) {

if (params.toX >= 2 || params.toY >= 2) {
if (params.fromY >= 0.5) {
params.fromY /= 2
params.toY = 0.25
} else {
params.fromY *= 2
params.toY = 0.75
}

if (params.fromX >= 0.5) {
params.fromX /= 2
params.toX = 0.25
} else {
params.fromX *= 2
params.toX = 0.75
}
}

switch(orientation) {
case 'PORTRAIT':
return {
Expand Down
5 changes: 4 additions & 1 deletion lib/units/ios-device/plugins/wda.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,11 @@ module.exports = syrup.serial()
wdaClient.typeKey({value: [iosutil.asciiparser(message.text)]})
})
.on(wire.KeyDownMessage, (channel, message) => {
log.verbose("wire.TypeMessage: ", message)
log.verbose("wire.KeyDownMessage: ", message)
wdaClient.typeKey({value: [iosutil.asciiparser(message.key)]})
if (message.key === 'home') {
wdaClient.homeBtn()
}
})
.on(wire.BrowserOpenMessage, (channel, message) => {
wdaClient.openUrl(message)
Expand Down
4 changes: 3 additions & 1 deletion lib/util/datautil.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ datautil.applyData = function(device) {
})

if (match) {
device.name = match.name.id
if (!device.name) {
device.name = match.name.id
}
device.releasedAt = match.date
device.image = match.image
device.cpu = match.cpu
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ module.exports = function EnhanceDeviceServiceFactory($filter, AppState) {
}

function enhanceDevice(device) {
device.enhancedName = device.model || device.product || device.marketName || device.serial || 'Unknown'
device.enhancedName = device.name || device.model || device.product || device.marketName || device.serial || 'Unknown'
device.enhancedModel = device.model || 'Unknown'
device.enhancedImage120 = '/static/app/devices/icon/x120/' + (device.platform || device.image || '_default.jpg')
device.enhancedImage24 = '/static/app/devices/icon/x24/' + (device.platform || device.image || '_default.jpg')
Expand Down
23 changes: 2 additions & 21 deletions res/app/components/stf/landscape/landscape-directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ module.exports =
link: function(scope) {
var body = angular.element($document[0].body)

if (typeof $window.orientation !== 'undefined') {
if ($window.orientation !== 0) {
rotateGuest(false)
}
}

function rotateGuest(portrait) {
if (portrait) {
body.addClass('guest-portrait')
Expand All @@ -31,20 +25,7 @@ module.exports =
var isPortrait = (window.innerHeight > window.innerWidth)
rotateGuest(isPortrait)
}

if (BrowserInfo.deviceorientation) {
window.addEventListener('orientationchange', guestDisplayRotated,
true)
}

function off() {
if (BrowserInfo.deviceorientation) {
window.removeEventListener('orientationchange',
guestDisplayRotated)
}
}

scope.$on('$destroy', off)

}
}
}
}
63 changes: 54 additions & 9 deletions res/app/components/stf/screen/screen-directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ module.exports = function DeviceScreenDirective(
function handleScreen() {
let ws, adjustedBoundSize
const canvas = element.querySelector('.screen__canvas')

const g = canvas.getContext('2d')
// const positioner = element.querySelector('div.positioner')
const devicePixelRatio = window.devicePixelRatio || 1
Expand Down Expand Up @@ -272,13 +273,17 @@ module.exports = function DeviceScreenDirective(

img.onload = function() {
updateImageArea(this)
g.drawImage(img, 0, 0, img.width, img.height)
if (canvas.width === 2484 && canvas.height === 5376) {
g.drawImage(img, 0, 0, canvas.width, canvas.height)
return cleanData()
}

// Try to forcefully clean everything to get rid of memory
// leaks. Note that despite this effort, Chrome will still
// leak huge amounts of memory when the developer tools are
// open, probably to save the resources for inspection. When
// the developer tools are closed no memory is leaked.
g.drawImage(img, 0, 0, img.width, img.height)
cleanData()
}

Expand Down Expand Up @@ -448,6 +453,10 @@ module.exports = function DeviceScreenDirective(
return screen.rotation === 90 || screen.rotation === 270
}

function canvasSizeExceeded() {
return $rootScope.basicMode && canvas.width * canvas.height >= 16777216
}

function updateImageArea(img) {
if (!hasImageAreaChanged(img)) {
return
Expand All @@ -465,6 +474,17 @@ module.exports = function DeviceScreenDirective(
canvas.height = cachedImageHeight
}

if (canvasSizeExceeded() && $scope.device.version !== '18.0') {
console.log(`exceeded canvas size limit, reducing previous size: ${canvas.width}x${canvas.height}`);
if ($scope.device.display.rotation === 90) {
canvas.width = 5376;
canvas.height = 2484;
return
}
canvas.width = 2484;
canvas.height = 5376;
}

cssRotation += rotator(cachedScreen.rotation, screen.rotation)
// canvas.style[cssTransform] = 'rotate(' + cssRotation + 'deg)'

Expand Down Expand Up @@ -750,6 +770,12 @@ module.exports = function DeviceScreenDirective(
$document.bind('mouseup', mouseUpListener)
$document.bind('mouseleave', mouseUpListener)

if (!$rootScope.basicMode) {
$element.bind('touchmove', mouseMoveListener)
$document.bind('touchend', mouseUpListener)
$document.bind('touchcancel', mouseUpListener)
}

if (lastPossiblyBuggyMouseUpEvent
&& lastPossiblyBuggyMouseUpEvent.timeStamp > e.timeStamp) {
// We got mouseup before mousedown. See mouseUpBugWorkaroundListener
Expand Down Expand Up @@ -938,6 +964,13 @@ module.exports = function DeviceScreenDirective(
}

function stopMousing() {

if (!$rootScope.basicMode) {
$element.unbind('touchmove', mouseMoveListener)
$document.unbind('touchend', mouseUpListener)
$document.unbind('touchcancel', mouseUpListener)
}

$element.unbind('mousemove', mouseMoveListener)
$document.unbind('mouseup', mouseUpListener)
$document.unbind('mouseleave', mouseUpListener)
Expand Down Expand Up @@ -1013,9 +1046,12 @@ module.exports = function DeviceScreenDirective(
activateFinger(slot, x, y, pressure)
}

$element.bind('touchmove', touchMoveListener)
$document.bind('touchend', touchEndListener)
$document.bind('touchleave', touchEndListener)

if ($rootScope.basicMode) {
$element.bind('touchmove', touchMoveListener)
$document.bind('touchend', touchEndListener)
$document.bind('touchleave', touchEndListener)
}

$scope.control.touchCommit(nextSeq())
}
Expand Down Expand Up @@ -1043,9 +1079,13 @@ module.exports = function DeviceScreenDirective(
$scope.device.ios
)

$scope.control.touchMove(nextSeq(), slot, scaled.xP, scaled.yP, pressure)
//$scope.control.touchMoveIos(nextSeq(), slot, scaled.xP, scaled.yP, pressure)
activateFinger(slot, x, y, pressure)
if ($scope.device.ios) {
const touchev = e.touches[0];

$scope.control.touchMoveIos(touchev.pageX, touchev.pageY, scaled.xP, scaled.yP, 0.5);

activateFinger(slot, x, y, pressure);
}
}

$scope.control.touchCommit(nextSeq())
Expand Down Expand Up @@ -1096,12 +1136,17 @@ module.exports = function DeviceScreenDirective(
$scope.control.gestureStop(nextSeq())
}

$element.on('touchstart', touchStartListener)
$element.on('touchstart', (e) => {
if (!$rootScope.basicMode) {
return mouseDownListener(e)
}
touchStartListener(e)
})
$element.on('mousedown', mouseDownListener)
$element.on('mouseup', mouseUpBugWorkaroundListener)

createSlots()
}
}
}
}
}
2 changes: 1 addition & 1 deletion res/app/control-panes/advanced/advanced.pug
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
.col-md-6
div(ng-include='"control-panes/advanced/maintenance/maintenance.pug"')
.col-md-6
div(ng-include='"control-panes/advanced/device-settings/device-settings.pug"')
div(ng-include='"control-panes/advanced/device-settings/device-settings.pug"', style='{{$root.basicMode ? "height: 250px" : "height: auto;" }}')

5 changes: 5 additions & 0 deletions res/app/control-panes/control-panes.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@media (max-width: 400px) {
.pane-bottom-p.fa-pane.pane-fa-pane.fa-pane-orientation-vertical {
display: none;
}
}
3 changes: 2 additions & 1 deletion res/app/control-panes/control-panes.pug
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ div(ng-controller='ControlPanesHotKeysCtrl').fill-height
.remote-control
div(ng-include='"control-panes/device-control/device-control.pug"').fill-height

div(fa-pane, pane-id='control-bottom-tabs', pane-anchor='south', pane-size='30% + 2px', pane-handle='4', style='{{!root.basicMode ? "display: none" : "display: initial"}}').pane-bottom-p
div(fa-pane, pane-id='control-bottom-tabs', pane-anchor='south', pane-size='30% + 2px', pane-handle='4').pane-bottom-p
.widget-container.fluid-height
nice-tabs(key='ControlBottomTabs', direction='below', tabs='belowTabs', filter='$root.platform')

div(fa-pane, pane-id='control-top-tabs', pane-anchor='' style='{{!$root.basicMode ? "" : "position: relative; height: auto; width: 350px" }}')
.widget-container.fluid-height
nice-tabs(key='ControlBottomTabs', tabs='topTabs', filter='$root.platform')
2 changes: 1 addition & 1 deletion res/app/control-panes/dashboard/dashboard.pug
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
.col-md-6
div(ng-include='"control-panes/dashboard/apps/apps.pug"')
.col-md-6
div(ng-include='"control-panes/advanced/remote-debug/remote-debug.pug"')
div(ng-include='"control-panes/advanced/remote-debug/remote-debug.pug"', style='{{$root.basicMode ? "height: 150px" : "height: auto;" }}')
17 changes: 17 additions & 0 deletions res/app/control-panes/device-control/device-control-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ var _ = require('lodash')
module.exports = function DeviceControlCtrl($scope, DeviceService, GroupService,
$location, $timeout, $window, $rootScope, LogcatService, $route) {

if ($rootScope.basicMode) {
let scrollbarDiv = document.getElementsByClassName('pane-center fill-height ng-scope fa-pane-scroller')[0]
scrollbarDiv.scroll(0, 0)
}

$scope.showScreen = true

$scope.groupTracker = DeviceService.trackGroup($scope)
Expand Down Expand Up @@ -91,11 +96,19 @@ module.exports = function DeviceControlCtrl($scope, DeviceService, GroupService,
$scope.tryToRotate = function(rotation) {
if (rotation === 'portrait') {
$scope.control.rotate(0)
if ($rootScope.basicMode) {
$scope.currentRotation = 'portrait'
return
}
$timeout(function() {
isLandscape() ? $scope.currentRotation = 'landscape' : $scope.currentRotation = 'portrait'
}, 400)
} else if (rotation === 'landscape') {
$scope.control.rotate(90)
if ($rootScope.basicMode) {
$scope.currentRotation = 'landscape'
return
}
$timeout(function() {
isPortrait() ? $scope.currentRotation = 'portrait' : $scope.currentRotation = 'landscape'
}, 400)
Expand All @@ -105,6 +118,10 @@ module.exports = function DeviceControlCtrl($scope, DeviceService, GroupService,
$scope.currentRotation = 'portrait'

$scope.$watch('device.display.rotation', function(newValue) {
if ($rootScope.basicMode) {
return
}

$scope.currentRotation = 'rotating'
if (isPortrait(newValue)) {
$timeout(function() {
Expand Down
4 changes: 2 additions & 2 deletions res/app/control-panes/device-control/device-control.pug
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
.stf-vnc-right-buttons.pull-right
.btn-group
label.btn-sm.btn-primary-outline(type='button', ng-click='tryToRotate("portrait")', ng-hide='device.platform === "tvOS"',
ng-model='currentRotation', uib-btn-radio='"portrait"',
ng-model='currentRotation', uib-btn-radio='"portrait"', id='portrait-label',
uib-tooltip='{{ "Portrait" | translate }} ({{ "Current rotation:" | translate }} {{ device.display.rotation }}°)', tooltip-placement='bottom').pointer
i.fa.fa-mobile
label.btn-sm.btn-primary-outline(type='button', ng-click='tryToRotate("landscape")', ng-hide='device.platform === "tvOS"',
ng-model='currentRotation', uib-btn-radio='"landscape"',
ng-model='currentRotation', uib-btn-radio='"landscape"', id='landscape-label',
uib-tooltip='{{ "Landscape" | translate }} ({{ "Current rotation:" | translate }} {{ device.display.rotation }}°)', tooltip-placement='bottom').pointer
i.fa.fa-mobile.fa-rotate-90
.button-spacer
Expand Down
2 changes: 2 additions & 0 deletions res/app/control-panes/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require('./control-panes.css')

module.exports = angular.module('control-panes', [
require('stf/common-ui/nice-tabs').name,
require('stf/device').name,
Expand Down
4 changes: 2 additions & 2 deletions res/app/control-panes/info/info.pug
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@
div.infocard-table__item {{device.manufacturer}}
div.infocard-table__row
div.infocard-table__item(translate) Product
div.infocard-table__item {{device.name ? device.name : '-'}}
div.infocard-table__item {{device.enhancedName}}
div.infocard-table__row
div.infocard-table__item(translate) Model
div.infocard-table__item {{device.model}}
div.infocard-table__item {{device.enhancedName}}
div.infocard-table__row
div.infocard-table__item(translate) Serial
div.infocard-table__item {{device.serial}}
Expand Down
4 changes: 2 additions & 2 deletions res/app/device-list/column/device-column-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ module.exports = function DeviceColumnService($filter, gettext, SettingsService,
, model: DeviceModelCell({
title: gettext('Model')
, value: function(device) {
return device.name || device.model || device.serial
return device.enhancedName
}
})
, name: DeviceNameCell({
title: gettext('Product')
, value: function(device) {
return device.name || device.model || device.serial
return device.enhancedName
}
}, AppState.user.email)
, platform: TextCell({
Expand Down
Loading

0 comments on commit f2a96aa

Please sign in to comment.