Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ packages:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0-nullsafety.3"
version: "1.3.0-nullsafety.4"
path:
dependency: transitive
description:
Expand All @@ -99,7 +99,7 @@ packages:
name: stack_trace
url: "https://pub.dartlang.org"
source: hosted
version: "1.10.0-nullsafety.1"
version: "1.10.0-nullsafety.2"
stream_channel:
dependency: transitive
description:
Expand Down Expand Up @@ -143,4 +143,4 @@ packages:
source: hosted
version: "2.1.0-nullsafety.3"
sdks:
dart: ">=2.10.0-110 <2.11.0"
dart: ">=2.10.0-110 <=2.11.0-213.1.beta"
131 changes: 53 additions & 78 deletions test/loader_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,22 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:getwidget/getwidget.dart';

void main() {

final childWidget = Container(
final Widget childWidget = Container(
width: 111,
height: 222,
);

final iconOne = Icon(Icons.directions_bike_sharp);
final iconTwo = Icon(Icons.directions_car);
final iconThree = Icon(Icons.directions_bus);
const iconOne = Icon(Icons.directions_bike_sharp);
const iconTwo = Icon(Icons.directions_car);
const iconThree = Icon(Icons.directions_bus);

final duration = Duration(milliseconds: 1000);
const duration = Duration(milliseconds: 1000);

final firstColor = Colors.teal;
final secondColor = Colors.tealAccent;
final thirdColor = Colors.tealAccent.shade400;
const firstColor = Colors.teal;
const secondColor = Colors.tealAccent;
const thirdColor = Colors.tealAccent;

final stroke = 4.0;
const stroke = 4.0;

debugDefaultTargetPlatformOverride = TargetPlatform.iOS;

Expand All @@ -41,17 +40,16 @@ void main() {
// });

testWidgets('GF Loader can be constructed', (tester) async {

final GFLoader loader = GFLoader(
loaderColorOne: firstColor,
loaderColorTwo: secondColor,
duration: duration,
type: GFLoaderType.ios,
loaderIconOne : iconOne,
// androidLoaderColor : Colors.amber,
loaderstrokeWidth: stroke,
size: GFSize.MEDIUM,
child : childWidget
loaderColorOne: firstColor,
loaderColorTwo: secondColor,
duration: duration,
type: GFLoaderType.ios,
loaderIconOne: iconOne,
// androidLoaderColor : Colors.amber,
loaderstrokeWidth: stroke,
size: GFSize.MEDIUM,
child: childWidget,
);

final TestApp app = TestApp(loader);
Expand All @@ -69,35 +67,29 @@ void main() {
expect(app.loader.size, GFSize.MEDIUM);

debugDefaultTargetPlatformOverride = null;

});

testWidgets('Basic GF Loader can be constructed', (tester) async {
const GFLoader loader = GFLoader();

final GFLoader loader = GFLoader(

);

final TestApp app = TestApp(loader);
const TestApp app = TestApp(loader);

await tester.pumpWidget(app);

});

testWidgets('GF Loader with icons can be constructed', (tester) async {
const customType = GFLoaderType.custom;

final customType = GFLoaderType.custom;

final GFLoader loader = GFLoader(
const GFLoader loader = GFLoader(
type: customType,
duration: duration,
loaderIconOne : iconOne,
loaderIconOne: iconOne,
loaderIconTwo: iconTwo,
loaderIconThree: iconThree,
loaderstrokeWidth: stroke,
);

final TestApp app = TestApp(loader);
const TestApp app = TestApp(loader);

await tester.pumpWidget(app);

Expand All @@ -108,10 +100,8 @@ void main() {
expect(app.loader.loaderIconTwo, iconTwo);
expect(app.loader.loaderIconThree, iconThree);
expect(app.loader.loaderstrokeWidth, stroke);

});


// testWidgets('Asserts.', (tester) async {
// // when type is null
//
Expand All @@ -126,10 +116,9 @@ void main() {
// });

testWidgets('GF Loader with square type can be constructed', (tester) async {
const customType = GFLoaderType.square;

final customType = GFLoaderType.square;

final GFLoader loader = GFLoader(
const GFLoader loader = GFLoader(
type: customType,
duration: duration,
loaderColorOne: firstColor,
Expand All @@ -138,7 +127,7 @@ void main() {
loaderstrokeWidth: stroke,
);

final TestApp app = TestApp(loader);
const TestApp app = TestApp(loader);

await tester.pumpWidget(app);

Expand All @@ -149,14 +138,12 @@ void main() {
expect(app.loader.loaderColorTwo, secondColor);
expect(app.loader.loaderColorThree, thirdColor);
expect(app.loader.loaderstrokeWidth, stroke);

});

testWidgets('GF Loader with round type can be constructed', (tester) async {
const customType = GFLoaderType.circle;

final customType = GFLoaderType.circle;

final GFLoader loader = GFLoader(
const GFLoader loader = GFLoader(
type: customType,
duration: duration,
loaderColorOne: firstColor,
Expand All @@ -165,7 +152,7 @@ void main() {
loaderstrokeWidth: stroke,
);

final TestApp app = TestApp(loader);
const TestApp app = TestApp(loader);

await tester.pumpWidget(app);

Expand All @@ -176,29 +163,24 @@ void main() {
expect(app.loader.loaderColorTwo, secondColor);
expect(app.loader.loaderColorThree, thirdColor);
expect(app.loader.loaderstrokeWidth, stroke);

});

testWidgets('GF Loader with android type loader can be constructed', (tester) async {
testWidgets('GF Loader with android type loader can be constructed',
(tester) async {
const customType = GFLoaderType.android;
const color = AlwaysStoppedAnimation<Color>(Colors.green);

final customType = GFLoaderType.android;
final color = AlwaysStoppedAnimation<Color>(Colors.green);
const GFLoader loader =
GFLoader(type: customType, androidLoaderColor: color);

final GFLoader loader = GFLoader(
type: customType,
androidLoaderColor : color
);

final TestApp app = TestApp(loader);
const TestApp app = TestApp(loader);

await tester.pumpWidget(app);

expect(app.loader.type, customType);
expect(app.loader.androidLoaderColor, color);

});


// testWidgets('Asserts.', (tester) async {
// // when type is null
//
Expand All @@ -212,14 +194,14 @@ void main() {
// //
// // );
//
// final GFLoader loader = GFLoader(
// const GFLoader loader = GFLoader(
// type: null,
// loaderIconOne : iconOne,
// loaderIconTwo: iconTwo,
// loaderIconThree: iconThree,
// );
//
// final TestApp app = TestApp(loader);
// const TestApp app = TestApp(loader);
//
// await tester.pumpWidget(app);
//
Expand All @@ -233,14 +215,11 @@ void main() {
// );
// });

testWidgets('GF Loader with custom loader can be constructed using child', (tester) async {

final customType = GFLoaderType.custom;
testWidgets('GF Loader with custom loader can be constructed using child',
(tester) async {
const customType = GFLoaderType.custom;

final GFLoader loader = GFLoader(
type: customType,
child : childWidget
);
final GFLoader loader = GFLoader(type: customType, child: childWidget);

final TestApp app = TestApp(loader);

Expand All @@ -252,31 +231,27 @@ void main() {

expect(app.loader.child, childWidget);
expect(app.loader.type, customType);

});

}

class TestApp extends StatefulWidget {
final GFLoader loader;
const TestApp(this.loader);

TestApp(this.loader);
final GFLoader loader;

@override
_TestAppState createState() => _TestAppState();
}

class _TestAppState extends State<TestApp> {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Column(
children: [
widget.loader,
],
Widget build(BuildContext context) => MaterialApp(
home: Scaffold(
body: Column(
children: [
widget.loader,
],
),
),
),
);
}
);
}