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
c1fabb98
Unverified
Commit
c1fabb98
authored
Jan 23, 2019
by
Jonah Williams
Committed by
GitHub
Jan 23, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make FDE opt-in via the environment variable (#26898)
parent
450abfe9
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
28 additions
and
78 deletions
+28
-78
desktop.dart
packages/flutter_tools/lib/src/desktop.dart
+7
-21
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
windows_workflow.dart
packages/flutter_tools/lib/src/windows/windows_workflow.dart
+2
-2
linux_workflow_test.dart
packages/flutter_tools/test/linux/linux_workflow_test.dart
+5
-17
macos_workflow_test.dart
packages/flutter_tools/test/macos/macos_workflow_test.dart
+5
-17
windows_workflow_test.dart
...ges/flutter_tools/test/windows/windows_workflow_test.dart
+5
-17
No files found.
packages/flutter_tools/lib/src/desktop.dart
View file @
c1fabb98
// Copyright 201
8
The Chromium Authors. All rights reserved.
// Copyright 201
9
The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'base/file_system.dart'
;
import
'base/platform.dart'
;
import
'cache.dart'
;
// Only launch or display desktop embedding devices if there is a sibling
// FDE repository or a `FLUTTER_DESKTOP_EMBEDDING` environment variable which
// contains a FDE repo.
bool
get
hasFlutterDesktopRepository
{
if
(
_hasFlutterDesktopRepository
==
null
)
{
final
String
desktopLocation
=
platform
.
environment
[
'FLUTTER_DESKTOP_EMBEDDING'
];
if
(
desktopLocation
!=
null
&&
desktopLocation
.
isNotEmpty
)
{
_hasFlutterDesktopRepository
=
fs
.
directory
(
desktopLocation
)
.
existsSync
();
}
else
{
final
Directory
parent
=
fs
.
directory
(
Cache
.
flutterRoot
).
parent
;
_hasFlutterDesktopRepository
=
parent
.
childDirectory
(
'flutter-desktop-embedding'
)
.
existsSync
();
}
}
return
_hasFlutterDesktopRepository
;
// Only launch or display desktop embedding devices if
// `FLUTTER_DESKTOP_EMBEDDING` environment variable is set to true.
bool
get
flutterDesktopEnabled
{
_flutterDesktopEnabled
??=
platform
.
environment
[
'FLUTTER_DESKTOP_EMBEDDING'
]?.
toLowerCase
()
==
'true'
;
return
_flutterDesktopEnabled
;
}
bool
_
hasFlutterDesktopRepository
;
bool
_
flutterDesktopEnabled
;
packages/flutter_tools/lib/src/linux/linux_workflow.dart
View file @
c1fabb98
...
...
@@ -21,10 +21,10 @@ class LinuxWorkflow implements Workflow {
bool
get
appliesToHostPlatform
=>
platform
.
isLinux
;
@override
bool
get
canLaunchDevices
=>
hasFlutterDesktopRepository
;
bool
get
canLaunchDevices
=>
flutterDesktopEnabled
;
@override
bool
get
canListDevices
=>
hasFlutterDesktopRepository
;
bool
get
canListDevices
=>
flutterDesktopEnabled
;
@override
bool
get
canListEmulators
=>
false
;
...
...
packages/flutter_tools/lib/src/macos/macos_workflow.dart
View file @
c1fabb98
...
...
@@ -21,10 +21,10 @@ class MacOSWorkflow implements Workflow {
bool
get
appliesToHostPlatform
=>
platform
.
isMacOS
;
@override
bool
get
canLaunchDevices
=>
hasFlutterDesktopRepository
;
bool
get
canLaunchDevices
=>
flutterDesktopEnabled
;
@override
bool
get
canListDevices
=>
hasFlutterDesktopRepository
;
bool
get
canListDevices
=>
flutterDesktopEnabled
;
@override
bool
get
canListEmulators
=>
false
;
...
...
packages/flutter_tools/lib/src/windows/windows_workflow.dart
View file @
c1fabb98
...
...
@@ -21,10 +21,10 @@ class WindowsWorkflow implements Workflow {
bool
get
appliesToHostPlatform
=>
platform
.
isWindows
;
@override
bool
get
canLaunchDevices
=>
hasFlutterDesktopRepository
;
bool
get
canLaunchDevices
=>
flutterDesktopEnabled
;
@override
bool
get
canListDevices
=>
hasFlutterDesktopRepository
;
bool
get
canListDevices
=>
flutterDesktopEnabled
;
@override
bool
get
canListEmulators
=>
false
;
...
...
packages/flutter_tools/test/linux/linux_workflow_test.dart
View file @
c1fabb98
...
...
@@ -4,9 +4,7 @@
import
'package:mockito/mockito.dart'
;
import
'package:flutter_tools/src/linux/linux_workflow.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/platform.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
import
'../src/common.dart'
;
import
'../src/context.dart'
;
...
...
@@ -14,8 +12,11 @@ import '../src/context.dart';
void
main
(
)
{
group
(
LinuxWorkflow
,
()
{
final
MockPlatform
linux
=
MockPlatform
();
final
MockPlatform
linuxWithFde
=
MockPlatform
()
..
environment
[
'FLUTTER_DESKTOP_EMBEDDING'
]
=
'true'
;
final
MockPlatform
notLinux
=
MockPlatform
();
when
(
linux
.
isLinux
).
thenReturn
(
true
);
when
(
linuxWithFde
.
isLinux
).
thenReturn
(
true
);
when
(
notLinux
.
isLinux
).
thenReturn
(
false
);
testUsingContext
(
'Applies to linux platform'
,
()
{
...
...
@@ -29,30 +30,17 @@ void main() {
Platform:
()
=>
notLinux
,
});
final
MockFileSystem
fileSystem
=
MockFileSystem
();
final
MockDirectory
directory
=
MockDirectory
();
Cache
.
flutterRoot
=
''
;
when
(
fileSystem
.
directory
(
Cache
.
flutterRoot
)).
thenReturn
(
directory
);
when
(
directory
.
parent
).
thenReturn
(
directory
);
when
(
directory
.
childDirectory
(
'flutter-desktop-embedding'
)).
thenReturn
(
directory
);
when
(
directory
.
existsSync
()).
thenReturn
(
true
);
testUsingContext
(
'defaults'
,
()
{
expect
(
linuxWorkflow
.
canListEmulators
,
false
);
expect
(
linuxWorkflow
.
canLaunchDevices
,
true
);
expect
(
linuxWorkflow
.
canListDevices
,
true
);
},
overrides:
<
Type
,
Generator
>{
Platform:
()
=>
linux
,
FileSystem:
()
=>
fileSystem
,
Platform:
()
=>
linuxWithFde
});
});
}
class
MockFileSystem
extends
Mock
implements
FileSystem
{}
class
MockDirectory
extends
Mock
implements
Directory
{}
class
MockPlatform
extends
Mock
implements
Platform
{
@override
Map
<
String
,
String
>
get
environment
=>
const
<
String
,
String
>{};
final
Map
<
String
,
String
>
environment
=
<
String
,
String
>{};
}
packages/flutter_tools/test/macos/macos_workflow_test.dart
View file @
c1fabb98
...
...
@@ -4,9 +4,7 @@
import
'package:mockito/mockito.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/platform.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/macos/macos_workflow.dart'
;
import
'../src/common.dart'
;
...
...
@@ -15,8 +13,11 @@ import '../src/context.dart';
void
main
(
)
{
group
(
MacOSWorkflow
,
()
{
final
MockPlatform
mac
=
MockPlatform
();
final
MockPlatform
macWithFde
=
MockPlatform
()
..
environment
[
'FLUTTER_DESKTOP_EMBEDDING'
]
=
'true'
;
final
MockPlatform
notMac
=
MockPlatform
();
when
(
mac
.
isMacOS
).
thenReturn
(
true
);
when
(
macWithFde
.
isMacOS
).
thenReturn
(
true
);
when
(
notMac
.
isMacOS
).
thenReturn
(
false
);
testUsingContext
(
'Applies to mac platform'
,
()
{
...
...
@@ -30,30 +31,17 @@ void main() {
Platform:
()
=>
notMac
,
});
final
MockFileSystem
fileSystem
=
MockFileSystem
();
final
MockDirectory
directory
=
MockDirectory
();
Cache
.
flutterRoot
=
''
;
when
(
fileSystem
.
directory
(
Cache
.
flutterRoot
)).
thenReturn
(
directory
);
when
(
directory
.
parent
).
thenReturn
(
directory
);
when
(
directory
.
childDirectory
(
'flutter-desktop-embedding'
)).
thenReturn
(
directory
);
when
(
directory
.
existsSync
()).
thenReturn
(
true
);
testUsingContext
(
'defaults'
,
()
{
expect
(
macOSWorkflow
.
canListEmulators
,
false
);
expect
(
macOSWorkflow
.
canLaunchDevices
,
true
);
expect
(
macOSWorkflow
.
canListDevices
,
true
);
},
overrides:
<
Type
,
Generator
>{
Platform:
()
=>
mac
,
FileSystem:
()
=>
fileSystem
,
Platform:
()
=>
macWithFde
,
});
});
}
class
MockFileSystem
extends
Mock
implements
FileSystem
{}
class
MockDirectory
extends
Mock
implements
Directory
{}
class
MockPlatform
extends
Mock
implements
Platform
{
@override
Map
<
String
,
String
>
get
environment
=>
const
<
String
,
String
>{};
Map
<
String
,
String
>
environment
=
<
String
,
String
>{};
}
packages/flutter_tools/test/windows/windows_workflow_test.dart
View file @
c1fabb98
...
...
@@ -4,9 +4,7 @@
import
'package:mockito/mockito.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/platform.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/windows/windows_workflow.dart'
;
import
'../src/common.dart'
;
...
...
@@ -15,8 +13,11 @@ import '../src/context.dart';
void
main
(
)
{
group
(
WindowsWorkflow
,
()
{
final
MockPlatform
windows
=
MockPlatform
();
final
MockPlatform
windowsWithFde
=
MockPlatform
()
..
environment
[
'FLUTTER_DESKTOP_EMBEDDING'
]
=
'true'
;
final
MockPlatform
notWindows
=
MockPlatform
();
when
(
windows
.
isWindows
).
thenReturn
(
true
);
when
(
windowsWithFde
.
isWindows
).
thenReturn
(
true
);
when
(
notWindows
.
isWindows
).
thenReturn
(
false
);
testUsingContext
(
'Applies to windows platform'
,
()
{
...
...
@@ -30,30 +31,17 @@ void main() {
Platform:
()
=>
notWindows
,
});
final
MockFileSystem
fileSystem
=
MockFileSystem
();
final
MockDirectory
directory
=
MockDirectory
();
Cache
.
flutterRoot
=
''
;
when
(
fileSystem
.
directory
(
Cache
.
flutterRoot
)).
thenReturn
(
directory
);
when
(
directory
.
parent
).
thenReturn
(
directory
);
when
(
directory
.
childDirectory
(
'flutter-desktop-embedding'
)).
thenReturn
(
directory
);
when
(
directory
.
existsSync
()).
thenReturn
(
true
);
testUsingContext
(
'defaults'
,
()
{
expect
(
windowsWorkflow
.
canListEmulators
,
false
);
expect
(
windowsWorkflow
.
canLaunchDevices
,
true
);
expect
(
windowsWorkflow
.
canListDevices
,
true
);
},
overrides:
<
Type
,
Generator
>{
Platform:
()
=>
windows
,
FileSystem:
()
=>
fileSystem
,
Platform:
()
=>
windowsWithFde
,
});
});
}
class
MockFileSystem
extends
Mock
implements
FileSystem
{}
class
MockDirectory
extends
Mock
implements
Directory
{}
class
MockPlatform
extends
Mock
implements
Platform
{
@override
Map
<
String
,
String
>
get
environment
=>
const
<
String
,
String
>{};
final
Map
<
String
,
String
>
environment
=
<
String
,
String
>{};
}
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