Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
fc0774e4
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
fc0774e4
编写于
4月 10, 2018
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
typeInEditor API
上级
7bd69c0c
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
65 addition
and
23 deletion
+65
-23
src/vs/platform/driver/common/driver.ts
src/vs/platform/driver/common/driver.ts
+14
-0
src/vs/platform/driver/electron-browser/driver.ts
src/vs/platform/driver/electron-browser/driver.ts
+23
-0
src/vs/platform/driver/electron-main/driver.ts
src/vs/platform/driver/electron-main/driver.ts
+5
-0
test/smoke/src/api.ts
test/smoke/src/api.ts
+4
-0
test/smoke/src/areas/editor/editor.ts
test/smoke/src/areas/editor/editor.ts
+4
-22
test/smoke/src/driver.ts
test/smoke/src/driver.ts
+14
-0
test/smoke/test/mocha.opts
test/smoke/test/mocha.opts
+1
-1
未找到文件。
src/vs/platform/driver/common/driver.ts
浏览文件 @
fc0774e4
...
...
@@ -33,6 +33,7 @@ export interface IDriver {
getTitle
(
windowId
:
number
):
TPromise
<
string
>
;
isActiveElement
(
windowId
:
number
,
selector
:
string
):
TPromise
<
boolean
>
;
getElements
(
windowId
:
number
,
selector
:
string
,
recursive
:
boolean
):
TPromise
<
IElement
[]
>
;
typeInEditor
(
windowId
:
number
,
selector
:
string
,
text
:
string
):
TPromise
<
void
>
;
selectorExecute
<
P
>
(
windowId
:
number
,
selector
:
string
,
script
:
(
elements
:
HTMLElement
[],
...
args
:
any
[])
=>
P
,
...
args
:
any
[]):
TPromise
<
P
>
;
}
//*END
...
...
@@ -47,6 +48,7 @@ export interface IDriverChannel extends IChannel {
call
(
command
:
'
getTitle
'
,
arg
:
[
number
]):
TPromise
<
string
>
;
call
(
command
:
'
isActiveElement
'
,
arg
:
[
number
,
string
]):
TPromise
<
boolean
>
;
call
(
command
:
'
getElements
'
,
arg
:
[
number
,
string
,
boolean
]):
TPromise
<
IElement
[]
>
;
call
(
command
:
'
typeInEditor
'
,
arg
:
[
number
,
string
,
string
]):
TPromise
<
void
>
;
call
(
command
:
'
selectorExecute
'
,
arg
:
[
number
,
string
,
string
,
any
[]]):
TPromise
<
any
>
;
call
(
command
:
string
,
arg
:
any
):
TPromise
<
any
>
;
}
...
...
@@ -66,6 +68,7 @@ export class DriverChannel implements IDriverChannel {
case
'
getTitle
'
:
return
this
.
driver
.
getTitle
(
arg
[
0
]);
case
'
isActiveElement
'
:
return
this
.
driver
.
isActiveElement
(
arg
[
0
],
arg
[
1
]);
case
'
getElements
'
:
return
this
.
driver
.
getElements
(
arg
[
0
],
arg
[
1
],
arg
[
2
]);
case
'
typeInEditor
'
:
return
this
.
driver
.
typeInEditor
(
arg
[
0
],
arg
[
1
],
arg
[
2
]);
// TODO@joao
case
'
selectorExecute
'
:
return
this
.
driver
.
selectorExecute
(
arg
[
0
],
arg
[
1
],
arg
[
1
],
...
arg
[
2
]);
...
...
@@ -117,6 +120,10 @@ export class DriverChannelClient implements IDriver {
return
this
.
channel
.
call
(
'
getElements
'
,
[
windowId
,
selector
,
recursive
]);
}
typeInEditor
(
windowId
:
number
,
selector
:
string
,
text
:
string
):
TPromise
<
void
>
{
return
this
.
channel
.
call
(
'
typeInEditor
'
,
[
windowId
,
selector
,
text
]);
}
selectorExecute
<
P
>
(
windowId
:
number
,
selector
:
string
,
script
:
(
elements
:
HTMLElement
[],
...
args
:
any
[])
=>
P
,
...
args
:
any
[]):
TPromise
<
P
>
{
// TODO@joao
return
this
.
channel
.
call
(
'
selectorExecute
'
,
[
windowId
,
selector
,
script
.
toString
(),
args
]);
...
...
@@ -164,6 +171,7 @@ export interface IWindowDriver {
getTitle
():
TPromise
<
string
>
;
isActiveElement
(
selector
:
string
):
TPromise
<
boolean
>
;
getElements
(
selector
:
string
,
recursive
:
boolean
):
TPromise
<
IElement
[]
>
;
typeInEditor
(
selector
:
string
,
text
:
string
):
TPromise
<
void
>
;
selectorExecute
<
P
>
(
selector
:
string
,
script
:
(
elements
:
HTMLElement
[],
...
args
:
any
[])
=>
P
,
...
args
:
any
[]):
TPromise
<
P
>
;
}
...
...
@@ -175,6 +183,7 @@ export interface IWindowDriverChannel extends IChannel {
call
(
command
:
'
getTitle
'
):
TPromise
<
string
>
;
call
(
command
:
'
isActiveElement
'
,
arg
:
string
):
TPromise
<
boolean
>
;
call
(
command
:
'
getElements
'
,
arg
:
[
string
,
boolean
]):
TPromise
<
IElement
[]
>
;
call
(
command
:
'
typeInEditor
'
,
arg
:
[
string
,
string
]):
TPromise
<
void
>
;
call
(
command
:
'
selectorExecute
'
,
arg
:
[
string
,
string
,
any
[]]):
TPromise
<
any
>
;
call
(
command
:
string
,
arg
:
any
):
TPromise
<
any
>
;
}
...
...
@@ -192,6 +201,7 @@ export class WindowDriverChannel implements IWindowDriverChannel {
case
'
getTitle
'
:
return
this
.
driver
.
getTitle
();
case
'
isActiveElement
'
:
return
this
.
driver
.
isActiveElement
(
arg
);
case
'
getElements
'
:
return
this
.
driver
.
getElements
(
arg
[
0
],
arg
[
1
]);
case
'
typeInEditor
'
:
return
this
.
driver
.
typeInEditor
(
arg
[
0
],
arg
[
1
]);
// TODO@joao
case
'
selectorExecute
'
:
return
this
.
driver
.
selectorExecute
(
arg
[
0
],
arg
[
1
],
...
arg
[
2
]);
}
...
...
@@ -234,6 +244,10 @@ export class WindowDriverChannelClient implements IWindowDriver {
return
this
.
channel
.
call
(
'
getElements
'
,
[
selector
,
recursive
]);
}
typeInEditor
(
selector
:
string
,
text
:
string
):
TPromise
<
void
>
{
return
this
.
channel
.
call
(
'
typeInEditor
'
,
[
selector
,
text
]);
}
selectorExecute
<
P
>
(
selector
:
string
,
script
:
(
elements
:
HTMLElement
[],
...
args
:
any
[])
=>
P
,
...
args
:
any
[]):
TPromise
<
P
>
{
// TODO@joao
return
this
.
channel
.
call
(
'
selectorExecute
'
,
[
selector
,
script
.
toString
(),
args
]);
...
...
src/vs/platform/driver/electron-browser/driver.ts
浏览文件 @
fc0774e4
...
...
@@ -87,6 +87,29 @@ class WindowDriver implements IWindowDriver {
return
result
;
}
async
typeInEditor
(
selector
:
string
,
text
:
string
):
TPromise
<
void
>
{
const
element
=
document
.
querySelector
(
selector
);
if
(
!
element
)
{
throw
new
Error
(
'
Editor not found:
'
+
selector
);
}
const
textarea
=
element
as
HTMLTextAreaElement
;
console
.
log
(
textarea
);
const
start
=
textarea
.
selectionStart
;
const
newStart
=
start
+
text
.
length
;
const
value
=
textarea
.
value
;
const
newValue
=
value
.
substr
(
0
,
start
)
+
text
+
value
.
substr
(
start
);
textarea
.
value
=
newValue
;
textarea
.
setSelectionRange
(
newStart
,
newStart
);
const
event
=
new
Event
(
'
input
'
,
{
'
bubbles
'
:
true
,
'
cancelable
'
:
true
});
textarea
.
dispatchEvent
(
event
);
}
selectorExecute
<
P
>
(
selector
:
string
,
script
:
(
elements
:
HTMLElement
[],
...
args
:
any
[])
=>
P
,
...
args
:
any
[]):
TPromise
<
P
>
{
return
TPromise
.
wrapError
(
new
Error
(
'
not implemented
'
));
}
...
...
src/vs/platform/driver/electron-main/driver.ts
浏览文件 @
fc0774e4
...
...
@@ -137,6 +137,11 @@ export class Driver implements IDriver, IWindowDriverRegistry {
return
windowDriver
.
selectorExecute
(
selector
,
script
,
...
args
);
}
typeInEditor
(
windowId
:
number
,
selector
:
string
,
text
:
string
):
TPromise
<
void
>
{
const
windowDriver
=
this
.
getWindowDriver
(
windowId
);
return
windowDriver
.
typeInEditor
(
selector
,
text
);
}
private
getWindowDriver
(
windowId
:
number
):
IWindowDriver
{
const
router
=
new
WindowRouter
(
windowId
);
const
windowDriverChannel
=
this
.
windowServer
.
getChannel
<
IWindowDriverChannel
>
(
'
windowDriver
'
,
router
);
...
...
test/smoke/src/api.ts
浏览文件 @
fc0774e4
...
...
@@ -80,6 +80,10 @@ export class API {
return
this
.
driver
.
selectorExecute
(
selector
,
script
,
...
args
);
}
typeInEditor
(
selector
:
string
,
text
:
string
):
Promise
<
void
>
{
return
this
.
driver
.
typeInEditor
(
selector
,
text
);
}
private
running
=
false
;
async
waitFor
<
T
>
(
func
:
()
=>
T
|
Promise
<
T
|
undefined
>
,
accept
?:
(
result
:
T
)
=>
boolean
|
Promise
<
boolean
>
,
timeoutMessage
?:
string
,
retryCount
?:
number
):
Promise
<
T
>
;
async
waitFor
<
T
>
(
func
:
()
=>
T
|
Promise
<
T
>
,
accept
:
(
result
:
T
)
=>
boolean
|
Promise
<
boolean
>
=
result
=>
!!
result
,
timeoutMessage
?:
string
,
retryCount
?:
number
):
Promise
<
T
>
{
...
...
test/smoke/src/areas/editor/editor.ts
浏览文件 @
fc0774e4
...
...
@@ -9,6 +9,7 @@ import { API } from '../../api';
const
RENAME_BOX
=
'
.monaco-editor .monaco-editor.rename-box
'
;
const
RENAME_INPUT
=
`
${
RENAME_BOX
}
.rename-input`
;
const
EDITOR
=
filename
=>
`.monaco-editor[data-uri$="
${
filename
}
"]`
;
export
class
Editor
{
...
...
@@ -87,39 +88,20 @@ export class Editor {
}
async
waitForTypeInEditor
(
filename
:
string
,
text
:
string
,
selectorPrefix
=
''
):
Promise
<
any
>
{
const
editor
=
[
selectorPrefix
||
''
,
`.monaco-editor[data-uri$="
${
filename
}
"]`
].
join
(
'
'
);
const
editor
=
[
selectorPrefix
||
''
,
EDITOR
(
filename
)].
join
(
'
'
);
await
this
.
api
.
waitForElement
(
editor
);
const
textarea
=
`
${
editor
}
textarea`
;
await
this
.
api
.
waitForActiveElement
(
textarea
);
// https://github.com/Microsoft/vscode/issues/34203#issuecomment-334441786
await
this
.
api
.
selectorExecute
(
textarea
,
(
elements
,
text
)
=>
{
const
textarea
=
(
Array
.
isArray
(
elements
)
?
elements
:
[
elements
])[
0
]
as
HTMLTextAreaElement
;
const
start
=
textarea
.
selectionStart
;
const
newStart
=
start
+
text
.
length
;
const
value
=
textarea
.
value
;
const
newValue
=
value
.
substr
(
0
,
start
)
+
text
+
value
.
substr
(
start
);
textarea
.
value
=
newValue
;
textarea
.
setSelectionRange
(
newStart
,
newStart
);
const
event
=
new
Event
(
'
input
'
,
{
'
bubbles
'
:
true
,
'
cancelable
'
:
true
});
textarea
.
dispatchEvent
(
event
);
},
text
);
await
this
.
api
.
typeInEditor
(
textarea
,
text
);
await
this
.
waitForEditorContents
(
filename
,
c
=>
c
.
indexOf
(
text
)
>
-
1
,
selectorPrefix
);
}
async
waitForEditorContents
(
filename
:
string
,
accept
:
(
contents
:
string
)
=>
boolean
,
selectorPrefix
=
''
):
Promise
<
any
>
{
const
selector
=
[
selectorPrefix
||
''
,
`.monaco-editor[data-uri$="
${
filename
}
"] .view-lines`
].
join
(
'
'
);
const
selector
=
[
selectorPrefix
||
''
,
`
${
EDITOR
(
filename
)}
.view-lines`
].
join
(
'
'
);
return
this
.
api
.
waitForTextContent
(
selector
,
undefined
,
c
=>
accept
(
c
.
replace
(
/
\u
00a0/g
,
'
'
)));
}
...
...
test/smoke/src/driver.ts
浏览文件 @
fc0774e4
...
...
@@ -23,6 +23,7 @@ export interface Driver {
isActiveElement
(
selector
:
string
):
Promise
<
boolean
>
;
getElements
(
selector
:
string
,
recursive
?:
boolean
):
Promise
<
Element
[]
>
;
typeInEditor
(
selector
:
string
,
text
:
string
):
Promise
<
void
>
;
selectorExecute
<
P
>
(
selector
:
string
,
script
:
(
elements
:
HTMLElement
[],
...
args
:
any
[])
=>
P
,
...
args
:
any
[]):
Promise
<
P
>
;
}
...
...
@@ -116,6 +117,10 @@ export class SpectronDriver implements Driver {
return
result
.
value
;
}
typeInEditor
(
selector
:
string
,
text
:
string
):
Promise
<
void
>
{
throw
new
Error
(
'
Method not implemented.
'
);
}
async
selectorExecute
<
P
>
(
selector
:
string
,
script
:
(
elements
:
HTMLElement
[],
...
args
:
any
[])
=>
P
,
...
args
:
any
[]):
Promise
<
P
>
{
if
(
this
.
verbose
)
{
console
.
log
(
'
- selectorExecute:
'
,
selector
);
...
...
@@ -217,6 +222,15 @@ export class CodeDriver implements Driver {
return
await
this
.
driver
.
selectorExecute
(
windowId
,
selector
,
script
,
...
args
);
}
async
typeInEditor
(
selector
:
string
,
text
:
string
):
Promise
<
void
>
{
if
(
this
.
verbose
)
{
console
.
log
(
'
- typeInEditor:
'
,
selector
,
text
);
}
const
windowId
=
await
this
.
getWindowId
();
return
await
this
.
driver
.
typeInEditor
(
windowId
,
selector
,
text
);
}
private
async
getWindowId
():
Promise
<
number
>
{
if
(
typeof
this
.
_activeWindowId
!==
'
number
'
)
{
const
windows
=
await
this
.
driver
.
getWindowIds
();
...
...
test/smoke/test/mocha.opts
浏览文件 @
fc0774e4
--timeout
1
0000
--timeout
2
0000
--slow 2000
out/main.js
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录