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
3c0f3f4e
Unverified
Commit
3c0f3f4e
authored
Jan 19, 2022
by
Jenn Magder
Committed by
GitHub
Jan 19, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add boxes around version freshness alerts (#96152)
parent
5d5958f3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
35 deletions
+18
-35
version.dart
packages/flutter_tools/lib/src/version.dart
+9
-22
version_test.dart
packages/flutter_tools/test/general.shard/version_test.dart
+9
-13
No files found.
packages/flutter_tools/lib/src/version.dart
View file @
3c0f3f4e
...
...
@@ -879,7 +879,7 @@ class VersionFreshnessValidator {
final
String
updateMessage
;
switch
(
remoteVersionStatus
)
{
case
VersionCheckResult
.
newVersionAvailable
:
updateMessage
=
newVersionAvailableMessage
()
;
updateMessage
=
_newVersionAvailableMessage
;
break
;
case
VersionCheckResult
.
versionIsCurrent
:
case
VersionCheckResult
.
unknown
:
...
...
@@ -887,7 +887,7 @@ class VersionFreshnessValidator {
break
;
}
logger
.
print
Status
(
updateMessage
,
emphasis:
tru
e
);
logger
.
print
Box
(
updateMessag
e
);
await
Future
.
wait
<
void
>(<
Future
<
void
>>[
stamp
.
store
(
newTimeWarningWasPrinted:
now
,
...
...
@@ -900,26 +900,13 @@ class VersionFreshnessValidator {
@visibleForTesting
String
versionOutOfDateMessage
(
Duration
frameworkAge
)
{
String
warning
=
'WARNING: your installation of Flutter is
${frameworkAge.inDays}
days old.'
;
// Append enough spaces to match the message box width.
warning
+=
' '
*
(
74
-
warning
.
length
);
return
'''
╔════════════════════════════════════════════════════════════════════════════╗
║
$warning
║
║ ║
║ To update to the latest version, run "flutter upgrade". ║
╚════════════════════════════════════════════════════════════════════════════╝
'''
;
}
WARNING: your installation of Flutter is
${frameworkAge.inDays}
days old.
@visibleForTesting
String
newVersionAvailableMessage
(
)
{
return
'''
╔════════════════════════════════════════════════════════════════════════════╗
║ A new version of Flutter is available! ║
║ ║
║ To update to the latest version, run "flutter upgrade". ║
╚════════════════════════════════════════════════════════════════════════════╝
'''
;
To update to the latest version, run "flutter upgrade".'''
;
}
const
String
_newVersionAvailableMessage
=
'''
A new version of Flutter is available!
To update to the latest version, run "flutter upgrade".'''
;
packages/flutter_tools/test/general.shard/version_test.dart
View file @
3c0f3f4e
...
...
@@ -134,7 +134,7 @@ void main() {
expect
(
flutterVersion
.
getVersionString
(
redactUnknownBranches:
true
),
'
$channel
/1234abcd'
);
expect
(
flutterVersion
.
getBranchName
(
redactUnknownBranches:
true
),
channel
);
_expectVersionMessage
(
''
,
testLogger
);
expect
(
testLogger
.
statusText
,
isEmpty
);
expect
(
processManager
.
hasRemainingExpectations
,
isFalse
);
},
overrides:
<
Type
,
Generator
>{
FlutterVersion:
()
=>
FlutterVersion
(
clock:
_testClock
),
...
...
@@ -160,7 +160,7 @@ void main() {
latestFlutterCommitDate:
getChannelOutOfDateVersion
(),
).
run
();
_expectVersionMessage
(
''
,
logger
);
expect
(
logger
.
statusText
,
isEmpty
);
});
testWithoutContext
(
'does not ping server when version stamp is up-to-date'
,
()
async
{
...
...
@@ -181,7 +181,7 @@ void main() {
latestFlutterCommitDate:
getChannelUpToDateVersion
(),
).
run
();
_expectVersionMessage
(
newVersionAvailableMessage
(),
logger
);
expect
(
logger
.
statusText
,
contains
(
'A new version of Flutter is available!'
)
);
expect
(
cache
.
setVersionStamp
,
true
);
});
...
...
@@ -204,7 +204,7 @@ void main() {
latestFlutterCommitDate:
getChannelUpToDateVersion
(),
).
run
();
_expectVersionMessage
(
''
,
logger
);
expect
(
logger
.
statusText
,
isEmpty
);
});
testWithoutContext
(
'pings server when version stamp is missing'
,
()
async
{
...
...
@@ -221,7 +221,7 @@ void main() {
latestFlutterCommitDate:
getChannelUpToDateVersion
(),
).
run
();
_expectVersionMessage
(
newVersionAvailableMessage
(),
logger
);
expect
(
logger
.
statusText
,
contains
(
'A new version of Flutter is available!'
)
);
expect
(
cache
.
setVersionStamp
,
true
);
});
...
...
@@ -243,7 +243,7 @@ void main() {
latestFlutterCommitDate:
getChannelUpToDateVersion
(),
).
run
();
_expectVersionMessage
(
newVersionAvailableMessage
(),
logger
);
expect
(
logger
.
statusText
,
contains
(
'A new version of Flutter is available!'
)
);
});
testWithoutContext
(
'does not print warning when unable to connect to server if not out of date'
,
()
async
{
...
...
@@ -260,7 +260,7 @@ void main() {
// latestFlutterCommitDate defaults to null because we failed to get remote version
).
run
();
_expectVersionMessage
(
''
,
logger
);
expect
(
logger
.
statusText
,
isEmpty
);
});
testWithoutContext
(
'prints warning when unable to connect to server if really out of date'
,
()
async
{
...
...
@@ -281,7 +281,8 @@ void main() {
// latestFlutterCommitDate defaults to null because we failed to get remote version
).
run
();
_expectVersionMessage
(
versionOutOfDateMessage
(
_testClock
.
now
().
difference
(
getChannelOutOfDateVersion
())),
logger
);
final
Duration
frameworkAge
=
_testClock
.
now
().
difference
(
getChannelOutOfDateVersion
());
expect
(
logger
.
statusText
,
contains
(
'WARNING: your installation of Flutter is
${frameworkAge.inDays}
days old.'
));
});
group
(
'
$VersionCheckStamp
for
$channel
'
,
()
{
...
...
@@ -593,11 +594,6 @@ void main() {
});
}
void
_expectVersionMessage
(
String
message
,
BufferLogger
logger
)
{
expect
(
logger
.
statusText
.
trim
(),
message
.
trim
());
logger
.
clear
();
}
class
FakeCache
extends
Fake
implements
Cache
{
String
versionStamp
;
bool
setVersionStamp
=
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