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
75486143
Unverified
Commit
75486143
authored
Jun 05, 2019
by
Jonah Williams
Committed by
GitHub
Jun 05, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent windows web doctor from launching chrome (#33874)
parent
b7a9a75b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
85 additions
and
12 deletions
+85
-12
web_device.dart
packages/flutter_tools/lib/src/web/web_device.dart
+30
-8
devices_test.dart
packages/flutter_tools/test/web/devices_test.dart
+55
-4
No files found.
packages/flutter_tools/lib/src/web/web_device.dart
View file @
75486143
...
@@ -2,12 +2,15 @@
...
@@ -2,12 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
import
'package:meta/meta.dart'
;
import
'../application_package.dart'
;
import
'../application_package.dart'
;
import
'../asset.dart'
;
import
'../asset.dart'
;
import
'../base/common.dart'
;
import
'../base/common.dart'
;
import
'../base/file_system.dart'
;
import
'../base/file_system.dart'
;
import
'../base/io.dart'
;
import
'../base/io.dart'
;
import
'../base/logger.dart'
;
import
'../base/logger.dart'
;
import
'../base/platform.dart'
;
import
'../base/process_manager.dart'
;
import
'../base/process_manager.dart'
;
import
'../build_info.dart'
;
import
'../build_info.dart'
;
import
'../bundle.dart'
;
import
'../bundle.dart'
;
...
@@ -82,15 +85,29 @@ class WebDevice extends Device {
...
@@ -82,15 +85,29 @@ class WebDevice extends Device {
@override
@override
Future
<
String
>
get
sdkNameAndVersion
async
{
Future
<
String
>
get
sdkNameAndVersion
async
{
// See https://bugs.chromium.org/p/chromium/issues/detail?id=158372
String
version
=
'unknown'
;
if
(
platform
.
isWindows
)
{
final
ProcessResult
result
=
await
processManager
.
run
(<
String
>[
r'reg'
,
'query'
,
'HKEY_CURRENT_USER
\\
Software
\\
Google
\\
Chrome
\\
BLBeacon'
,
'/v'
,
'version'
]);
if
(
result
.
exitCode
==
0
)
{
final
List
<
String
>
parts
=
result
.
stdout
.
split
(
RegExp
(
r'\s+'
));
if
(
parts
.
length
>
2
)
{
version
=
'Google Chrome '
+
parts
[
parts
.
length
-
2
];
}
}
}
else
{
final
String
chrome
=
findChromeExecutable
();
final
String
chrome
=
findChromeExecutable
();
final
ProcessResult
result
=
await
processManager
.
run
(<
String
>[
final
ProcessResult
result
=
await
processManager
.
run
(<
String
>[
chrome
,
chrome
,
'--version'
,
'--version'
,
]);
]);
if
(
result
.
exitCode
==
0
)
{
if
(
result
.
exitCode
==
0
)
{
return
result
.
stdout
;
version
=
result
.
stdout
;
}
}
}
return
'unknown'
;
return
version
;
}
}
@override
@override
...
@@ -199,3 +216,8 @@ class WebDevices extends PollingDeviceDiscovery {
...
@@ -199,3 +216,8 @@ class WebDevices extends PollingDeviceDiscovery {
@override
@override
bool
get
supportsPlatform
=>
flutterWebEnabled
;
bool
get
supportsPlatform
=>
flutterWebEnabled
;
}
}
@visibleForTesting
String
parseVersionForWindows
(
String
input
)
{
return
input
.
split
(
RegExp
(
'
\
w'
)).
last
;
}
packages/flutter_tools/test/web/devices_test.dart
View file @
75486143
...
@@ -3,24 +3,31 @@
...
@@ -3,24 +3,31 @@
// found in the LICENSE file.
// found in the LICENSE file.
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/io.dart'
;
import
'package:flutter_tools/src/base/platform.dart'
;
import
'package:flutter_tools/src/base/platform.dart'
;
import
'package:flutter_tools/src/project.dart'
;
import
'package:flutter_tools/src/project.dart'
;
import
'package:flutter_tools/src/web/chrome.dart'
;
import
'package:flutter_tools/src/web/chrome.dart'
;
import
'package:flutter_tools/src/web/compile.dart'
;
import
'package:flutter_tools/src/web/compile.dart'
;
import
'package:flutter_tools/src/web/web_device.dart'
;
import
'package:flutter_tools/src/web/web_device.dart'
;
import
'package:mockito/mockito.dart'
;
import
'package:mockito/mockito.dart'
;
import
'package:process/process.dart'
;
import
'../src/common.dart'
;
import
'../src/common.dart'
;
import
'../src/context.dart'
;
import
'../src/context.dart'
;
void
main
(
)
{
void
main
(
)
{
group
(
WebDevice
,
()
{
group
(
WebDevice
,
()
{
final
MockWebCompiler
mockWebCompiler
=
MockWebCompiler
()
;
MockWebCompiler
mockWebCompiler
;
final
MockChromeLauncher
mockChromeLauncher
=
MockChromeLauncher
()
;
MockChromeLauncher
mockChromeLauncher
;
final
MockPlatform
mockPlatform
=
MockPlatform
()
;
MockPlatform
mockPlatform
;
FlutterProject
flutterProject
;
FlutterProject
flutterProject
;
MockProcessManager
mockProcessManager
;
setUp
(()
async
{
setUp
(()
async
{
mockProcessManager
=
MockProcessManager
();
mockChromeLauncher
=
MockChromeLauncher
();
mockPlatform
=
MockPlatform
();
mockWebCompiler
=
MockWebCompiler
();
flutterProject
=
FlutterProject
.
fromPath
(
fs
.
path
.
join
(
getFlutterRoot
(),
'dev'
,
'integration_tests'
,
'web'
));
flutterProject
=
FlutterProject
.
fromPath
(
fs
.
path
.
join
(
getFlutterRoot
(),
'dev'
,
'integration_tests'
,
'web'
));
when
(
mockWebCompiler
.
compileDart2js
(
when
(
mockWebCompiler
.
compileDart2js
(
target:
anyNamed
(
'target'
),
target:
anyNamed
(
'target'
),
...
@@ -40,10 +47,54 @@ void main() {
...
@@ -40,10 +47,54 @@ void main() {
WebCompiler:
()
=>
mockWebCompiler
,
WebCompiler:
()
=>
mockWebCompiler
,
Platform:
()
=>
mockPlatform
,
Platform:
()
=>
mockPlatform
,
});
});
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
.
run
(<
String
>[
'chrome.foo'
,
'--version'
])).
thenAnswer
((
Invocation
invocation
)
async
{
return
MockProcessResult
(
0
,
'ABC'
);
});
final
WebDevice
webDevice
=
WebDevice
();
expect
(
await
webDevice
.
sdkNameAndVersion
,
'ABC'
);
},
overrides:
<
Type
,
Generator
>{
Platform:
()
=>
mockPlatform
,
ProcessManager:
()
=>
mockProcessManager
,
});
testUsingContext
(
'Invokes different version command on windows.'
,
()
async
{
when
(
mockPlatform
.
isWindows
).
thenReturn
(
true
);
when
(
mockProcessManager
.
run
(<
String
>[
'reg'
,
'query'
,
'HKEY_CURRENT_USER
\\
Software
\\
Google
\\
Chrome
\\
BLBeacon'
,
'/v'
,
'version'
,
])).
thenAnswer
((
Invocation
invocation
)
async
{
return
MockProcessResult
(
0
,
r'HKEY_CURRENT_USER\Software\Google\Chrome\BLBeacon\ version REG_SZ 74.0.0 A'
);
});
final
WebDevice
webDevice
=
WebDevice
();
expect
(
await
webDevice
.
sdkNameAndVersion
,
'Google Chrome 74.0.0'
);
},
overrides:
<
Type
,
Generator
>{
Platform:
()
=>
mockPlatform
,
ProcessManager:
()
=>
mockProcessManager
,
});
});
});
}
}
class
MockChromeLauncher
extends
Mock
implements
ChromeLauncher
{}
class
MockChromeLauncher
extends
Mock
implements
ChromeLauncher
{}
class
MockWebCompiler
extends
Mock
implements
WebCompiler
{}
class
MockWebCompiler
extends
Mock
implements
WebCompiler
{}
class
MockPlatform
extends
Mock
implements
Platform
{}
class
MockPlatform
extends
Mock
implements
Platform
{}
class
MockProcessManager
extends
Mock
implements
ProcessManager
{}
class
MockProcessResult
extends
Mock
implements
ProcessResult
{
MockProcessResult
(
this
.
exitCode
,
this
.
stdout
);
@override
final
int
exitCode
;
@override
final
String
stdout
;
}
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