Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zentaoatf
提交
fae15ebc
Z
zentaoatf
项目概览
易企天创
/
zentaoatf
10 个月 前同步成功
通知
11
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
3
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Z
zentaoatf
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
3
Issue
3
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
fae15ebc
编写于
8月 16, 2019
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add textarea input for bug steps for user edit
上级
d4fbd987
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
217 addition
and
226 deletion
+217
-226
src/action/gen.go
src/action/gen.go
+2
-168
src/atf.go
src/atf.go
+1
-1
src/service/script/assert.go
src/service/script/assert.go
+1
-1
src/service/script/generator.go
src/service/script/generator.go
+180
-0
src/service/script/lang.go
src/service/script/lang.go
+2
-2
src/service/testing/check.go
src/service/testing/check.go
+1
-1
src/service/testing/suite.go
src/service/testing/suite.go
+0
-14
src/ui/page/pageImport.go
src/ui/page/pageImport.go
+3
-3
src/ui/page/pageReportBug.go
src/ui/page/pageReportBug.go
+8
-8
src/ui/page/pageSwitch.go
src/ui/page/pageSwitch.go
+1
-1
src/ui/page/pageTestResult.go
src/ui/page/pageTestResult.go
+4
-4
src/ui/uiUtils.go
src/ui/uiUtils.go
+11
-20
src/ui/widget/widgetSelect.go
src/ui/widget/widgetSelect.go
+2
-2
src/ui/widget/widgetText.go
src/ui/widget/widgetText.go
+1
-1
未找到文件。
src/action/gen.go
浏览文件 @
fae15ebc
...
...
@@ -4,22 +4,16 @@ import (
"fmt"
"github.com/easysoft/zentaoatf/src/model"
"github.com/easysoft/zentaoatf/src/service/script"
testingService
"github.com/easysoft/zentaoatf/src/service/testing"
zentaoService
"github.com/easysoft/zentaoatf/src/service/zentao"
"github.com/easysoft/zentaoatf/src/utils/common"
"github.com/easysoft/zentaoatf/src/utils/config"
constant
"github.com/easysoft/zentaoatf/src/utils/const"
"github.com/easysoft/zentaoatf/src/utils/date"
"github.com/easysoft/zentaoatf/src/utils/file"
"github.com/easysoft/zentaoatf/src/utils/vari"
zentaoUtils
"github.com/easysoft/zentaoatf/src/utils/zentao"
"os"
"strconv"
"strings"
"time"
)
func
GenFromCmd
(
url
string
,
entityType
string
,
entityVal
string
,
langType
string
,
singleFile
bool
,
func
Gen
erateScript
FromCmd
(
url
string
,
entityType
string
,
entityVal
string
,
langType
string
,
singleFile
bool
,
account
string
,
password
string
)
{
params
:=
make
(
map
[
string
]
string
)
...
...
@@ -47,7 +41,7 @@ func GenFromCmd(url string, entityType string, entityVal string, langType string
}
if
testcases
!=
nil
{
count
,
err
:=
Generate
(
testcases
,
langType
,
singleFile
,
account
,
password
)
count
,
err
:=
scriptService
.
Generate
(
testcases
,
langType
,
singleFile
,
account
,
password
)
if
err
==
nil
{
configUtils
.
SaveConfig
(
""
,
url
,
params
[
"entityType"
],
params
[
"entityVal"
],
productId
,
projectId
,
langType
,
singleFile
,
...
...
@@ -60,163 +54,3 @@ func GenFromCmd(url string, entityType string, entityVal string, langType string
}
}
}
func
Generate
(
testcases
[]
model
.
TestCase
,
langType
string
,
singleFile
bool
,
account
string
,
password
string
)
(
int
,
error
)
{
casePaths
:=
make
([]
string
,
0
)
for
_
,
cs
:=
range
testcases
{
DealwithTestCase
(
cs
,
langType
,
singleFile
,
&
casePaths
)
}
testingService
.
GenSuite
(
casePaths
)
return
len
(
testcases
),
nil
}
func
DealwithTestCase
(
cs
model
.
TestCase
,
langType
string
,
singleFile
bool
,
casePaths
*
[]
string
)
{
LangMap
:=
scriptService
.
GetLangMap
()
langs
:=
""
if
LangMap
[
langType
]
==
nil
{
i
:=
0
for
lang
,
_
:=
range
LangMap
{
if
i
>
0
{
langs
+=
", "
}
langs
+=
lang
i
++
}
fmt
.
Printf
(
"only support languages %s
\n
"
,
langs
)
os
.
Exit
(
1
)
}
caseId
:=
cs
.
Id
caseInTaskId
:=
cs
.
IdInTask
taskId
:=
cs
.
TaskId
if
caseInTaskId
==
""
{
caseInTaskId
=
"0"
}
caseTitle
:=
cs
.
Title
scriptFile
:=
fmt
.
Sprintf
(
constant
.
ScriptDir
+
"tc-%s.%s"
,
caseId
,
LangMap
[
langType
][
"extName"
])
if
fileUtils
.
FileExist
(
scriptFile
)
{
scriptFile
=
fmt
.
Sprintf
(
constant
.
ScriptDir
+
"tc-%s.%s"
,
caseId
+
"-"
+
dateUtils
.
DateTimeStrLong
(
time
.
Now
()),
LangMap
[
langType
][
"extName"
])
}
fileUtils
.
MkDirIfNeeded
(
vari
.
Prefer
.
WorkDir
+
constant
.
ScriptDir
)
*
casePaths
=
append
(
*
casePaths
,
scriptFile
)
scriptFullPath
:=
vari
.
Prefer
.
WorkDir
+
scriptFile
steps
:=
make
([]
string
,
0
)
expects
:=
make
([]
string
,
0
)
srcCode
:=
make
([]
string
,
0
)
steps
=
append
(
steps
,
"@开头的为含验证点的步骤"
)
temp
:=
fmt
.
Sprintf
(
"
\n
%sCODE: 此处编写操作步骤代码
\n
"
,
LangMap
[
langType
][
"commentsTag"
])
srcCode
=
append
(
srcCode
,
temp
)
readme
:=
zentaoUtils
.
ReadResData
(
"res/template/readme.tpl"
)
+
"
\n
"
StepWidth
:=
20
stepDisplayMaxWidth
:=
0
ComputerTestStepWidth
(
cs
.
StepArr
,
&
stepDisplayMaxWidth
,
StepWidth
)
for
_
,
ts
:=
range
cs
.
StepArr
{
DealwithTestStep
(
ts
,
langType
,
StepWidth
,
&
steps
,
&
expects
,
&
srcCode
)
}
var
expectsTxt
string
if
singleFile
{
expectsTxt
=
strings
.
Join
(
expects
,
"
\n
"
)
}
else
{
expectFile
:=
zentaoUtils
.
ScriptToExpectName
(
scriptFullPath
)
expectsTxt
=
"@file
\n
"
fileUtils
.
WriteFile
(
expectFile
,
strings
.
Join
(
expects
,
"
\n
"
))
}
path
:=
fmt
.
Sprintf
(
"res%stemplate%s"
,
string
(
os
.
PathSeparator
),
string
(
os
.
PathSeparator
))
template
:=
zentaoUtils
.
ReadResData
(
path
+
langType
+
".tpl"
)
content
:=
fmt
.
Sprintf
(
template
,
caseId
,
caseInTaskId
,
taskId
,
caseTitle
,
strings
.
Join
(
steps
,
"
\n
"
),
expectsTxt
,
readme
,
strings
.
Join
(
srcCode
,
"
\n
"
))
//fmt.Println(content)
fileUtils
.
WriteFile
(
scriptFullPath
,
content
)
}
func
ComputerTestStepWidth
(
steps
[]
model
.
TestStep
,
stepSDisplayMaxWidth
*
int
,
stepWidth
int
)
{
for
_
,
ts
:=
range
steps
{
length
:=
len
(
ts
.
Id
)
if
length
>
*
stepSDisplayMaxWidth
{
*
stepSDisplayMaxWidth
=
length
}
}
*
stepSDisplayMaxWidth
+=
stepWidth
// prefix space and @step
}
func
DealwithTestStep
(
ts
model
.
TestStep
,
langType
string
,
stepWidth
int
,
steps
*
[]
string
,
expects
*
[]
string
,
srcCode
*
[]
string
)
{
LangMap
:=
scriptService
.
GetLangMap
()
isGroup
:=
ts
.
Type
==
"group"
isCheckPoint
:=
ts
.
Expect
!=
""
stepId
:=
ts
.
Id
stepTitle
:=
ts
.
Desc
stepExpect
:=
ts
.
Expect
stepParent
:=
ts
.
Parent
// 处理steps
preFixSpace
:=
3
if
stepParent
!=
""
&&
stepParent
!=
"0"
{
preFixSpace
=
6
}
var
stepType
string
if
isGroup
{
stepType
=
"group"
}
else
{
stepType
=
"step"
}
stepIdent
:=
stepType
+
stepId
if
isCheckPoint
{
stepIdent
=
"@"
+
stepIdent
}
postFixSpace
:=
stepWidth
-
preFixSpace
-
len
(
stepIdent
)
stepLine
:=
fmt
.
Sprintf
(
"%*s"
,
preFixSpace
,
" "
)
+
stepIdent
stepLine
+=
fmt
.
Sprintf
(
"%*s"
,
postFixSpace
,
" "
)
stepLine
+=
stepTitle
*
steps
=
append
(
*
steps
,
stepLine
)
// 处理expects
if
isCheckPoint
{
expectsLine
:=
""
expectsLine
=
"# "
+
stepIdent
+
"
\n
"
expectsLine
+=
"CODE: "
+
"期望结果, 可以有多行
\n
"
*
expects
=
append
(
*
expects
,
expectsLine
)
}
// 处理srcCode
if
isCheckPoint
{
codeLine
:=
LangMap
[
langType
][
"printGrammar"
]
codeLine
+=
fmt
.
Sprintf
(
" %s %s: %s
\n
"
,
LangMap
[
langType
][
"commentsTag"
],
stepIdent
,
stepExpect
)
codeLine
+=
LangMap
[
langType
][
"commentsTag"
]
+
"CODE: 输出验证点实际结果
\n
"
*
srcCode
=
append
(
*
srcCode
,
codeLine
)
}
}
src/atf.go
浏览文件 @
fae15ebc
...
...
@@ -111,7 +111,7 @@ func main() {
genSet
.
Usage
()
os
.
Exit
(
1
)
}
else
{
action
.
GenFromCmd
(
zentaoUrl
,
entityType
,
entityVal
,
langType
,
singleFile
,
account
,
password
)
action
.
Gen
erateScript
FromCmd
(
zentaoUrl
,
entityType
,
entityVal
,
langType
,
singleFile
,
account
,
password
)
}
}
case
"list"
:
...
...
src/service/script/assert.go
浏览文件 @
fae15ebc
...
...
@@ -9,7 +9,7 @@ import (
func
LoadTestAssets
()
([]
string
,
[]
string
)
{
config
:=
config2
.
ReadCurrConfig
()
ext
:=
Get
LangMap
()[
config
.
LangType
][
"extName"
]
ext
:=
Get
SupportedScriptLang
()[
config
.
LangType
][
"extName"
]
caseFiles
:=
make
([]
string
,
0
)
suitesFiles
:=
make
([]
string
,
0
)
...
...
src/service/script/generator.go
0 → 100644
浏览文件 @
fae15ebc
package
scriptService
import
(
"fmt"
"github.com/easysoft/zentaoatf/src/model"
constant
"github.com/easysoft/zentaoatf/src/utils/const"
dateUtils
"github.com/easysoft/zentaoatf/src/utils/date"
fileUtils
"github.com/easysoft/zentaoatf/src/utils/file"
"github.com/easysoft/zentaoatf/src/utils/vari"
zentaoUtils
"github.com/easysoft/zentaoatf/src/utils/zentao"
"os"
"strings"
"time"
)
func
Generate
(
testcases
[]
model
.
TestCase
,
langType
string
,
singleFile
bool
,
account
string
,
password
string
)
(
int
,
error
)
{
casePaths
:=
make
([]
string
,
0
)
for
_
,
cs
:=
range
testcases
{
GenerateTestCaseScrrpt
(
cs
,
langType
,
singleFile
,
&
casePaths
)
}
GenSuite
(
casePaths
)
return
len
(
testcases
),
nil
}
func
GenerateTestCaseScrrpt
(
cs
model
.
TestCase
,
langType
string
,
singleFile
bool
,
casePaths
*
[]
string
)
{
LangMap
:=
GetSupportedScriptLang
()
langs
:=
""
if
LangMap
[
langType
]
==
nil
{
i
:=
0
for
lang
,
_
:=
range
LangMap
{
if
i
>
0
{
langs
+=
", "
}
langs
+=
lang
i
++
}
fmt
.
Printf
(
"only support languages %s
\n
"
,
langs
)
os
.
Exit
(
1
)
}
caseId
:=
cs
.
Id
caseInTaskId
:=
cs
.
IdInTask
taskId
:=
cs
.
TaskId
if
caseInTaskId
==
""
{
caseInTaskId
=
"0"
}
caseTitle
:=
cs
.
Title
scriptFile
:=
fmt
.
Sprintf
(
constant
.
ScriptDir
+
"tc-%s.%s"
,
caseId
,
LangMap
[
langType
][
"extName"
])
if
fileUtils
.
FileExist
(
scriptFile
)
{
scriptFile
=
fmt
.
Sprintf
(
constant
.
ScriptDir
+
"tc-%s.%s"
,
caseId
+
"-"
+
dateUtils
.
DateTimeStrLong
(
time
.
Now
()),
LangMap
[
langType
][
"extName"
])
}
fileUtils
.
MkDirIfNeeded
(
vari
.
Prefer
.
WorkDir
+
constant
.
ScriptDir
)
*
casePaths
=
append
(
*
casePaths
,
scriptFile
)
scriptFullPath
:=
vari
.
Prefer
.
WorkDir
+
scriptFile
steps
:=
make
([]
string
,
0
)
expects
:=
make
([]
string
,
0
)
srcCode
:=
make
([]
string
,
0
)
steps
=
append
(
steps
,
"@开头的为含验证点的步骤"
)
temp
:=
fmt
.
Sprintf
(
"
\n
%sCODE: 此处编写操作步骤代码
\n
"
,
LangMap
[
langType
][
"commentsTag"
])
srcCode
=
append
(
srcCode
,
temp
)
readme
:=
zentaoUtils
.
ReadResData
(
"res/template/readme.tpl"
)
+
"
\n
"
StepWidth
:=
20
stepDisplayMaxWidth
:=
0
computerTestStepWidth
(
cs
.
StepArr
,
&
stepDisplayMaxWidth
,
StepWidth
)
for
_
,
ts
:=
range
cs
.
StepArr
{
GenerateTestStepScript
(
ts
,
langType
,
StepWidth
,
&
steps
,
&
expects
,
&
srcCode
)
}
var
expectsTxt
string
if
singleFile
{
expectsTxt
=
strings
.
Join
(
expects
,
"
\n
"
)
}
else
{
expectFile
:=
zentaoUtils
.
ScriptToExpectName
(
scriptFullPath
)
expectsTxt
=
"@file
\n
"
fileUtils
.
WriteFile
(
expectFile
,
strings
.
Join
(
expects
,
"
\n
"
))
}
path
:=
fmt
.
Sprintf
(
"res%stemplate%s"
,
string
(
os
.
PathSeparator
),
string
(
os
.
PathSeparator
))
template
:=
zentaoUtils
.
ReadResData
(
path
+
langType
+
".tpl"
)
content
:=
fmt
.
Sprintf
(
template
,
caseId
,
caseInTaskId
,
taskId
,
caseTitle
,
strings
.
Join
(
steps
,
"
\n
"
),
expectsTxt
,
readme
,
strings
.
Join
(
srcCode
,
"
\n
"
))
//fmt.Println(content)
fileUtils
.
WriteFile
(
scriptFullPath
,
content
)
}
func
GenerateTestStepScript
(
ts
model
.
TestStep
,
langType
string
,
stepWidth
int
,
steps
*
[]
string
,
expects
*
[]
string
,
srcCode
*
[]
string
)
{
LangMap
:=
GetSupportedScriptLang
()
isGroup
:=
ts
.
Type
==
"group"
isCheckPoint
:=
ts
.
Expect
!=
""
stepId
:=
ts
.
Id
stepTitle
:=
ts
.
Desc
stepExpect
:=
ts
.
Expect
stepParent
:=
ts
.
Parent
// 处理steps
preFixSpace
:=
3
if
stepParent
!=
""
&&
stepParent
!=
"0"
{
preFixSpace
=
6
}
var
stepType
string
if
isGroup
{
stepType
=
"group"
}
else
{
stepType
=
"step"
}
stepIdent
:=
stepType
+
stepId
if
isCheckPoint
{
stepIdent
=
"@"
+
stepIdent
}
postFixSpace
:=
stepWidth
-
preFixSpace
-
len
(
stepIdent
)
stepLine
:=
fmt
.
Sprintf
(
"%*s"
,
preFixSpace
,
" "
)
+
stepIdent
stepLine
+=
fmt
.
Sprintf
(
"%*s"
,
postFixSpace
,
" "
)
stepLine
+=
stepTitle
*
steps
=
append
(
*
steps
,
stepLine
)
// 处理expects
if
isCheckPoint
{
expectsLine
:=
""
expectsLine
=
"# "
+
stepIdent
+
"
\n
"
expectsLine
+=
"CODE: "
+
"期望结果, 可以有多行
\n
"
*
expects
=
append
(
*
expects
,
expectsLine
)
}
// 处理srcCode
if
isCheckPoint
{
codeLine
:=
LangMap
[
langType
][
"printGrammar"
]
codeLine
+=
fmt
.
Sprintf
(
" %s %s: %s
\n
"
,
LangMap
[
langType
][
"commentsTag"
],
stepIdent
,
stepExpect
)
codeLine
+=
LangMap
[
langType
][
"commentsTag"
]
+
"CODE: 输出验证点实际结果
\n
"
*
srcCode
=
append
(
*
srcCode
,
codeLine
)
}
}
func
GenSuite
(
cases
[]
string
)
{
str
:=
strings
.
Join
(
cases
,
"
\n
"
)
fileUtils
.
WriteFile
(
vari
.
Prefer
.
WorkDir
+
constant
.
ScriptDir
+
"all."
+
constant
.
SuiteExt
,
str
)
}
func
computerTestStepWidth
(
steps
[]
model
.
TestStep
,
stepSDisplayMaxWidth
*
int
,
stepWidth
int
)
{
for
_
,
ts
:=
range
steps
{
length
:=
len
(
ts
.
Id
)
if
length
>
*
stepSDisplayMaxWidth
{
*
stepSDisplayMaxWidth
=
length
}
}
*
stepSDisplayMaxWidth
+=
stepWidth
// prefix space and @step
}
src/service/script/
script
.go
→
src/service/script/
lang
.go
浏览文件 @
fae15ebc
...
...
@@ -4,7 +4,7 @@ import "sync"
var
LangMap
map
[
string
]
map
[
string
]
string
func
Get
LangMap
()
map
[
string
]
map
[
string
]
string
{
func
Get
SupportedScriptLang
()
map
[
string
]
map
[
string
]
string
{
var
once
sync
.
Once
once
.
Do
(
func
()
{
LangMap
=
map
[
string
]
map
[
string
]
string
{
...
...
@@ -55,5 +55,5 @@ func GetLangMap() map[string]map[string]string {
}
func
init
()
{
Get
LangMap
()
Get
SupportedScriptLang
()
}
src/service/testing/check.go
浏览文件 @
fae15ebc
...
...
@@ -3,7 +3,7 @@ package testingService
import
(
"github.com/easysoft/zentaoatf/src/model"
"github.com/easysoft/zentaoatf/src/utils/const"
i118Utils
"github.com/easysoft/zentaoatf/src/utils/i118"
"github.com/easysoft/zentaoatf/src/utils/i118"
"github.com/easysoft/zentaoatf/src/utils/log"
"github.com/easysoft/zentaoatf/src/utils/string"
zentaoUtils
"github.com/easysoft/zentaoatf/src/utils/zentao"
...
...
src/service/testing/suite.go
已删除
100644 → 0
浏览文件 @
d4fbd987
package
testingService
import
(
constant
"github.com/easysoft/zentaoatf/src/utils/const"
"github.com/easysoft/zentaoatf/src/utils/file"
"github.com/easysoft/zentaoatf/src/utils/vari"
"strings"
)
func
GenSuite
(
cases
[]
string
)
{
str
:=
strings
.
Join
(
cases
,
"
\n
"
)
fileUtils
.
WriteFile
(
vari
.
Prefer
.
WorkDir
+
constant
.
ScriptDir
+
"all."
+
constant
.
SuiteExt
,
str
)
}
src/ui/page/pageImport.go
浏览文件 @
fae15ebc
...
...
@@ -2,8 +2,8 @@ package page
import
(
"fmt"
"github.com/easysoft/zentaoatf/src/action"
"github.com/easysoft/zentaoatf/src/model"
scriptService
"github.com/easysoft/zentaoatf/src/service/script"
zentaoService
"github.com/easysoft/zentaoatf/src/service/zentao"
"github.com/easysoft/zentaoatf/src/ui"
"github.com/easysoft/zentaoatf/src/ui/widget"
...
...
@@ -104,7 +104,7 @@ func InitImportPage() error {
submitInput
:=
widget
.
NewButtonWidgetAutoWidth
(
"submitInput"
,
buttonX
,
13
,
"Submit"
,
ImportRequest
)
ui
.
ViewMap
[
"import"
]
=
append
(
ui
.
ViewMap
[
"import"
],
submitInput
.
Name
())
ui
.
KeyBindsInput
(
ui
.
ViewMap
[
"import"
])
ui
.
AddEventForInputWidgets
(
ui
.
ViewMap
[
"import"
])
return
nil
}
...
...
@@ -162,7 +162,7 @@ func ImportRequest(g *gocui.Gui, v *gocui.View) error {
cases
=
zentaoService
.
ListCaseByTask
(
url
,
taskId
)
}
count
,
err
:=
action
.
Generate
(
cases
,
language
,
singleFile
,
account
,
password
)
count
,
err
:=
scriptService
.
Generate
(
cases
,
language
,
singleFile
,
account
,
password
)
if
err
==
nil
{
configUtils
.
SaveConfig
(
""
,
url
,
params
[
"entityType"
],
params
[
"entityVal"
],
productIdInt
,
projectId
,
language
,
singleFile
,
...
...
src/ui/page/pageReportBug.go
浏览文件 @
fae15ebc
...
...
@@ -51,7 +51,7 @@ func InitReportBugPage() error {
// steps
left
=
right
+
ui
.
Space
stepsWidth
:=
pageWidth
-
left
-
ui
.
Space
+
x
stepsInput
:=
widget
.
NewText
WidgetWithHeigh
t
(
"stepsInput"
,
left
,
y
,
stepsWidth
,
pageHeight
-
2
,
bug
.
Steps
)
stepsInput
:=
widget
.
NewText
areaWidge
t
(
"stepsInput"
,
left
,
y
,
stepsWidth
,
pageHeight
-
2
,
bug
.
Steps
)
stepsInput
.
Title
=
"Steps"
ui
.
ViewMap
[
"reportBug"
]
=
append
(
ui
.
ViewMap
[
"reportBug"
],
stepsInput
.
Name
())
...
...
@@ -114,7 +114,7 @@ func InitReportBugPage() error {
buttonX
+
11
,
y
,
"Cancel"
,
cancelReportBug
)
ui
.
ViewMap
[
"reportBug"
]
=
append
(
ui
.
ViewMap
[
"reportBug"
],
cancelReportBugInput
.
Name
())
ui
.
KeyBindsInput
(
ui
.
ViewMap
[
"reportBug"
])
ui
.
AddEventForInputWidgets
(
ui
.
ViewMap
[
"reportBug"
])
return
nil
}
...
...
@@ -131,11 +131,11 @@ func reportBug(g *gocui.Gui, v *gocui.View) error {
title
:=
strings
.
TrimSpace
(
titleView
.
Buffer
())
stepsStr
:=
strings
.
TrimSpace
(
stepsView
.
Buffer
())
moduleStr
:=
strings
.
TrimSpace
(
ui
.
GetSelected
Line
Val
(
moduleView
))
typeStr
:=
strings
.
TrimSpace
(
ui
.
GetSelected
Line
Val
(
typeView
))
versionStr
:=
strings
.
TrimSpace
(
ui
.
GetSelected
Line
Val
(
versionView
))
severityStr
:=
strings
.
TrimSpace
(
ui
.
GetSelected
Line
Val
(
severityView
))
priorityStr
:=
strings
.
TrimSpace
(
ui
.
GetSelected
Line
Val
(
priorityView
))
moduleStr
:=
strings
.
TrimSpace
(
ui
.
GetSelected
Row
Val
(
moduleView
))
typeStr
:=
strings
.
TrimSpace
(
ui
.
GetSelected
Row
Val
(
typeView
))
versionStr
:=
strings
.
TrimSpace
(
ui
.
GetSelected
Row
Val
(
versionView
))
severityStr
:=
strings
.
TrimSpace
(
ui
.
GetSelected
Row
Val
(
severityView
))
priorityStr
:=
strings
.
TrimSpace
(
ui
.
GetSelected
Row
Val
(
priorityView
))
if
title
==
""
{
v
,
_
:=
vari
.
Cui
.
View
(
"reportBugMsg"
)
...
...
@@ -166,7 +166,7 @@ func bugSelectFieldCheckEvent(filedValMap map[string]int) func(g *gocui.Gui, v *
g
.
SetCurrentView
(
name
)
//line, _ := GetSelected
Line
(v, ".*")
//line, _ := GetSelected
Row
(v, ".*")
//line = strings.TrimSpace(line)
//
//zentaoUtils.SetBugField(name, line, filedValMap)
...
...
src/ui/page/pageSwitch.go
浏览文件 @
fae15ebc
...
...
@@ -38,7 +38,7 @@ func InitSwitchPage() error {
submitInput
:=
widget
.
NewButtonWidgetAutoWidth
(
"submitInput"
,
buttonX
,
4
,
"Switch"
,
SwitchWorkDir
)
ui
.
ViewMap
[
"switch"
]
=
append
(
ui
.
ViewMap
[
"switch"
],
submitInput
.
Name
())
ui
.
KeyBindsInput
(
ui
.
ViewMap
[
"switch"
])
ui
.
AddEventForInputWidgets
(
ui
.
ViewMap
[
"switch"
])
return
nil
}
...
...
src/ui/page/pageTestResult.go
浏览文件 @
fae15ebc
...
...
@@ -40,8 +40,8 @@ func showRun(g *gocui.Gui, v *gocui.View) error {
ui
.
SupportScroll
(
"panelCaseList"
)
ui
.
SupportScroll
(
"panelCaseResult"
)
ui
.
Support
Line
Highlight
(
"panelResultList"
)
ui
.
Support
Line
Highlight
(
"panelCaseList"
)
ui
.
Support
Row
Highlight
(
"panelResultList"
)
ui
.
Support
Row
Highlight
(
"panelCaseList"
)
ui
.
AddLineSelectedEvent
(
"panelResultList"
,
selectResultEvent
)
ui
.
AddLineSelectedEvent
(
"panelCaseList"
,
selectCaseEvent
)
...
...
@@ -61,7 +61,7 @@ func selectResultEvent(g *gocui.Gui, v *gocui.View) error {
v
.
Highlight
=
true
line
,
_
:=
ui
.
GetSelectedLine
(
v
,
".*"
)
line
:=
ui
.
GetSelectedRowVal
(
v
)
vari
.
CurrResultDate
=
line
content
:=
make
([]
string
,
0
)
...
...
@@ -90,7 +90,7 @@ func selectResultEvent(g *gocui.Gui, v *gocui.View) error {
func
selectCaseEvent
(
g
*
gocui
.
Gui
,
v
*
gocui
.
View
)
error
{
v
.
Highlight
=
true
caseLine
,
_
:=
ui
.
GetSelectedLine
(
v
,
".*"
)
caseLine
:=
ui
.
GetSelectedRowVal
(
v
)
caseIdStr
:=
strings
.
Split
(
caseLine
,
"-"
)[
0
]
caseId
,
_
:=
strconv
.
Atoi
(
caseIdStr
)
vari
.
CurrCaseId
=
caseId
...
...
src/ui/uiUtils.go
浏览文件 @
fae15ebc
...
...
@@ -12,15 +12,14 @@ const (
Space
=
2
)
func
KeyBindsInput
(
arr
[]
string
)
{
func
AddEventForInputWidgets
(
arr
[]
string
)
{
for
_
,
v
:=
range
arr
{
if
I
sInput
(
v
)
{
AddEventForInputWidth
(
v
)
if
i
sInput
(
v
)
{
vari
.
Cui
.
SetKeybinding
(
v
,
gocui
.
MouseLeft
,
gocui
.
ModNone
,
SetCurrView
(
v
)
)
}
}
}
func
IsInput
(
v
string
)
bool
{
func
isInput
(
v
string
)
bool
{
return
strings
.
Index
(
v
,
"Input"
)
>
-
1
}
...
...
@@ -95,7 +94,7 @@ func scrollAction(v *gocui.View, dy int, isSelectWidget bool) error {
return
nil
}
func
Support
Line
Highlight
(
name
string
)
error
{
func
Support
Row
Highlight
(
name
string
)
error
{
v
,
_
:=
vari
.
Cui
.
View
(
name
)
v
.
Wrap
=
true
...
...
@@ -123,13 +122,6 @@ func SetCurrView(name string) func(g *gocui.Gui, v *gocui.View) error {
}
}
func
AddEventForInputWidth
(
name
string
)
error
{
if
err
:=
vari
.
Cui
.
SetKeybinding
(
name
,
gocui
.
MouseLeft
,
gocui
.
ModNone
,
SetCurrView
(
name
));
err
!=
nil
{
return
err
}
return
nil
}
func
HighlightTab
(
view
string
,
views
[]
string
)
{
for
_
,
name
:=
range
views
{
v
,
_
:=
vari
.
Cui
.
View
(
name
)
...
...
@@ -146,7 +138,12 @@ func HighlightTab(view string, views []string) {
}
}
func
GetSelectedLine
(
v
*
gocui
.
View
,
reg
string
)
(
string
,
error
)
{
func
GetSelectedRowVal
(
v
*
gocui
.
View
)
string
{
line
,
_
:=
getSelectedRow
(
v
,
".*"
)
return
line
}
func
getSelectedRow
(
v
*
gocui
.
View
,
reg
string
)
(
string
,
error
)
{
var
line
string
var
err
error
...
...
@@ -164,9 +161,3 @@ func GetSelectedLine(v *gocui.View, reg string) (string, error) {
return
line
,
nil
}
func
GetSelectedLineVal
(
v
*
gocui
.
View
)
string
{
line
,
_
:=
GetSelectedLine
(
v
,
".*"
)
return
line
}
src/ui/widget/widgetSelect.go
浏览文件 @
fae15ebc
...
...
@@ -49,7 +49,7 @@ func (w *SelectWidget) Layout() (*gocui.View, error) {
v
,
_
:=
vari
.
Cui
.
SetView
(
w
.
name
,
w
.
x
,
w
.
y
,
w
.
x
+
w
.
w
,
w
.
y
+
w
.
h
)
v
.
Highlight
=
true
ui
.
SupportScroll
(
w
.
name
)
ui
.
Support
Line
Highlight
(
w
.
name
)
ui
.
Support
Row
Highlight
(
w
.
name
)
v
.
Title
=
w
.
title
...
...
@@ -62,7 +62,7 @@ func (w *SelectWidget) Layout() (*gocui.View, error) {
_
,
height
:=
v
.
Size
()
for
true
{
line
,
_
:=
ui
.
GetSelectedLine
(
v
,
".*"
)
line
:=
ui
.
GetSelectedRowVal
(
v
)
if
w
.
defaultt
!=
""
{
if
line
==
w
.
defaultt
{
break
...
...
src/ui/widget/widgetText.go
浏览文件 @
fae15ebc
...
...
@@ -27,7 +27,7 @@ func NewTextWidget(name string, x, y, w int, text string) *gocui.View {
return
v
}
func
NewText
WidgetWithHeigh
t
(
name
string
,
x
,
y
,
w
,
h
int
,
text
string
)
*
gocui
.
View
{
func
NewText
areaWidge
t
(
name
string
,
x
,
y
,
w
,
h
int
,
text
string
)
*
gocui
.
View
{
widget
:=
TextWidget
{
name
:
name
,
x
:
x
,
y
:
y
,
w
:
w
,
h
:
h
,
text
:
text
}
v
,
_
:=
widget
.
Layout
()
return
v
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录