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
0d9a1b20
Unverified
Commit
0d9a1b20
authored
Jun 19, 2019
by
Jonah Williams
Committed by
GitHub
Jun 19, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove environment variable guards for command line desktop and web (#33867)
parent
42d8383c
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
64 additions
and
30 deletions
+64
-30
daemon.dart
packages/flutter_tools/lib/src/commands/daemon.dart
+5
-0
desktop.dart
packages/flutter_tools/lib/src/desktop.dart
+17
-5
linux_workflow.dart
packages/flutter_tools/lib/src/linux/linux_workflow.dart
+2
-2
macos_workflow.dart
packages/flutter_tools/lib/src/macos/macos_workflow.dart
+2
-2
web_device.dart
packages/flutter_tools/lib/src/web/web_device.dart
+1
-1
workflow.dart
packages/flutter_tools/lib/src/web/workflow.dart
+16
-4
windows_workflow.dart
packages/flutter_tools/lib/src/windows/windows_workflow.dart
+2
-2
devices_test.dart
packages/flutter_tools/test/commands/devices_test.dart
+3
-0
linux_device_test.dart
packages/flutter_tools/test/linux/linux_device_test.dart
+0
-1
common.dart
packages/flutter_tools/test/src/common.dart
+15
-0
workflow_test.dart
packages/flutter_tools/test/web/workflow_test.dart
+1
-13
No files found.
packages/flutter_tools/lib/src/commands/daemon.dart
View file @
0d9a1b20
...
...
@@ -28,6 +28,10 @@ import '../vmservice.dart';
const
String
protocolVersion
=
'0.5.2'
;
/// Whether the tool started from the daemon, as opposed to the command line.
bool
get
isRunningFromDaemon
=>
_isRunningFromDaemon
;
bool
_isRunningFromDaemon
=
false
;
/// A server process command. This command will start up a long-lived server.
/// It reads JSON-RPC based commands from stdin, executes them, and returns
/// JSON-RPC based responses and events to stdout.
...
...
@@ -49,6 +53,7 @@ class DaemonCommand extends FlutterCommand {
@override
Future
<
FlutterCommandResult
>
runCommand
()
async
{
printStatus
(
'Starting device daemon...'
);
_isRunningFromDaemon
=
true
;
final
NotifyingLogger
notifyingLogger
=
NotifyingLogger
();
...
...
packages/flutter_tools/lib/src/desktop.dart
View file @
0d9a1b20
...
...
@@ -4,20 +4,32 @@
import
'dart:async'
;
import
'package:meta/meta.dart'
;
import
'base/io.dart'
;
import
'base/platform.dart'
;
import
'base/process_manager.dart'
;
import
'commands/daemon.dart'
show
isRunningFromDaemon
;
import
'convert.dart'
;
import
'device.dart'
;
import
'version.dart'
;
// Only launch or display desktop embedding devices if
// `ENABLE_FLUTTER_DESKTOP` environment variable is set to true.
@visibleForTesting
bool
debugDisableDesktop
=
false
;
/// Only launch or display desktop embedding devices from the command line
/// or if `ENABLE_FLUTTER_DESKTOP` environment variable is set to true.
bool
get
flutterDesktopEnabled
{
_flutterDesktopEnabled
??=
platform
.
environment
[
'ENABLE_FLUTTER_DESKTOP'
]?.
toLowerCase
()
==
'true'
;
return
_flutterDesktopEnabled
&&
!
FlutterVersion
.
instance
.
isStable
;
if
(
debugDisableDesktop
)
{
return
false
;
}
if
(
isRunningFromDaemon
)
{
final
bool
platformEnabled
=
platform
.
environment
[
'ENABLE_FLUTTER_DESKTOP'
]?.
toLowerCase
()
==
'true'
;
return
platformEnabled
&&
!
FlutterVersion
.
instance
.
isStable
;
}
return
!
FlutterVersion
.
instance
.
isStable
;
}
bool
_flutterDesktopEnabled
;
/// Kills a process on linux or macOS.
Future
<
bool
>
killProcess
(
String
executable
)
async
{
...
...
packages/flutter_tools/lib/src/linux/linux_workflow.dart
View file @
0d9a1b20
...
...
@@ -21,10 +21,10 @@ class LinuxWorkflow implements Workflow {
bool
get
appliesToHostPlatform
=>
platform
.
isLinux
;
@override
bool
get
canLaunchDevices
=>
flutterDesktopEnabled
;
bool
get
canLaunchDevices
=>
platform
.
isLinux
&&
flutterDesktopEnabled
;
@override
bool
get
canListDevices
=>
flutterDesktopEnabled
;
bool
get
canListDevices
=>
platform
.
isLinux
&&
flutterDesktopEnabled
;
@override
bool
get
canListEmulators
=>
false
;
...
...
packages/flutter_tools/lib/src/macos/macos_workflow.dart
View file @
0d9a1b20
...
...
@@ -21,10 +21,10 @@ class MacOSWorkflow implements Workflow {
bool
get
appliesToHostPlatform
=>
platform
.
isMacOS
;
@override
bool
get
canLaunchDevices
=>
flutterDesktopEnabled
;
bool
get
canLaunchDevices
=>
platform
.
isMacOS
&&
flutterDesktopEnabled
;
@override
bool
get
canListDevices
=>
flutterDesktopEnabled
;
bool
get
canListDevices
=>
platform
.
isMacOS
&&
flutterDesktopEnabled
;
@override
bool
get
canListEmulators
=>
false
;
...
...
packages/flutter_tools/lib/src/web/web_device.dart
View file @
0d9a1b20
...
...
@@ -12,8 +12,8 @@ import '../base/process_manager.dart';
import
'../build_info.dart'
;
import
'../device.dart'
;
import
'../project.dart'
;
import
'../web/workflow.dart'
;
import
'chrome.dart'
;
import
'workflow.dart'
;
class
WebApplicationPackage
extends
ApplicationPackage
{
WebApplicationPackage
(
this
.
flutterProject
)
:
super
(
id:
flutterProject
.
manifest
.
appName
);
...
...
packages/flutter_tools/lib/src/web/workflow.dart
View file @
0d9a1b20
...
...
@@ -2,20 +2,32 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:meta/meta.dart'
;
import
'../base/context.dart'
;
import
'../base/platform.dart'
;
import
'../base/process_manager.dart'
;
import
'../commands/daemon.dart'
show
isRunningFromDaemon
;
import
'../doctor.dart'
;
import
'../version.dart'
;
import
'chrome.dart'
;
@visibleForTesting
bool
debugDisableWeb
=
false
;
/// Only launch or display web devices if `FLUTTER_WEB`
/// environment variable is set to true.
/// environment variable is set to true
from the daemon
.
bool
get
flutterWebEnabled
{
_flutterWebEnabled
=
platform
.
environment
[
'FLUTTER_WEB'
]?.
toLowerCase
()
==
'true'
;
return
_flutterWebEnabled
&&
!
FlutterVersion
.
instance
.
isStable
;
if
(
debugDisableWeb
)
{
return
false
;
}
if
(
isRunningFromDaemon
)
{
final
bool
platformEnabled
=
platform
.
environment
[
'FLUTTER_WEB'
]?.
toLowerCase
()
==
'true'
;
return
platformEnabled
&&
!
FlutterVersion
.
instance
.
isStable
;
}
return
!
FlutterVersion
.
instance
.
isStable
;
}
bool
_flutterWebEnabled
;
/// The web workflow instance.
WebWorkflow
get
webWorkflow
=>
context
.
get
<
WebWorkflow
>();
...
...
packages/flutter_tools/lib/src/windows/windows_workflow.dart
View file @
0d9a1b20
...
...
@@ -21,10 +21,10 @@ class WindowsWorkflow implements Workflow {
bool
get
appliesToHostPlatform
=>
platform
.
isWindows
;
@override
bool
get
canLaunchDevices
=>
flutterDesktopEnabled
;
bool
get
canLaunchDevices
=>
platform
.
isWindows
&&
flutterDesktopEnabled
;
@override
bool
get
canListDevices
=>
flutterDesktopEnabled
;
bool
get
canListDevices
=>
platform
.
isWindows
&&
flutterDesktopEnabled
;
@override
bool
get
canListEmulators
=>
false
;
...
...
packages/flutter_tools/test/commands/devices_test.dart
View file @
0d9a1b20
...
...
@@ -20,6 +20,9 @@ void main() {
group
(
'devices'
,
()
{
setUpAll
(()
{
Cache
.
disableLocking
();
// TODO(jonahwilliams): adjust the individual tests so they do not
// depend on the host environment.
debugDisableWebAndDesktop
=
true
;
});
testUsingContext
(
'returns 0 when called'
,
()
async
{
...
...
packages/flutter_tools/test/linux/linux_device_test.dart
View file @
0d9a1b20
...
...
@@ -24,7 +24,6 @@ void main() {
final
MockProcessManager
mockProcessManager
=
MockProcessManager
();
when
(
notLinux
.
isLinux
).
thenReturn
(
false
);
when
(
notLinux
.
environment
).
thenReturn
(
const
<
String
,
String
>{});
when
(
mockProcessManager
.
run
(<
String
>[
'ps'
,
'aux'
,
])).
thenAnswer
((
Invocation
invocation
)
async
{
...
...
packages/flutter_tools/test/src/common.dart
View file @
0d9a1b20
...
...
@@ -5,6 +5,8 @@
import
'dart:async'
;
import
'package:args/command_runner.dart'
;
import
'package:flutter_tools/src/desktop.dart'
;
import
'package:flutter_tools/src/web/workflow.dart'
;
import
'package:test_api/test_api.dart'
hide
TypeMatcher
,
isInstanceOf
;
import
'package:test_api/test_api.dart'
as
test_package
show
TypeMatcher
;
...
...
@@ -18,6 +20,19 @@ import 'package:flutter_tools/src/runner/flutter_command_runner.dart';
export
'package:test_api/test_api.dart'
hide
TypeMatcher
,
isInstanceOf
;
// Defines a 'package:test' shim.
/// Disable both web and desktop to make testing easier. For example, prevent
/// them from showing up in the devices list if the host happens to be setup
/// properly.
set
debugDisableWebAndDesktop
(
bool
value
)
{
if
(
value
)
{
debugDisableDesktop
=
true
;
debugDisableWeb
=
true
;
}
else
{
debugDisableDesktop
=
false
;
debugDisableWeb
=
false
;
}
}
/// A matcher that compares the type of the actual value to the type argument T.
// TODO(ianh): Remove this once https://github.com/dart-lang/matcher/issues/98 is fixed
Matcher
isInstanceOf
<
T
>()
=>
test_package
.
TypeMatcher
<
T
>();
...
...
packages/flutter_tools/test/web/workflow_test.dart
View file @
0d9a1b20
...
...
@@ -17,7 +17,6 @@ import '../src/testbed.dart';
void
main
(
)
{
group
(
'WebWorkflow'
,
()
{
Testbed
testbed
;
MockPlatform
noEnvironment
;
MockPlatform
notSupported
;
MockPlatform
windows
;
MockPlatform
linux
;
...
...
@@ -30,7 +29,6 @@ void main() {
setUpAll
(()
{
unstable
=
MockFlutterVersion
(
false
);
stable
=
MockFlutterVersion
(
true
);
noEnvironment
=
MockPlatform
(
environment:
const
<
String
,
String
>{});
notSupported
=
MockPlatform
(
linux:
false
,
windows:
false
,
macos:
false
);
windows
=
MockPlatform
(
windows:
true
);
linux
=
MockPlatform
(
linux:
true
);
...
...
@@ -46,15 +44,6 @@ void main() {
});
});
test
(
'does not apply if FLUTTER_WEB is not true'
,
()=>
testbed
.
run
(()
{
expect
(
workflow
.
appliesToHostPlatform
,
false
);
expect
(
workflow
.
canLaunchDevices
,
false
);
expect
(
workflow
.
canListDevices
,
false
);
expect
(
workflow
.
canListEmulators
,
false
);
},
overrides:
<
Type
,
Generator
>{
Platform:
()
=>
noEnvironment
,
}));
test
(
'Applies on Linux'
,
()
=>
testbed
.
run
(()
{
expect
(
workflow
.
appliesToHostPlatform
,
true
);
expect
(
workflow
.
canLaunchDevices
,
true
);
...
...
@@ -92,7 +81,7 @@ void main() {
Platform:
()
=>
notSupported
,
}));
test
(
'does not apply on stable br
na
ch'
,
()
=>
testbed
.
run
(()
{
test
(
'does not apply on stable br
an
ch'
,
()
=>
testbed
.
run
(()
{
expect
(
workflow
.
appliesToHostPlatform
,
false
);
expect
(
workflow
.
canLaunchDevices
,
false
);
expect
(
workflow
.
canListDevices
,
false
);
...
...
@@ -119,7 +108,6 @@ class MockPlatform extends Mock implements Platform {
this
.
macos
=
false
,
this
.
linux
=
false
,
this
.
environment
=
const
<
String
,
String
>{
'FLUTTER_WEB'
:
'true'
,
kChromeEnvironment:
'chrome'
,
}});
...
...
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