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
855b8eb2
Commit
855b8eb2
authored
Aug 21, 2015
by
Adam Barth
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #740 from abarth/migrate_more_tests
Migrate sky/tests/layout to sky/unit/test
parents
ce877f09
ccd00bc5
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
261 additions
and
0 deletions
+261
-0
image_test.dart
packages/unit/test/rendering/image_test.dart
+161
-0
layout_utils.dart
packages/unit/test/rendering/layout_utils.dart
+30
-0
stack_test.dart
packages/unit/test/rendering/stack_test.dart
+40
-0
viewport_test.dart
packages/unit/test/rendering/viewport_test.dart
+30
-0
No files found.
packages/unit/test/rendering/image_test.dart
0 → 100644
View file @
855b8eb2
import
'dart:sky'
as
sky
;
import
'package:sky/rendering.dart'
;
import
'package:test/test.dart'
;
import
'layout_utils.dart'
;
class
SquareImage
implements
sky
.
Image
{
int
get
width
=>
10
;
int
get
height
=>
10
;
}
class
WideImage
implements
sky
.
Image
{
int
get
width
=>
20
;
int
get
height
=>
10
;
}
class
TallImage
implements
sky
.
Image
{
int
get
width
=>
10
;
int
get
height
=>
20
;
}
void
main
(
)
{
test
(
'Image sizing'
,
()
{
RenderImage
image
;
image
=
new
RenderImage
(
image:
new
SquareImage
());
layout
(
image
,
constraints:
new
BoxConstraints
(
minWidth:
25.0
,
minHeight:
25.0
,
maxWidth:
100.0
,
maxHeight:
100.0
));
expect
(
image
.
size
.
width
,
equals
(
25.0
));
expect
(
image
.
size
.
height
,
equals
(
25.0
));
image
=
new
RenderImage
(
image:
new
WideImage
());
layout
(
image
,
constraints:
new
BoxConstraints
(
minWidth:
5.0
,
minHeight:
30.0
,
maxWidth:
100.0
,
maxHeight:
100.0
));
expect
(
image
.
size
.
width
,
equals
(
60.0
));
expect
(
image
.
size
.
height
,
equals
(
30.0
));
image
=
new
RenderImage
(
image:
new
TallImage
());
layout
(
image
,
constraints:
new
BoxConstraints
(
minWidth:
50.0
,
minHeight:
5.0
,
maxWidth:
75.0
,
maxHeight:
75.0
));
expect
(
image
.
size
.
width
,
equals
(
50.0
));
expect
(
image
.
size
.
height
,
equals
(
75.0
));
image
=
new
RenderImage
(
image:
new
WideImage
());
layout
(
image
,
constraints:
new
BoxConstraints
(
minWidth:
5.0
,
minHeight:
5.0
,
maxWidth:
100.0
,
maxHeight:
100.0
));
expect
(
image
.
size
.
width
,
equals
(
20.0
));
expect
(
image
.
size
.
height
,
equals
(
10.0
));
image
=
new
RenderImage
(
image:
new
WideImage
());
layout
(
image
,
constraints:
new
BoxConstraints
(
minWidth:
5.0
,
minHeight:
5.0
,
maxWidth:
16.0
,
maxHeight:
16.0
));
expect
(
image
.
size
.
width
,
equals
(
16.0
));
expect
(
image
.
size
.
height
,
equals
(
8.0
));
image
=
new
RenderImage
(
image:
new
TallImage
());
layout
(
image
,
constraints:
new
BoxConstraints
(
minWidth:
5.0
,
minHeight:
5.0
,
maxWidth:
16.0
,
maxHeight:
16.0
));
expect
(
image
.
size
.
width
,
equals
(
8.0
));
expect
(
image
.
size
.
height
,
equals
(
16.0
));
image
=
new
RenderImage
(
image:
new
SquareImage
());
layout
(
image
,
constraints:
new
BoxConstraints
(
minWidth:
4.0
,
minHeight:
4.0
,
maxWidth:
8.0
,
maxHeight:
8.0
));
expect
(
image
.
size
.
width
,
equals
(
8.0
));
expect
(
image
.
size
.
height
,
equals
(
8.0
));
image
=
new
RenderImage
(
image:
new
WideImage
());
layout
(
image
,
constraints:
new
BoxConstraints
(
minWidth:
20.0
,
minHeight:
20.0
,
maxWidth:
30.0
,
maxHeight:
30.0
));
expect
(
image
.
size
.
width
,
equals
(
30.0
));
expect
(
image
.
size
.
height
,
equals
(
20.0
));
image
=
new
RenderImage
(
image:
new
TallImage
());
layout
(
image
,
constraints:
new
BoxConstraints
(
minWidth:
20.0
,
minHeight:
20.0
,
maxWidth:
30.0
,
maxHeight:
30.0
));
expect
(
image
.
size
.
width
,
equals
(
20.0
));
expect
(
image
.
size
.
height
,
equals
(
30.0
));
});
test
(
'Null image sizing'
,
()
{
RenderImage
image
;
image
=
new
RenderImage
();
layout
(
image
,
constraints:
new
BoxConstraints
(
minWidth:
25.0
,
minHeight:
25.0
,
maxWidth:
100.0
,
maxHeight:
100.0
));
expect
(
image
.
size
.
width
,
equals
(
25.0
));
expect
(
image
.
size
.
height
,
equals
(
25.0
));
image
=
new
RenderImage
(
width:
50.0
);
layout
(
image
,
constraints:
new
BoxConstraints
(
minWidth:
25.0
,
minHeight:
25.0
,
maxWidth:
100.0
,
maxHeight:
100.0
));
expect
(
image
.
size
.
width
,
equals
(
50.0
));
expect
(
image
.
size
.
height
,
equals
(
25.0
));
image
=
new
RenderImage
(
height:
50.0
);
layout
(
image
,
constraints:
new
BoxConstraints
(
minWidth:
25.0
,
minHeight:
25.0
,
maxWidth:
100.0
,
maxHeight:
100.0
));
expect
(
image
.
size
.
width
,
equals
(
25.0
));
expect
(
image
.
size
.
height
,
equals
(
50.0
));
image
=
new
RenderImage
(
width:
100.0
,
height:
100.0
);
layout
(
image
,
constraints:
new
BoxConstraints
(
minWidth:
25.0
,
minHeight:
25.0
,
maxWidth:
75.0
,
maxHeight:
75.0
));
expect
(
image
.
size
.
width
,
equals
(
75.0
));
expect
(
image
.
size
.
height
,
equals
(
75.0
));
});
}
packages/unit/test/rendering/layout_utils.dart
0 → 100644
View file @
855b8eb2
import
'package:sky/rendering.dart'
;
const
Size
_kTestViewSize
=
const
Size
(
800.0
,
600.0
);
class
TestRenderView
extends
RenderView
{
TestRenderView
({
RenderBox
child
})
:
super
(
child:
child
)
{
attach
();
rootConstraints
=
new
ViewConstraints
(
size:
_kTestViewSize
);
scheduleInitialLayout
();
}
void
beginFrame
(
double
timeStamp
)
{
RenderObject
.
flushLayout
();
}
}
RenderView
layout
(
RenderBox
box
,
{
BoxConstraints
constraints
})
{
if
(
constraints
!=
null
)
{
box
=
new
RenderPositionedBox
(
child:
new
RenderConstrainedBox
(
additionalConstraints:
constraints
,
child:
box
)
);
}
TestRenderView
renderView
=
new
TestRenderView
(
child:
box
);
renderView
.
beginFrame
(
0.0
);
return
renderView
;
}
packages/unit/test/rendering/stack_test.dart
0 → 100644
View file @
855b8eb2
import
'package:sky/rendering.dart'
;
import
'package:test/test.dart'
;
import
'layout_utils.dart'
;
void
main
(
)
{
test
(
'Stack can layout with top, right, bottom, left 0.0'
,
()
{
RenderBox
size
=
new
RenderConstrainedBox
(
additionalConstraints:
new
BoxConstraints
.
tight
(
const
Size
(
100.0
,
100.0
)));
RenderBox
red
=
new
RenderDecoratedBox
(
decoration:
new
BoxDecoration
(
backgroundColor:
const
Color
(
0xFFFF0000
)
),
child:
size
);
RenderBox
green
=
new
RenderDecoratedBox
(
decoration:
new
BoxDecoration
(
backgroundColor:
const
Color
(
0xFFFF0000
)
));
RenderBox
stack
=
new
RenderStack
(
children:
[
red
,
green
]);
(
green
.
parentData
as
StackParentData
)
..
top
=
0.0
..
right
=
0.0
..
bottom
=
0.0
..
left
=
0.0
;
layout
(
stack
,
constraints:
const
BoxConstraints
());
expect
(
stack
.
size
.
width
,
equals
(
100.0
));
expect
(
stack
.
size
.
height
,
equals
(
100.0
));
expect
(
red
.
size
.
width
,
equals
(
100.0
));
expect
(
red
.
size
.
height
,
equals
(
100.0
));
expect
(
green
.
size
.
width
,
equals
(
100.0
));
expect
(
green
.
size
.
height
,
equals
(
100.0
));
});
}
packages/unit/test/rendering/viewport_test.dart
0 → 100644
View file @
855b8eb2
import
'package:sky/rendering.dart'
;
import
'package:test/test.dart'
;
import
'layout_utils.dart'
;
void
main
(
)
{
test
(
'Should be able to hit with negative scroll offset'
,
()
{
RenderBox
size
=
new
RenderConstrainedBox
(
additionalConstraints:
new
BoxConstraints
.
tight
(
const
Size
(
100.0
,
100.0
)));
RenderBox
red
=
new
RenderDecoratedBox
(
decoration:
new
BoxDecoration
(
backgroundColor:
const
Color
(
0xFFFF0000
)
),
child:
size
);
RenderViewport
viewport
=
new
RenderViewport
(
child:
red
,
scrollOffset:
new
Offset
(
0.0
,
-
10.0
));
RenderView
renderView
=
layout
(
viewport
);
HitTestResult
result
;
result
=
new
HitTestResult
();
renderView
.
hitTest
(
result
,
position:
new
Point
(
15.0
,
0.0
));
expect
(
result
.
path
.
first
.
target
,
equals
(
viewport
));
result
=
new
HitTestResult
();
renderView
.
hitTest
(
result
,
position:
new
Point
(
15.0
,
15.0
));
expect
(
result
.
path
.
first
.
target
,
equals
(
size
));
});
}
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