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
34ec94a1
Unverified
Commit
34ec94a1
authored
Oct 19, 2021
by
Christopher Fujino
Committed by
GitHub
Oct 19, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] migrate web_device.dart to null-safety (#91632)
parent
ef634b39
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
122 additions
and
84 deletions
+122
-84
android_device.dart
packages/flutter_tools/lib/src/android/android_device.dart
+1
-1
device.dart
packages/flutter_tools/lib/src/device.dart
+11
-11
web_device.dart
packages/flutter_tools/lib/src/web/web_device.dart
+64
-66
devices_test.dart
...es/flutter_tools/test/general.shard/web/devices_test.dart
+46
-6
No files found.
packages/flutter_tools/lib/src/android/android_device.dart
View file @
34ec94a1
...
@@ -541,7 +541,7 @@ class AndroidDevice extends Device {
...
@@ -541,7 +541,7 @@ class AndroidDevice extends Device {
String
mainPath
,
String
mainPath
,
String
route
,
String
route
,
DebuggingOptions
debuggingOptions
,
DebuggingOptions
debuggingOptions
,
Map
<
String
,
dynamic
>
platformArgs
,
Map
<
String
,
dynamic
>
platformArgs
=
const
<
String
,
Object
>{}
,
bool
prebuiltApplication
=
false
,
bool
prebuiltApplication
=
false
,
bool
ipv6
=
false
,
bool
ipv6
=
false
,
String
userIdentifier
,
String
userIdentifier
,
...
...
packages/flutter_tools/lib/src/device.dart
View file @
34ec94a1
...
@@ -468,7 +468,7 @@ abstract class Device {
...
@@ -468,7 +468,7 @@ abstract class Device {
/// The ID returned matches that in the output of `flutter emulators`. Fetching
/// The ID returned matches that in the output of `flutter emulators`. Fetching
/// this name may require connecting to the device and if an error occurs null
/// this name may require connecting to the device and if an error occurs null
/// will be returned.
/// will be returned.
Future
<
String
>
get
emulatorId
;
Future
<
String
?
>
get
emulatorId
;
/// Whether this device can run the provided [buildMode].
/// Whether this device can run the provided [buildMode].
///
///
...
@@ -501,7 +501,7 @@ abstract class Device {
...
@@ -501,7 +501,7 @@ abstract class Device {
/// Specify [userIdentifier] to install for a particular user (Android only).
/// Specify [userIdentifier] to install for a particular user (Android only).
Future
<
bool
>
installApp
(
Future
<
bool
>
installApp
(
covariant
ApplicationPackage
app
,
{
covariant
ApplicationPackage
app
,
{
String
userIdentifier
,
String
?
userIdentifier
,
});
});
/// Uninstall an app package from the current device.
/// Uninstall an app package from the current device.
...
@@ -510,7 +510,7 @@ abstract class Device {
...
@@ -510,7 +510,7 @@ abstract class Device {
/// defaults to all users (Android only).
/// defaults to all users (Android only).
Future
<
bool
>
uninstallApp
(
Future
<
bool
>
uninstallApp
(
covariant
ApplicationPackage
app
,
{
covariant
ApplicationPackage
app
,
{
String
userIdentifier
,
String
?
userIdentifier
,
});
});
/// Check if the device is supported by Flutter.
/// Check if the device is supported by Flutter.
...
@@ -550,12 +550,12 @@ abstract class Device {
...
@@ -550,12 +550,12 @@ abstract class Device {
/// reader will also include log messages from before the invocation time.
/// reader will also include log messages from before the invocation time.
/// Defaults to false.
/// Defaults to false.
FutureOr
<
DeviceLogReader
>
getLogReader
({
FutureOr
<
DeviceLogReader
>
getLogReader
({
covariant
ApplicationPackage
app
,
covariant
ApplicationPackage
?
app
,
bool
includePastLogs
=
false
,
bool
includePastLogs
=
false
,
});
});
/// Get the port forwarder for this device.
/// Get the port forwarder for this device.
DevicePortForwarder
get
portForwarder
;
DevicePortForwarder
?
get
portForwarder
;
/// Get the DDS instance for this device.
/// Get the DDS instance for this device.
final
DartDevelopmentService
dds
=
DartDevelopmentService
();
final
DartDevelopmentService
dds
=
DartDevelopmentService
();
...
@@ -572,13 +572,13 @@ abstract class Device {
...
@@ -572,13 +572,13 @@ abstract class Device {
/// start call. The build mode is not used by all platforms.
/// start call. The build mode is not used by all platforms.
Future
<
LaunchResult
>
startApp
(
Future
<
LaunchResult
>
startApp
(
covariant
ApplicationPackage
package
,
{
covariant
ApplicationPackage
package
,
{
String
mainPath
,
String
?
mainPath
,
String
route
,
String
?
route
,
DebuggingOptions
debuggingOptions
,
required
DebuggingOptions
debuggingOptions
,
Map
<
String
,
Object
?>
platformArgs
,
Map
<
String
,
Object
?>
platformArgs
,
bool
prebuiltApplication
=
false
,
bool
prebuiltApplication
=
false
,
bool
ipv6
=
false
,
bool
ipv6
=
false
,
String
userIdentifier
,
String
?
userIdentifier
,
});
});
/// Whether this device implements support for hot reload.
/// Whether this device implements support for hot reload.
...
@@ -603,7 +603,7 @@ abstract class Device {
...
@@ -603,7 +603,7 @@ abstract class Device {
/// Specify [userIdentifier] to stop app installed to a profile (Android only).
/// Specify [userIdentifier] to stop app installed to a profile (Android only).
Future
<
bool
>
stopApp
(
Future
<
bool
>
stopApp
(
covariant
ApplicationPackage
app
,
{
covariant
ApplicationPackage
app
,
{
String
userIdentifier
,
String
?
userIdentifier
,
});
});
/// Query the current application memory usage..
/// Query the current application memory usage..
...
@@ -917,7 +917,7 @@ class DiscoveredApp {
...
@@ -917,7 +917,7 @@ class DiscoveredApp {
// An empty device log reader
// An empty device log reader
class
NoOpDeviceLogReader
implements
DeviceLogReader
{
class
NoOpDeviceLogReader
implements
DeviceLogReader
{
NoOpDeviceLogReader
(
this
.
name
)
;
NoOpDeviceLogReader
(
String
?
nameOrNull
)
:
name
=
nameOrNull
??
''
;
@override
@override
final
String
name
;
final
String
name
;
...
...
packages/flutter_tools/lib/src/web/web_device.dart
View file @
34ec94a1
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:meta/meta.dart'
;
import
'package:meta/meta.dart'
;
import
'package:process/process.dart'
;
import
'package:process/process.dart'
;
...
@@ -36,10 +34,10 @@ class WebApplicationPackage extends ApplicationPackage {
...
@@ -36,10 +34,10 @@ class WebApplicationPackage extends ApplicationPackage {
/// A web device that supports a chromium browser.
/// A web device that supports a chromium browser.
abstract
class
ChromiumDevice
extends
Device
{
abstract
class
ChromiumDevice
extends
Device
{
ChromiumDevice
({
ChromiumDevice
({
@
required
String
name
,
required
String
name
,
@
required
this
.
chromeLauncher
,
required
this
.
chromeLauncher
,
@
required
FileSystem
fileSystem
,
required
FileSystem
fileSystem
,
@
required
Logger
logger
,
required
Logger
logger
,
})
:
_fileSystem
=
fileSystem
,
})
:
_fileSystem
=
fileSystem
,
_logger
=
logger
,
_logger
=
logger
,
super
(
super
(
...
@@ -55,7 +53,7 @@ abstract class ChromiumDevice extends Device {
...
@@ -55,7 +53,7 @@ abstract class ChromiumDevice extends Device {
final
Logger
_logger
;
final
Logger
_logger
;
/// The active chrome instance.
/// The active chrome instance.
Chromium
_chrome
;
Chromium
?
_chrome
;
// This device does not actually support hot reload, but the current implementation of the resident runner
// This device does not actually support hot reload, but the current implementation of the resident runner
// requires both supportsHotReload and supportsHotRestart to be true in order to allow hot restart.
// requires both supportsHotReload and supportsHotRestart to be true in order to allow hot restart.
...
@@ -80,11 +78,11 @@ abstract class ChromiumDevice extends Device {
...
@@ -80,11 +78,11 @@ abstract class ChromiumDevice extends Device {
@override
@override
void
clearLogs
()
{
}
void
clearLogs
()
{
}
DeviceLogReader
_logReader
;
DeviceLogReader
?
_logReader
;
@override
@override
DeviceLogReader
getLogReader
({
DeviceLogReader
getLogReader
({
ApplicationPackage
app
,
ApplicationPackage
?
app
,
bool
includePastLogs
=
false
,
bool
includePastLogs
=
false
,
})
{
})
{
return
_logReader
??=
NoOpDeviceLogReader
(
app
?.
name
);
return
_logReader
??=
NoOpDeviceLogReader
(
app
?.
name
);
...
@@ -93,13 +91,13 @@ abstract class ChromiumDevice extends Device {
...
@@ -93,13 +91,13 @@ abstract class ChromiumDevice extends Device {
@override
@override
Future
<
bool
>
installApp
(
Future
<
bool
>
installApp
(
ApplicationPackage
app
,
{
ApplicationPackage
app
,
{
String
userIdentifier
,
String
?
userIdentifier
,
})
async
=>
true
;
})
async
=>
true
;
@override
@override
Future
<
bool
>
isAppInstalled
(
Future
<
bool
>
isAppInstalled
(
ApplicationPackage
app
,
{
ApplicationPackage
app
,
{
String
userIdentifier
,
String
?
userIdentifier
,
})
async
=>
true
;
})
async
=>
true
;
@override
@override
...
@@ -109,28 +107,28 @@ abstract class ChromiumDevice extends Device {
...
@@ -109,28 +107,28 @@ abstract class ChromiumDevice extends Device {
Future
<
bool
>
get
isLocalEmulator
async
=>
false
;
Future
<
bool
>
get
isLocalEmulator
async
=>
false
;
@override
@override
Future
<
String
>
get
emulatorId
async
=>
null
;
Future
<
String
?
>
get
emulatorId
async
=>
null
;
@override
@override
bool
isSupported
()
=>
chromeLauncher
.
canFindExecutable
();
bool
isSupported
()
=>
chromeLauncher
.
canFindExecutable
();
@override
@override
DevicePortForwarder
get
portForwarder
=>
const
NoOpDevicePortForwarder
();
DevicePortForwarder
?
get
portForwarder
=>
const
NoOpDevicePortForwarder
();
@override
@override
Future
<
LaunchResult
>
startApp
(
Future
<
LaunchResult
>
startApp
(
covariant
WebApplicationPackage
package
,
{
covariant
WebApplicationPackage
package
,
{
String
mainPath
,
String
?
mainPath
,
String
route
,
String
?
route
,
DebuggingOptions
debuggingOptions
,
required
DebuggingOptions
debuggingOptions
,
Map
<
String
,
Object
>
platformArgs
,
Map
<
String
,
Object
?>
platformArgs
=
const
<
String
,
Object
?>{}
,
bool
prebuiltApplication
=
false
,
bool
prebuiltApplication
=
false
,
bool
ipv6
=
false
,
bool
ipv6
=
false
,
String
userIdentifier
,
String
?
userIdentifier
,
})
async
{
})
async
{
// See [ResidentWebRunner.run] in flutter_tools/lib/src/resident_web_runner.dart
// See [ResidentWebRunner.run] in flutter_tools/lib/src/resident_web_runner.dart
// for the web initialization and server logic.
// for the web initialization and server logic.
final
String
url
=
platformArgs
[
'uri'
]
as
String
;
final
String
url
=
platformArgs
[
'uri'
]
!
as
String
;
final
bool
launchChrome
=
platformArgs
[
'no-launch-chrome'
]
!=
true
;
final
bool
launchChrome
=
platformArgs
[
'no-launch-chrome'
]
!=
true
;
if
(
launchChrome
)
{
if
(
launchChrome
)
{
_chrome
=
await
chromeLauncher
.
launch
(
_chrome
=
await
chromeLauncher
.
launch
(
...
@@ -142,14 +140,14 @@ abstract class ChromiumDevice extends Device {
...
@@ -142,14 +140,14 @@ abstract class ChromiumDevice extends Device {
debugPort:
debuggingOptions
.
webBrowserDebugPort
,
debugPort:
debuggingOptions
.
webBrowserDebugPort
,
);
);
}
}
_logger
.
sendEvent
(
'app.webLaunchUrl'
,
<
String
,
dynamic
>{
'url'
:
url
,
'launched'
:
launchChrome
});
_logger
.
sendEvent
(
'app.webLaunchUrl'
,
<
String
,
Object
>{
'url'
:
url
,
'launched'
:
launchChrome
});
return
LaunchResult
.
succeeded
(
observatoryUri:
url
!=
null
?
Uri
.
parse
(
url
):
null
);
return
LaunchResult
.
succeeded
(
observatoryUri:
url
!=
null
?
Uri
.
parse
(
url
):
null
);
}
}
@override
@override
Future
<
bool
>
stopApp
(
Future
<
bool
>
stopApp
(
ApplicationPackage
app
,
{
ApplicationPackage
app
,
{
String
userIdentifier
,
String
?
userIdentifier
,
})
async
{
})
async
{
await
_chrome
?.
close
();
await
_chrome
?.
close
();
return
true
;
return
true
;
...
@@ -161,7 +159,7 @@ abstract class ChromiumDevice extends Device {
...
@@ -161,7 +159,7 @@ abstract class ChromiumDevice extends Device {
@override
@override
Future
<
bool
>
uninstallApp
(
Future
<
bool
>
uninstallApp
(
ApplicationPackage
app
,
{
ApplicationPackage
app
,
{
String
userIdentifier
,
String
?
userIdentifier
,
})
async
=>
true
;
})
async
=>
true
;
@override
@override
...
@@ -179,11 +177,11 @@ abstract class ChromiumDevice extends Device {
...
@@ -179,11 +177,11 @@ abstract class ChromiumDevice extends Device {
/// The Google Chrome browser based on Chromium.
/// The Google Chrome browser based on Chromium.
class
GoogleChromeDevice
extends
ChromiumDevice
{
class
GoogleChromeDevice
extends
ChromiumDevice
{
GoogleChromeDevice
({
GoogleChromeDevice
({
@
required
Platform
platform
,
required
Platform
platform
,
@
required
ProcessManager
processManager
,
required
ProcessManager
processManager
,
@
required
ChromiumLauncher
chromiumLauncher
,
required
ChromiumLauncher
chromiumLauncher
,
@
required
Logger
logger
,
required
Logger
logger
,
@
required
FileSystem
fileSystem
,
required
FileSystem
fileSystem
,
})
:
_platform
=
platform
,
})
:
_platform
=
platform
,
_processManager
=
processManager
,
_processManager
=
processManager
,
super
(
super
(
...
@@ -200,9 +198,8 @@ class GoogleChromeDevice extends ChromiumDevice {
...
@@ -200,9 +198,8 @@ class GoogleChromeDevice extends ChromiumDevice {
String
get
name
=>
'Chrome'
;
String
get
name
=>
'Chrome'
;
@override
@override
Future
<
String
>
get
sdkNameAndVersion
async
=>
_sdkNameAndVersion
??=
await
_computeSdkNameAndVersion
();
late
final
Future
<
String
>
sdkNameAndVersion
=
_computeSdkNameAndVersion
();
String
_sdkNameAndVersion
;
Future
<
String
>
_computeSdkNameAndVersion
()
async
{
Future
<
String
>
_computeSdkNameAndVersion
()
async
{
if
(!
isSupported
())
{
if
(!
isSupported
())
{
return
'unknown'
;
return
'unknown'
;
...
@@ -238,10 +235,10 @@ class GoogleChromeDevice extends ChromiumDevice {
...
@@ -238,10 +235,10 @@ class GoogleChromeDevice extends ChromiumDevice {
/// The Microsoft Edge browser based on Chromium.
/// The Microsoft Edge browser based on Chromium.
class
MicrosoftEdgeDevice
extends
ChromiumDevice
{
class
MicrosoftEdgeDevice
extends
ChromiumDevice
{
MicrosoftEdgeDevice
({
MicrosoftEdgeDevice
({
@
required
ChromiumLauncher
chromiumLauncher
,
required
ChromiumLauncher
chromiumLauncher
,
@
required
Logger
logger
,
required
Logger
logger
,
@
required
FileSystem
fileSystem
,
required
FileSystem
fileSystem
,
@
required
ProcessManager
processManager
,
required
ProcessManager
processManager
,
})
:
_processManager
=
processManager
,
})
:
_processManager
=
processManager
,
super
(
super
(
name:
'edge'
,
name:
'edge'
,
...
@@ -260,7 +257,7 @@ class MicrosoftEdgeDevice extends ChromiumDevice {
...
@@ -260,7 +257,7 @@ class MicrosoftEdgeDevice extends ChromiumDevice {
Future
<
bool
>
_meetsVersionConstraint
()
async
{
Future
<
bool
>
_meetsVersionConstraint
()
async
{
final
String
rawVersion
=
(
await
sdkNameAndVersion
).
replaceFirst
(
'Microsoft Edge '
,
''
);
final
String
rawVersion
=
(
await
sdkNameAndVersion
).
replaceFirst
(
'Microsoft Edge '
,
''
);
final
Version
version
=
Version
.
parse
(
rawVersion
);
final
Version
?
version
=
Version
.
parse
(
rawVersion
);
if
(
version
==
null
)
{
if
(
version
==
null
)
{
return
false
;
return
false
;
}
}
...
@@ -268,8 +265,8 @@ class MicrosoftEdgeDevice extends ChromiumDevice {
...
@@ -268,8 +265,8 @@ class MicrosoftEdgeDevice extends ChromiumDevice {
}
}
@override
@override
Future
<
String
>
get
sdkNameAndVersion
async
=>
_sdkNameAndVersion
??=
await
_getSdkNameAndVersion
();
late
final
Future
<
String
>
sdkNameAndVersion
=
_getSdkNameAndVersion
();
String
_sdkNameAndVersion
;
Future
<
String
>
_getSdkNameAndVersion
()
async
{
Future
<
String
>
_getSdkNameAndVersion
()
async
{
if
(
_processManager
.
canRun
(
'reg'
))
{
if
(
_processManager
.
canRun
(
'reg'
))
{
final
ProcessResult
result
=
await
_processManager
.
run
(<
String
>[
final
ProcessResult
result
=
await
_processManager
.
run
(<
String
>[
...
@@ -290,12 +287,15 @@ class MicrosoftEdgeDevice extends ChromiumDevice {
...
@@ -290,12 +287,15 @@ class MicrosoftEdgeDevice extends ChromiumDevice {
class
WebDevices
extends
PollingDeviceDiscovery
{
class
WebDevices
extends
PollingDeviceDiscovery
{
WebDevices
({
WebDevices
({
@
required
FileSystem
fileSystem
,
required
FileSystem
fileSystem
,
@
required
Logger
logger
,
required
Logger
logger
,
@
required
Platform
platform
,
required
Platform
platform
,
@
required
ProcessManager
processManager
,
required
ProcessManager
processManager
,
@
required
FeatureFlags
featureFlags
,
required
FeatureFlags
featureFlags
,
})
:
_featureFlags
=
featureFlags
,
})
:
_featureFlags
=
featureFlags
,
_webServerDevice
=
WebServerDevice
(
logger:
logger
,
),
super
(
'Chrome'
)
{
super
(
'Chrome'
)
{
final
OperatingSystemUtils
operatingSystemUtils
=
OperatingSystemUtils
(
final
OperatingSystemUtils
operatingSystemUtils
=
OperatingSystemUtils
(
fileSystem:
fileSystem
,
fileSystem:
fileSystem
,
...
@@ -332,31 +332,29 @@ class WebDevices extends PollingDeviceDiscovery {
...
@@ -332,31 +332,29 @@ class WebDevices extends PollingDeviceDiscovery {
fileSystem:
fileSystem
,
fileSystem:
fileSystem
,
);
);
}
}
_webServerDevice
=
WebServerDevice
(
logger:
logger
,
);
}
}
GoogleChromeDevice
_chromeDevice
;
late
final
GoogleChromeDevice
_chromeDevice
;
WebServerDevice
_webServerDevice
;
final
WebServerDevice
_webServerDevice
;
MicrosoftEdgeDevice
_edgeDevice
;
MicrosoftEdgeDevice
?
_edgeDevice
;
final
FeatureFlags
_featureFlags
;
final
FeatureFlags
_featureFlags
;
@override
@override
bool
get
canListAnything
=>
featureFlags
.
isWebEnabled
;
bool
get
canListAnything
=>
featureFlags
.
isWebEnabled
;
@override
@override
Future
<
List
<
Device
>>
pollingGetDevices
({
Duration
timeout
})
async
{
Future
<
List
<
Device
>>
pollingGetDevices
({
Duration
?
timeout
})
async
{
if
(!
_featureFlags
.
isWebEnabled
)
{
if
(!
_featureFlags
.
isWebEnabled
)
{
return
<
Device
>[];
return
<
Device
>[];
}
}
final
MicrosoftEdgeDevice
?
edgeDevice
=
_edgeDevice
;
return
<
Device
>[
return
<
Device
>[
if
(
WebServerDevice
.
showWebServerDevice
)
if
(
WebServerDevice
.
showWebServerDevice
)
_webServerDevice
,
_webServerDevice
,
if
(
_chromeDevice
.
isSupported
())
if
(
_chromeDevice
.
isSupported
())
_chromeDevice
,
_chromeDevice
,
if
(
await
_edgeDevice
?.
_meetsVersionConstraint
()
??
false
)
if
(
edgeDevice
!=
null
&&
await
edgeDevice
.
_meetsVersionConstraint
()
)
_
edgeDevice
,
edgeDevice
,
];
];
}
}
...
@@ -376,7 +374,7 @@ String parseVersionForWindows(String input) {
...
@@ -376,7 +374,7 @@ String parseVersionForWindows(String input) {
/// A special device type to allow serving for arbitrary browsers.
/// A special device type to allow serving for arbitrary browsers.
class
WebServerDevice
extends
Device
{
class
WebServerDevice
extends
Device
{
WebServerDevice
({
WebServerDevice
({
@
required
Logger
logger
,
required
Logger
logger
,
})
:
_logger
=
logger
,
})
:
_logger
=
logger
,
super
(
super
(
'web-server'
,
'web-server'
,
...
@@ -394,13 +392,13 @@ class WebServerDevice extends Device {
...
@@ -394,13 +392,13 @@ class WebServerDevice extends Device {
void
clearLogs
()
{
}
void
clearLogs
()
{
}
@override
@override
Future
<
String
>
get
emulatorId
async
=>
null
;
Future
<
String
?
>
get
emulatorId
async
=>
null
;
DeviceLogReader
_logReader
;
DeviceLogReader
?
_logReader
;
@override
@override
DeviceLogReader
getLogReader
({
DeviceLogReader
getLogReader
({
ApplicationPackage
app
,
ApplicationPackage
?
app
,
bool
includePastLogs
=
false
,
bool
includePastLogs
=
false
,
})
{
})
{
return
_logReader
??=
NoOpDeviceLogReader
(
app
?.
name
);
return
_logReader
??=
NoOpDeviceLogReader
(
app
?.
name
);
...
@@ -409,13 +407,13 @@ class WebServerDevice extends Device {
...
@@ -409,13 +407,13 @@ class WebServerDevice extends Device {
@override
@override
Future
<
bool
>
installApp
(
Future
<
bool
>
installApp
(
ApplicationPackage
app
,
{
ApplicationPackage
app
,
{
String
userIdentifier
,
String
?
userIdentifier
,
})
async
=>
true
;
})
async
=>
true
;
@override
@override
Future
<
bool
>
isAppInstalled
(
Future
<
bool
>
isAppInstalled
(
ApplicationPackage
app
,
{
ApplicationPackage
app
,
{
String
userIdentifier
,
String
?
userIdentifier
,
})
async
=>
true
;
})
async
=>
true
;
@override
@override
...
@@ -442,22 +440,22 @@ class WebServerDevice extends Device {
...
@@ -442,22 +440,22 @@ class WebServerDevice extends Device {
String
get
name
=>
'Web Server'
;
String
get
name
=>
'Web Server'
;
@override
@override
DevicePortForwarder
get
portForwarder
=>
const
NoOpDevicePortForwarder
();
DevicePortForwarder
?
get
portForwarder
=>
const
NoOpDevicePortForwarder
();
@override
@override
Future
<
String
>
get
sdkNameAndVersion
async
=>
'Flutter Tools'
;
Future
<
String
>
get
sdkNameAndVersion
async
=>
'Flutter Tools'
;
@override
@override
Future
<
LaunchResult
>
startApp
(
ApplicationPackage
package
,
{
Future
<
LaunchResult
>
startApp
(
ApplicationPackage
package
,
{
String
mainPath
,
String
?
mainPath
,
String
route
,
String
?
route
,
DebuggingOptions
debuggingOptions
,
required
DebuggingOptions
debuggingOptions
,
Map
<
String
,
Object
>
platformArgs
,
Map
<
String
,
Object
?>
platformArgs
=
const
<
String
,
Object
?>{}
,
bool
prebuiltApplication
=
false
,
bool
prebuiltApplication
=
false
,
bool
ipv6
=
false
,
bool
ipv6
=
false
,
String
userIdentifier
,
String
?
userIdentifier
,
})
async
{
})
async
{
final
String
url
=
platformArgs
[
'uri'
]
as
String
;
final
String
?
url
=
platformArgs
[
'uri'
]
as
String
?
;
if
(
debuggingOptions
.
startPaused
)
{
if
(
debuggingOptions
.
startPaused
)
{
_logger
.
printStatus
(
'Waiting for connection from Dart debug extension at
$url
'
,
emphasis:
true
);
_logger
.
printStatus
(
'Waiting for connection from Dart debug extension at
$url
'
,
emphasis:
true
);
}
else
{
}
else
{
...
@@ -467,14 +465,14 @@ class WebServerDevice extends Device {
...
@@ -467,14 +465,14 @@ class WebServerDevice extends Device {
'The web-server device requires the Dart Debug Chrome extension for debugging. '
'The web-server device requires the Dart Debug Chrome extension for debugging. '
'Consider using the Chrome or Edge devices for an improved development workflow.'
'Consider using the Chrome or Edge devices for an improved development workflow.'
);
);
_logger
.
sendEvent
(
'app.webLaunchUrl'
,
<
String
,
dynamic
>{
'url'
:
url
,
'launched'
:
false
});
_logger
.
sendEvent
(
'app.webLaunchUrl'
,
<
String
,
Object
?
>{
'url'
:
url
,
'launched'
:
false
});
return
LaunchResult
.
succeeded
(
observatoryUri:
url
!=
null
?
Uri
.
parse
(
url
):
null
);
return
LaunchResult
.
succeeded
(
observatoryUri:
url
!=
null
?
Uri
.
parse
(
url
):
null
);
}
}
@override
@override
Future
<
bool
>
stopApp
(
Future
<
bool
>
stopApp
(
ApplicationPackage
app
,
{
ApplicationPackage
app
,
{
String
userIdentifier
,
String
?
userIdentifier
,
})
async
{
})
async
{
return
true
;
return
true
;
}
}
...
@@ -485,7 +483,7 @@ class WebServerDevice extends Device {
...
@@ -485,7 +483,7 @@ class WebServerDevice extends Device {
@override
@override
Future
<
bool
>
uninstallApp
(
Future
<
bool
>
uninstallApp
(
ApplicationPackage
app
,
{
ApplicationPackage
app
,
{
String
userIdentifier
,
String
?
userIdentifier
,
})
async
{
})
async
{
return
true
;
return
true
;
}
}
...
...
packages/flutter_tools/test/general.shard/web/devices_test.dart
View file @
34ec94a1
...
@@ -2,9 +2,10 @@
...
@@ -2,9 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'dart:async'
;
import
'package:file/memory.dart'
;
import
'package:file/memory.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/logger.dart'
;
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/build_info.dart'
;
import
'package:flutter_tools/src/build_info.dart'
;
...
@@ -32,8 +33,10 @@ void main() {
...
@@ -32,8 +33,10 @@ void main() {
});
});
testWithoutContext
(
'GoogleChromeDevice defaults'
,
()
async
{
testWithoutContext
(
'GoogleChromeDevice defaults'
,
()
async
{
final
TestChromiumLauncher
launcher
=
TestChromiumLauncher
();
final
GoogleChromeDevice
chromeDevice
=
GoogleChromeDevice
(
final
GoogleChromeDevice
chromeDevice
=
GoogleChromeDevice
(
chromiumLauncher:
null
,
chromiumLauncher:
launcher
,
fileSystem:
MemoryFileSystem
.
test
(),
fileSystem:
MemoryFileSystem
.
test
(),
logger:
BufferLogger
.
test
(),
logger:
BufferLogger
.
test
(),
platform:
FakePlatform
(),
platform:
FakePlatform
(),
...
@@ -50,7 +53,7 @@ void main() {
...
@@ -50,7 +53,7 @@ void main() {
expect
(
await
chromeDevice
.
isLocalEmulator
,
false
);
expect
(
await
chromeDevice
.
isLocalEmulator
,
false
);
expect
(
chromeDevice
.
getLogReader
(),
isA
<
NoOpDeviceLogReader
>());
expect
(
chromeDevice
.
getLogReader
(),
isA
<
NoOpDeviceLogReader
>());
expect
(
chromeDevice
.
getLogReader
(),
isA
<
NoOpDeviceLogReader
>());
expect
(
chromeDevice
.
getLogReader
(),
isA
<
NoOpDeviceLogReader
>());
expect
(
await
chromeDevice
.
portForwarder
.
forward
(
1
),
1
);
expect
(
await
chromeDevice
.
portForwarder
!
.
forward
(
1
),
1
);
expect
(
chromeDevice
.
supportsRuntimeMode
(
BuildMode
.
debug
),
true
);
expect
(
chromeDevice
.
supportsRuntimeMode
(
BuildMode
.
debug
),
true
);
expect
(
chromeDevice
.
supportsRuntimeMode
(
BuildMode
.
profile
),
true
);
expect
(
chromeDevice
.
supportsRuntimeMode
(
BuildMode
.
profile
),
true
);
...
@@ -59,8 +62,10 @@ void main() {
...
@@ -59,8 +62,10 @@ void main() {
});
});
testWithoutContext
(
'MicrosoftEdge defaults'
,
()
async
{
testWithoutContext
(
'MicrosoftEdge defaults'
,
()
async
{
final
TestChromiumLauncher
launcher
=
TestChromiumLauncher
();
final
MicrosoftEdgeDevice
chromeDevice
=
MicrosoftEdgeDevice
(
final
MicrosoftEdgeDevice
chromeDevice
=
MicrosoftEdgeDevice
(
chromiumLauncher:
null
,
chromiumLauncher:
launcher
,
fileSystem:
MemoryFileSystem
.
test
(),
fileSystem:
MemoryFileSystem
.
test
(),
logger:
BufferLogger
.
test
(),
logger:
BufferLogger
.
test
(),
processManager:
FakeProcessManager
.
any
(),
processManager:
FakeProcessManager
.
any
(),
...
@@ -76,7 +81,7 @@ void main() {
...
@@ -76,7 +81,7 @@ void main() {
expect
(
await
chromeDevice
.
isLocalEmulator
,
false
);
expect
(
await
chromeDevice
.
isLocalEmulator
,
false
);
expect
(
chromeDevice
.
getLogReader
(),
isA
<
NoOpDeviceLogReader
>());
expect
(
chromeDevice
.
getLogReader
(),
isA
<
NoOpDeviceLogReader
>());
expect
(
chromeDevice
.
getLogReader
(),
isA
<
NoOpDeviceLogReader
>());
expect
(
chromeDevice
.
getLogReader
(),
isA
<
NoOpDeviceLogReader
>());
expect
(
await
chromeDevice
.
portForwarder
.
forward
(
1
),
1
);
expect
(
await
chromeDevice
.
portForwarder
!
.
forward
(
1
),
1
);
expect
(
chromeDevice
.
supportsRuntimeMode
(
BuildMode
.
debug
),
true
);
expect
(
chromeDevice
.
supportsRuntimeMode
(
BuildMode
.
debug
),
true
);
expect
(
chromeDevice
.
supportsRuntimeMode
(
BuildMode
.
profile
),
true
);
expect
(
chromeDevice
.
supportsRuntimeMode
(
BuildMode
.
profile
),
true
);
...
@@ -99,7 +104,7 @@ void main() {
...
@@ -99,7 +104,7 @@ void main() {
expect
(
await
device
.
isLocalEmulator
,
false
);
expect
(
await
device
.
isLocalEmulator
,
false
);
expect
(
device
.
getLogReader
(),
isA
<
NoOpDeviceLogReader
>());
expect
(
device
.
getLogReader
(),
isA
<
NoOpDeviceLogReader
>());
expect
(
device
.
getLogReader
(),
isA
<
NoOpDeviceLogReader
>());
expect
(
device
.
getLogReader
(),
isA
<
NoOpDeviceLogReader
>());
expect
(
await
device
.
portForwarder
.
forward
(
1
),
1
);
expect
(
await
device
.
portForwarder
!
.
forward
(
1
),
1
);
expect
(
device
.
supportsRuntimeMode
(
BuildMode
.
debug
),
true
);
expect
(
device
.
supportsRuntimeMode
(
BuildMode
.
debug
),
true
);
expect
(
device
.
supportsRuntimeMode
(
BuildMode
.
profile
),
true
);
expect
(
device
.
supportsRuntimeMode
(
BuildMode
.
profile
),
true
);
...
@@ -353,3 +358,38 @@ void main() {
...
@@ -353,3 +358,38 @@ void main() {
expect
((
await
macosWebDevices
.
pollingGetDevices
()).
whereType
<
MicrosoftEdgeDevice
>(),
isEmpty
);
expect
((
await
macosWebDevices
.
pollingGetDevices
()).
whereType
<
MicrosoftEdgeDevice
>(),
isEmpty
);
});
});
}
}
/// A test implementation of the [ChromiumLauncher] that launches a fixed instance.
class
TestChromiumLauncher
implements
ChromiumLauncher
{
TestChromiumLauncher
();
bool
_hasInstance
=
false
;
void
setInstance
(
Chromium
chromium
)
{
_hasInstance
=
true
;
currentCompleter
.
complete
(
chromium
);
}
@override
Completer
<
Chromium
>
currentCompleter
=
Completer
<
Chromium
>();
@override
bool
canFindExecutable
()
{
return
true
;
}
@override
Future
<
Chromium
>
get
connectedInstance
=>
currentCompleter
.
future
;
@override
String
findExecutable
()
{
return
'chrome'
;
}
@override
bool
get
hasChromeInstance
=>
_hasInstance
;
@override
Future
<
Chromium
>
launch
(
String
url
,
{
bool
headless
=
false
,
int
?
debugPort
,
bool
skipCheck
=
false
,
Directory
?
cacheDir
})
async
{
return
currentCompleter
.
future
;
}
}
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