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
cf54d6a2
Unverified
Commit
cf54d6a2
authored
Jan 28, 2021
by
Jonah Williams
Committed by
GitHub
Jan 28, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] remove mocks from file system test (#74919)
parent
a664731a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
35 deletions
+39
-35
file_system_test.dart
...utter_tools/test/general.shard/base/file_system_test.dart
+12
-10
io_test.dart
packages/flutter_tools/test/general.shard/base/io_test.dart
+10
-7
signals_test.dart
...s/flutter_tools/test/general.shard/base/signals_test.dart
+17
-18
No files found.
packages/flutter_tools/test/general.shard/base/file_system_test.dart
View file @
cf54d6a2
...
...
@@ -12,7 +12,7 @@ import 'package:flutter_tools/src/base/file_system.dart';
import
'package:flutter_tools/src/base/io.dart'
;
import
'package:flutter_tools/src/base/platform.dart'
;
import
'package:flutter_tools/src/base/signals.dart'
;
import
'package:
mockito/mockito
.dart'
;
import
'package:
test/fake
.dart'
;
import
'../../src/common.dart'
;
import
'../../src/context.dart'
;
...
...
@@ -147,15 +147,12 @@ void main() {
});
group
(
'LocalFileSystem'
,
()
{
MockIoProcessSignal
mock
Signal
;
FakeProcessSignal
fake
Signal
;
ProcessSignal
signalUnderTest
;
StreamController
<
io
.
ProcessSignal
>
controller
;
setUp
(()
{
mockSignal
=
MockIoProcessSignal
();
signalUnderTest
=
ProcessSignal
(
mockSignal
);
controller
=
StreamController
<
io
.
ProcessSignal
>();
when
(
mockSignal
.
watch
()).
thenAnswer
((
Invocation
invocation
)
=>
controller
.
stream
);
fakeSignal
=
FakeProcessSignal
();
signalUnderTest
=
ProcessSignal
(
fakeSignal
);
});
testUsingContext
(
'deletes system temp entry on a fatal signal'
,
()
async
{
...
...
@@ -173,7 +170,7 @@ void main() {
expect
(
temp
.
existsSync
(),
isTrue
);
controller
.
add
(
mock
Signal
);
fakeSignal
.
controller
.
add
(
fake
Signal
);
await
completer
.
future
;
expect
(
temp
.
existsSync
(),
isFalse
);
...
...
@@ -181,5 +178,10 @@ void main() {
});
}
class
MockIoProcessSignal
extends
Mock
implements
io
.
ProcessSignal
{}
class
MockFile
extends
Mock
implements
File
{}
class
FakeProcessSignal
extends
Fake
implements
io
.
ProcessSignal
{
final
StreamController
<
io
.
ProcessSignal
>
controller
=
StreamController
<
io
.
ProcessSignal
>();
@override
Stream
<
io
.
ProcessSignal
>
watch
()
=>
controller
.
stream
;
}
class
FakeFile
extends
Fake
implements
File
{}
packages/flutter_tools/test/general.shard/base/io_test.dart
View file @
cf54d6a2
...
...
@@ -9,7 +9,7 @@ import 'dart:io' as io;
import
'package:file/memory.dart'
;
import
'package:flutter_tools/src/base/io.dart'
;
import
'package:
mockito/mockito
.dart'
;
import
'package:
test/fake
.dart'
;
import
'../../src/common.dart'
;
import
'../../src/context.dart'
;
...
...
@@ -57,12 +57,10 @@ void main() {
},
flutterIOOverrides
);
});
testUsingContext
(
'ProcessSignal signals are properly delegated'
,
()
async
{
final
MockIoProcessSignal
mockSignal
=
MockIoProcessSignal
();
final
ProcessSignal
signalUnderTest
=
ProcessSignal
(
mockSignal
);
final
StreamController
<
io
.
ProcessSignal
>
controller
=
StreamController
<
io
.
ProcessSignal
>();
final
FakeProcessSignal
signal
=
FakeProcessSignal
();
final
ProcessSignal
signalUnderTest
=
ProcessSignal
(
signal
);
when
(
mockSignal
.
watch
()).
thenAnswer
((
Invocation
invocation
)
=>
controller
.
stream
);
controller
.
add
(
mockSignal
);
signal
.
controller
.
add
(
signal
);
expect
(
signalUnderTest
,
await
signalUnderTest
.
watch
().
first
);
});
...
...
@@ -104,4 +102,9 @@ void main() {
});
}
class
MockIoProcessSignal
extends
Mock
implements
io
.
ProcessSignal
{}
class
FakeProcessSignal
extends
Fake
implements
io
.
ProcessSignal
{
final
StreamController
<
io
.
ProcessSignal
>
controller
=
StreamController
<
io
.
ProcessSignal
>();
@override
Stream
<
io
.
ProcessSignal
>
watch
()
=>
controller
.
stream
;
}
packages/flutter_tools/test/general.shard/base/signals_test.dart
View file @
cf54d6a2
...
...
@@ -16,16 +16,13 @@ import '../../src/common.dart';
void
main
(
)
{
group
(
'Signals'
,
()
{
Signals
signals
;
MockIoProcessSignal
mock
Signal
;
FakeProcessSignal
fake
Signal
;
ProcessSignal
signalUnderTest
;
StreamController
<
io
.
ProcessSignal
>
controller
;
setUp
(()
{
signals
=
Signals
.
test
();
mockSignal
=
MockIoProcessSignal
();
signalUnderTest
=
ProcessSignal
(
mockSignal
);
controller
=
StreamController
<
io
.
ProcessSignal
>();
when
(
mockSignal
.
watch
()).
thenAnswer
((
Invocation
invocation
)
=>
controller
.
stream
);
fakeSignal
=
FakeProcessSignal
();
signalUnderTest
=
ProcessSignal
(
fakeSignal
);
});
testWithoutContext
(
'signal handler runs'
,
()
async
{
...
...
@@ -35,7 +32,7 @@ void main() {
completer
.
complete
();
});
controller
.
add
(
mock
Signal
);
fakeSignal
.
controller
.
add
(
fake
Signal
);
await
completer
.
future
;
});
...
...
@@ -55,7 +52,7 @@ void main() {
completer
.
complete
();
});
controller
.
add
(
mock
Signal
);
fakeSignal
.
controller
.
add
(
fake
Signal
);
await
completer
.
future
;
});
...
...
@@ -74,7 +71,7 @@ void main() {
},
);
controller
.
add
(
mock
Signal
);
fakeSignal
.
controller
.
add
(
fake
Signal
);
await
completer
.
future
;
await
errSub
.
cancel
();
expect
(
errList
,
contains
(
exn
));
...
...
@@ -97,7 +94,7 @@ void main() {
},
);
controller
.
add
(
mock
Signal
);
fakeSignal
.
controller
.
add
(
fake
Signal
);
await
errSub
.
cancel
();
expect
(
errList
,
isEmpty
);
...
...
@@ -125,19 +122,16 @@ void main() {
},
);
controller
.
add
(
mock
Signal
);
fakeSignal
.
controller
.
add
(
fake
Signal
);
await
completer
.
future
;
await
errSub
.
cancel
();
expect
(
errList
,
isEmpty
);
});
testWithoutContext
(
'only handlers for the correct signal run'
,
()
async
{
final
MockIoProcessSignal
mockSignal2
=
MockIoProcessSignal
();
final
StreamController
<
io
.
ProcessSignal
>
controller2
=
StreamController
<
io
.
ProcessSignal
>();
final
FakeProcessSignal
mockSignal2
=
FakeProcessSignal
();
final
ProcessSignal
otherSignal
=
ProcessSignal
(
mockSignal2
);
when
(
mockSignal2
.
watch
()).
thenAnswer
((
Invocation
invocation
)
=>
controller2
.
stream
);
final
Completer
<
void
>
completer
=
Completer
<
void
>();
signals
.
addHandler
(
signalUnderTest
,
(
ProcessSignal
s
)
{
expect
(
s
,
signalUnderTest
);
...
...
@@ -155,7 +149,7 @@ void main() {
},
);
controller
.
add
(
mock
Signal
);
fakeSignal
.
controller
.
add
(
fake
Signal
);
await
completer
.
future
;
await
errSub
.
cancel
();
expect
(
errList
,
isEmpty
);
...
...
@@ -192,10 +186,15 @@ void main() {
second
=
true
;
});
controller
.
add
(
mock
Signal
);
fakeSignal
.
controller
.
add
(
fake
Signal
);
await
completer
.
future
;
});
});
}
class
MockIoProcessSignal
extends
Mock
implements
io
.
ProcessSignal
{}
class
FakeProcessSignal
extends
Fake
implements
io
.
ProcessSignal
{
final
StreamController
<
io
.
ProcessSignal
>
controller
=
StreamController
<
io
.
ProcessSignal
>();
@override
Stream
<
io
.
ProcessSignal
>
watch
()
=>
controller
.
stream
;
}
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