Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
d3c8a0bd
Unverified
Commit
d3c8a0bd
authored
Feb 18, 2021
by
Jenn Magder
Committed by
GitHub
Feb 18, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove mocks from visual_studio_test (#76260)
parent
805fffd1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
80 deletions
+63
-80
visual_studio_test.dart
..._tools/test/general.shard/windows/visual_studio_test.dart
+63
-55
mocks.dart
packages/flutter_tools/test/src/mocks.dart
+0
-25
No files found.
packages/flutter_tools/test/general.shard/windows/visual_studio_test.dart
View file @
d3c8a0bd
...
@@ -11,11 +11,9 @@ import 'package:flutter_tools/src/base/logger.dart';
...
@@ -11,11 +11,9 @@ import 'package:flutter_tools/src/base/logger.dart';
import
'package:flutter_tools/src/base/platform.dart'
;
import
'package:flutter_tools/src/base/platform.dart'
;
import
'package:flutter_tools/src/convert.dart'
;
import
'package:flutter_tools/src/convert.dart'
;
import
'package:flutter_tools/src/windows/visual_studio.dart'
;
import
'package:flutter_tools/src/windows/visual_studio.dart'
;
import
'package:mockito/mockito.dart'
;
import
'../../src/common.dart'
;
import
'../../src/common.dart'
;
import
'../../src/context.dart'
;
import
'../../src/context.dart'
;
import
'../../src/mocks.dart'
;
const
String
programFilesPath
=
r'C:\Program Files (x86)'
;
const
String
programFilesPath
=
r'C:\Program Files (x86)'
;
const
String
visualStudioPath
=
programFilesPath
+
r'\Microsoft Visual Studio\2017\Community'
;
const
String
visualStudioPath
=
programFilesPath
+
r'\Microsoft Visual Studio\2017\Community'
;
...
@@ -108,6 +106,8 @@ void setMockVswhereResponse(
...
@@ -108,6 +106,8 @@ void setMockVswhereResponse(
List
<
String
>
additionalArguments
,
List
<
String
>
additionalArguments
,
Map
<
String
,
dynamic
>
response
,
Map
<
String
,
dynamic
>
response
,
String
responseOverride
,
String
responseOverride
,
int
exitCode
,
Exception
exception
,
])
{
])
{
fileSystem
.
file
(
vswherePath
).
createSync
(
recursive:
true
);
fileSystem
.
file
(
vswherePath
).
createSync
(
recursive:
true
);
fileSystem
.
file
(
cmakePath
).
createSync
(
recursive:
true
);
fileSystem
.
file
(
cmakePath
).
createSync
(
recursive:
true
);
...
@@ -130,6 +130,8 @@ void setMockVswhereResponse(
...
@@ -130,6 +130,8 @@ void setMockVswhereResponse(
...?
requirementArguments
,
...?
requirementArguments
,
],
],
stdout:
finalResponse
,
stdout:
finalResponse
,
exception:
exception
,
exitCode:
exitCode
??
0
,
));
));
}
}
...
@@ -138,14 +140,19 @@ void setMockVswhereResponse(
...
@@ -138,14 +140,19 @@ void setMockVswhereResponse(
void
setMockCompatibleVisualStudioInstallation
(
void
setMockCompatibleVisualStudioInstallation
(
Map
<
String
,
dynamic
>
response
,
Map
<
String
,
dynamic
>
response
,
FileSystem
fileSystem
,
FileSystem
fileSystem
,
FakeProcessManager
processManager
,
FakeProcessManager
processManager
,
[
)
{
int
exitCode
,
Exception
exception
,
])
{
setMockVswhereResponse
(
setMockVswhereResponse
(
fileSystem
,
fileSystem
,
processManager
,
processManager
,
_requirements
,
_requirements
,
<
String
>[
'-version'
,
'16'
],
<
String
>[
'-version'
,
'16'
],
response
,
response
,
null
,
exitCode
,
exception
,
);
);
}
}
...
@@ -154,14 +161,19 @@ void setMockCompatibleVisualStudioInstallation(
...
@@ -154,14 +161,19 @@ void setMockCompatibleVisualStudioInstallation(
void
setMockPrereleaseVisualStudioInstallation
(
void
setMockPrereleaseVisualStudioInstallation
(
Map
<
String
,
dynamic
>
response
,
Map
<
String
,
dynamic
>
response
,
FileSystem
fileSystem
,
FileSystem
fileSystem
,
FakeProcessManager
processManager
,
FakeProcessManager
processManager
,
[
)
{
int
exitCode
,
Exception
exception
,
])
{
setMockVswhereResponse
(
setMockVswhereResponse
(
fileSystem
,
fileSystem
,
processManager
,
processManager
,
_requirements
,
_requirements
,
<
String
>[
'-version'
,
'16'
,
'-prerelease'
],
<
String
>[
'-version'
,
'16'
,
'-prerelease'
],
response
,
response
,
null
,
exitCode
,
exception
,
);
);
}
}
...
@@ -170,14 +182,19 @@ void setMockPrereleaseVisualStudioInstallation(
...
@@ -170,14 +182,19 @@ void setMockPrereleaseVisualStudioInstallation(
void
setMockCompatibleVisualStudioBuildToolsInstallation
(
void
setMockCompatibleVisualStudioBuildToolsInstallation
(
Map
<
String
,
dynamic
>
response
,
Map
<
String
,
dynamic
>
response
,
FileSystem
fileSystem
,
FileSystem
fileSystem
,
FakeProcessManager
processManager
,
FakeProcessManager
processManager
,
[
)
{
int
exitCode
,
Exception
exception
,
])
{
setMockVswhereResponse
(
setMockVswhereResponse
(
fileSystem
,
fileSystem
,
processManager
,
processManager
,
_requirementsBuildTools
,
_requirementsBuildTools
,
<
String
>[
'-version'
,
'16'
],
<
String
>[
'-version'
,
'16'
],
response
,
response
,
null
,
exitCode
,
exception
,
);
);
}
}
...
@@ -186,14 +203,19 @@ void setMockCompatibleVisualStudioBuildToolsInstallation(
...
@@ -186,14 +203,19 @@ void setMockCompatibleVisualStudioBuildToolsInstallation(
void
setMockPrereleaseVisualStudioBuildToolsInstallation
(
void
setMockPrereleaseVisualStudioBuildToolsInstallation
(
Map
<
String
,
dynamic
>
response
,
Map
<
String
,
dynamic
>
response
,
FileSystem
fileSystem
,
FileSystem
fileSystem
,
FakeProcessManager
processManager
,
FakeProcessManager
processManager
,
[
)
{
int
exitCode
,
Exception
exception
,
])
{
setMockVswhereResponse
(
setMockVswhereResponse
(
fileSystem
,
fileSystem
,
processManager
,
processManager
,
_requirementsBuildTools
,
_requirementsBuildTools
,
<
String
>[
'-version'
,
'16'
,
'-prerelease'
],
<
String
>[
'-version'
,
'16'
,
'-prerelease'
],
response
,
response
,
null
,
exitCode
,
exception
,
);
);
}
}
...
@@ -202,14 +224,19 @@ void setMockPrereleaseVisualStudioBuildToolsInstallation(
...
@@ -202,14 +224,19 @@ void setMockPrereleaseVisualStudioBuildToolsInstallation(
void
setMockAnyVisualStudioInstallation
(
void
setMockAnyVisualStudioInstallation
(
Map
<
String
,
dynamic
>
response
,
Map
<
String
,
dynamic
>
response
,
FileSystem
fileSystem
,
FileSystem
fileSystem
,
FakeProcessManager
processManager
,
FakeProcessManager
processManager
,
[
)
{
int
exitCode
,
Exception
exception
,
])
{
setMockVswhereResponse
(
setMockVswhereResponse
(
fileSystem
,
fileSystem
,
processManager
,
processManager
,
null
,
null
,
<
String
>[
'-prerelease'
,
'-all'
],
<
String
>[
'-prerelease'
,
'-all'
],
response
,
response
,
null
,
exitCode
,
exception
,
);
);
}
}
...
@@ -315,65 +342,48 @@ void setNoViableToolchainInstallation(
...
@@ -315,65 +342,48 @@ void setNoViableToolchainInstallation(
void
main
(
)
{
void
main
(
)
{
group
(
'Visual Studio'
,
()
{
group
(
'Visual Studio'
,
()
{
testWithoutContext
(
'isInstalled returns false when vswhere is missing'
,
()
{
testWithoutContext
(
'isInstalled and cmakePath correct when vswhere is missing'
,
()
{
final
MockProcessManager
mockProcessManager
=
MockProcessManager
();
final
FileSystem
fileSystem
=
MemoryFileSystem
.
test
(
style:
FileSystemStyle
.
windows
);
when
(
mockProcessManager
.
runSync
(
const
Exception
exception
=
ProcessException
(
'vswhere'
,
<
String
>[]);
any
,
final
FakeProcessManager
fakeProcessManager
=
FakeProcessManager
.
list
(<
FakeCommand
>[]);
workingDirectory:
anyNamed
(
'workingDirectory'
),
environment:
anyNamed
(
'environment'
),
stdoutEncoding:
utf8
,
stderrEncoding:
utf8
,
)).
thenThrow
(
const
ProcessException
(
'vswhere'
,
<
String
>[]));
final
VisualStudio
visualStudio
=
VisualStudio
(
logger:
BufferLogger
.
test
(),
fileSystem:
MemoryFileSystem
.
test
(
style:
FileSystemStyle
.
windows
),
platform:
windowsPlatform
,
processManager:
mockProcessManager
,
);
expect
(
visualStudio
.
isInstalled
,
false
);
setMockCompatibleVisualStudioInstallation
(
null
,
fileSystem
,
fakeProcessManager
,
null
,
exception
);
});
setMockCompatibleVisualStudioBuildToolsInstallation
(
null
,
fileSystem
,
fakeProcessManager
,
null
,
exception
);
setMockPrereleaseVisualStudioInstallation
(
null
,
fileSystem
,
fakeProcessManager
,
null
,
exception
);
setMockPrereleaseVisualStudioBuildToolsInstallation
(
null
,
fileSystem
,
fakeProcessManager
,
null
,
exception
);
setMockAnyVisualStudioInstallation
(
null
,
fileSystem
,
fakeProcessManager
,
null
,
exception
);
testWithoutContext
(
'cmakePath returns null when vswhere is missing'
,
()
{
final
MockProcessManager
mockProcessManager
=
MockProcessManager
();
when
(
mockProcessManager
.
runSync
(
any
,
workingDirectory:
anyNamed
(
'workingDirectory'
),
environment:
anyNamed
(
'environment'
),
stdoutEncoding:
utf8
,
stderrEncoding:
utf8
,
)).
thenThrow
(
const
ProcessException
(
'vswhere'
,
<
String
>[]));
final
VisualStudio
visualStudio
=
VisualStudio
(
final
VisualStudio
visualStudio
=
VisualStudio
(
logger:
BufferLogger
.
test
(),
logger:
BufferLogger
.
test
(),
fileSystem:
MemoryFileSystem
.
test
(
style:
FileSystemStyle
.
windows
)
,
fileSystem:
fileSystem
,
platform:
windowsPlatform
,
platform:
windowsPlatform
,
processManager:
mock
ProcessManager
,
processManager:
fake
ProcessManager
,
);
);
expect
(
visualStudio
.
isInstalled
,
false
);
expect
(
visualStudio
.
cmakePath
,
isNull
);
expect
(
visualStudio
.
cmakePath
,
isNull
);
});
});
testWithoutContext
(
testWithoutContext
(
'isInstalled returns false when vswhere returns non-zero'
,
()
{
'isInstalled returns false when vswhere returns non-zero'
,
()
{
final
MockProcessManager
mockProcessManager
=
MockProcessManager
();
final
FileSystem
fileSystem
=
MemoryFileSystem
.
test
(
style:
FileSystemStyle
.
windows
);
when
(
mockProcessManager
.
runSync
(
final
FakeProcessManager
fakeProcessManager
=
FakeProcessManager
.
list
(<
FakeCommand
>[]);
any
,
workingDirectory:
anyNamed
(
'workingDirectory'
),
setMockCompatibleVisualStudioInstallation
(
null
,
fileSystem
,
fakeProcessManager
,
1
);
environment:
anyNamed
(
'environment'
),
setMockCompatibleVisualStudioBuildToolsInstallation
(
null
,
fileSystem
,
fakeProcessManager
,
1
);
stdoutEncoding:
utf8
,
setMockPrereleaseVisualStudioInstallation
(
null
,
fileSystem
,
fakeProcessManager
,
1
);
stderrEncoding:
utf8
,
setMockPrereleaseVisualStudioBuildToolsInstallation
(
null
,
fileSystem
,
fakeProcessManager
,
1
);
)).
thenAnswer
((
Invocation
invocation
)
{
setMockAnyVisualStudioInstallation
(
null
,
fileSystem
,
fakeProcessManager
,
1
);
return
FakeProcessResult
(
exitCode:
1
,
stderr:
''
,
stdout:
''
);
});
final
VisualStudio
visualStudio
=
VisualStudio
(
final
VisualStudio
visualStudio
=
VisualStudio
(
logger:
BufferLogger
.
test
(),
logger:
BufferLogger
.
test
(),
fileSystem:
MemoryFileSystem
.
test
(
style:
FileSystemStyle
.
windows
)
,
fileSystem:
fileSystem
,
platform:
windowsPlatform
,
platform:
windowsPlatform
,
processManager:
mock
ProcessManager
,
processManager:
fake
ProcessManager
,
);
);
expect
(
visualStudio
.
isInstalled
,
false
);
expect
(
visualStudio
.
isInstalled
,
false
);
expect
(
visualStudio
.
isInstalled
,
false
);
expect
(
visualStudio
.
cmakePath
,
isNull
);
});
});
testWithoutContext
(
'VisualStudio getters return the right values if no installation is found'
,
()
{
testWithoutContext
(
'VisualStudio getters return the right values if no installation is found'
,
()
{
...
@@ -820,5 +830,3 @@ class VisualStudioFixture {
...
@@ -820,5 +830,3 @@ class VisualStudioFixture {
final
FileSystem
fileSystem
;
final
FileSystem
fileSystem
;
final
FakeProcessManager
processManager
;
final
FakeProcessManager
processManager
;
}
}
class
MockProcessManager
extends
Mock
implements
ProcessManager
{}
packages/flutter_tools/test/src/mocks.dart
View file @
d3c8a0bd
...
@@ -323,31 +323,6 @@ class MockResidentCompiler extends _BasicMock implements ResidentCompiler {
...
@@ -323,31 +323,6 @@ class MockResidentCompiler extends _BasicMock implements ResidentCompiler {
void
addFileSystemRoot
(
String
root
)
{
}
void
addFileSystemRoot
(
String
root
)
{
}
}
}
/// A fake implementation of [ProcessResult].
class
FakeProcessResult
implements
ProcessResult
{
FakeProcessResult
({
this
.
exitCode
=
0
,
this
.
pid
=
1
,
this
.
stderr
,
this
.
stdout
,
});
@override
final
int
exitCode
;
@override
final
int
pid
;
@override
final
dynamic
stderr
;
@override
final
dynamic
stdout
;
@override
String
toString
()
=>
stdout
?.
toString
()
??
stderr
?.
toString
()
??
runtimeType
.
toString
();
}
class
MockStdIn
extends
Mock
implements
IOSink
{
class
MockStdIn
extends
Mock
implements
IOSink
{
final
StringBuffer
stdInWrites
=
StringBuffer
();
final
StringBuffer
stdInWrites
=
StringBuffer
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment