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
d14a9eaa
Unverified
Commit
d14a9eaa
authored
Mar 02, 2021
by
Jonah Williams
Committed by
GitHub
Mar 02, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] remove chrome launcher, analytics mock from web unit tests (#77066)
parent
ea8e6161
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
97 additions
and
85 deletions
+97
-85
resident_web_runner.dart
...s/flutter_tools/lib/src/isolated/resident_web_runner.dart
+6
-5
chrome.dart
packages/flutter_tools/lib/src/web/chrome.dart
+8
-12
resident_web_runner_test.dart
...er_tools/test/general.shard/resident_web_runner_test.dart
+83
-68
No files found.
packages/flutter_tools/lib/src/isolated/resident_web_runner.dart
View file @
d14a9eaa
...
@@ -569,7 +569,7 @@ class _ResidentWebRunner extends ResidentWebRunner {
...
@@ -569,7 +569,7 @@ class _ResidentWebRunner extends ResidentWebRunner {
String
reason
,
String
reason
,
bool
benchmarkMode
=
false
,
bool
benchmarkMode
=
false
,
})
async
{
})
async
{
final
Stopwatch
timer
=
Stopwatch
()..
start
();
final
DateTime
start
=
globals
.
systemClock
.
now
();
final
Status
status
=
globals
.
logger
.
startProgress
(
final
Status
status
=
globals
.
logger
.
startProgress
(
'Performing hot restart...'
,
'Performing hot restart...'
,
progressId:
'hot.restart'
,
progressId:
'hot.restart'
,
...
@@ -620,12 +620,13 @@ class _ResidentWebRunner extends ResidentWebRunner {
...
@@ -620,12 +620,13 @@ class _ResidentWebRunner extends ResidentWebRunner {
status
.
stop
();
status
.
stop
();
}
}
final
String
elapsed
=
getElapsedAsMilliseconds
(
timer
.
elapsed
);
final
Duration
elapsed
=
globals
.
systemClock
.
now
().
difference
(
start
);
globals
.
printStatus
(
'Restarted application in
$elapsed
.'
);
final
String
elapsedMS
=
getElapsedAsMilliseconds
(
elapsed
);
globals
.
printStatus
(
'Restarted application in
$elapsedMS
.'
);
// Don't track restart times for dart2js builds or web-server devices.
// Don't track restart times for dart2js builds or web-server devices.
if
(
debuggingOptions
.
buildInfo
.
isDebug
&&
deviceIsDebuggable
)
{
if
(
debuggingOptions
.
buildInfo
.
isDebug
&&
deviceIsDebuggable
)
{
globals
.
flutterUsage
.
sendTiming
(
'hot'
,
'web-incremental-restart'
,
timer
.
elapsed
);
globals
.
flutterUsage
.
sendTiming
(
'hot'
,
'web-incremental-restart'
,
elapsed
);
HotEvent
(
HotEvent
(
'restart'
,
'restart'
,
targetPlatform:
getNameForTargetPlatform
(
TargetPlatform
.
web_javascript
),
targetPlatform:
getNameForTargetPlatform
(
TargetPlatform
.
web_javascript
),
...
@@ -633,7 +634,7 @@ class _ResidentWebRunner extends ResidentWebRunner {
...
@@ -633,7 +634,7 @@ class _ResidentWebRunner extends ResidentWebRunner {
emulator:
false
,
emulator:
false
,
fullRestart:
true
,
fullRestart:
true
,
reason:
reason
,
reason:
reason
,
overallTimeInMs:
timer
.
elapsed
.
inMilliseconds
,
overallTimeInMs:
elapsed
.
inMilliseconds
,
fastReassemble:
null
,
fastReassemble:
null
,
).
send
();
).
send
();
}
}
...
...
packages/flutter_tools/lib/src/web/chrome.dart
View file @
d14a9eaa
...
@@ -134,14 +134,10 @@ class ChromiumLauncher {
...
@@ -134,14 +134,10 @@ class ChromiumLauncher {
final
BrowserFinder
_browserFinder
;
final
BrowserFinder
_browserFinder
;
final
Logger
_logger
;
final
Logger
_logger
;
bool
get
hasChromeInstance
=>
_currentCompleter
.
isCompleted
;
bool
get
hasChromeInstance
=>
currentCompleter
.
isCompleted
;
Completer
<
Chromium
>
_currentCompleter
=
Completer
<
Chromium
>();
@visibleForTesting
@visibleForTesting
void
testLaunchChromium
(
Chromium
chromium
)
{
Completer
<
Chromium
>
currentCompleter
=
Completer
<
Chromium
>();
_currentCompleter
.
complete
(
chromium
);
}
/// Whether we can locate the chrome executable.
/// Whether we can locate the chrome executable.
bool
canFindExecutable
()
{
bool
canFindExecutable
()
{
...
@@ -171,7 +167,7 @@ class ChromiumLauncher {
...
@@ -171,7 +167,7 @@ class ChromiumLauncher {
bool
skipCheck
=
false
,
bool
skipCheck
=
false
,
Directory
cacheDir
,
Directory
cacheDir
,
})
async
{
})
async
{
if
(
_
currentCompleter
.
isCompleted
)
{
if
(
currentCompleter
.
isCompleted
)
{
throwToolExit
(
'Only one instance of chrome can be started.'
);
throwToolExit
(
'Only one instance of chrome can be started.'
);
}
}
...
@@ -226,7 +222,7 @@ class ChromiumLauncher {
...
@@ -226,7 +222,7 @@ class ChromiumLauncher {
_cacheUserSessionInformation
(
userDataDir
,
cacheDir
);
_cacheUserSessionInformation
(
userDataDir
,
cacheDir
);
}));
}));
}
}
return
_connect
(
Chromium
.
_
(
return
_connect
(
Chromium
(
port
,
port
,
ChromeConnection
(
'localhost'
,
port
),
ChromeConnection
(
'localhost'
,
port
),
url:
url
,
url:
url
,
...
@@ -358,16 +354,16 @@ class ChromiumLauncher {
...
@@ -358,16 +354,16 @@ class ChromiumLauncher {
'Unable to connect to Chrome debug port:
${chrome.debugPort}
\n
$e
'
);
'Unable to connect to Chrome debug port:
${chrome.debugPort}
\n
$e
'
);
}
}
}
}
_
currentCompleter
.
complete
(
chrome
);
currentCompleter
.
complete
(
chrome
);
return
chrome
;
return
chrome
;
}
}
Future
<
Chromium
>
get
connectedInstance
=>
_
currentCompleter
.
future
;
Future
<
Chromium
>
get
connectedInstance
=>
currentCompleter
.
future
;
}
}
/// A class for managing an instance of a Chromium browser.
/// A class for managing an instance of a Chromium browser.
class
Chromium
{
class
Chromium
{
Chromium
.
_
(
Chromium
(
this
.
debugPort
,
this
.
debugPort
,
this
.
chromeConnection
,
{
this
.
chromeConnection
,
{
this
.
url
,
this
.
url
,
...
@@ -386,7 +382,7 @@ class Chromium {
...
@@ -386,7 +382,7 @@ class Chromium {
Future
<
void
>
close
()
async
{
Future
<
void
>
close
()
async
{
if
(
_chromiumLauncher
.
hasChromeInstance
)
{
if
(
_chromiumLauncher
.
hasChromeInstance
)
{
_chromiumLauncher
.
_
currentCompleter
=
Completer
<
Chromium
>();
_chromiumLauncher
.
currentCompleter
=
Completer
<
Chromium
>();
}
}
chromeConnection
.
close
();
chromeConnection
.
close
();
_process
?.
kill
();
_process
?.
kill
();
...
...
packages/flutter_tools/test/general.shard/resident_web_runner_test.dart
View file @
d14a9eaa
...
@@ -15,6 +15,7 @@ import 'package:flutter_tools/src/base/file_system.dart';
...
@@ -15,6 +15,7 @@ import 'package:flutter_tools/src/base/file_system.dart';
import
'package:flutter_tools/src/base/logger.dart'
;
import
'package:flutter_tools/src/base/logger.dart'
;
import
'package:flutter_tools/src/base/platform.dart'
;
import
'package:flutter_tools/src/base/platform.dart'
;
import
'package:flutter_tools/src/base/terminal.dart'
;
import
'package:flutter_tools/src/base/terminal.dart'
;
import
'package:flutter_tools/src/base/time.dart'
;
import
'package:flutter_tools/src/build_info.dart'
;
import
'package:flutter_tools/src/build_info.dart'
;
import
'package:flutter_tools/src/isolated/devfs_web.dart'
;
import
'package:flutter_tools/src/isolated/devfs_web.dart'
;
import
'package:flutter_tools/src/isolated/resident_web_runner.dart'
;
import
'package:flutter_tools/src/isolated/resident_web_runner.dart'
;
...
@@ -87,7 +88,6 @@ void main() {
...
@@ -87,7 +88,6 @@ void main() {
MockFlutterDevice
mockFlutterDevice
;
MockFlutterDevice
mockFlutterDevice
;
MockWebDevFS
mockWebDevFS
;
MockWebDevFS
mockWebDevFS
;
MockResidentCompiler
mockResidentCompiler
;
MockResidentCompiler
mockResidentCompiler
;
MockChrome
mockChrome
;
MockChromeConnection
mockChromeConnection
;
MockChromeConnection
mockChromeConnection
;
MockChromeTab
mockChromeTab
;
MockChromeTab
mockChromeTab
;
MockWipConnection
mockWipConnection
;
MockWipConnection
mockWipConnection
;
...
@@ -97,8 +97,10 @@ void main() {
...
@@ -97,8 +97,10 @@ void main() {
FakeVmServiceHost
fakeVmServiceHost
;
FakeVmServiceHost
fakeVmServiceHost
;
FileSystem
fileSystem
;
FileSystem
fileSystem
;
ProcessManager
processManager
;
ProcessManager
processManager
;
TestUsage
testUsage
;
setUp
(()
{
setUp
(()
{
testUsage
=
TestUsage
();
fileSystem
=
MemoryFileSystem
.
test
();
fileSystem
=
MemoryFileSystem
.
test
();
processManager
=
FakeProcessManager
.
any
();
processManager
=
FakeProcessManager
.
any
();
mockDebugConnection
=
MockDebugConnection
();
mockDebugConnection
=
MockDebugConnection
();
...
@@ -107,7 +109,6 @@ void main() {
...
@@ -107,7 +109,6 @@ void main() {
mockFlutterDevice
=
MockFlutterDevice
();
mockFlutterDevice
=
MockFlutterDevice
();
mockWebDevFS
=
MockWebDevFS
();
mockWebDevFS
=
MockWebDevFS
();
mockResidentCompiler
=
MockResidentCompiler
();
mockResidentCompiler
=
MockResidentCompiler
();
mockChrome
=
MockChrome
();
mockChromeConnection
=
MockChromeConnection
();
mockChromeConnection
=
MockChromeConnection
();
mockChromeTab
=
MockChromeTab
();
mockChromeTab
=
MockChromeTab
();
mockWipConnection
=
MockWipConnection
();
mockWipConnection
=
MockWipConnection
();
...
@@ -153,7 +154,6 @@ void main() {
...
@@ -153,7 +154,6 @@ void main() {
when
(
mockWebDevFS
.
sources
).
thenReturn
(<
Uri
>[]);
when
(
mockWebDevFS
.
sources
).
thenReturn
(<
Uri
>[]);
when
(
mockWebDevFS
.
baseUri
).
thenReturn
(
Uri
.
parse
(
'http://localhost:12345'
));
when
(
mockWebDevFS
.
baseUri
).
thenReturn
(
Uri
.
parse
(
'http://localhost:12345'
));
when
(
mockFlutterDevice
.
generator
).
thenReturn
(
mockResidentCompiler
);
when
(
mockFlutterDevice
.
generator
).
thenReturn
(
mockResidentCompiler
);
when
(
mockChrome
.
chromeConnection
).
thenReturn
(
mockChromeConnection
);
when
(
mockChromeConnection
.
getTab
(
any
)).
thenAnswer
((
Invocation
invocation
)
async
{
when
(
mockChromeConnection
.
getTab
(
any
)).
thenAnswer
((
Invocation
invocation
)
async
{
return
mockChromeTab
;
return
mockChromeTab
;
});
});
...
@@ -521,14 +521,10 @@ void main() {
...
@@ -521,14 +521,10 @@ void main() {
),
),
]);
]);
_setupMocks
();
_setupMocks
();
final
ChromiumLauncher
chromiumLauncher
=
MockChromeLauncher
();
final
TestChromiumLauncher
chromiumLauncher
=
TestChromiumLauncher
();
when
(
chromiumLauncher
.
launch
(
any
,
cacheDir:
anyNamed
(
'cacheDir'
)))
final
Chromium
chrome
=
Chromium
(
1
,
mockChromeConnection
,
chromiumLauncher:
chromiumLauncher
);
.
thenAnswer
((
Invocation
invocation
)
async
{
chromiumLauncher
.
instance
=
chrome
;
return
mockChrome
;
});
when
(
chromiumLauncher
.
connectedInstance
).
thenAnswer
((
Invocation
invocation
)
async
{
return
mockChrome
;
});
when
(
mockFlutterDevice
.
device
).
thenReturn
(
GoogleChromeDevice
(
when
(
mockFlutterDevice
.
device
).
thenReturn
(
GoogleChromeDevice
(
fileSystem:
fileSystem
,
fileSystem:
fileSystem
,
chromiumLauncher:
chromiumLauncher
,
chromiumLauncher:
chromiumLauncher
,
...
@@ -536,8 +532,6 @@ void main() {
...
@@ -536,8 +532,6 @@ void main() {
platform:
FakePlatform
(
operatingSystem:
'linux'
),
platform:
FakePlatform
(
operatingSystem:
'linux'
),
processManager:
FakeProcessManager
.
any
(),
processManager:
FakeProcessManager
.
any
(),
));
));
when
(
chromiumLauncher
.
canFindExecutable
()).
thenReturn
(
true
);
chromiumLauncher
.
testLaunchChromium
(
mockChrome
);
when
(
mockWebDevFS
.
update
(
when
(
mockWebDevFS
.
update
(
mainUri:
anyNamed
(
'mainUri'
),
mainUri:
anyNamed
(
'mainUri'
),
target:
anyNamed
(
'target'
),
target:
anyNamed
(
'target'
),
...
@@ -570,23 +564,21 @@ void main() {
...
@@ -570,23 +564,21 @@ void main() {
expect
(
testLogger
.
statusText
,
contains
(
'Restarted application in'
));
expect
(
testLogger
.
statusText
,
contains
(
'Restarted application in'
));
expect
(
result
.
code
,
0
);
expect
(
result
.
code
,
0
);
verify
(
mockResidentCompiler
.
accept
()).
called
(
2
);
verify
(
mockResidentCompiler
.
accept
()).
called
(
2
);
// ensure that analytics are sent.
final
Map
<
String
,
String
>
config
=
verify
(
globals
.
flutterUsage
.
sendEvent
(
'hot'
,
'restart'
,
// ensure that analytics are sent.
parameters:
captureAnyNamed
(
'parameters'
))).
captured
.
first
as
Map
<
String
,
String
>;
expect
(
testUsage
.
events
,
const
<
TestUsageEvent
>[
TestUsageEvent
(
'hot'
,
'restart'
,
parameters:
<
String
,
String
>{
'cd27'
:
'web-javascript'
,
'cd28'
:
''
,
'cd29'
:
'false'
,
'cd30'
:
'true'
,
'cd13'
:
'0'
}),
expect
(
config
,
allOf
(<
Matcher
>[
]);
containsPair
(
'cd27'
,
'web-javascript'
),
expect
(
testUsage
.
timings
,
const
<
TestTimingEvent
>[
containsPair
(
'cd28'
,
''
),
TestTimingEvent
(
'hot'
,
'web-incremental-restart'
,
Duration
.
zero
),
containsPair
(
'cd29'
,
'false'
),
]);
containsPair
(
'cd30'
,
'true'
),
]));
verify
(
globals
.
flutterUsage
.
sendTiming
(
'hot'
,
'web-incremental-restart'
,
any
)).
called
(
1
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
Usage:
()
=>
MockFlutterUsage
()
,
Usage:
()
=>
testUsage
,
FileSystem:
()
=>
fileSystem
,
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
FakePub
(),
Pub:
()
=>
FakePub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
SystemClock:
()
=>
SystemClock
.
fixed
(
DateTime
(
2001
,
1
,
1
))
});
});
testUsingContext
(
'Can hot restart after attaching'
,
()
async
{
testUsingContext
(
'Can hot restart after attaching'
,
()
async
{
...
@@ -601,15 +593,10 @@ void main() {
...
@@ -601,15 +593,10 @@ void main() {
),
),
]);
]);
_setupMocks
();
_setupMocks
();
final
ChromiumLauncher
chromiumLauncher
=
MockChromeLauncher
();
final
TestChromiumLauncher
chromiumLauncher
=
TestChromiumLauncher
();
when
(
chromiumLauncher
.
launch
(
any
,
cacheDir:
anyNamed
(
'cacheDir'
)))
final
Chromium
chrome
=
Chromium
(
1
,
mockChromeConnection
,
chromiumLauncher:
chromiumLauncher
);
.
thenAnswer
((
Invocation
invocation
)
async
{
chromiumLauncher
.
instance
=
chrome
;
return
mockChrome
;
});
when
(
chromiumLauncher
.
connectedInstance
).
thenAnswer
((
Invocation
invocation
)
async
{
return
mockChrome
;
});
when
(
chromiumLauncher
.
canFindExecutable
()).
thenReturn
(
true
);
when
(
mockFlutterDevice
.
device
).
thenReturn
(
GoogleChromeDevice
(
when
(
mockFlutterDevice
.
device
).
thenReturn
(
GoogleChromeDevice
(
fileSystem:
fileSystem
,
fileSystem:
fileSystem
,
chromiumLauncher:
chromiumLauncher
,
chromiumLauncher:
chromiumLauncher
,
...
@@ -617,7 +604,6 @@ void main() {
...
@@ -617,7 +604,6 @@ void main() {
platform:
FakePlatform
(
operatingSystem:
'linux'
),
platform:
FakePlatform
(
operatingSystem:
'linux'
),
processManager:
FakeProcessManager
.
any
(),
processManager:
FakeProcessManager
.
any
(),
));
));
chromiumLauncher
.
testLaunchChromium
(
mockChrome
);
Uri
entrypointFileUri
;
Uri
entrypointFileUri
;
when
(
mockWebDevFS
.
update
(
when
(
mockWebDevFS
.
update
(
mainUri:
anyNamed
(
'mainUri'
),
mainUri:
anyNamed
(
'mainUri'
),
...
@@ -654,23 +640,21 @@ void main() {
...
@@ -654,23 +640,21 @@ void main() {
expect
(
testLogger
.
statusText
,
contains
(
'Restarted application in'
));
expect
(
testLogger
.
statusText
,
contains
(
'Restarted application in'
));
expect
(
result
.
code
,
0
);
expect
(
result
.
code
,
0
);
verify
(
mockResidentCompiler
.
accept
()).
called
(
2
);
verify
(
mockResidentCompiler
.
accept
()).
called
(
2
);
// ensure that analytics are sent.
// ensure that analytics are sent.
final
Map
<
String
,
String
>
config
=
verify
(
globals
.
flutterUsage
.
sendEvent
(
'hot'
,
'restart'
,
expect
(
testUsage
.
events
,
const
<
TestUsageEvent
>[
parameters:
captureAnyNamed
(
'parameters'
))).
captured
.
first
as
Map
<
String
,
String
>;
TestUsageEvent
(
'hot'
,
'restart'
,
parameters:
<
String
,
String
>{
'cd27'
:
'web-javascript'
,
'cd28'
:
''
,
'cd29'
:
'false'
,
'cd30'
:
'true'
,
'cd13'
:
'0'
}),
]);
expect
(
config
,
allOf
(<
Matcher
>[
expect
(
testUsage
.
timings
,
const
<
TestTimingEvent
>[
containsPair
(
'cd27'
,
'web-javascript'
),
TestTimingEvent
(
'hot'
,
'web-incremental-restart'
,
Duration
.
zero
),
containsPair
(
'cd28'
,
''
),
]);
containsPair
(
'cd29'
,
'false'
),
containsPair
(
'cd30'
,
'true'
),
]));
verify
(
globals
.
flutterUsage
.
sendTiming
(
'hot'
,
'web-incremental-restart'
,
any
)).
called
(
1
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
Usage:
()
=>
MockFlutterUsage
()
,
Usage:
()
=>
testUsage
,
FileSystem:
()
=>
fileSystem
,
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
FakePub
(),
Pub:
()
=>
FakePub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
SystemClock:
()
=>
SystemClock
.
fixed
(
DateTime
(
2001
,
1
,
1
))
});
});
testUsingContext
(
'Can hot restart after attaching with web-server device'
,
()
async
{
testUsingContext
(
'Can hot restart after attaching with web-server device'
,
()
async
{
...
@@ -705,14 +689,17 @@ void main() {
...
@@ -705,14 +689,17 @@ void main() {
expect
(
testLogger
.
statusText
,
contains
(
'Restarted application in'
));
expect
(
testLogger
.
statusText
,
contains
(
'Restarted application in'
));
expect
(
result
.
code
,
0
);
expect
(
result
.
code
,
0
);
verify
(
mockResidentCompiler
.
accept
()).
called
(
2
);
verify
(
mockResidentCompiler
.
accept
()).
called
(
2
);
// ensure that analytics are sent.
verifyNever
(
globals
.
flutterUsage
.
sendTiming
(
'hot'
,
'web-incremental-restart'
,
any
));
// web-server device does not send restart analytics
expect
(
testUsage
.
events
,
isEmpty
);
expect
(
testUsage
.
timings
,
isEmpty
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
Usage:
()
=>
MockFlutterUsage
()
,
Usage:
()
=>
testUsage
,
FileSystem:
()
=>
fileSystem
,
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
FakePub
(),
Pub:
()
=>
FakePub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
SystemClock:
()
=>
SystemClock
.
fixed
(
DateTime
(
2001
,
1
,
1
))
});
});
testUsingContext
(
'web resident runner is debuggable'
,
()
{
testUsingContext
(
'web resident runner is debuggable'
,
()
{
...
@@ -725,6 +712,7 @@ void main() {
...
@@ -725,6 +712,7 @@ void main() {
ProcessManager:
()
=>
processManager
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
FakePub
(),
Pub:
()
=>
FakePub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
SystemClock:
()
=>
SystemClock
.
fixed
(
DateTime
(
2001
,
1
,
1
))
});
});
testUsingContext
(
'Exits when initial compile fails'
,
()
async
{
testUsingContext
(
'Exits when initial compile fails'
,
()
async
{
...
@@ -754,9 +742,10 @@ void main() {
...
@@ -754,9 +742,10 @@ void main() {
));
));
expect
(
await
residentWebRunner
.
run
(),
1
);
expect
(
await
residentWebRunner
.
run
(),
1
);
verifyNever
(
globals
.
flutterUsage
.
sendTiming
(
'hot'
,
'web-restart'
,
any
));
expect
(
testUsage
.
events
,
isEmpty
);
expect
(
testUsage
.
timings
,
isEmpty
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
Usage:
()
=>
MockFlutterUsage
()
,
Usage:
()
=>
testUsage
,
FileSystem:
()
=>
fileSystem
,
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
FakePub
(),
Pub:
()
=>
FakePub
(),
...
@@ -827,9 +816,10 @@ void main() {
...
@@ -827,9 +816,10 @@ void main() {
expect
(
result
.
code
,
1
);
expect
(
result
.
code
,
1
);
expect
(
result
.
message
,
contains
(
'Failed to recompile application.'
));
expect
(
result
.
message
,
contains
(
'Failed to recompile application.'
));
verifyNever
(
globals
.
flutterUsage
.
sendTiming
(
'hot'
,
'web-restart'
,
any
));
expect
(
testUsage
.
events
,
isEmpty
);
expect
(
testUsage
.
timings
,
isEmpty
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
Usage:
()
=>
MockFlutterUsage
()
,
Usage:
()
=>
testUsage
,
FileSystem:
()
=>
fileSystem
,
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
FakePub
(),
Pub:
()
=>
FakePub
(),
...
@@ -1421,14 +1411,11 @@ void main() {
...
@@ -1421,14 +1411,11 @@ void main() {
...
kAttachIsolateExpectations
,
...
kAttachIsolateExpectations
,
]);
]);
_setupMocks
();
_setupMocks
();
final
ChromiumLauncher
chromiumLauncher
=
MockChromeLauncher
();
final
MockChromeConnection
mockChromeConnection
=
MockChromeConnection
();
when
(
chromiumLauncher
.
launch
(
any
,
cacheDir:
anyNamed
(
'cacheDir'
)))
final
TestChromiumLauncher
chromiumLauncher
=
TestChromiumLauncher
();
.
thenAnswer
((
Invocation
invocation
)
async
{
final
Chromium
chrome
=
Chromium
(
1
,
mockChromeConnection
,
chromiumLauncher:
chromiumLauncher
);
return
mockChrome
;
chromiumLauncher
.
instance
=
chrome
;
});
when
(
chromiumLauncher
.
connectedInstance
).
thenAnswer
((
Invocation
invocation
)
async
{
return
mockChrome
;
});
when
(
mockFlutterDevice
.
device
).
thenReturn
(
GoogleChromeDevice
(
when
(
mockFlutterDevice
.
device
).
thenReturn
(
GoogleChromeDevice
(
fileSystem:
fileSystem
,
fileSystem:
fileSystem
,
chromiumLauncher:
chromiumLauncher
,
chromiumLauncher:
chromiumLauncher
,
...
@@ -1436,12 +1423,9 @@ void main() {
...
@@ -1436,12 +1423,9 @@ void main() {
platform:
FakePlatform
(
operatingSystem:
'linux'
),
platform:
FakePlatform
(
operatingSystem:
'linux'
),
processManager:
FakeProcessManager
.
any
(),
processManager:
FakeProcessManager
.
any
(),
));
));
when
(
chromiumLauncher
.
canFindExecutable
()).
thenReturn
(
true
);
when
(
mockWebDevFS
.
create
()).
thenAnswer
((
Invocation
invocation
)
async
{
when
(
mockWebDevFS
.
create
()).
thenAnswer
((
Invocation
invocation
)
async
{
return
Uri
.
parse
(
'http://localhost:8765/app/'
);
return
Uri
.
parse
(
'http://localhost:8765/app/'
);
});
});
final
MockChrome
chrome
=
MockChrome
();
final
MockChromeConnection
mockChromeConnection
=
MockChromeConnection
();
final
MockChromeTab
mockChromeTab
=
MockChromeTab
();
final
MockChromeTab
mockChromeTab
=
MockChromeTab
();
final
MockWipConnection
mockWipConnection
=
MockWipConnection
();
final
MockWipConnection
mockWipConnection
=
MockWipConnection
();
when
(
mockChromeConnection
.
getTab
(
any
)).
thenAnswer
((
Invocation
invocation
)
async
{
when
(
mockChromeConnection
.
getTab
(
any
)).
thenAnswer
((
Invocation
invocation
)
async
{
...
@@ -1450,8 +1434,6 @@ void main() {
...
@@ -1450,8 +1434,6 @@ void main() {
when
(
mockChromeTab
.
connect
()).
thenAnswer
((
Invocation
invocation
)
async
{
when
(
mockChromeTab
.
connect
()).
thenAnswer
((
Invocation
invocation
)
async
{
return
mockWipConnection
;
return
mockWipConnection
;
});
});
when
(
chrome
.
chromeConnection
).
thenReturn
(
mockChromeConnection
);
chromiumLauncher
.
testLaunchChromium
(
chrome
);
final
FakeStatusLogger
fakeStatusLogger
=
globals
.
logger
as
FakeStatusLogger
;
final
FakeStatusLogger
fakeStatusLogger
=
globals
.
logger
as
FakeStatusLogger
;
final
MockStatus
mockStatus
=
MockStatus
();
final
MockStatus
mockStatus
=
MockStatus
();
...
@@ -1642,8 +1624,6 @@ ResidentRunner setUpResidentRunner(FlutterDevice flutterDevice) {
...
@@ -1642,8 +1624,6 @@ ResidentRunner setUpResidentRunner(FlutterDevice flutterDevice) {
)
as
ResidentWebRunner
;
)
as
ResidentWebRunner
;
}
}
class
MockChromeLauncher
extends
Mock
implements
ChromiumLauncher
{}
class
MockFlutterUsage
extends
Mock
implements
Usage
{}
class
MockChromeDevice
extends
Mock
implements
ChromiumDevice
{}
class
MockChromeDevice
extends
Mock
implements
ChromiumDevice
{}
class
MockDebugConnection
extends
Mock
implements
DebugConnection
{}
class
MockDebugConnection
extends
Mock
implements
DebugConnection
{}
class
MockAppConnection
extends
Mock
implements
AppConnection
{}
class
MockAppConnection
extends
Mock
implements
AppConnection
{}
...
@@ -1658,3 +1638,38 @@ class MockWipConnection extends Mock implements WipConnection {}
...
@@ -1658,3 +1638,38 @@ class MockWipConnection extends Mock implements WipConnection {}
class
MockWipDebugger
extends
Mock
implements
WipDebugger
{}
class
MockWipDebugger
extends
Mock
implements
WipDebugger
{}
class
MockWebServerDevice
extends
Mock
implements
WebServerDevice
{}
class
MockWebServerDevice
extends
Mock
implements
WebServerDevice
{}
class
MockDevice
extends
Mock
implements
Device
{}
class
MockDevice
extends
Mock
implements
Device
{}
/// A test implementation of the [ChromiumLauncher] that launches a fixed instance.
class
TestChromiumLauncher
implements
ChromiumLauncher
{
TestChromiumLauncher
();
set
instance
(
Chromium
chromium
)
{
_hasInstance
=
true
;
currentCompleter
.
complete
(
chromium
);
}
bool
_hasInstance
=
false
;
@override
Completer
<
Chromium
>
currentCompleter
=
Completer
<
Chromium
>();
@override
bool
canFindExecutable
()
{
return
true
;
}
@override
Future
<
Chromium
>
get
connectedInstance
=>
currentCompleter
.
future
;
@override
String
findExecutable
()
{
return
'chrome'
;
}
@override
bool
get
hasChromeInstance
=>
_hasInstance
;
@override
Future
<
Chromium
>
launch
(
String
url
,
{
bool
headless
=
false
,
int
debugPort
,
bool
skipCheck
=
false
,
Directory
cacheDir
})
async
{
return
currentCompleter
.
future
;
}
}
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