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
028b7dce
Unverified
Commit
028b7dce
authored
Mar 16, 2020
by
Jonah Williams
Committed by
GitHub
Mar 16, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] remove context from WebWorkflow (#52613)
parent
48fc1350
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
80 additions
and
115 deletions
+80
-115
context_runner.dart
packages/flutter_tools/lib/src/context_runner.dart
+4
-1
doctor.dart
packages/flutter_tools/lib/src/doctor.dart
+10
-9
workflow.dart
packages/flutter_tools/lib/src/web/workflow.dart
+17
-9
doctor_test.dart
...utter_tools/test/commands.shard/hermetic/doctor_test.dart
+2
-1
workflow_test.dart
...s/flutter_tools/test/general.shard/web/workflow_test.dart
+47
-95
No files found.
packages/flutter_tools/lib/src/context_runner.dart
View file @
028b7dce
...
...
@@ -197,7 +197,10 @@ Future<T> runInContext<T>(
processManager:
globals
.
processManager
,
)
),
WebWorkflow:
()
=>
const
WebWorkflow
(),
WebWorkflow:
()
=>
WebWorkflow
(
featureFlags:
featureFlags
,
platform:
globals
.
platform
,
),
WindowsWorkflow:
()
=>
const
WindowsWorkflow
(),
Xcode:
()
=>
Xcode
(
logger:
globals
.
logger
,
...
...
packages/flutter_tools/lib/src/doctor.dart
View file @
028b7dce
...
...
@@ -56,6 +56,16 @@ class _DefaultDoctorValidatorsProvider implements DoctorValidatorsProvider {
List
<
DoctorValidator
>
_validators
;
List
<
Workflow
>
_workflows
;
final
LinuxWorkflow
linuxWorkflow
=
LinuxWorkflow
(
platform:
globals
.
platform
,
featureFlags:
featureFlags
,
);
final
WebWorkflow
webWorkflow
=
WebWorkflow
(
platform:
globals
.
platform
,
featureFlags:
featureFlags
,
);
@override
List
<
DoctorValidator
>
get
validators
{
if
(
_validators
!=
null
)
{
...
...
@@ -67,11 +77,6 @@ class _DefaultDoctorValidatorsProvider implements DoctorValidatorsProvider {
...
IntelliJValidator
.
installedValidators
,
...
VsCodeValidator
.
installedValidators
,
];
final
LinuxWorkflow
linuxWorkflow
=
LinuxWorkflow
(
platform:
globals
.
platform
,
featureFlags:
featureFlags
,
);
_validators
=
<
DoctorValidator
>[
FlutterValidator
(),
if
(
androidWorkflow
.
appliesToHostPlatform
)
...
...
@@ -119,10 +124,6 @@ class _DefaultDoctorValidatorsProvider implements DoctorValidatorsProvider {
_workflows
.
add
(
fuchsiaWorkflow
);
}
final
LinuxWorkflow
linuxWorkflow
=
LinuxWorkflow
(
platform:
globals
.
platform
,
featureFlags:
featureFlags
,
);
if
(
linuxWorkflow
.
appliesToHostPlatform
)
{
_workflows
.
add
(
linuxWorkflow
);
}
...
...
packages/flutter_tools/lib/src/web/workflow.dart
View file @
028b7dce
...
...
@@ -2,25 +2,33 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'../base/context.dart'
;
import
'package:meta/meta.dart'
;
import
'package:platform/platform.dart'
;
import
'../doctor.dart'
;
import
'../features.dart'
;
import
'../globals.dart'
as
globals
;
/// The web workflow instance.
WebWorkflow
get
webWorkflow
=>
context
.
get
<
WebWorkflow
>();
class
WebWorkflow
extends
Workflow
{
const
WebWorkflow
();
const
WebWorkflow
({
@required
Platform
platform
,
@required
FeatureFlags
featureFlags
,
})
:
_platform
=
platform
,
_featureFlags
=
featureFlags
;
final
Platform
_platform
;
final
FeatureFlags
_featureFlags
;
@override
bool
get
appliesToHostPlatform
=>
featureFlags
.
isWebEnabled
&&
(
globals
.
platform
.
isWindows
||
globals
.
platform
.
isMacOS
||
globals
.
platform
.
isLinux
);
bool
get
appliesToHostPlatform
=>
_featureFlags
.
isWebEnabled
&&
(
_platform
.
isWindows
||
_platform
.
isMacOS
||
_platform
.
isLinux
);
@override
bool
get
canLaunchDevices
=>
featureFlags
.
isWebEnabled
;
bool
get
canLaunchDevices
=>
_
featureFlags
.
isWebEnabled
;
@override
bool
get
canListDevices
=>
featureFlags
.
isWebEnabled
;
bool
get
canListDevices
=>
_
featureFlags
.
isWebEnabled
;
@override
bool
get
canListEmulators
=>
false
;
...
...
packages/flutter_tools/test/commands.shard/hermetic/doctor_test.dart
View file @
028b7dce
...
...
@@ -722,7 +722,8 @@ void main() {
testUsingContext
(
'WebWorkflow is a part of validator workflows if enabled'
,
()
async
{
when
(
globals
.
processManager
.
canRun
(
any
)).
thenReturn
(
true
);
expect
(
DoctorValidatorsProvider
.
defaultInstance
.
workflows
.
contains
(
webWorkflow
),
true
);
expect
(
DoctorValidatorsProvider
.
defaultInstance
.
workflows
,
contains
(
isA
<
WebWorkflow
>()));
},
overrides:
<
Type
,
Generator
>{
FeatureFlags:
()
=>
TestFeatureFlags
(
isWebEnabled:
true
),
ProcessManager:
()
=>
MockProcessManager
(),
...
...
packages/flutter_tools/test/general.shard/web/workflow_test.dart
View file @
028b7dce
...
...
@@ -2,115 +2,67 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter_tools/src/features.dart'
;
import
'package:flutter_tools/src/web/chrome.dart'
;
import
'package:flutter_tools/src/web/workflow.dart'
;
import
'package:flutter_tools/src/globals.dart'
as
globals
;
import
'package:mockito/mockito.dart'
;
import
'package:process/process.dart'
;
import
'package:platform/platform.dart'
;
import
'package:flutter_tools/src/web/workflow.dart'
;
import
'../../src/common.dart'
;
import
'../../src/context.dart'
;
import
'../../src/testbed.dart'
;
void
main
(
)
{
group
(
'WebWorkflow'
,
()
{
Testbed
testbed
;
MockPlatform
notSupported
;
MockPlatform
windows
;
MockPlatform
linux
;
MockPlatform
macos
;
MockProcessManager
mockProcessManager
;
WebWorkflow
workflow
;
setUpAll
(()
{
notSupported
=
MockPlatform
(
linux:
false
,
windows:
false
,
macos:
false
);
windows
=
MockPlatform
(
windows:
true
);
linux
=
MockPlatform
(
linux:
true
);
macos
=
MockPlatform
(
macos:
true
);
workflow
=
const
WebWorkflow
();
mockProcessManager
=
MockProcessManager
();
testbed
=
Testbed
(
setup:
()
async
{
globals
.
fs
.
file
(
'chrome'
).
createSync
();
when
(
mockProcessManager
.
canRun
(
'chrome'
)).
thenReturn
(
true
);
},
overrides:
<
Type
,
Generator
>{
FeatureFlags:
()
=>
TestFeatureFlags
(
isWebEnabled:
true
),
ProcessManager:
()
=>
mockProcessManager
,
});
});
test
(
'Applies on Linux'
,
()
=>
testbed
.
run
(()
{
expect
(
workflow
.
appliesToHostPlatform
,
true
);
expect
(
workflow
.
canLaunchDevices
,
true
);
expect
(
workflow
.
canListDevices
,
true
);
expect
(
workflow
.
canListEmulators
,
false
);
},
overrides:
<
Type
,
Generator
>{
Platform:
()
=>
linux
,
}));
test
(
'Applies on macOS'
,
()
=>
testbed
.
run
(()
{
expect
(
workflow
.
appliesToHostPlatform
,
true
);
expect
(
workflow
.
canLaunchDevices
,
true
);
expect
(
workflow
.
canListDevices
,
true
);
expect
(
workflow
.
canListEmulators
,
false
);
},
overrides:
<
Type
,
Generator
>{
Platform:
()
=>
macos
,
}));
test
(
'Applies on Windows'
,
()
=>
testbed
.
run
(()
{
expect
(
workflow
.
appliesToHostPlatform
,
true
);
expect
(
workflow
.
canLaunchDevices
,
true
);
expect
(
workflow
.
canListDevices
,
true
);
expect
(
workflow
.
canListEmulators
,
false
);
},
overrides:
<
Type
,
Generator
>{
Platform:
()
=>
windows
,
}));
testWithoutContext
(
'WebWorkflow applies on Linux'
,
()
{
final
WebWorkflow
workflow
=
WebWorkflow
(
platform:
FakePlatform
(
operatingSystem:
'linux'
),
featureFlags:
TestFeatureFlags
(
isWebEnabled:
true
),
);
expect
(
workflow
.
appliesToHostPlatform
,
true
);
expect
(
workflow
.
canLaunchDevices
,
true
);
expect
(
workflow
.
canListDevices
,
true
);
expect
(
workflow
.
canListEmulators
,
false
);
});
test
(
'does not apply on other platforms'
,
()
=>
testbed
.
run
(
()
{
expect
(
workflow
.
appliesToHostPlatform
,
false
);
},
overrides:
<
Type
,
Generator
>{
Platform:
()
=>
notSupported
,
})
);
testWithoutContext
(
'WebWorkflow applies on macOS'
,
()
{
final
WebWorkflow
workflow
=
WebWorkflow
(
platform:
FakePlatform
(
operatingSystem:
'macos'
),
featureFlags:
TestFeatureFlags
(
isWebEnabled:
true
)
,
);
test
(
'does not apply if feature flag is disabled'
,
()
=>
testbed
.
run
(()
{
expect
(
workflow
.
appliesToHostPlatform
,
false
);
expect
(
workflow
.
canLaunchDevices
,
false
);
expect
(
workflow
.
canListDevices
,
false
);
expect
(
workflow
.
canListEmulators
,
false
);
},
overrides:
<
Type
,
Generator
>{
Platform:
()
=>
macos
,
FeatureFlags:
()
=>
TestFeatureFlags
(
isWebEnabled:
false
),
}));
expect
(
workflow
.
appliesToHostPlatform
,
true
);
expect
(
workflow
.
canLaunchDevices
,
true
);
expect
(
workflow
.
canListDevices
,
true
);
expect
(
workflow
.
canListEmulators
,
false
);
});
}
class
MockProcessManager
extends
Mock
implements
ProcessManager
{}
testWithoutContext
(
'WebWorkflow applies on Windows'
,
()
{
final
WebWorkflow
workflow
=
WebWorkflow
(
platform:
FakePlatform
(
operatingSystem:
'windows'
),
featureFlags:
TestFeatureFlags
(
isWebEnabled:
true
),
);
class
MockPlatform
extends
Mock
implements
Platform
{
MockPlatform
({
this
.
windows
=
false
,
this
.
macos
=
false
,
this
.
linux
=
false
,
this
.
environment
=
const
<
String
,
String
>{
kChromeEnvironment:
'chrome'
,
},
expect
(
workflow
.
appliesToHostPlatform
,
true
);
expect
(
workflow
.
canLaunchDevices
,
true
);
expect
(
workflow
.
canListDevices
,
true
);
expect
(
workflow
.
canListEmulators
,
false
);
});
final
bool
windows
;
final
bool
macos
;
final
bool
linux
;
testWithoutContext
(
'WebWorkflow does not apply on other platforms'
,
()
{
final
WebWorkflow
workflow
=
WebWorkflow
(
platform:
FakePlatform
(
operatingSystem:
'fuchsia'
),
featureFlags:
TestFeatureFlags
(
isWebEnabled:
true
),
);
@override
final
Map
<
String
,
String
>
environment
;
@override
bool
get
isLinux
=>
linux
;
expect
(
workflow
.
appliesToHostPlatform
,
false
);
});
@override
bool
get
isMacOS
=>
macos
;
testWithoutContext
(
'WebWorkflow does not apply if feature flag is disabled'
,
()
{
final
WebWorkflow
workflow
=
WebWorkflow
(
platform:
FakePlatform
(
operatingSystem:
'linux'
),
featureFlags:
TestFeatureFlags
(),
);
@override
bool
get
isWindows
=>
windows
;
expect
(
workflow
.
appliesToHostPlatform
,
false
);
expect
(
workflow
.
canLaunchDevices
,
false
);
expect
(
workflow
.
canListDevices
,
false
);
expect
(
workflow
.
canListEmulators
,
false
);
});
}
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