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
79d435d0
Unverified
Commit
79d435d0
authored
Feb 22, 2022
by
Michael Goderbauer
Committed by
GitHub
Feb 22, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reland "Add more tests to slider to avoid future breakages (#98772)" (#98936)
parent
48c9bbe1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
233 additions
and
0 deletions
+233
-0
value_indicating_slider_test.dart
...s/flutter/test/material/value_indicating_slider_test.dart
+233
-0
No files found.
packages/flutter/test/material/value_indicating_slider_test.dart
0 → 100644
View file @
79d435d0
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This file is run as part of a reduced test set in CI on Mac and Windows
// machines.
@Tags
(<
String
>[
'reduced-test-set'
])
import
'package:flutter/material.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
void
main
(
)
{
testWidgets
(
'Slider value indicator'
,
(
WidgetTester
tester
)
async
{
await
_buildValueIndicatorStaticSlider
(
tester
,
value:
0
,
);
await
_pressStartThumb
(
tester
);
await
expectLater
(
find
.
byType
(
MaterialApp
),
matchesGoldenFile
(
'slider_start_text_scale_1_width_0.png'
),
);
await
_buildValueIndicatorStaticSlider
(
tester
,
value:
0.5
,
);
await
_pressMiddleThumb
(
tester
);
await
expectLater
(
find
.
byType
(
MaterialApp
),
matchesGoldenFile
(
'slider_middle_text_scale_1_width_0.png'
),
);
await
_buildValueIndicatorStaticSlider
(
tester
,
value:
1
,
);
await
_pressEndThumb
(
tester
);
await
expectLater
(
find
.
byType
(
MaterialApp
),
matchesGoldenFile
(
'slider_end_text_scale_1_width_0.png'
),
);
});
testWidgets
(
'Slider value indicator wide text'
,
(
WidgetTester
tester
)
async
{
await
_buildValueIndicatorStaticSlider
(
tester
,
value:
0
,
decimalCount:
5
,
);
await
_pressStartThumb
(
tester
);
await
expectLater
(
find
.
byType
(
MaterialApp
),
matchesGoldenFile
(
'slider_start_text_scale_1_width_5.png'
),
);
await
_buildValueIndicatorStaticSlider
(
tester
,
value:
0.5
,
decimalCount:
5
,
);
await
_pressMiddleThumb
(
tester
);
await
expectLater
(
find
.
byType
(
MaterialApp
),
matchesGoldenFile
(
'slider_middle_text_scale_1_width_5.png'
),
);
await
_buildValueIndicatorStaticSlider
(
tester
,
value:
1
,
decimalCount:
5
,
);
await
_pressEndThumb
(
tester
);
await
expectLater
(
find
.
byType
(
MaterialApp
),
matchesGoldenFile
(
'slider_end_text_scale_1_width_5.png'
),
);
});
testWidgets
(
'Slider value indicator large text scale'
,
(
WidgetTester
tester
)
async
{
await
_buildValueIndicatorStaticSlider
(
tester
,
value:
0
,
textScale:
3
,
);
await
_pressStartThumb
(
tester
);
await
expectLater
(
find
.
byType
(
MaterialApp
),
matchesGoldenFile
(
'slider_start_text_scale_4_width_0.png'
),
);
await
_buildValueIndicatorStaticSlider
(
tester
,
value:
0.5
,
textScale:
3
,
);
await
_pressMiddleThumb
(
tester
);
await
expectLater
(
find
.
byType
(
MaterialApp
),
matchesGoldenFile
(
'slider_middle_text_scale_4_width_0.png'
),
);
await
_buildValueIndicatorStaticSlider
(
tester
,
value:
1
,
textScale:
3
,
);
await
_pressEndThumb
(
tester
);
await
expectLater
(
find
.
byType
(
MaterialApp
),
matchesGoldenFile
(
'slider_end_text_scale_4_width_0.png'
),
);
});
testWidgets
(
'Slider value indicator large text scale and wide text'
,
(
WidgetTester
tester
)
async
{
await
_buildValueIndicatorStaticSlider
(
tester
,
value:
0
,
textScale:
3
,
decimalCount:
5
,
);
await
_pressStartThumb
(
tester
);
await
expectLater
(
find
.
byType
(
MaterialApp
),
matchesGoldenFile
(
'slider_start_text_scale_4_width_5.png'
),
);
await
_buildValueIndicatorStaticSlider
(
tester
,
value:
0.5
,
textScale:
3
,
decimalCount:
5
,
);
await
_pressMiddleThumb
(
tester
);
await
expectLater
(
find
.
byType
(
MaterialApp
),
matchesGoldenFile
(
'slider_middle_text_scale_4_width_5.png'
),
);
await
_buildValueIndicatorStaticSlider
(
tester
,
value:
1
,
textScale:
3
,
decimalCount:
5
,
);
await
_pressEndThumb
(
tester
);
await
expectLater
(
find
.
byType
(
MaterialApp
),
matchesGoldenFile
(
'slider_end_text_scale_4_width_5.png'
),
);
});
}
Future
<
void
>
_pressStartThumb
(
WidgetTester
tester
)
async
{
final
Offset
bottomLeft
=
tester
.
getBottomLeft
(
find
.
byType
(
Slider
));
final
Offset
topLeft
=
tester
.
getTopLeft
(
find
.
byType
(
Slider
));
final
Offset
left
=
(
bottomLeft
+
topLeft
)
/
2
;
final
Offset
start
=
left
+
const
Offset
(
24
,
0
);
await
tester
.
startGesture
(
start
);
await
tester
.
pumpAndSettle
();
}
Future
<
void
>
_pressMiddleThumb
(
WidgetTester
tester
)
async
{
await
tester
.
press
(
find
.
byType
(
Slider
));
await
tester
.
pumpAndSettle
();
}
Future
<
void
>
_pressEndThumb
(
WidgetTester
tester
)
async
{
final
Offset
bottomRight
=
tester
.
getBottomRight
(
find
.
byType
(
Slider
));
final
Offset
topRight
=
tester
.
getTopRight
(
find
.
byType
(
Slider
));
final
Offset
right
=
(
bottomRight
+
topRight
)
/
2
;
final
Offset
start
=
right
-
const
Offset
(
24
,
0
);
await
tester
.
startGesture
(
start
);
await
tester
.
pumpAndSettle
();
}
Future
<
void
>
_buildValueIndicatorStaticSlider
(
WidgetTester
tester
,
{
required
double
value
,
double
textScale
=
1.0
,
int
decimalCount
=
0
,
})
async
{
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Scaffold
(
body:
Builder
(
builder:
(
BuildContext
context
)
{
return
Center
(
child:
MediaQuery
(
data:
MediaQueryData
(
textScaleFactor:
textScale
),
child:
SliderTheme
(
data:
Theme
.
of
(
context
).
sliderTheme
.
copyWith
(
showValueIndicator:
ShowValueIndicator
.
always
,
),
child:
Slider
(
value:
value
,
label:
value
.
toStringAsFixed
(
decimalCount
),
onChanged:
(
double
newValue
)
{},
),
),
),
);
},
),
),
),
);
}
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