Skip to content

Commit

Permalink
add more tests!
Browse files Browse the repository at this point in the history
  • Loading branch information
kingwill101 committed Apr 6, 2020
1 parent 9e0d1b9 commit f5915a4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
1 change: 1 addition & 0 deletions lib/media_break_points.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ bool is_xl(BuildContext context) {
}

/// Returns value corresponding to current breakpoint
/// returns [null] if corresponding breakpoint is not provided
///
/// ```dart
/// Container c = Container(
Expand Down
35 changes: 29 additions & 6 deletions test/media_break_points_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const _d = {
"lg": 40,
"xl": 50,
};

EdgeInsets _testData(BuildContext context) {
return valueFor<EdgeInsets>(
context,
Expand All @@ -23,8 +24,6 @@ EdgeInsets _testData(BuildContext context) {
}

void main() {


testWidgets('xs', (WidgetTester tester) async {
EdgeInsets _g;
EdgeInsets _g2;
Expand All @@ -50,7 +49,8 @@ void main() {
EdgeInsets _g;
EdgeInsets _g2;

tester.binding.window.physicalSizeTestValue = Size(mobileBreakPointStart, 200);
tester.binding.window.physicalSizeTestValue =
Size(mobileBreakPointStart, 200);
tester.binding.window.devicePixelRatioTestValue = 1.0;
// resets the screen to its orinal size after the test end
await tester.pumpWidget(MaterialApp(
Expand All @@ -71,7 +71,8 @@ void main() {
EdgeInsets _g;
EdgeInsets _g2;

tester.binding.window.physicalSizeTestValue = Size(tabletBreakPointEnd, 200);
tester.binding.window.physicalSizeTestValue =
Size(tabletBreakPointEnd, 200);
tester.binding.window.devicePixelRatioTestValue = 1.0;
// resets the screen to its orinal size after the test end
await tester.pumpWidget(MaterialApp(
Expand All @@ -92,7 +93,8 @@ void main() {
EdgeInsets _g;
EdgeInsets _g2;

tester.binding.window.physicalSizeTestValue = Size(desktopBreakPointStart, 200);
tester.binding.window.physicalSizeTestValue =
Size(desktopBreakPointStart, 200);
tester.binding.window.devicePixelRatioTestValue = 1.0;
// resets the screen to its orinal size after the test end
await tester.pumpWidget(MaterialApp(
Expand All @@ -112,7 +114,8 @@ void main() {
EdgeInsets _g;
EdgeInsets _g2;

tester.binding.window.physicalSizeTestValue = Size(wideScreenBreakPointStart, 200);
tester.binding.window.physicalSizeTestValue =
Size(wideScreenBreakPointStart, 200);
tester.binding.window.devicePixelRatioTestValue = 1.0;
// resets the screen to its orinal size after the test end
await tester.pumpWidget(MaterialApp(
Expand All @@ -128,4 +131,24 @@ void main() {
));
addTearDown(tester.binding.window.clearPhysicalSizeTestValue);
});

testWidgets('xl', (WidgetTester tester) async {
String test;

tester.binding.window.physicalSizeTestValue =
Size(wideScreenBreakPointStart, 200);
tester.binding.window.devicePixelRatioTestValue = 1.0;
// resets the screen to its orinal size after the test end
await tester.pumpWidget(MaterialApp(
home: Builder(
builder: (BuildContext context) {
String _test_value = "value for extra large";
test = valueFor<String>(context, xl: _test_value);
expect(_test_value, test);
return Placeholder();
},
),
));
addTearDown(tester.binding.window.clearPhysicalSizeTestValue);
});
}

0 comments on commit f5915a4

Please sign in to comment.