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
14f42a6a
Commit
14f42a6a
authored
Jun 28, 2016
by
Adam Barth
Committed by
GitHub
Jun 28, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve test coverage in rendering.dart (#4775)
parent
bb0c41f2
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
135 additions
and
22 deletions
+135
-22
rendering.dart
packages/flutter/lib/rendering.dart
+2
-1
block.dart
packages/flutter/lib/src/rendering/block.dart
+6
-6
box.dart
packages/flutter/lib/src/rendering/box.dart
+0
-15
tweens.dart
packages/flutter/lib/src/rendering/tweens.dart
+21
-0
box_constraints_test.dart
packages/flutter/test/rendering/box_constraints_test.dart
+106
-0
No files found.
packages/flutter/lib/rendering.dart
View file @
14f42a6a
...
...
@@ -48,6 +48,7 @@ export 'src/rendering/semantics.dart';
export
'src/rendering/shifted_box.dart'
;
export
'src/rendering/stack.dart'
;
export
'src/rendering/table.dart'
;
export
'src/rendering/tweens.dart'
;
export
'src/rendering/view.dart'
;
export
'src/rendering/viewport.dart'
;
...
...
packages/flutter/lib/src/rendering/block.dart
View file @
14f42a6a
...
...
@@ -51,13 +51,13 @@ class RenderBlock extends RenderBox
}
BoxConstraints
_getInnerConstraints
(
BoxConstraints
constraints
)
{
assert
(
_mainAxis
!=
null
);
switch
(
_mainAxis
)
{
case
Axis
.
horizontal
:
return
new
BoxConstraints
.
tightFor
(
height:
constraints
.
maxHeight
);
case
Axis
.
vertical
:
return
new
BoxConstraints
.
tightFor
(
width:
constraints
.
maxWidth
);
}
assert
(
_mainAxis
!=
null
);
return
null
;
}
...
...
@@ -66,13 +66,13 @@ class RenderBlock extends RenderBox
if
(
child
==
null
)
return
0.0
;
BoxParentData
parentData
=
child
.
parentData
;
assert
(
mainAxis
!=
null
);
switch
(
mainAxis
)
{
case
Axis
.
horizontal
:
return
parentData
.
offset
.
dx
+
child
.
size
.
width
;
case
Axis
.
vertical
:
return
parentData
.
offset
.
dy
+
child
.
size
.
height
;
}
assert
(
mainAxis
!=
null
);
return
null
;
}
...
...
@@ -183,49 +183,49 @@ class RenderBlock extends RenderBox
@override
double
computeMinIntrinsicWidth
(
double
height
)
{
assert
(
mainAxis
!=
null
);
switch
(
mainAxis
)
{
case
Axis
.
horizontal
:
return
_getIntrinsicMainAxis
((
RenderBox
child
)
=>
child
.
getMinIntrinsicWidth
(
height
));
case
Axis
.
vertical
:
return
_getIntrinsicCrossAxis
((
RenderBox
child
)
=>
child
.
getMinIntrinsicWidth
(
height
));
}
assert
(
mainAxis
!=
null
);
return
null
;
}
@override
double
computeMaxIntrinsicWidth
(
double
height
)
{
assert
(
mainAxis
!=
null
);
switch
(
mainAxis
)
{
case
Axis
.
horizontal
:
return
_getIntrinsicMainAxis
((
RenderBox
child
)
=>
child
.
getMaxIntrinsicWidth
(
height
));
case
Axis
.
vertical
:
return
_getIntrinsicCrossAxis
((
RenderBox
child
)
=>
child
.
getMaxIntrinsicWidth
(
height
));
}
assert
(
mainAxis
!=
null
);
return
null
;
}
@override
double
computeMinIntrinsicHeight
(
double
width
)
{
assert
(
mainAxis
!=
null
);
switch
(
mainAxis
)
{
case
Axis
.
horizontal
:
return
_getIntrinsicMainAxis
((
RenderBox
child
)
=>
child
.
getMinIntrinsicHeight
(
width
));
case
Axis
.
vertical
:
return
_getIntrinsicCrossAxis
((
RenderBox
child
)
=>
child
.
getMinIntrinsicHeight
(
width
));
}
assert
(
mainAxis
!=
null
);
return
null
;
}
@override
double
computeMaxIntrinsicHeight
(
double
width
)
{
assert
(
mainAxis
!=
null
);
switch
(
mainAxis
)
{
case
Axis
.
horizontal
:
return
_getIntrinsicMainAxis
((
RenderBox
child
)
=>
child
.
getMaxIntrinsicHeight
(
width
));
case
Axis
.
vertical
:
return
_getIntrinsicCrossAxis
((
RenderBox
child
)
=>
child
.
getMaxIntrinsicHeight
(
width
));
}
assert
(
mainAxis
!=
null
);
return
null
;
}
...
...
packages/flutter/lib/src/rendering/box.dart
View file @
14f42a6a
...
...
@@ -5,7 +5,6 @@
import
'dart:math'
as
math
;
import
'dart:ui'
as
ui
show
lerpDouble
;
import
'package:flutter/animation.dart'
;
import
'package:flutter/gestures.dart'
;
import
'package:meta/meta.dart'
;
import
'package:vector_math/vector_math_64.dart'
;
...
...
@@ -1456,17 +1455,3 @@ abstract class RenderBoxContainerDefaultsMixin<ChildType extends RenderBox, Pare
return
result
;
}
}
/// An interpolation between two fractional offsets.
///
/// This class specializes the interpolation of Tween<FractionalOffset> to be
/// appropriate for rectangles.
class
FractionalOffsetTween
extends
Tween
<
FractionalOffset
>
{
/// Creates a fractional offset tween.
///
/// The [begin] and [end] arguments must not be null.
FractionalOffsetTween
({
FractionalOffset
begin
,
FractionalOffset
end
})
:
super
(
begin:
begin
,
end:
end
);
@override
FractionalOffset
lerp
(
double
t
)
=>
FractionalOffset
.
lerp
(
begin
,
end
,
t
);
}
packages/flutter/lib/src/rendering/tweens.dart
0 → 100644
View file @
14f42a6a
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter/animation.dart'
;
import
'package:flutter/painting.dart'
;
/// An interpolation between two fractional offsets.
///
/// This class specializes the interpolation of Tween<FractionalOffset> to be
/// appropriate for rectangles.
class
FractionalOffsetTween
extends
Tween
<
FractionalOffset
>
{
/// Creates a fractional offset tween.
///
/// The [begin] and [end] arguments must not be null.
FractionalOffsetTween
({
FractionalOffset
begin
,
FractionalOffset
end
})
:
super
(
begin:
begin
,
end:
end
);
@override
FractionalOffset
lerp
(
double
t
)
=>
FractionalOffset
.
lerp
(
begin
,
end
,
t
);
}
packages/flutter/test/rendering/box_constraints_test.dart
0 → 100644
View file @
14f42a6a
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter/rendering.dart'
;
import
'package:test/test.dart'
;
void
main
(
)
{
test
(
'BoxConstraints toString'
,
()
{
expect
(
const
BoxConstraints
.
expand
().
toString
(),
contains
(
'biggest'
));
expect
(
new
BoxConstraints
().
toString
(),
contains
(
'unconstrained'
));
expect
(
new
BoxConstraints
.
tightFor
(
width:
50.0
).
toString
(),
contains
(
'w=50'
));
});
test
(
'BoxConstraints copyWith'
,
()
{
BoxConstraints
constraints
=
new
BoxConstraints
(
minWidth:
3.0
,
maxWidth:
7.0
,
minHeight:
11.0
,
maxHeight:
17.0
);
BoxConstraints
copy
=
constraints
.
copyWith
();
expect
(
copy
,
equals
(
constraints
));
copy
=
constraints
.
copyWith
(
minWidth:
13.0
,
maxWidth:
17.0
,
minHeight:
111.0
,
maxHeight:
117.0
);
expect
(
copy
.
minWidth
,
13.0
);
expect
(
copy
.
maxWidth
,
17.0
);
expect
(
copy
.
minHeight
,
111.0
);
expect
(
copy
.
maxHeight
,
117.0
);
expect
(
copy
,
isNot
(
equals
(
constraints
)));
expect
(
copy
.
hashCode
,
isNot
(
equals
(
constraints
.
hashCode
)));
});
test
(
'BoxConstraints operators'
,
()
{
BoxConstraints
constraints
=
new
BoxConstraints
(
minWidth:
3.0
,
maxWidth:
7.0
,
minHeight:
11.0
,
maxHeight:
17.0
);
BoxConstraints
copy
=
constraints
*
2.0
;
expect
(
copy
.
minWidth
,
6.0
);
expect
(
copy
.
maxWidth
,
14.0
);
expect
(
copy
.
minHeight
,
22.0
);
expect
(
copy
.
maxHeight
,
34.0
);
expect
(
copy
/
2.0
,
equals
(
constraints
));
copy
=
constraints
~/
2.0
;
expect
(
copy
.
minWidth
,
1.0
);
expect
(
copy
.
maxWidth
,
3.0
);
expect
(
copy
.
minHeight
,
5.0
);
expect
(
copy
.
maxHeight
,
8.0
);
copy
=
constraints
%
3.0
;
expect
(
copy
.
minWidth
,
0.0
);
expect
(
copy
.
maxWidth
,
1.0
);
expect
(
copy
.
minHeight
,
2.0
);
expect
(
copy
.
maxHeight
,
2.0
);
});
test
(
'BoxConstraints lerp'
,
()
{
expect
(
BoxConstraints
.
lerp
(
null
,
null
,
0.5
),
isNull
);
BoxConstraints
constraints
=
new
BoxConstraints
(
minWidth:
3.0
,
maxWidth:
7.0
,
minHeight:
11.0
,
maxHeight:
17.0
);
BoxConstraints
copy
=
BoxConstraints
.
lerp
(
null
,
constraints
,
0.5
);
expect
(
copy
.
minWidth
,
1.5
);
expect
(
copy
.
maxWidth
,
3.5
);
expect
(
copy
.
minHeight
,
5.5
);
expect
(
copy
.
maxHeight
,
8.5
);
copy
=
BoxConstraints
.
lerp
(
constraints
,
null
,
0.5
);
expect
(
copy
.
minWidth
,
1.5
);
expect
(
copy
.
maxWidth
,
3.5
);
expect
(
copy
.
minHeight
,
5.5
);
expect
(
copy
.
maxHeight
,
8.5
);
copy
=
BoxConstraints
.
lerp
(
new
BoxConstraints
(
minWidth:
13.0
,
maxWidth:
17.0
,
minHeight:
111.0
,
maxHeight:
117.0
),
constraints
,
0.2
);
expect
(
copy
.
minWidth
,
11.0
);
expect
(
copy
.
maxWidth
,
15.0
);
expect
(
copy
.
minHeight
,
91.0
);
expect
(
copy
.
maxHeight
,
97.0
);
});
test
(
'BoxConstraints normalize'
,
()
{
BoxConstraints
constraints
=
new
BoxConstraints
(
minWidth:
3.0
,
maxWidth:
2.0
,
minHeight:
11.0
,
maxHeight:
18.0
);
BoxConstraints
copy
=
constraints
.
normalize
();
expect
(
copy
.
minWidth
,
3.0
);
expect
(
copy
.
maxWidth
,
3.0
);
expect
(
copy
.
minHeight
,
11.0
);
expect
(
copy
.
maxHeight
,
18.0
);
});
}
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