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
4e650a89
Commit
4e650a89
authored
Aug 26, 2015
by
Hans Muller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix ProgressIndicators and add a regression test
Added some unit test infrasture for checking layers.
parent
bb38d1d9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
2 deletions
+52
-2
progress_indicator.dart
packages/flutter/lib/widgets/progress_indicator.dart
+3
-2
build_utils.dart
packages/unit/test/widget/build_utils.dart
+25
-0
progress_indicator_test.dart
packages/unit/test/widget/progress_indicator_test.dart
+24
-0
No files found.
packages/flutter/lib/widgets/progress_indicator.dart
View file @
4e650a89
...
...
@@ -31,6 +31,7 @@ abstract class ProgressIndicator extends StatefulComponent {
double
get
_animationValue
=>
(
_animation
.
variable
as
AnimatedValue
<
double
>).
value
;
Color
get
_backgroundColor
=>
Theme
.
of
(
this
).
primarySwatch
[
200
];
Color
get
_valueColor
=>
Theme
.
of
(
this
).
primaryColor
;
Object
get
_customPaintToken
=>
value
!=
null
?
value
:
_animationValue
;
void
initState
()
{
_animation
=
new
AnimationPerformance
()
...
...
@@ -92,7 +93,7 @@ class LinearProgressIndicator extends ProgressIndicator {
Widget
_buildIndicator
()
{
return
new
Container
(
child:
new
CustomPaint
(
callback:
_paint
),
child:
new
CustomPaint
(
callback:
_paint
,
token:
_customPaintToken
),
constraints:
new
BoxConstraints
.
tightFor
(
width:
double
.
INFINITY
,
height:
_kLinearProgressIndicatorHeight
...
...
@@ -138,7 +139,7 @@ class CircularProgressIndicator extends ProgressIndicator {
Widget
_buildIndicator
()
{
return
new
Container
(
child:
new
CustomPaint
(
callback:
_paint
),
child:
new
CustomPaint
(
callback:
_paint
,
token:
_customPaintToken
),
constraints:
new
BoxConstraints
(
minWidth:
_kMinCircularProgressIndicatorSize
,
minHeight:
_kMinCircularProgressIndicatorSize
...
...
packages/unit/test/widget/build_utils.dart
View file @
4e650a89
...
...
@@ -9,6 +9,7 @@ class TestRenderView extends RenderView {
attach
();
rootConstraints
=
new
ViewConstraints
(
size:
_kTestViewSize
);
scheduleInitialLayout
();
scheduleInitialPaint
(
new
TransformLayer
(
transform:
new
Matrix4
.
identity
()));
}
}
...
...
@@ -63,6 +64,20 @@ class WidgetTester {
TestApp
_app
;
RenderView
_renderView
;
List
<
Layer
>
_layers
(
Layer
layer
)
{
List
<
Layer
>
result
=
[
layer
];
if
(
layer
is
ContainerLayer
)
{
ContainerLayer
root
=
layer
;
Layer
child
=
root
.
firstChild
;
while
(
child
!=
null
)
{
result
.
addAll
(
_layers
(
child
));
child
=
child
.
nextSibling
;
}
}
return
result
;
}
List
<
Layer
>
get
layers
=>
_layers
(
_renderView
.
layer
);
void
walkWidgets
(
WidgetTreeWalker
walker
)
{
void
walk
(
Widget
widget
)
{
walker
(
widget
);
...
...
@@ -113,4 +128,14 @@ class WidgetTester {
Component
.
flushBuild
();
RenderObject
.
flushLayout
();
}
// TODO(hansmuller): just having one pumpFrame() fn would be preferable.
void
pumpPaintFrame
(
WidgetBuilder
builder
)
{
_app
.
builder
=
builder
;
Component
.
flushBuild
();
RenderObject
.
flushLayout
();
_renderView
.
updateCompositingBits
();
RenderObject
.
flushPaint
();
}
}
packages/unit/test/widget/progress_indicator_test.dart
0 → 100644
View file @
4e650a89
import
'package:sky/rendering.dart'
;
import
'package:sky/widgets.dart'
;
import
'package:test/test.dart'
;
import
'build_utils.dart'
;
void
main
(
)
{
test
(
'LinearProgressIndicator changes when its value changes'
,
()
{
WidgetTester
tester
=
new
WidgetTester
();
tester
.
pumpPaintFrame
(()
{
return
new
Block
([
new
LinearProgressIndicator
(
value:
0.0
)]);
});
List
<
Layer
>
layers1
=
tester
.
layers
;
tester
.
pumpPaintFrame
(()
{
return
new
Block
([
new
LinearProgressIndicator
(
value:
0.5
)]);
});
List
<
Layer
>
layers2
=
tester
.
layers
;
expect
(
layers1
,
isNot
(
equals
(
layers2
)));
});
}
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