Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
cd3c17be
R
roslyn
项目概览
lwm1986
/
roslyn
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
roslyn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
cd3c17be
编写于
9月 30, 2015
作者:
G
Gen Lu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add a mocked clipboard for interactive window tests
上级
e2ded549
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
43 addition
and
19 deletion
+43
-19
src/InteractiveWindow/Editor/InteractiveWindow.cs
src/InteractiveWindow/Editor/InteractiveWindow.cs
+6
-8
src/InteractiveWindow/EditorTest/InteractiveWindowTests.cs
src/InteractiveWindow/EditorTest/InteractiveWindowTests.cs
+37
-11
未找到文件。
src/InteractiveWindow/Editor/InteractiveWindow.cs
浏览文件 @
cd3c17be
...
@@ -543,18 +543,16 @@ private static void DoEvents()
...
@@ -543,18 +543,16 @@ private static void DoEvents()
#
endregion
#
endregion
internal
class
ClipboardWrapper
internal
class
ClipboardWrapper
{
{
internal
virtual
void
Clear
()
=>
Clipboard
.
Clear
();
internal
bool
ContainsData
(
string
format
)
=>
Clipboard
.
ContainsData
(
format
);
internal
virtual
bool
ContainsData
(
string
format
)
=>
Clipboard
.
ContainsData
(
format
);
internal
virtual
object
GetData
(
string
format
)
=>
Clipboard
.
GetData
(
format
);
internal
object
GetData
(
string
format
)
=>
Clipboard
.
GetData
(
format
);
internal
virtual
bool
ContainsText
()
=>
Clipboard
.
ContainsText
();
internal
bool
ContainsText
()
=>
Clipboard
.
ContainsText
();
internal
virtual
string
GetText
()
=>
Clipboard
.
GetText
();
internal
string
GetText
()
=>
Clipboard
.
GetText
();
internal
v
irtual
v
oid
SetDataObject
(
object
data
,
bool
copy
)
=>
Clipboard
.
SetDataObject
(
data
,
copy
);
internal
void
SetDataObject
(
object
data
,
bool
copy
)
=>
Clipboard
.
SetDataObject
(
data
,
copy
);
}
}
}
}
}
}
src/InteractiveWindow/EditorTest/InteractiveWindowTests.cs
浏览文件 @
cd3c17be
...
@@ -25,6 +25,8 @@ public InteractiveWindowTests()
...
@@ -25,6 +25,8 @@ public InteractiveWindowTests()
{
{
_states
=
new
List
<
InteractiveWindow
.
State
>();
_states
=
new
List
<
InteractiveWindow
.
State
>();
_testHost
=
new
InteractiveWindowTestHost
(
_states
.
Add
);
_testHost
=
new
InteractiveWindowTestHost
(
_states
.
Add
);
((
InteractiveWindow
)
Window
).
InteractiveWindowClipboard
=
new
TestClipboard
();
}
}
void
IDisposable
.
Dispose
()
void
IDisposable
.
Dispose
()
...
@@ -34,6 +36,8 @@ void IDisposable.Dispose()
...
@@ -34,6 +36,8 @@ void IDisposable.Dispose()
private
IInteractiveWindow
Window
=>
_testHost
.
Window
;
private
IInteractiveWindow
Window
=>
_testHost
.
Window
;
private
InteractiveWindow
.
ClipboardWrapper
WindowClipboard
=>
((
InteractiveWindow
)
Window
).
InteractiveWindowClipboard
;
private
static
IEnumerable
<
IInteractiveWindowCommand
>
MockCommands
(
params
string
[]
commandNames
)
private
static
IEnumerable
<
IInteractiveWindowCommand
>
MockCommands
(
params
string
[]
commandNames
)
{
{
foreach
(
var
name
in
commandNames
)
foreach
(
var
name
in
commandNames
)
...
@@ -582,7 +586,7 @@ public void ReformatBraces()
...
@@ -582,7 +586,7 @@ public void ReformatBraces()
[
Fact
(
Skip
=
"5544"
),
WorkItem
(
5544
,
"https://github.com/dotnet/roslyn/issues/5544"
)]
[
Fact
(
Skip
=
"5544"
),
WorkItem
(
5544
,
"https://github.com/dotnet/roslyn/issues/5544"
)]
public
void
CopyWithinInput
()
public
void
CopyWithinInput
()
{
{
Cl
ipboard
.
Clear
();
Cl
earClipboard
();
Window
.
InsertCode
(
"1 + 2"
);
Window
.
InsertCode
(
"1 + 2"
);
Window
.
Operations
.
SelectAll
();
Window
.
Operations
.
SelectAll
();
...
@@ -601,7 +605,7 @@ public void CopyWithinInput()
...
@@ -601,7 +605,7 @@ public void CopyWithinInput()
[
Fact
(
Skip
=
"5544"
),
WorkItem
(
5544
,
"https://github.com/dotnet/roslyn/issues/5544"
)]
[
Fact
(
Skip
=
"5544"
),
WorkItem
(
5544
,
"https://github.com/dotnet/roslyn/issues/5544"
)]
public
void
CopyInputAndOutput
()
public
void
CopyInputAndOutput
()
{
{
Cl
ipboard
.
Clear
();
Cl
earClipboard
();
Submit
(
Submit
(
@"foreach (var o in new[] { 1, 2, 3 })
@"foreach (var o in new[] { 1, 2, 3 })
...
@@ -644,7 +648,7 @@ public void CopyInputAndOutput()
...
@@ -644,7 +648,7 @@ public void CopyInputAndOutput()
[
Fact
(
Skip
=
"5544"
),
WorkItem
(
5544
,
"https://github.com/dotnet/roslyn/issues/5544"
)]
[
Fact
(
Skip
=
"5544"
),
WorkItem
(
5544
,
"https://github.com/dotnet/roslyn/issues/5544"
)]
public
void
CutWithinInput
()
public
void
CutWithinInput
()
{
{
Cl
ipboard
.
Clear
();
Cl
earClipboard
();
Window
.
InsertCode
(
"foreach (var o in new[] { 1, 2, 3 })"
);
Window
.
InsertCode
(
"foreach (var o in new[] { 1, 2, 3 })"
);
Window
.
Operations
.
BreakLine
();
Window
.
Operations
.
BreakLine
();
...
@@ -672,7 +676,7 @@ public void CutWithinInput()
...
@@ -672,7 +676,7 @@ public void CutWithinInput()
[
Fact
(
Skip
=
"5544"
),
WorkItem
(
5544
,
"https://github.com/dotnet/roslyn/issues/5544"
)]
[
Fact
(
Skip
=
"5544"
),
WorkItem
(
5544
,
"https://github.com/dotnet/roslyn/issues/5544"
)]
public
void
CutInputAndOutput
()
public
void
CutInputAndOutput
()
{
{
Cl
ipboard
.
Clear
();
Cl
earClipboard
();
Submit
(
Submit
(
@"foreach (var o in new[] { 1, 2, 3 })
@"foreach (var o in new[] { 1, 2, 3 })
...
@@ -719,7 +723,7 @@ private void CopyNoSelectionAndVerify(int start, int end, string expectedText, s
...
@@ -719,7 +723,7 @@ private void CopyNoSelectionAndVerify(int start, int end, string expectedText, s
var
snapshot
=
Window
.
TextView
.
TextBuffer
.
CurrentSnapshot
;
var
snapshot
=
Window
.
TextView
.
TextBuffer
.
CurrentSnapshot
;
for
(
int
i
=
start
;
i
<
end
;
i
++)
for
(
int
i
=
start
;
i
<
end
;
i
++)
{
{
Cl
ipboard
.
Clear
();
Cl
earClipboard
();
caret
.
MoveTo
(
new
SnapshotPoint
(
snapshot
,
i
));
caret
.
MoveTo
(
new
SnapshotPoint
(
snapshot
,
i
));
Window
.
Operations
.
Copy
();
Window
.
Operations
.
Copy
();
VerifyClipboardData
(
expectedText
,
expectedRtf
,
expectedRepl
);
VerifyClipboardData
(
expectedText
,
expectedRtf
,
expectedRepl
);
...
@@ -1115,8 +1119,8 @@ public void CutWithOutSelectionInReadOnlyArea()
...
@@ -1115,8 +1119,8 @@ public void CutWithOutSelectionInReadOnlyArea()
"
);
"
);
Window
.
InsertCode
(
"2"
);
Window
.
InsertCode
(
"2"
);
var
caret
=
Window
.
TextView
.
Caret
;
var
caret
=
Window
.
TextView
.
Caret
;
Cl
ipboard
.
Clear
();
Cl
earClipboard
();
// Cut() with caret in readonly area, no-op
// Cut() with caret in readonly area, no-op
caret
.
MoveToPreviousCaretPosition
();
caret
.
MoveToPreviousCaretPosition
();
...
@@ -1152,7 +1156,7 @@ public void CutWithSelectionInReadonlyArea()
...
@@ -1152,7 +1156,7 @@ public void CutWithSelectionInReadonlyArea()
var
caret
=
Window
.
TextView
.
Caret
;
var
caret
=
Window
.
TextView
.
Caret
;
var
selection
=
Window
.
TextView
.
Selection
;
var
selection
=
Window
.
TextView
.
Selection
;
Cl
ipboard
.
Clear
();
Cl
earClipboard
();
// Cut() with selection in readonly area, no-op
// Cut() with selection in readonly area, no-op
...
@@ -1211,7 +1215,7 @@ public void PasteWithOutSelectionInReadOnlyArea()
...
@@ -1211,7 +1215,7 @@ public void PasteWithOutSelectionInReadOnlyArea()
var
caret
=
Window
.
TextView
.
Caret
;
var
caret
=
Window
.
TextView
.
Caret
;
Cl
ipboard
.
Clear
();
Cl
earClipboard
();
Window
.
Operations
.
Home
(
true
);
Window
.
Operations
.
Home
(
true
);
Window
.
Operations
.
Copy
();
Window
.
Operations
.
Copy
();
VerifyClipboardData
(
"2"
,
@"\ansi{\fonttbl{\f0 Consolas;}}{\colortbl;\red0\green0\blue0;\red255\green255\blue255;}\f0 \fs24 \cf1 \cb2 \highlight2 2"
,
@"[{""content"":""2"",""kind"":2}]"
);
VerifyClipboardData
(
"2"
,
@"\ansi{\fonttbl{\f0 Consolas;}}{\colortbl;\red0\green0\blue0;\red255\green255\blue255;}\f0 \fs24 \cf1 \cb2 \highlight2 2"
,
@"[{""content"":""2"",""kind"":2}]"
);
...
@@ -1236,7 +1240,7 @@ public void PasteWithOutSelectionInReadOnlyArea()
...
@@ -1236,7 +1240,7 @@ public void PasteWithOutSelectionInReadOnlyArea()
AssertCaretVirtualPosition
(
2
,
3
);
AssertCaretVirtualPosition
(
2
,
3
);
}
}
[
Fact
(
Skip
=
"5544"
),
WorkItem
(
5544
,
"https://github.com/dotnet/roslyn/issues/5544"
)]
[
Fact
(
Skip
=
"5544"
),
WorkItem
(
5544
,
"https://github.com/dotnet/roslyn/issues/5544"
)]
public
void
PasteWithSelectionInReadonlyArea
()
public
void
PasteWithSelectionInReadonlyArea
()
{
{
Submit
(
Submit
(
...
@@ -1248,7 +1252,7 @@ public void PasteWithSelectionInReadonlyArea()
...
@@ -1248,7 +1252,7 @@ public void PasteWithSelectionInReadonlyArea()
var
caret
=
Window
.
TextView
.
Caret
;
var
caret
=
Window
.
TextView
.
Caret
;
var
selection
=
Window
.
TextView
.
Selection
;
var
selection
=
Window
.
TextView
.
Selection
;
Cl
ipboard
.
Clear
();
Cl
earClipboard
();
Window
.
Operations
.
Home
(
true
);
Window
.
Operations
.
Home
(
true
);
Window
.
Operations
.
Copy
();
Window
.
Operations
.
Copy
();
VerifyClipboardData
(
"23"
,
@"\ansi{\fonttbl{\f0 Consolas;}}{\colortbl;\red0\green0\blue0;\red255\green255\blue255;}\f0 \fs24 \cf1 \cb2 \highlight2 23"
,
@"[{""content"":""23"",""kind"":2}]"
);
VerifyClipboardData
(
"23"
,
@"\ansi{\fonttbl{\f0 Consolas;}}{\colortbl;\red0\green0\blue0;\red255\green255\blue255;}\f0 \fs24 \cf1 \cb2 \highlight2 23"
,
@"[{""content"":""23"",""kind"":2}]"
);
...
@@ -1295,6 +1299,11 @@ public void PasteWithSelectionInReadonlyArea()
...
@@ -1295,6 +1299,11 @@ public void PasteWithSelectionInReadonlyArea()
AssertCaretVirtualPosition
(
2
,
4
);
AssertCaretVirtualPosition
(
2
,
4
);
}
}
private
void
ClearClipboard
()
{
((
TestClipboard
)((
InteractiveWindow
)
Window
).
InteractiveWindowClipboard
).
Clear
();
}
private
void
Submit
(
string
submission
,
string
output
)
private
void
Submit
(
string
submission
,
string
output
)
{
{
Task
.
Run
(()
=>
Window
.
SubmitAsync
(
new
[]
{
submission
})).
PumpingWait
();
Task
.
Run
(()
=>
Window
.
SubmitAsync
(
new
[]
{
submission
})).
PumpingWait
();
...
@@ -1362,4 +1371,21 @@ internal static void Copy(this IInteractiveWindowOperations operations)
...
@@ -1362,4 +1371,21 @@ internal static void Copy(this IInteractiveWindowOperations operations)
((
IInteractiveWindowOperations2
)
operations
).
Copy
();
((
IInteractiveWindowOperations2
)
operations
).
Copy
();
}
}
}
}
internal
sealed
class
TestClipboard
:
InteractiveWindow
.
ClipboardWrapper
{
private
DataObject
_data
=
null
;
internal
void
Clear
()
=>
_data
=
null
;
internal
new
bool
ContainsData
(
string
format
)
=>
_data
?.
GetData
(
format
)
!=
null
;
internal
new
object
GetData
(
string
format
)
=>
_data
?.
GetData
(
format
);
internal
new
bool
ContainsText
()
=>
_data
!=
null
?
_data
.
ContainsText
()
:
false
;
internal
new
string
GetText
()
=>
_data
?.
GetText
();
internal
new
void
SetDataObject
(
object
data
,
bool
copy
)
=>
_data
=
data
as
DataObject
;
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录