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
d21ab518
Unverified
Commit
d21ab518
authored
Apr 20, 2020
by
kwkr
Committed by
GitHub
Apr 20, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix/set mocks defaults (#54756)
parent
6a490ed4
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
97 additions
and
14 deletions
+97
-14
run_test.dart
.../flutter_tools/test/commands.shard/hermetic/run_test.dart
+6
-1
shell_completion_test.dart
...s/test/commands.shard/hermetic/shell_completion_test.dart
+1
-1
packages_test.dart
...er_tools/test/commands.shard/permeable/packages_test.dart
+1
-1
channel_test.dart
packages/flutter_tools/test/general.shard/channel_test.dart
+6
-2
build_apk_test.dart
...ter_tools/test/general.shard/commands/build_apk_test.dart
+2
-2
build_appbundle_test.dart
...ols/test/general.shard/commands/build_appbundle_test.dart
+10
-7
common_test.dart
packages/flutter_tools/test/general.shard/common_test.dart
+62
-0
common.dart
packages/flutter_tools/test/src/common.dart
+9
-0
No files found.
packages/flutter_tools/test/commands.shard/hermetic/run_test.dart
View file @
d21ab518
...
...
@@ -42,6 +42,7 @@ void main() {
MockDeviceManager
mockDeviceManager
;
MockFlutterVersion
mockStableFlutterVersion
;
MockFlutterVersion
mockUnstableFlutterVersion
;
MockStdio
mockStdio
;
setUpAll
(()
{
Cache
.
disableLocking
();
...
...
@@ -51,6 +52,10 @@ void main() {
mockUnstableFlutterVersion
=
MockFlutterVersion
(
isStable:
false
);
});
setUp
((){
mockStdio
=
MockStdio
()..
stdout
.
terminalColumns
=
80
;
});
testUsingContext
(
'fails when target not found'
,
()
async
{
final
RunCommand
command
=
RunCommand
();
applyMocksToCommand
(
command
);
...
...
@@ -145,7 +150,7 @@ void main() {
FileSystem:
()
=>
MemoryFileSystem
.
test
(),
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
DeviceManager:
()
=>
MockDeviceManager
(),
Stdio:
()
=>
MockStdio
()
,
Stdio:
()
=>
mockStdio
,
});
testUsingContext
(
'Walks upward looking for a pubspec.yaml and exits if missing'
,
()
async
{
...
...
packages/flutter_tools/test/commands.shard/hermetic/shell_completion_test.dart
View file @
d21ab518
...
...
@@ -22,7 +22,7 @@ void main() {
setUp
(()
{
Cache
.
disableLocking
();
mockStdio
=
MockStdio
();
mockStdio
=
MockStdio
()
..
stdout
.
terminalColumns
=
80
;
});
testUsingContext
(
'generates bash initialization script to stdout'
,
()
async
{
...
...
packages/flutter_tools/test/commands.shard/permeable/packages_test.dart
View file @
d21ab518
...
...
@@ -337,7 +337,7 @@ void main() {
setUp
(()
{
mockProcessManager
=
MockProcessManager
();
mockStdio
=
MockStdio
();
mockStdio
=
MockStdio
()
..
stdout
.
terminalColumns
=
80
;
});
testUsingContext
(
'test without bot'
,
()
async
{
...
...
packages/flutter_tools/test/general.shard/channel_test.dart
View file @
d21ab518
...
...
@@ -290,8 +290,12 @@ void main() {
environment:
anyNamed
(
'environment'
),
)).
called
(
1
);
expect
(
testLogger
.
statusText
,
contains
(
"Successfully switched to flutter channel 'beta'."
));
expect
(
testLogger
.
statusText
,
contains
(
"To ensure that you're on the latest build from this channel, run 'flutter upgrade'"
));
expect
(
testLogger
.
statusText
,
containsIgnoringWhitespace
(
"Successfully switched to flutter channel 'beta'."
));
expect
(
testLogger
.
statusText
,
containsIgnoringWhitespace
(
"To ensure that you're on the latest build "
"from this channel, run 'flutter upgrade'"
));
expect
(
testLogger
.
errorText
,
hasLength
(
0
));
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
MemoryFileSystem
(),
...
...
packages/flutter_tools/test/general.shard/commands/build_apk_test.dart
View file @
d21ab518
...
...
@@ -433,8 +433,8 @@ void main() {
);
},
throwsToolExit
());
expect
(
testLogger
.
statusText
,
contains
(
"Your app isn't using AndroidX"
));
expect
(
testLogger
.
statusText
,
contains
(
expect
(
testLogger
.
statusText
,
contains
IgnoringWhitespace
(
"Your app isn't using AndroidX"
));
expect
(
testLogger
.
statusText
,
contains
IgnoringWhitespace
(
'To avoid potential build failures, you can quickly migrate your app by '
'following the steps on https://goo.gl/CP92wY'
)
...
...
packages/flutter_tools/test/general.shard/commands/build_appbundle_test.dart
View file @
d21ab518
...
...
@@ -361,8 +361,8 @@ void main() {
);
},
throwsToolExit
());
expect
(
testLogger
.
statusText
,
contains
(
"Your app isn't using AndroidX"
));
expect
(
testLogger
.
statusText
,
contains
(
expect
(
testLogger
.
statusText
,
contains
IgnoringWhitespace
(
"Your app isn't using AndroidX"
));
expect
(
testLogger
.
statusText
,
contains
IgnoringWhitespace
(
'To avoid potential build failures, you can quickly migrate your app by '
'following the steps on https://goo.gl/CP92wY'
)
...
...
@@ -412,13 +412,12 @@ void main() {
);
},
throwsToolExit
());
expect
(
testLogger
.
statusText
.
contains
(
"Your app isn't using AndroidX"
),
isFalse
);
expect
(
testLogger
.
statusText
,
not
(
containsIgnoringWhitespace
(
"Your app isn't using AndroidX"
)));
expect
(
testLogger
.
statusText
.
contains
(
testLogger
.
statusText
,
not
(
containsIgnoringWhitespace
(
'To avoid potential build failures, you can quickly migrate your app by '
'following the steps on https://goo.gl/CP92wY'
),
isFalse
,
'following the steps on https://goo.gl/CP92wY'
))
);
verify
(
mockUsage
.
sendEvent
(
'build'
,
...
...
@@ -451,6 +450,10 @@ Future<BuildAppBundleCommand> runBuildAppBundleCommand(
return
command
;
}
Matcher
not
(
Matcher
target
){
return
isNot
(
target
);
}
class
MockAndroidSdk
extends
Mock
implements
AndroidSdk
{}
class
MockProcessManager
extends
Mock
implements
ProcessManager
{}
class
MockProcess
extends
Mock
implements
Process
{}
...
...
packages/flutter_tools/test/general.shard/common_test.dart
0 → 100644
View file @
d21ab518
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'../src/common.dart'
;
void
main
(
)
{
group
(
'containsIgnoreWhitespace Matcher'
,
()
{
group
(
'on item to be contained'
,
()
{
test
(
'matches simple case.'
,
()
{
expect
(
'Give me any text!'
,
containsIgnoringWhitespace
(
'any text!'
));
});
test
(
"shouldn't match when it's only because of removing whitespaces"
,
()
{
expect
(
'Give me anytext!'
,
isNot
(
containsIgnoringWhitespace
(
'any text!'
)));
});
test
(
'ignores trailing spaces.'
,
()
{
expect
(
'Give me any text!'
,
containsIgnoringWhitespace
(
'any text! '
));
});
test
(
'ignores leading spaces.'
,
()
{
expect
(
'Give me any text!'
,
containsIgnoringWhitespace
(
' any text!'
));
});
test
(
'ignores linebreaks.'
,
()
{
expect
(
'Give me any text!'
,
containsIgnoringWhitespace
(
'any
\n
text!'
));
});
test
(
'ignores tabs.'
,
()
{
expect
(
'Give me any text!'
,
containsIgnoringWhitespace
(
'any
\t
text!'
));
});
test
(
'is case sensitive.'
,
()
{
expect
(
'Give me Any text!'
,
isNot
(
containsIgnoringWhitespace
(
'any text!'
)));
});
});
group
(
'on value to match against'
,
()
{
test
(
'ignores trailing spaces.'
,
()
{
expect
(
'Give me any value to include! '
,
containsIgnoringWhitespace
(
'any value to include!'
));
});
test
(
'ignores leading spaces.'
,
()
{
expect
(
' Give me any value to include!'
,
containsIgnoringWhitespace
(
'any value to include!'
));
});
test
(
'ignores linebreaks.'
,
()
{
expect
(
'Give me
\n
any
\n
value
\n
to
\n
include!'
,
containsIgnoringWhitespace
(
'any value to include!'
));
});
test
(
'ignores tabs.'
,
()
{
expect
(
'
\t
Give
\t
me any
\t
value
\t
to
\t
include!'
,
containsIgnoringWhitespace
(
'any value to include!'
));
});
});
});
}
packages/flutter_tools/test/src/common.dart
View file @
d21ab518
...
...
@@ -145,6 +145,15 @@ Future<void> expectToolExitLater(Future<dynamic> future, Matcher messageMatcher)
}
}
Matcher
containsIgnoringWhitespace
(
String
toSearch
)
{
return
predicate
(
(
String
source
)
{
return
collapseWhitespace
(
source
).
contains
(
collapseWhitespace
(
toSearch
));
},
'contains "
$toSearch
" ignoring whitespace.'
,
);
}
/// Executes a test body in zone that does not allow context-based injection.
///
/// For classes which have been refactored to excluded context-based injection
...
...
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