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
Expand all
Hide 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 {
String
mainPath
,
String
route
,
DebuggingOptions
debuggingOptions
,
Map
<
String
,
dynamic
>
platformArgs
,
Map
<
String
,
dynamic
>
platformArgs
=
const
<
String
,
Object
>{}
,
bool
prebuiltApplication
=
false
,
bool
ipv6
=
false
,
String
userIdentifier
,
...
...
packages/flutter_tools/lib/src/device.dart
View file @
34ec94a1
...
...
@@ -468,7 +468,7 @@ abstract class Device {
/// 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
/// will be returned.
Future
<
String
>
get
emulatorId
;
Future
<
String
?
>
get
emulatorId
;
/// Whether this device can run the provided [buildMode].
///
...
...
@@ -501,7 +501,7 @@ abstract class Device {
/// Specify [userIdentifier] to install for a particular user (Android only).
Future
<
bool
>
installApp
(
covariant
ApplicationPackage
app
,
{
String
userIdentifier
,
String
?
userIdentifier
,
});
/// Uninstall an app package from the current device.
...
...
@@ -510,7 +510,7 @@ abstract class Device {
/// defaults to all users (Android only).
Future
<
bool
>
uninstallApp
(
covariant
ApplicationPackage
app
,
{
String
userIdentifier
,
String
?
userIdentifier
,
});
/// Check if the device is supported by Flutter.
...
...
@@ -550,12 +550,12 @@ abstract class Device {
/// reader will also include log messages from before the invocation time.
/// Defaults to false.
FutureOr
<
DeviceLogReader
>
getLogReader
({
covariant
ApplicationPackage
app
,
covariant
ApplicationPackage
?
app
,
bool
includePastLogs
=
false
,
});
/// Get the port forwarder for this device.
DevicePortForwarder
get
portForwarder
;
DevicePortForwarder
?
get
portForwarder
;
/// Get the DDS instance for this device.
final
DartDevelopmentService
dds
=
DartDevelopmentService
();
...
...
@@ -572,13 +572,13 @@ abstract class Device {
/// start call. The build mode is not used by all platforms.
Future
<
LaunchResult
>
startApp
(
covariant
ApplicationPackage
package
,
{
String
mainPath
,
String
route
,
DebuggingOptions
debuggingOptions
,
String
?
mainPath
,
String
?
route
,
required
DebuggingOptions
debuggingOptions
,
Map
<
String
,
Object
?>
platformArgs
,
bool
prebuiltApplication
=
false
,
bool
ipv6
=
false
,
String
userIdentifier
,
String
?
userIdentifier
,
});
/// Whether this device implements support for hot reload.
...
...
@@ -603,7 +603,7 @@ abstract class Device {
/// Specify [userIdentifier] to stop app installed to a profile (Android only).
Future
<
bool
>
stopApp
(
covariant
ApplicationPackage
app
,
{
String
userIdentifier
,
String
?
userIdentifier
,
});
/// Query the current application memory usage..
...
...
@@ -917,7 +917,7 @@ class DiscoveredApp {
// An empty device log reader
class
NoOpDeviceLogReader
implements
DeviceLogReader
{
NoOpDeviceLogReader
(
this
.
name
)
;
NoOpDeviceLogReader
(
String
?
nameOrNull
)
:
name
=
nameOrNull
??
''
;
@override
final
String
name
;
...
...
packages/flutter_tools/lib/src/web/web_device.dart
View file @
34ec94a1
This diff is collapsed.
Click to expand it.
packages/flutter_tools/test/general.shard/web/devices_test.dart
View file @
34ec94a1
...
...
@@ -2,9 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'dart:async'
;
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/platform.dart'
;
import
'package:flutter_tools/src/build_info.dart'
;
...
...
@@ -32,8 +33,10 @@ void main() {
});
testWithoutContext
(
'GoogleChromeDevice defaults'
,
()
async
{
final
TestChromiumLauncher
launcher
=
TestChromiumLauncher
();
final
GoogleChromeDevice
chromeDevice
=
GoogleChromeDevice
(
chromiumLauncher:
null
,
chromiumLauncher:
launcher
,
fileSystem:
MemoryFileSystem
.
test
(),
logger:
BufferLogger
.
test
(),
platform:
FakePlatform
(),
...
...
@@ -50,7 +53,7 @@ void main() {
expect
(
await
chromeDevice
.
isLocalEmulator
,
false
);
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
.
profile
),
true
);
...
...
@@ -59,8 +62,10 @@ void main() {
});
testWithoutContext
(
'MicrosoftEdge defaults'
,
()
async
{
final
TestChromiumLauncher
launcher
=
TestChromiumLauncher
();
final
MicrosoftEdgeDevice
chromeDevice
=
MicrosoftEdgeDevice
(
chromiumLauncher:
null
,
chromiumLauncher:
launcher
,
fileSystem:
MemoryFileSystem
.
test
(),
logger:
BufferLogger
.
test
(),
processManager:
FakeProcessManager
.
any
(),
...
...
@@ -76,7 +81,7 @@ void main() {
expect
(
await
chromeDevice
.
isLocalEmulator
,
false
);
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
.
profile
),
true
);
...
...
@@ -99,7 +104,7 @@ void main() {
expect
(
await
device
.
isLocalEmulator
,
false
);
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
.
profile
),
true
);
...
...
@@ -353,3 +358,38 @@ void main() {
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