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
8bb09dbc
Commit
8bb09dbc
authored
Dec 10, 2015
by
Jim Beveridge
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added rotation test for new PageableList code.
parent
13baf51e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
11 deletions
+58
-11
pageable_list.dart
examples/widgets/pageable_list.dart
+0
-6
pageable_list_test.dart
packages/unit/test/widget/pageable_list_test.dart
+58
-5
No files found.
examples/widgets/pageable_list.dart
View file @
8bb09dbc
...
...
@@ -41,12 +41,6 @@ class PageableListAppState extends State<PageableListApp> {
ScrollDirection
scrollDirection
=
ScrollDirection
.
horizontal
;
bool
itemsWrap
=
false
;
void
updatePageSize
(
Size
newSize
)
{
setState
(()
{
pageSize
=
newSize
;
});
}
Widget
buildCard
(
BuildContext
context
,
CardModel
cardModel
,
int
index
)
{
Widget
card
=
new
Card
(
color:
cardModel
.
color
,
...
...
packages/unit/test/widget/pageable_list_test.dart
View file @
8bb09dbc
...
...
@@ -3,17 +3,19 @@
// found in the LICENSE file.
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:test/test.dart'
;
const
Size
pageSize
=
const
Size
(
800.0
,
6
00.0
);
Size
pageSize
=
new
Size
(
600.0
,
3
00.0
);
const
List
<
int
>
defaultPages
=
const
<
int
>[
0
,
1
,
2
,
3
,
4
,
5
];
final
List
<
GlobalKey
>
globalKeys
=
defaultPages
.
map
((
_
)
=>
new
GlobalKey
()).
toList
();
int
currentPage
=
null
;
bool
itemsWrap
=
false
;
Widget
buildPage
(
BuildContext
context
,
int
page
,
int
index
)
{
return
new
Container
(
key:
new
ValueKey
<
int
>(
page
)
,
key:
globalKeys
[
page
]
,
width:
pageSize
.
width
,
height:
pageSize
.
height
,
child:
new
Text
(
page
.
toString
())
...
...
@@ -21,15 +23,20 @@ Widget buildPage(BuildContext context, int page, int index) {
}
Widget
buildFrame
(
{
List
<
int
>
pages:
defaultPages
})
{
// The test framework forces the frame (and so the PageableList)
// to be 800x600. The pageSize constant reflects this.
return
new
PageableList
<
int
>(
final
list
=
new
PageableList
<
int
>(
items:
pages
,
itemBuilder:
buildPage
,
itemsWrap:
itemsWrap
,
scrollDirection:
ScrollDirection
.
horizontal
,
onPageChanged:
(
int
page
)
{
currentPage
=
page
;
}
);
// The test framework forces the frame to be 800x600, so we need to create
// an outer container where we can change the size.
return
new
Center
(
child:
new
Container
(
width:
pageSize
.
width
,
height:
pageSize
.
height
,
child:
list
)
);
}
void
page
(
WidgetTester
tester
,
Offset
offset
)
{
...
...
@@ -57,8 +64,24 @@ void main() {
expect
(
currentPage
,
isNull
);
pageLeft
(
tester
);
expect
(
currentPage
,
equals
(
1
));
expect
(
tester
.
findText
(
'0'
),
isNull
);
expect
(
tester
.
findText
(
'1'
),
isNotNull
);
expect
(
tester
.
findText
(
'2'
),
isNull
);
expect
(
tester
.
findText
(
'3'
),
isNull
);
expect
(
tester
.
findText
(
'4'
),
isNull
);
expect
(
tester
.
findText
(
'5'
),
isNull
);
pageRight
(
tester
);
expect
(
currentPage
,
equals
(
0
));
expect
(
tester
.
findText
(
'0'
),
isNotNull
);
expect
(
tester
.
findText
(
'1'
),
isNull
);
expect
(
tester
.
findText
(
'2'
),
isNull
);
expect
(
tester
.
findText
(
'3'
),
isNull
);
expect
(
tester
.
findText
(
'4'
),
isNull
);
expect
(
tester
.
findText
(
'5'
),
isNull
);
pageRight
(
tester
);
expect
(
currentPage
,
equals
(
0
));
});
...
...
@@ -118,4 +141,34 @@ void main() {
});
});
test
(
'PageableList resize parent'
,
()
{
testWidgets
((
WidgetTester
tester
)
{
tester
.
pumpWidget
(
new
Container
());
currentPage
=
null
;
itemsWrap
=
true
;
tester
.
pumpWidget
(
buildFrame
());
expect
(
currentPage
,
isNull
);
pageRight
(
tester
);
expect
(
currentPage
,
equals
(
5
));
RenderBox
box
=
globalKeys
[
5
].
currentContext
.
findRenderObject
();
expect
(
box
.
size
.
width
,
equals
(
pageSize
.
width
));
expect
(
box
.
size
.
height
,
equals
(
pageSize
.
height
));
pageSize
=
new
Size
(
pageSize
.
height
,
pageSize
.
width
);
tester
.
pumpWidget
(
buildFrame
());
expect
(
tester
.
findText
(
'0'
),
isNull
);
expect
(
tester
.
findText
(
'1'
),
isNull
);
expect
(
tester
.
findText
(
'2'
),
isNull
);
expect
(
tester
.
findText
(
'3'
),
isNull
);
expect
(
tester
.
findText
(
'4'
),
isNull
);
expect
(
tester
.
findText
(
'5'
),
isNotNull
);
box
=
globalKeys
[
5
].
currentContext
.
findRenderObject
();
expect
(
box
.
size
.
width
,
equals
(
pageSize
.
width
));
expect
(
box
.
size
.
height
,
equals
(
pageSize
.
height
));
});
});
}
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