Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade front-page to adapt to grant permission and device action #228

Merged
merged 3 commits into from
Jan 13, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 46 additions & 18 deletions react/src/component/RunnerView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ export default class RunnerView extends BaseView {
instrumentationArgs: "",
frameworkType: "JUnit4",
testRunnerName: "androidx.test.runner.AndroidJUnitRunner",
neededPermissions: null,
deviceActions: null,

teamList: null,
selectedTeamName: null
Expand Down Expand Up @@ -819,6 +821,25 @@ export default class RunnerView extends BaseView {
</IconButton>
</Tooltip>
</Stack>
<TextField
margin="dense"
name="neededPermissions"
type="text"
label="Needed Permissions"
fullWidth
value={this.state.neededPermissions}
onChange={this.handleValueChange}
/>
<TextField
margin="dense"
name="deviceActions"
type="text"
label="Device Actions"
fullWidth
multiline={true}
value={this.state.deviceActions}
onChange={this.handleValueChange}
/>
</Box>
}
}
Expand Down Expand Up @@ -924,25 +945,19 @@ export default class RunnerView extends BaseView {
}

runTest = () => {
let argsObj = {}
if (this.state.instrumentationArgs !== "") {
try {
argsObj = JSON.parse(this.state.instrumentationArgs)
} catch (error) {
this.snackBarMsg("Error Test config, please input JSON Object")
this.setState({
running: false
})
return
}
}
if (!(typeof argsObj === 'object')) {
let instrumentationArgsObj = {};
let neededPermissionsObj = [];
let deviceActionsObj = {};
try {
instrumentationArgsObj = this.handleJSONParams(this.state.instrumentationArgs);
neededPermissionsObj = this.handleJSONParams(this.state.neededPermissions, []);
deviceActionsObj = this.handleJSONParams(this.state.deviceActions);
} catch (error) {
this.snackBarMsg("Error Test config, please input JSON Object")
this.setState({
running: false
})
this.setState({ running: false })
return
}

const formParams = {
fileSetId: this.state.currentAppId,
pkgName: this.state.currentAppPackageName,
Expand All @@ -955,9 +970,11 @@ export default class RunnerView extends BaseView {
maxStepCount: this.state.maxStepCount,
deviceTestCount: this.state.deviceTestCount,
testTimeOutSec: this.state.testTimeOutSec,
instrumentationArgs: argsObj,
instrumentationArgs: instrumentationArgsObj,
frameworkType: this.state.frameworkType,
testRunnerName: this.state.testRunnerName
testRunnerName: this.state.testRunnerName,
neededPermissions: neededPermissionsObj,
deviceActions: deviceActionsObj
}

axios.post('/api/test/task/run/', formParams, {
Expand Down Expand Up @@ -1111,6 +1128,17 @@ export default class RunnerView extends BaseView {
})
}

handleJSONParams(argString, initObj={}){
let argObj = initObj;
if (argString) {
argObj = JSON.parse(argString)
}
if (typeof argObj !== 'object') {
throw new Error()
}
return argObj
}

componentDidMount() {
this.getUserInfo()
this.refreshPackageList()
Expand Down