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
84c0b347
Commit
84c0b347
authored
Jan 23, 2017
by
Ian Hickson
Committed by
GitHub
Jan 23, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test some of the sliver helper classes (#7574)
parent
76460967
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
83 additions
and
0 deletions
+83
-0
slivers_helpers_test.dart
packages/flutter/test/rendering/slivers_helpers_test.dart
+83
-0
No files found.
packages/flutter/test/rendering/slivers_helpers_test.dart
0 → 100644
View file @
84c0b347
// 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:flutter_test/flutter_test.dart'
;
void
main
(
)
{
test
(
'AxisDirection and applyGrowthDirectionToAxisDirection'
,
()
{
expect
(
AxisDirection
.
values
.
length
,
4
);
for
(
AxisDirection
axisDirection
in
AxisDirection
.
values
)
expect
(
applyGrowthDirectionToAxisDirection
(
axisDirection
,
GrowthDirection
.
forward
),
axisDirection
);
expect
(
applyGrowthDirectionToAxisDirection
(
AxisDirection
.
up
,
GrowthDirection
.
reverse
),
AxisDirection
.
down
);
expect
(
applyGrowthDirectionToAxisDirection
(
AxisDirection
.
down
,
GrowthDirection
.
reverse
),
AxisDirection
.
up
);
expect
(
applyGrowthDirectionToAxisDirection
(
AxisDirection
.
left
,
GrowthDirection
.
reverse
),
AxisDirection
.
right
);
expect
(
applyGrowthDirectionToAxisDirection
(
AxisDirection
.
right
,
GrowthDirection
.
reverse
),
AxisDirection
.
left
);
});
test
(
'SliverConstraints'
,
()
{
SliverConstraints
a
=
new
SliverConstraints
(
axisDirection:
AxisDirection
.
down
,
growthDirection:
GrowthDirection
.
forward
,
userScrollDirection:
ScrollDirection
.
idle
,
scrollOffset:
0.0
,
overlap:
0.0
,
remainingPaintExtent:
0.0
,
crossAxisExtent:
0.0
,
);
SliverConstraints
b
=
a
.
copyWith
();
expect
(
a
,
equals
(
b
));
expect
(
a
.
hashCode
,
equals
(
b
.
hashCode
));
expect
(
a
.
toString
(),
equals
(
b
.
toString
()));
expect
(
a
,
hasOneLineDescription
);
expect
(
a
.
scrollOffsetAsOffset
,
equals
(
const
Offset
(
0.0
,
0.0
)));
expect
(
a
.
normalizedGrowthDirection
,
equals
(
GrowthDirection
.
forward
));
SliverConstraints
c
=
a
.
copyWith
(
axisDirection:
AxisDirection
.
up
,
growthDirection:
GrowthDirection
.
reverse
,
userScrollDirection:
ScrollDirection
.
forward
,
scrollOffset:
10.0
,
overlap:
20.0
,
remainingPaintExtent:
30.0
,
crossAxisExtent:
40.0
,
);
SliverConstraints
d
=
new
SliverConstraints
(
axisDirection:
AxisDirection
.
up
,
growthDirection:
GrowthDirection
.
reverse
,
userScrollDirection:
ScrollDirection
.
forward
,
scrollOffset:
10.0
,
overlap:
20.0
,
remainingPaintExtent:
30.0
,
crossAxisExtent:
40.0
,
);
expect
(
c
,
equals
(
d
));
expect
(
c
.
scrollOffsetAsOffset
,
equals
(
const
Offset
(
0.0
,
-
10.0
)));
expect
(
c
.
normalizedGrowthDirection
,
equals
(
GrowthDirection
.
forward
));
expect
(
d
.
scrollOffsetAsOffset
,
equals
(
const
Offset
(
0.0
,
-
10.0
)));
expect
(
d
.
normalizedGrowthDirection
,
equals
(
GrowthDirection
.
forward
));
SliverConstraints
e
=
d
.
copyWith
(
axisDirection:
AxisDirection
.
right
);
expect
(
e
.
scrollOffsetAsOffset
,
equals
(
const
Offset
(
10.0
,
0.0
)));
expect
(
e
.
normalizedGrowthDirection
,
equals
(
GrowthDirection
.
reverse
));
SliverConstraints
f
=
d
.
copyWith
(
axisDirection:
AxisDirection
.
left
);
expect
(
f
.
scrollOffsetAsOffset
,
equals
(
const
Offset
(-
10.0
,
0.0
)));
expect
(
f
.
normalizedGrowthDirection
,
equals
(
GrowthDirection
.
forward
));
SliverConstraints
g
=
d
.
copyWith
(
growthDirection:
GrowthDirection
.
forward
);
expect
(
g
.
scrollOffsetAsOffset
,
equals
(
const
Offset
(
0.0
,
-
10.0
)));
expect
(
g
.
normalizedGrowthDirection
,
equals
(
GrowthDirection
.
reverse
));
});
test
(
'SliverGeometry'
,
()
{
expect
(
new
SliverGeometry
().
debugAssertIsValid
,
isTrue
);
expect
(()
{
new
SliverGeometry
(
layoutExtent:
10.0
,
paintExtent:
9.0
).
debugAssertIsValid
;
},
throwsFlutterError
);
expect
(()
{
new
SliverGeometry
(
paintExtent:
9.0
,
maxPaintExtent:
8.0
).
debugAssertIsValid
;
},
throwsFlutterError
);
});
}
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