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
317e4cb0
Unverified
Commit
317e4cb0
authored
Jun 08, 2019
by
Jonah Williams
Committed by
GitHub
Jun 08, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
don't warn on CHROME_EXECUTABLE missing if we've already located it. (#34079)
parent
938e4eb6
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
56 additions
and
19 deletions
+56
-19
doctor.dart
packages/flutter_tools/lib/src/doctor.dart
+13
-0
web_device.dart
packages/flutter_tools/lib/src/web/web_device.dart
+4
-1
web_validator.dart
packages/flutter_tools/lib/src/web/web_validator.dart
+10
-3
workflow.dart
packages/flutter_tools/lib/src/web/workflow.dart
+3
-7
devices_test.dart
packages/flutter_tools/test/web/devices_test.dart
+8
-4
web_validator_test.dart
packages/flutter_tools/test/web/web_validator_test.dart
+17
-4
workflow_test.dart
packages/flutter_tools/test/web/workflow_test.dart
+1
-0
No files found.
packages/flutter_tools/lib/src/doctor.dart
View file @
317e4cb0
...
...
@@ -463,6 +463,19 @@ class ValidationMessage {
@override
String
toString
()
=>
message
;
@override
bool
operator
==(
Object
other
)
{
if
(
other
.
runtimeType
!=
runtimeType
)
{
return
false
;
}
final
ValidationMessage
typedOther
=
other
;
return
typedOther
.
message
==
message
&&
typedOther
.
type
==
type
;
}
@override
int
get
hashCode
=>
type
.
hashCode
^
message
.
hashCode
;
}
class
FlutterValidator
extends
DoctorValidator
{
...
...
packages/flutter_tools/lib/src/web/web_device.dart
View file @
317e4cb0
...
...
@@ -71,7 +71,7 @@ class WebDevice extends Device {
Future
<
bool
>
get
isLocalEmulator
async
=>
false
;
@override
bool
isSupported
()
=>
flutterWebEnabled
;
bool
isSupported
()
=>
flutterWebEnabled
&&
canFindChrome
()
;
@override
String
get
name
=>
'web'
;
...
...
@@ -81,6 +81,9 @@ class WebDevice extends Device {
@override
Future
<
String
>
get
sdkNameAndVersion
async
{
if
(!
isSupported
())
{
return
'unknown'
;
}
// See https://bugs.chromium.org/p/chromium/issues/detail?id=158372
String
version
=
'unknown'
;
if
(
platform
.
isWindows
)
{
...
...
packages/flutter_tools/lib/src/web/web_validator.dart
View file @
317e4cb0
...
...
@@ -17,10 +17,17 @@ class WebValidator extends DoctorValidator {
final
bool
canRunChrome
=
canFindChrome
();
final
List
<
ValidationMessage
>
messages
=
<
ValidationMessage
>[];
if
(
platform
.
environment
.
containsKey
(
kChromeEnvironment
))
{
messages
.
add
(
ValidationMessage
(
'
$kChromeEnvironment
=
$chrome
'
));
if
(!
canRunChrome
)
{
messages
.
add
(
ValidationMessage
.
hint
(
'
$chrome
is not executable.'
));
}
else
{
messages
.
add
(
ValidationMessage
(
'
$kChromeEnvironment
=
$chrome
'
));
}
}
else
{
messages
.
add
(
ValidationMessage
(
'Chrome at
$chrome
'
));
messages
.
add
(
ValidationMessage
.
hint
(
'
$kChromeEnvironment
not set'
));
if
(!
canRunChrome
)
{
messages
.
add
(
ValidationMessage
.
hint
(
'
$kChromeEnvironment
not set'
));
}
else
{
messages
.
add
(
ValidationMessage
(
'Chrome at
$chrome
'
));
}
}
if
(!
canRunChrome
)
{
return
ValidationResult
(
...
...
packages/flutter_tools/lib/src/web/workflow.dart
View file @
317e4cb0
...
...
@@ -3,7 +3,6 @@
// found in the LICENSE file.
import
'../base/context.dart'
;
import
'../base/file_system.dart'
;
import
'../base/platform.dart'
;
import
'../base/process_manager.dart'
;
import
'../doctor.dart'
;
...
...
@@ -40,12 +39,9 @@ class WebWorkflow extends Workflow {
/// Whether we can locate the chrome executable.
bool
canFindChrome
(
)
{
final
String
chrome
=
findChromeExecutable
();
if
(
platform
.
isLinux
)
{
try
{
return
processManager
.
canRun
(
chrome
);
}
else
if
(
platform
.
isMacOS
)
{
return
fs
.
file
(
chrome
).
existsSync
();
}
else
if
(
platform
.
isWindows
)
{
return
fs
.
file
(
chrome
).
existsSync
();
}
on
ArgumentError
{
return
false
;
}
return
false
;
}
packages/flutter_tools/test/web/devices_test.dart
View file @
317e4cb0
...
...
@@ -28,14 +28,13 @@ void main() {
});
testUsingContext
(
'Invokes version command on non-Windows platforms'
,
()
async
{
when
(
mockPlatform
.
isWindows
).
thenReturn
(
false
);
when
(
mockPlatform
.
environment
).
thenReturn
(<
String
,
String
>{
kChromeEnvironment:
'chrome.foo'
});
when
(
mockProcessManager
.
canRun
(
'chrome.foo'
)).
thenReturn
(
true
);
when
(
mockProcessManager
.
run
(<
String
>[
'chrome.foo'
,
'--version'
])).
thenAnswer
((
Invocation
invocation
)
async
{
return
MockProcessResult
(
0
,
'ABC'
);
});
final
WebDevice
webDevice
=
WebDevice
();
expect
(
webDevice
.
isSupported
(),
true
);
expect
(
await
webDevice
.
sdkNameAndVersion
,
'ABC'
);
},
overrides:
<
Type
,
Generator
>{
Platform:
()
=>
mockPlatform
,
...
...
@@ -44,6 +43,7 @@ void main() {
testUsingContext
(
'Invokes different version command on windows.'
,
()
async
{
when
(
mockPlatform
.
isWindows
).
thenReturn
(
true
);
when
(
mockProcessManager
.
canRun
(
'chrome.foo'
)).
thenReturn
(
true
);
when
(
mockProcessManager
.
run
(<
String
>[
'reg'
,
'query'
,
...
...
@@ -55,6 +55,7 @@ void main() {
});
final
WebDevice
webDevice
=
WebDevice
();
expect
(
webDevice
.
isSupported
(),
true
);
expect
(
await
webDevice
.
sdkNameAndVersion
,
'Google Chrome 74.0.0'
);
},
overrides:
<
Type
,
Generator
>{
Platform:
()
=>
mockPlatform
,
...
...
@@ -64,7 +65,10 @@ void main() {
}
class
MockChromeLauncher
extends
Mock
implements
ChromeLauncher
{}
class
MockPlatform
extends
Mock
implements
Platform
{}
class
MockPlatform
extends
Mock
implements
Platform
{
@override
Map
<
String
,
String
>
environment
=
<
String
,
String
>{
'FLUTTER_WEB'
:
'true'
,
kChromeEnvironment:
'chrome.foo'
};
}
class
MockProcessManager
extends
Mock
implements
ProcessManager
{}
class
MockProcessResult
extends
Mock
implements
ProcessResult
{
MockProcessResult
(
this
.
exitCode
,
this
.
stdout
);
...
...
packages/flutter_tools/test/web/web_validator_test.dart
View file @
317e4cb0
...
...
@@ -2,12 +2,12 @@
// 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/base/file_system.dart'
;
import
'package:flutter_tools/src/base/platform.dart'
;
import
'package:flutter_tools/src/doctor.dart'
;
import
'package:flutter_tools/src/web/chrome.dart'
;
import
'package:flutter_tools/src/web/web_validator.dart'
;
import
'package:mockito/mockito.dart'
;
import
'package:process/process.dart'
;
import
'../src/common.dart'
;
import
'../src/testbed.dart'
;
...
...
@@ -17,14 +17,16 @@ void main() {
Testbed
testbed
;
WebValidator
webValidator
;
MockPlatform
mockPlatform
;
MockProcessManager
mockProcessManager
;
setUp
(()
{
mockProcessManager
=
MockProcessManager
();
testbed
=
Testbed
(
setup:
()
{
fs
.
file
(
kMacOSExecutable
).
createSync
(
recursive:
true
);
fs
.
file
(
'chrome_foo'
).
createSync
();
when
(
mockProcessManager
.
canRun
(
kMacOSExecutable
)).
thenReturn
(
true
);
return
null
;
},
overrides:
<
Type
,
Generator
>{
Platform:
()
=>
mockPlatform
,
ProcessManager:
()
=>
mockProcessManager
,
});
webValidator
=
const
WebValidator
();
mockPlatform
=
MockPlatform
();
...
...
@@ -39,10 +41,19 @@ void main() {
}));
test
(
'Can notice missing macOS executable '
,
()
=>
testbed
.
run
(()
async
{
fs
.
file
(
kMacOSExecutable
).
deleteSync
(
);
when
(
mockProcessManager
.
canRun
(
kMacOSExecutable
)).
thenReturn
(
false
);
final
ValidationResult
result
=
await
webValidator
.
validate
();
expect
(
result
.
type
,
ValidationType
.
missing
);
}));
test
(
'Doesn
\'
t warn about CHROME_EXECUTABLE unless it cant find chrome '
,
()
=>
testbed
.
run
(()
async
{
when
(
mockProcessManager
.
canRun
(
kMacOSExecutable
)).
thenReturn
(
false
);
final
ValidationResult
result
=
await
webValidator
.
validate
();
expect
(
result
.
messages
,
<
ValidationMessage
>[
ValidationMessage
.
hint
(
'CHROME_EXECUTABLE not set'
)
]);
expect
(
result
.
type
,
ValidationType
.
missing
);
}));
});
}
...
...
@@ -50,3 +61,5 @@ class MockPlatform extends Mock implements Platform {
@override
Map
<
String
,
String
>
get
environment
=>
const
<
String
,
String
>{};
}
class
MockProcessManager
extends
Mock
implements
ProcessManager
{}
\ No newline at end of file
packages/flutter_tools/test/web/workflow_test.dart
View file @
317e4cb0
...
...
@@ -83,6 +83,7 @@ void main() {
}));
test
(
'does not apply on other platforms'
,
()
=>
testbed
.
run
(()
{
when
(
mockProcessManager
.
canRun
(
'chrome'
)).
thenReturn
(
false
);
expect
(
workflow
.
appliesToHostPlatform
,
false
);
expect
(
workflow
.
canLaunchDevices
,
false
);
expect
(
workflow
.
canListDevices
,
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