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
e1538d1b
Unverified
Commit
e1538d1b
authored
Jun 26, 2020
by
Jonah Williams
Committed by
GitHub
Jun 26, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] last pass on general.shard unit tests (#60263)
Last batch of test fixes for general shard.
parent
7518a146
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
453 additions
and
175 deletions
+453
-175
package_map.dart
packages/flutter_tools/lib/src/dart/package_map.dart
+9
-3
globals.dart
packages/flutter_tools/lib/src/globals.dart
+1
-3
run_hot.dart
packages/flutter_tools/lib/src/run_hot.dart
+1
-2
logs_test.dart
...ages/flutter_tools/test/general.shard/base/logs_test.dart
+9
-0
macos_test.dart
...s/test/general.shard/build_system/targets/macos_test.dart
+20
-26
xcode_test.dart
...es/flutter_tools/test/general.shard/macos/xcode_test.dart
+3
-0
resident_web_runner_test.dart
...er_tools/test/general.shard/resident_web_runner_test.dart
+401
-135
flutter_command_test.dart
...tools/test/general.shard/runner/flutter_command_test.dart
+5
-0
golden_comparator_test.dart
..._tools/test/general.shard/web/golden_comparator_test.dart
+0
-1
plist_parser_test.dart
...utter_tools/test/integration.shard/plist_parser_test.dart
+2
-2
context.dart
packages/flutter_tools/test/src/context.dart
+2
-3
No files found.
packages/flutter_tools/lib/src/dart/package_map.dart
View file @
e1538d1b
...
...
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:async'
;
import
'dart:typed_data'
;
import
'package:meta/meta.dart'
;
...
...
@@ -32,9 +33,10 @@ String _globalPackagesPath;
Future
<
PackageConfig
>
loadPackageConfigWithLogging
(
File
file
,
{
@required
Logger
logger
,
bool
throwOnError
=
true
,
})
{
})
async
{
final
FileSystem
fileSystem
=
file
.
fileSystem
;
return
loadPackageConfigUri
(
bool
didError
=
false
;
final
PackageConfig
result
=
await
loadPackageConfigUri
(
file
.
absolute
.
uri
,
loader:
(
Uri
uri
)
{
final
File
configFile
=
fileSystem
.
file
(
uri
);
...
...
@@ -56,7 +58,11 @@ Future<PackageConfig> loadPackageConfigWithLogging(File file, {
message
+=
'
\n
Did you run this command from the same directory as your pubspec.yaml file?'
;
}
logger
.
printError
(
message
);
throwToolExit
(
file
.
path
)
;
didError
=
true
;
}
);
if
(
didError
)
{
throwToolExit
(
null
);
}
return
result
;
}
packages/flutter_tools/lib/src/globals.dart
View file @
e1538d1b
...
...
@@ -66,13 +66,11 @@ FileSystem get fs => ErrorHandlingFileSystem(
platform:
platform
,
);
final
FileSystemUtils
_defaultFileSystemUtils
=
FileSystemUtils
(
FileSystemUtils
get
fsUtils
=>
context
.
get
<
FileSystemUtils
>()
??
FileSystemUtils
(
fileSystem:
fs
,
platform:
platform
,
);
FileSystemUtils
get
fsUtils
=>
context
.
get
<
FileSystemUtils
>()
??
_defaultFileSystemUtils
;
const
ProcessManager
_kLocalProcessManager
=
LocalProcessManager
();
/// The active process manager.
...
...
packages/flutter_tools/lib/src/run_hot.dart
View file @
e1538d1b
...
...
@@ -26,8 +26,7 @@ import 'reporting/reporting.dart';
import
'resident_runner.dart'
;
import
'vmservice.dart'
;
ProjectFileInvalidator
get
projectFileInvalidator
=>
context
.
get
<
ProjectFileInvalidator
>()
??
_defaultInvalidator
;
final
ProjectFileInvalidator
_defaultInvalidator
=
ProjectFileInvalidator
(
ProjectFileInvalidator
get
projectFileInvalidator
=>
context
.
get
<
ProjectFileInvalidator
>()
??
ProjectFileInvalidator
(
fileSystem:
globals
.
fs
,
platform:
globals
.
platform
,
logger:
globals
.
logger
,
...
...
packages/flutter_tools/test/general.shard/base/logs_test.dart
View file @
e1538d1b
...
...
@@ -3,6 +3,7 @@
// found in the LICENSE file.
import
'package:flutter_tools/src/base/common.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/commands/logs.dart'
;
import
'../../src/common.dart'
;
...
...
@@ -11,6 +12,14 @@ import '../../src/mocks.dart';
void
main
(
)
{
group
(
'logs'
,
()
{
setUp
(()
{
Cache
.
disableLocking
();
});
tearDown
(()
{
Cache
.
enableLocking
();
});
testUsingContext
(
'fail with a bad device id'
,
()
async
{
final
LogsCommand
command
=
LogsCommand
();
applyMocksToCommand
(
command
);
...
...
packages/flutter_tools/test/general.shard/build_system/targets/macos_test.dart
View file @
e1538d1b
...
...
@@ -12,7 +12,6 @@ import 'package:flutter_tools/src/build_system/build_system.dart';
import
'package:flutter_tools/src/build_system/targets/assets.dart'
;
import
'package:flutter_tools/src/build_system/targets/common.dart'
;
import
'package:flutter_tools/src/build_system/targets/macos.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/convert.dart'
;
import
'package:flutter_tools/src/globals.dart'
as
globals
;
import
'package:flutter_tools/src/macos/xcode.dart'
;
...
...
@@ -26,26 +25,26 @@ import '../../../src/testbed.dart';
const
String
_kInputPrefix
=
'bin/cache/artifacts/engine/darwin-x64/FlutterMacOS.framework'
;
const
String
_kOutputPrefix
=
'FlutterMacOS.framework'
;
final
List
<
File
>
inputs
=
<
File
>[
globals
.
fs
.
file
(
'
$_kInputPrefix
/FlutterMacOS'
)
,
final
List
<
String
>
inputs
=
<
String
>[
'
$_kInputPrefix
/FlutterMacOS'
,
// Headers
globals
.
fs
.
file
(
'
$_kInputPrefix
/Headers/FlutterDartProject.h'
)
,
globals
.
fs
.
file
(
'
$_kInputPrefix
/Headers/FlutterEngine.h'
)
,
globals
.
fs
.
file
(
'
$_kInputPrefix
/Headers/FlutterViewController.h'
)
,
globals
.
fs
.
file
(
'
$_kInputPrefix
/Headers/FlutterBinaryMessenger.h'
)
,
globals
.
fs
.
file
(
'
$_kInputPrefix
/Headers/FlutterChannels.h'
)
,
globals
.
fs
.
file
(
'
$_kInputPrefix
/Headers/FlutterCodecs.h'
)
,
globals
.
fs
.
file
(
'
$_kInputPrefix
/Headers/FlutterMacros.h'
)
,
globals
.
fs
.
file
(
'
$_kInputPrefix
/Headers/FlutterPluginMacOS.h'
)
,
globals
.
fs
.
file
(
'
$_kInputPrefix
/Headers/FlutterPluginRegistrarMacOS.h'
)
,
globals
.
fs
.
file
(
'
$_kInputPrefix
/Headers/FlutterMacOS.h'
)
,
'
$_kInputPrefix
/Headers/FlutterDartProject.h'
,
'
$_kInputPrefix
/Headers/FlutterEngine.h'
,
'
$_kInputPrefix
/Headers/FlutterViewController.h'
,
'
$_kInputPrefix
/Headers/FlutterBinaryMessenger.h'
,
'
$_kInputPrefix
/Headers/FlutterChannels.h'
,
'
$_kInputPrefix
/Headers/FlutterCodecs.h'
,
'
$_kInputPrefix
/Headers/FlutterMacros.h'
,
'
$_kInputPrefix
/Headers/FlutterPluginMacOS.h'
,
'
$_kInputPrefix
/Headers/FlutterPluginRegistrarMacOS.h'
,
'
$_kInputPrefix
/Headers/FlutterMacOS.h'
,
// Modules
globals
.
fs
.
file
(
'
$_kInputPrefix
/Modules/module.modulemap'
)
,
'
$_kInputPrefix
/Modules/module.modulemap'
,
// Resources
globals
.
fs
.
file
(
'
$_kInputPrefix
/Resources/icudtl.dat'
)
,
globals
.
fs
.
file
(
'
$_kInputPrefix
/Resources/Info.plist'
)
,
'
$_kInputPrefix
/Resources/icudtl.dat'
,
'
$_kInputPrefix
/Resources/Info.plist'
,
// Ignore Versions folder for now
globals
.
fs
.
file
(
'packages/flutter_tools/lib/src/build_system/targets/macos.dart'
)
,
'packages/flutter_tools/lib/src/build_system/targets/macos.dart'
,
];
void
main
(
)
{
...
...
@@ -53,11 +52,6 @@ void main() {
Environment
environment
;
Platform
platform
;
setUpAll
(()
{
Cache
.
disableLocking
();
Cache
.
flutterRoot
=
''
;
});
setUp
(()
{
platform
=
FakePlatform
(
operatingSystem:
'macos'
,
environment:
<
String
,
String
>{});
testbed
=
Testbed
(
setup:
()
{
...
...
@@ -82,8 +76,8 @@ void main() {
});
test
(
'Copies files to correct cache directory'
,
()
=>
testbed
.
run
(()
async
{
for
(
final
File
input
in
inputs
)
{
input
.
createSync
(
recursive:
true
);
for
(
final
String
input
in
inputs
)
{
globals
.
fs
.
file
(
input
)
.
createSync
(
recursive:
true
);
}
// Create output directory so we can test that it is deleted.
environment
.
outputDir
.
childDirectory
(
_kOutputPrefix
)
...
...
@@ -111,8 +105,8 @@ void main() {
await
const
DebugUnpackMacOS
().
build
(
environment
);
expect
(
globals
.
fs
.
directory
(
_kOutputPrefix
).
existsSync
(),
true
);
for
(
final
File
file
in
inputs
)
{
expect
(
globals
.
fs
.
file
(
file
.
path
.
replaceFirst
(
_kInputPrefix
,
_kOutputPrefix
)),
exists
);
for
(
final
String
path
in
inputs
)
{
expect
(
globals
.
fs
.
file
(
path
.
replaceFirst
(
_kInputPrefix
,
_kOutputPrefix
)),
exists
);
}
}));
...
...
packages/flutter_tools/test/general.shard/macos/xcode_test.dart
View file @
e1538d1b
...
...
@@ -538,6 +538,7 @@ void main() {
expect
(
fakeProcessManager
.
hasRemainingExpectations
,
isFalse
);
},
overrides:
<
Type
,
Generator
>{
Platform:
()
=>
macPlatform
,
Artifacts:
()
=>
Artifacts
.
test
(),
});
testWithoutContext
(
'uses timeout'
,
()
async
{
...
...
@@ -596,6 +597,7 @@ void main() {
expect
(
fakeProcessManager
.
hasRemainingExpectations
,
isFalse
);
},
overrides:
<
Type
,
Generator
>{
Platform:
()
=>
macPlatform
,
Artifacts:
()
=>
Artifacts
.
test
(),
});
testUsingContext
(
'handles unknown architectures'
,
()
async
{
...
...
@@ -644,6 +646,7 @@ void main() {
expect
(
fakeProcessManager
.
hasRemainingExpectations
,
isFalse
);
},
overrides:
<
Type
,
Generator
>{
Platform:
()
=>
macPlatform
,
Artifacts:
()
=>
Artifacts
.
test
(),
});
});
...
...
packages/flutter_tools/test/general.shard/resident_web_runner_test.dart
View file @
e1538d1b
...
...
@@ -7,7 +7,9 @@ import 'dart:convert';
import
'dart:io'
;
import
'package:dwds/dwds.dart'
;
import
'package:file/memory.dart'
;
import
'package:flutter_tools/src/base/common.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/io.dart'
;
import
'package:flutter_tools/src/base/logger.dart'
;
import
'package:flutter_tools/src/base/platform.dart'
;
...
...
@@ -78,8 +80,6 @@ const List<VmServiceExpectation> kAttachExpectations = <VmServiceExpectation>[
];
void
main
(
)
{
Testbed
testbed
;
ResidentWebRunner
residentWebRunner
;
MockDebugConnection
mockDebugConnection
;
MockChromeDevice
mockChromeDevice
;
MockAppConnection
mockAppConnection
;
...
...
@@ -94,8 +94,12 @@ void main() {
MockWebServerDevice
mockWebServerDevice
;
MockDevice
mockDevice
;
FakeVmServiceHost
fakeVmServiceHost
;
FileSystem
fileSystem
;
ProcessManager
processManager
;
setUp
(()
{
fileSystem
=
MemoryFileSystem
.
test
();
processManager
=
FakeProcessManager
.
any
();
mockDebugConnection
=
MockDebugConnection
();
mockDevice
=
MockDevice
();
mockAppConnection
=
MockAppConnection
();
...
...
@@ -113,30 +117,13 @@ void main() {
when
(
mockWebDevFS
.
connect
(
any
)).
thenAnswer
((
Invocation
invocation
)
async
{
return
ConnectionResult
(
mockAppConnection
,
mockDebugConnection
);
});
testbed
=
Testbed
(
setup:
()
{
globals
.
fs
.
file
(
'.packages'
)
..
createSync
(
recursive:
true
)
..
writeAsStringSync
(
'
\n
'
);
residentWebRunner
=
DwdsWebRunnerFactory
().
createWebRunner
(
mockFlutterDevice
,
flutterProject:
FlutterProject
.
current
(),
debuggingOptions:
DebuggingOptions
.
enabled
(
BuildInfo
.
debug
),
ipv6:
true
,
stayResident:
true
,
urlTunneller:
null
,
)
as
ResidentWebRunner
;
},
overrides:
<
Type
,
Generator
>{
Pub:
()
=>
MockPub
(),
}
);
fileSystem
.
file
(
'.packages'
).
writeAsStringSync
(
'
\n
'
);
});
void
_setupMocks
()
{
globals
.
fs
.
file
(
'pubspec.yaml'
).
createSync
();
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'lib'
,
'main.dart'
)
).
createSync
(
recursive:
true
);
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'web'
,
'index.html'
)
).
createSync
(
recursive:
true
);
fileSystem
.
file
(
'pubspec.yaml'
).
createSync
();
fileSystem
.
file
(
'lib/main.dart'
).
createSync
(
recursive:
true
);
fileSystem
.
file
(
'web/index.html'
).
createSync
(
recursive:
true
);
when
(
mockWebDevFS
.
update
(
mainUri:
anyNamed
(
'mainUri'
),
target:
anyNamed
(
'target'
),
...
...
@@ -175,7 +162,8 @@ void main() {
when
(
mockWipConnection
.
debugger
).
thenReturn
(
mockWipDebugger
);
}
test
(
'runner with web server device does not support debugging without --start-paused'
,
()
=>
testbed
.
run
(()
{
testUsingContext
(
'runner with web server device does not support debugging without --start-paused'
,
()
{
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
);
when
(
mockFlutterDevice
.
device
).
thenReturn
(
WebServerDevice
(
logger:
BufferLogger
.
test
(),
));
...
...
@@ -192,11 +180,20 @@ void main() {
expect
(
profileResidentWebRunner
.
debuggingEnabled
,
false
);
when
(
mockFlutterDevice
.
device
).
thenReturn
(
MockChromeDevice
());
expect
(
residentWebRunner
.
debuggingEnabled
,
true
);
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
}));
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
MockPub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
test
(
'runner with web server device supports debugging with --start-paused'
,
()
=>
testbed
.
run
(()
{
testUsingContext
(
'runner with web server device supports debugging with --start-paused'
,
()
{
fileSystem
.
file
(
'.packages'
)
..
createSync
(
recursive:
true
)
..
writeAsStringSync
(
'
\n
'
);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[]);
_setupMocks
();
when
(
mockFlutterDevice
.
device
).
thenReturn
(
WebServerDevice
(
...
...
@@ -213,9 +210,24 @@ void main() {
expect
(
profileResidentWebRunner
.
uri
,
mockWebDevFS
.
baseUri
);
expect
(
profileResidentWebRunner
.
debuggingEnabled
,
true
);
}));
test
(
'profile does not supportsServiceProtocol'
,
()
=>
testbed
.
run
(()
{
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
MockPub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
testUsingContext
(
'profile does not supportsServiceProtocol'
,
()
{
fileSystem
.
file
(
'.packages'
)
..
createSync
(
recursive:
true
)
..
writeAsStringSync
(
'
\n
'
);
final
ResidentRunner
residentWebRunner
=
DwdsWebRunnerFactory
().
createWebRunner
(
mockFlutterDevice
,
flutterProject:
FlutterProject
.
current
(),
debuggingOptions:
DebuggingOptions
.
enabled
(
BuildInfo
.
debug
),
ipv6:
true
,
stayResident:
true
,
urlTunneller:
null
,
)
as
ResidentWebRunner
;
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[]);
when
(
mockFlutterDevice
.
device
).
thenReturn
(
mockChromeDevice
);
final
ResidentRunner
profileResidentWebRunner
=
DwdsWebRunnerFactory
().
createWebRunner
(
...
...
@@ -229,20 +241,45 @@ void main() {
expect
(
profileResidentWebRunner
.
supportsServiceProtocol
,
false
);
expect
(
residentWebRunner
.
supportsServiceProtocol
,
true
);
}));
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
MockPub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
test
(
'Exits on run if target file does not exist'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'Exits on run if target file does not exist'
,
()
async
{
fileSystem
.
file
(
'.packages'
)
..
createSync
(
recursive:
true
)
..
writeAsStringSync
(
'
\n
'
);
final
ResidentRunner
residentWebRunner
=
DwdsWebRunnerFactory
().
createWebRunner
(
mockFlutterDevice
,
flutterProject:
FlutterProject
.
current
(),
debuggingOptions:
DebuggingOptions
.
enabled
(
BuildInfo
.
debug
),
ipv6:
true
,
stayResident:
true
,
urlTunneller:
null
,
)
as
ResidentWebRunner
;
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[]);
globals
.
fs
.
file
(
'pubspec.yaml'
).
createSync
();
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'web'
,
'index.html'
))
fileSystem
.
file
(
'pubspec.yaml'
).
createSync
();
fileSystem
.
file
(
fileSystem
.
path
.
join
(
'web'
,
'index.html'
))
.
createSync
(
recursive:
true
);
expect
(
await
residentWebRunner
.
run
(),
1
);
final
String
absoluteMain
=
globals
.
fs
.
path
.
absolute
(
globals
.
fs
.
path
.
join
(
'lib'
,
'main.dart'
));
final
String
absoluteMain
=
fileSystem
.
path
.
absolute
(
fileSystem
.
path
.
join
(
'lib'
,
'main.dart'
));
expect
(
testLogger
.
errorText
,
contains
(
'Tried to run
$absoluteMain
, but that file does not exist.'
));
}));
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
MockPub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
test
(
'Can successfully run and connect to vmservice'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'Can successfully run and connect to vmservice'
,
()
async
{
fileSystem
.
file
(
'.packages'
)
..
createSync
(
recursive:
true
)
..
writeAsStringSync
(
'
\n
'
);
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
kAttachExpectations
.
toList
());
_setupMocks
();
final
DelegateLogger
delegateLogger
=
globals
.
logger
as
DelegateLogger
;
...
...
@@ -259,16 +296,21 @@ void main() {
verify
(
status
.
stop
()).
called
(
1
);
verify
(
pub
.
get
(
context:
PubContext
.
pubGet
,
directory:
globals
.
fs
.
path
.
join
(
'packages'
,
'flutter_tools'
)
directory:
anyNamed
(
'directory'
),
)).
called
(
1
);
expect
(
bufferLogger
.
statusText
,
contains
(
'Debug service listening on ws://127.0.0.1/abcd/'
));
expect
(
debugConnectionInfo
.
wsUri
.
toString
(),
'ws://127.0.0.1/abcd/'
);
},
overrides:
<
Type
,
Generator
>{
Logger:
()
=>
DelegateLogger
(
BufferLogger
.
test
()),
}));
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
MockPub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
test
(
'WebRunner copies compiled app.dill to cache during startup'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'WebRunner copies compiled app.dill to cache during startup'
,
()
async
{
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
kAttachExpectations
.
toList
());
_setupMocks
();
...
...
@@ -279,32 +321,42 @@ void main() {
));
await
connectionInfoCompleter
.
future
;
expect
(
await
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'build'
,
'cache.dill'
)).
readAsString
(),
'ABC'
);
}));
expect
(
await
fileSystem
.
file
(
fileSystem
.
path
.
join
(
'build'
,
'cache.dill'
)).
readAsString
(),
'ABC'
);
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
MockPub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
test
(
'Can successfully run without an index.html including status warning'
,
()
=>
testbed
.
run
(
()
async
{
test
UsingContext
(
'Can successfully run without an index.html including status warning'
,
()
async
{
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
kAttachExpectations
.
toList
());
_setupMocks
();
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'web'
,
'index.html'
))
fileSystem
.
file
(
fileSystem
.
path
.
join
(
'web'
,
'index.html'
))
.
deleteSync
();
residentWebRunner
=
DwdsWebRunnerFactory
().
createWebRunner
(
mockFlutterDevice
,
flutterProject:
FlutterProject
.
current
(),
debuggingOptions:
DebuggingOptions
.
enabled
(
BuildInfo
.
debug
),
ipv6:
true
,
stayResident:
false
,
urlTunneller:
null
,
)
as
ResidentWebRunner
;
final
ResidentWebRunner
residentWebRunner
=
DwdsWebRunnerFactory
().
createWebRunner
(
mockFlutterDevice
,
flutterProject:
FlutterProject
.
current
(),
debuggingOptions:
DebuggingOptions
.
enabled
(
BuildInfo
.
debug
),
ipv6:
true
,
stayResident:
false
,
urlTunneller:
null
,
)
as
ResidentWebRunner
;
expect
(
await
residentWebRunner
.
run
(),
0
);
expect
(
testLogger
.
statusText
,
contains
(
'This application is not configured to build on the web'
));
}));
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
MockPub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
test
(
'Can successfully run and disconnect with --no-resident'
,
()
=>
testbed
.
run
(
()
async
{
test
UsingContext
(
'Can successfully run and disconnect with --no-resident'
,
()
async
{
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
kAttachExpectations
.
toList
());
_setupMocks
();
residentWebRunner
=
DwdsWebRunnerFactory
().
createWebRunner
(
final
ResidentRunner
residentWebRunner
=
DwdsWebRunnerFactory
().
createWebRunner
(
mockFlutterDevice
,
flutterProject:
FlutterProject
.
current
(),
debuggingOptions:
DebuggingOptions
.
enabled
(
BuildInfo
.
debug
),
...
...
@@ -314,9 +366,15 @@ void main() {
)
as
ResidentWebRunner
;
expect
(
await
residentWebRunner
.
run
(),
0
);
}));
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
MockPub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
test
(
'Listens to stdout and stderr streams before running main'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'Listens to stdout and stderr streams before running main'
,
()
async
{
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
...
kAttachLogExpectations
,
FakeVmServiceStreamResponse
(
...
...
@@ -346,9 +404,15 @@ void main() {
expect
(
testLogger
.
statusText
,
contains
(
'THIS MESSAGE IS IMPORTANT'
));
expect
(
testLogger
.
statusText
,
contains
(
'SO IS THIS'
));
}));
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
MockPub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
test
(
'Listens to extension events with structured errors'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'Listens to extension events with structured errors'
,
()
async
{
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
);
final
Map
<
String
,
String
>
extensionData
=
<
String
,
String
>{
'test'
:
'data'
,
'renderedErrorText'
:
'error text'
,
...
...
@@ -408,11 +472,15 @@ void main() {
expect
(
testLogger
.
statusText
,
contains
(
'
\n
error text'
));
expect
(
testLogger
.
statusText
,
isNot
(
contains
(
'other stuff'
)));
}));
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
MockPub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
test
(
'Does not run main with --start-paused'
,
()
=>
testbed
.
run
(()
async
{
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
kAttachExpectations
.
toList
());
residentWebRunner
=
DwdsWebRunnerFactory
().
createWebRunner
(
testUsingContext
(
'Does not run main with --start-paused'
,
()
async
{
final
ResidentRunner
residentWebRunner
=
DwdsWebRunnerFactory
().
createWebRunner
(
mockFlutterDevice
,
flutterProject:
FlutterProject
.
current
(),
debuggingOptions:
DebuggingOptions
.
enabled
(
BuildInfo
.
debug
,
startPaused:
true
),
...
...
@@ -420,6 +488,7 @@ void main() {
stayResident:
true
,
urlTunneller:
null
,
)
as
ResidentWebRunner
;
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
kAttachExpectations
.
toList
());
_setupMocks
();
final
Completer
<
DebugConnectionInfo
>
connectionInfoCompleter
=
Completer
<
DebugConnectionInfo
>();
...
...
@@ -429,9 +498,15 @@ void main() {
await
connectionInfoCompleter
.
future
;
verifyNever
(
mockAppConnection
.
runMain
());
}));
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
MockPub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
test
(
'Can hot reload after attaching'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'Can hot reload after attaching'
,
()
async
{
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
...
kAttachExpectations
,
const
FakeVmServiceRequest
(
...
...
@@ -451,7 +526,7 @@ void main() {
return
mockChrome
;
});
when
(
mockFlutterDevice
.
device
).
thenReturn
(
GoogleChromeDevice
(
fileSystem:
globals
.
fs
,
fileSystem:
fileSystem
,
chromiumLauncher:
chromiumLauncher
,
logger:
globals
.
logger
,
platform:
FakePlatform
(
operatingSystem:
'linux'
),
...
...
@@ -505,9 +580,14 @@ void main() {
verify
(
globals
.
flutterUsage
.
sendTiming
(
'hot'
,
'web-incremental-restart'
,
any
)).
called
(
1
);
},
overrides:
<
Type
,
Generator
>{
Usage:
()
=>
MockFlutterUsage
(),
}));
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
MockPub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
test
(
'Can hot restart after attaching'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'Can hot restart after attaching'
,
()
async
{
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
...
kAttachExpectations
,
const
FakeVmServiceRequest
(
...
...
@@ -528,7 +608,7 @@ void main() {
});
when
(
chromiumLauncher
.
canFindExecutable
()).
thenReturn
(
true
);
when
(
mockFlutterDevice
.
device
).
thenReturn
(
GoogleChromeDevice
(
fileSystem:
globals
.
fs
,
fileSystem:
fileSystem
,
chromiumLauncher:
chromiumLauncher
,
logger:
globals
.
logger
,
platform:
FakePlatform
(
operatingSystem:
'linux'
),
...
...
@@ -564,7 +644,7 @@ void main() {
// Ensure that generated entrypoint is generated correctly.
expect
(
entrypointFileUri
,
isNotNull
);
final
String
entrypointContents
=
globals
.
fs
.
file
(
entrypointFileUri
).
readAsStringSync
();
final
String
entrypointContents
=
fileSystem
.
file
(
entrypointFileUri
).
readAsStringSync
();
expect
(
entrypointContents
,
contains
(
'// Flutter web bootstrap script'
));
expect
(
entrypointContents
,
contains
(
"import 'dart:ui' as ui;"
));
expect
(
entrypointContents
,
contains
(
'await ui.webOnlyInitializePlatform();'
));
...
...
@@ -585,9 +665,14 @@ void main() {
verify
(
globals
.
flutterUsage
.
sendTiming
(
'hot'
,
'web-incremental-restart'
,
any
)).
called
(
1
);
},
overrides:
<
Type
,
Generator
>{
Usage:
()
=>
MockFlutterUsage
(),
}));
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
MockPub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
test
(
'Can hot restart after attaching with web-server device'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'Can hot restart after attaching with web-server device'
,
()
async
{
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests
:
kAttachExpectations
);
_setupMocks
();
when
(
mockFlutterDevice
.
device
).
thenReturn
(
mockWebServerDevice
);
...
...
@@ -623,15 +708,26 @@ void main() {
verifyNever
(
globals
.
flutterUsage
.
sendTiming
(
'hot'
,
'web-incremental-restart'
,
any
));
},
overrides:
<
Type
,
Generator
>{
Usage:
()
=>
MockFlutterUsage
(),
}));
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
MockPub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
test
(
'web resident runner is debuggable'
,
()
=>
testbed
.
run
(()
{
testUsingContext
(
'web resident runner is debuggable'
,
()
{
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
kAttachExpectations
.
toList
());
expect
(
residentWebRunner
.
debuggingEnabled
,
true
);
}));
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
MockPub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
test
(
'web resident runner can toggle CanvasKit'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'web resident runner can toggle CanvasKit'
,
()
async
{
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[]);
final
WebAssetServer
webAssetServer
=
WebAssetServer
(
null
,
null
,
null
,
null
,
null
);
when
(
mockWebDevFS
.
webAssetServer
).
thenReturn
(
webAssetServer
);
...
...
@@ -643,9 +739,15 @@ void main() {
expect
(
webAssetServer
.
canvasKitRendering
,
true
);
expect
(
toggleResult
,
true
);
}));
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
MockPub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
test
(
'Exits when initial compile fails'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'Exits when initial compile fails'
,
()
async
{
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[]);
_setupMocks
();
when
(
mockWebDevFS
.
update
(
...
...
@@ -674,9 +776,14 @@ void main() {
verifyNever
(
globals
.
flutterUsage
.
sendTiming
(
'hot'
,
'web-restart'
,
any
));
},
overrides:
<
Type
,
Generator
>{
Usage:
()
=>
MockFlutterUsage
(),
}));
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
MockPub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
test
(
'Faithfully displays stdout messages with leading/trailing spaces'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'Faithfully displays stdout messages with leading/trailing spaces'
,
()
async
{
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
...
kAttachLogExpectations
,
FakeVmServiceStreamResponse
(
...
...
@@ -701,9 +808,15 @@ void main() {
expect
(
testLogger
.
statusText
,
contains
(
' This is a message with 4 leading and trailing spaces '
));
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
}));
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
MockPub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
test
(
'Fails on compilation errors in hot restart'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'Fails on compilation errors in hot restart'
,
()
async
{
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
kAttachExpectations
.
toList
());
_setupMocks
();
final
Completer
<
DebugConnectionInfo
>
connectionInfoCompleter
=
Completer
<
DebugConnectionInfo
>();
...
...
@@ -736,9 +849,14 @@ void main() {
verifyNever
(
globals
.
flutterUsage
.
sendTiming
(
'hot'
,
'web-restart'
,
any
));
},
overrides:
<
Type
,
Generator
>{
Usage:
()
=>
MockFlutterUsage
(),
}));
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
MockPub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
test
(
'Fails non-fatally on vmservice response error for hot restart'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'Fails non-fatally on vmservice response error for hot restart'
,
()
async
{
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
...
kAttachExpectations
,
const
FakeVmServiceRequest
(
...
...
@@ -758,9 +876,15 @@ void main() {
final
OperationResult
result
=
await
residentWebRunner
.
restart
(
fullRestart:
false
);
expect
(
result
.
code
,
0
);
}));
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
MockPub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
test
(
'Fails fatally on Vm Service error response'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'Fails fatally on Vm Service error response'
,
()
async
{
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
...
kAttachExpectations
,
const
FakeVmServiceRequest
(
...
...
@@ -780,18 +904,30 @@ void main() {
expect
(
result
.
code
,
1
);
expect
(
result
.
message
,
contains
(
RPCErrorCodes
.
kInternalError
.
toString
()));
}));
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
MockPub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
test
(
'printHelp without details has web warning'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'printHelp without details has web warning'
,
()
async
{
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[]);
residentWebRunner
.
printHelp
(
details:
false
);
expect
(
testLogger
.
statusText
,
contains
(
'Warning'
));
expect
(
testLogger
.
statusText
,
contains
(
'https://flutter.dev/web'
));
expect
(
testLogger
.
statusText
,
isNot
(
contains
(
'https://flutter.dev/web.'
)));
}));
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
MockPub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
test
(
'debugDumpApp'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'debugDumpApp'
,
()
async
{
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
...
kAttachExpectations
,
const
FakeVmServiceRequest
(
...
...
@@ -810,9 +946,15 @@ void main() {
await
residentWebRunner
.
debugDumpApp
();
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
}));
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
MockPub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
test
(
'debugDumpLayerTree'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'debugDumpLayerTree'
,
()
async
{
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
...
kAttachExpectations
,
const
FakeVmServiceRequest
(
...
...
@@ -831,9 +973,15 @@ void main() {
await
residentWebRunner
.
debugDumpLayerTree
();
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
}));
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
MockPub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
test
(
'debugDumpRenderTree'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'debugDumpRenderTree'
,
()
async
{
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
...
kAttachExpectations
,
const
FakeVmServiceRequest
(
...
...
@@ -852,9 +1000,15 @@ void main() {
await
residentWebRunner
.
debugDumpRenderTree
();
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
}));
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
MockPub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
test
(
'debugDumpSemanticsTreeInTraversalOrder'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'debugDumpSemanticsTreeInTraversalOrder'
,
()
async
{
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
...
kAttachExpectations
,
const
FakeVmServiceRequest
(
...
...
@@ -873,9 +1027,15 @@ void main() {
await
residentWebRunner
.
debugDumpSemanticsTreeInTraversalOrder
();
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
}));
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
MockPub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
test
(
'debugDumpSemanticsTreeInInverseHitTestOrder'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'debugDumpSemanticsTreeInInverseHitTestOrder'
,
()
async
{
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
...
kAttachExpectations
,
const
FakeVmServiceRequest
(
...
...
@@ -895,9 +1055,15 @@ void main() {
await
residentWebRunner
.
debugDumpSemanticsTreeInInverseHitTestOrder
();
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
}));
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
MockPub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
test
(
'debugToggleDebugPaintSizeEnabled'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'debugToggleDebugPaintSizeEnabled'
,
()
async
{
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
...
kAttachExpectations
,
const
FakeVmServiceRequest
(
...
...
@@ -930,10 +1096,15 @@ void main() {
await
residentWebRunner
.
debugToggleDebugPaintSizeEnabled
();
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
}));
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
MockPub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
test
(
'debugTogglePerformanceOverlayOverride'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'debugTogglePerformanceOverlayOverride'
,
()
async
{
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
...
kAttachExpectations
,
const
FakeVmServiceRequest
(
...
...
@@ -966,9 +1137,15 @@ void main() {
await
residentWebRunner
.
debugTogglePerformanceOverlayOverride
();
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
}));
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
MockPub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
test
(
'debugToggleWidgetInspector'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'debugToggleWidgetInspector'
,
()
async
{
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
...
kAttachExpectations
,
const
FakeVmServiceRequest
(
...
...
@@ -1001,9 +1178,15 @@ void main() {
await
residentWebRunner
.
debugToggleWidgetInspector
();
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
}));
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
MockPub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
test
(
'debugToggleProfileWidgetBuilds'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'debugToggleProfileWidgetBuilds'
,
()
async
{
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
...
kAttachExpectations
,
const
FakeVmServiceRequest
(
...
...
@@ -1036,9 +1219,15 @@ void main() {
await
residentWebRunner
.
debugToggleProfileWidgetBuilds
();
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
}));
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
MockPub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
test
(
'debugTogglePlatform'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'debugTogglePlatform'
,
()
async
{
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
...
kAttachExpectations
,
const
FakeVmServiceRequest
(
...
...
@@ -1073,9 +1262,15 @@ void main() {
expect
(
testLogger
.
statusText
,
contains
(
'Switched operating system to fuchsia'
));
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
}));
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
MockPub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
test
(
'debugToggleBrightness'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'debugToggleBrightness'
,
()
async
{
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
...
kAttachExpectations
,
const
FakeVmServiceRequest
(
...
...
@@ -1110,9 +1305,15 @@ void main() {
expect
(
testLogger
.
statusText
,
contains
(
'Changed brightness to Brightness.dark.'
));
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
}));
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
MockPub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
test
(
'cleanup of resources is safe to call multiple times'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'cleanup of resources is safe to call multiple times'
,
()
async
{
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
...
kAttachExpectations
,
]);
...
...
@@ -1136,9 +1337,15 @@ void main() {
verifyNever
(
mockDebugConnection
.
close
());
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
}));
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
MockPub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
test
(
'cleans up Chrome if tab is closed'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'cleans up Chrome if tab is closed'
,
()
async
{
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
...
kAttachExpectations
,
]);
...
...
@@ -1156,9 +1363,15 @@ void main() {
await
result
;
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
}));
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
MockPub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
test
(
'Prints target and device name on run'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'Prints target and device name on run'
,
()
async
{
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
...
kAttachExpectations
,
]);
...
...
@@ -1171,13 +1384,18 @@ void main() {
await
connectionInfoCompleter
.
future
;
expect
(
testLogger
.
statusText
,
contains
(
'Launching
${
globals.fs
.path.join('lib', 'main.dart')}
on '
'Launching
${
fileSystem
.path.join('lib', 'main.dart')}
on '
'Chromez in debug mode'
,
));
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
}));
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
MockPub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
test
(
'Sends launched app.webLaunchUrl event for Chrome device'
,
()
=>
testbed
.
run
(
()
async
{
test
UsingContext
(
'Sends launched app.webLaunchUrl event for Chrome device'
,
()
async
{
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
...
kAttachLogExpectations
,
...
kAttachIsolateExpectations
,
...
...
@@ -1192,7 +1410,7 @@ void main() {
return
mockChrome
;
});
when
(
mockFlutterDevice
.
device
).
thenReturn
(
GoogleChromeDevice
(
fileSystem:
globals
.
fs
,
fileSystem:
fileSystem
,
chromiumLauncher:
chromiumLauncher
,
logger:
globals
.
logger
,
platform:
FakePlatform
(
operatingSystem:
'linux'
),
...
...
@@ -1246,9 +1464,13 @@ void main() {
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
},
overrides:
<
Type
,
Generator
>{
Logger:
()
=>
DelegateLogger
(
BufferLogger
.
test
()),
}));
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
MockPub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
test
(
'Sends unlaunched app.webLaunchUrl event for Web Server device'
,
()
=>
testbed
.
run
(
()
async
{
test
UsingContext
(
'Sends unlaunched app.webLaunchUrl event for Web Server device'
,
()
async
{
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[]);
_setupMocks
();
when
(
mockFlutterDevice
.
device
).
thenReturn
(
WebServerDevice
(
...
...
@@ -1288,10 +1510,15 @@ void main() {
)));
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
},
overrides:
<
Type
,
Generator
>{
Logger:
()
=>
DelegateLogger
(
BufferLogger
.
test
())
}));
Logger:
()
=>
DelegateLogger
(
BufferLogger
.
test
()),
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
MockPub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
test
(
'Successfully turns WebSocketException into ToolExit'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'Successfully turns WebSocketException into ToolExit'
,
()
async
{
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[]);
_setupMocks
();
...
...
@@ -1300,9 +1527,15 @@ void main() {
await
expectLater
(()
=>
residentWebRunner
.
run
(),
throwsToolExit
());
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
}));
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
MockPub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
test
(
'Successfully turns AppConnectionException into ToolExit'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'Successfully turns AppConnectionException into ToolExit'
,
()
async
{
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[]);
_setupMocks
();
...
...
@@ -1311,9 +1544,15 @@ void main() {
await
expectLater
(()
=>
residentWebRunner
.
run
(),
throwsToolExit
());
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
}));
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
MockPub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
test
(
'Successfully turns ChromeDebugError into ToolExit'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'Successfully turns ChromeDebugError into ToolExit'
,
()
async
{
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[]);
_setupMocks
();
...
...
@@ -1322,18 +1561,30 @@ void main() {
await
expectLater
(()
=>
residentWebRunner
.
run
(),
throwsToolExit
());
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
}));
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
MockPub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
test
(
'Rethrows unknown Exception type from dwds'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'Rethrows unknown Exception type from dwds'
,
()
async
{
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[]);
_setupMocks
();
when
(
mockWebDevFS
.
connect
(
any
)).
thenThrow
(
Exception
());
await
expectLater
(()
=>
residentWebRunner
.
run
(),
throwsException
);
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
}));
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
MockPub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
test
(
'Rethrows unknown Error type from dwds tooling'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'Rethrows unknown Error type from dwds tooling'
,
()
async
{
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[]);
_setupMocks
();
final
DelegateLogger
delegateLogger
=
globals
.
logger
as
DelegateLogger
;
...
...
@@ -1352,8 +1603,23 @@ void main() {
platform:
const
LocalPlatform
(),
),
outputPreferences:
OutputPreferences
.
test
(),
))
}));
)),
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
MockPub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
}
ResidentRunner
setUpResidentRunner
(
FlutterDevice
flutterDevice
)
{
return
DwdsWebRunnerFactory
().
createWebRunner
(
flutterDevice
,
flutterProject:
FlutterProject
.
current
(),
debuggingOptions:
DebuggingOptions
.
enabled
(
BuildInfo
.
debug
),
ipv6:
true
,
stayResident:
true
,
urlTunneller:
null
,
)
as
ResidentWebRunner
;
}
class
MockChromeLauncher
extends
Mock
implements
ChromiumLauncher
{}
...
...
packages/flutter_tools/test/general.shard/runner/flutter_command_test.dart
View file @
e1538d1b
...
...
@@ -31,6 +31,7 @@ void main() {
List
<
int
>
mockTimes
;
setUp
(()
{
Cache
.
disableLocking
();
cache
=
MockitoCache
();
usage
=
MockitoUsage
();
clock
=
MockClock
();
...
...
@@ -43,6 +44,10 @@ void main() {
when
(
mockProcessInfo
.
maxRss
).
thenReturn
(
10
);
});
tearDown
(()
{
Cache
.
enableLocking
();
});
testUsingContext
(
'help text contains global options'
,
()
{
final
FakeDeprecatedCommand
fake
=
FakeDeprecatedCommand
();
createTestCommandRunner
(
fake
);
...
...
packages/flutter_tools/test/general.shard/web/golden_comparator_test.dart
View file @
e1538d1b
...
...
@@ -40,7 +40,6 @@ void main() {
testbed
=
Testbed
(
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
{
print
(
'in get process manager'
);
return
mockProcessManager
;
}
});
...
...
packages/flutter_tools/test/
general.shard/ios
/plist_parser_test.dart
→
packages/flutter_tools/test/
integration.shard
/plist_parser_test.dart
View file @
e1538d1b
...
...
@@ -13,8 +13,8 @@ import 'package:flutter_tools/src/base/terminal.dart';
import
'package:flutter_tools/src/ios/plist_parser.dart'
;
import
'package:process/process.dart'
;
import
'../
../
src/common.dart'
;
import
'../
../
src/context.dart'
;
import
'../src/common.dart'
;
import
'../src/context.dart'
;
const
String
base64PlistXml
=
'PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPCFET0NUWVBFIHBsaXN0I'
...
...
packages/flutter_tools/test/src/context.dart
View file @
e1538d1b
...
...
@@ -3,7 +3,6 @@
// found in the LICENSE file.
import
'dart:async'
;
import
'dart:io'
as
io
;
import
'package:flutter_tools/src/android/android_workflow.dart'
;
import
'package:flutter_tools/src/base/bot_detector.dart'
;
...
...
@@ -158,8 +157,8 @@ void testUsingContext(
rethrow
;
}
},
onError:
(
Object
error
,
StackTrace
stackTrace
)
{
// ignore: deprecated_member_use
io
.
stdout
.
writeln
(
error
);
io
.
stdout
.
writeln
(
stackTrace
);
print
(
error
);
print
(
stackTrace
);
_printBufferedErrors
(
context
);
throw
error
;
});
...
...
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