Skip to content

Commit

Permalink
Testes
Browse files Browse the repository at this point in the history
  • Loading branch information
wjrcode committed Oct 20, 2022
1 parent 5894197 commit 0a7b6f4
Show file tree
Hide file tree
Showing 4 changed files with 165 additions and 144 deletions.
4 changes: 3 additions & 1 deletion lib/components/dialogs/login/entrarDialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Future<dynamic> entrar(BuildContext context) {
Padding(
padding: EdgeInsets.only(bottom: 16),
child: input(
key: Key("keyTextEmail"),
onSaved: loginController.loginUsuario,
textController:
loginController.controllerUsuario,
Expand All @@ -51,6 +52,7 @@ Future<dynamic> entrar(BuildContext context) {
Padding(
padding: EdgeInsets.only(bottom: 16),
child: input(
key: Key("keyTextSenha"),
onSaved: loginController.loginSenha,
textController:
loginController.controllerSenha,
Expand All @@ -60,7 +62,7 @@ Future<dynamic> entrar(BuildContext context) {
Padding(
padding: const EdgeInsets.fromLTRB(0, 0, 0, 16.0),
child: Botao(
key: Key("BB"),
key: Key("keyEntrarButton"),
texto: 'Entrar',
cor: const Color(0xFF6BC8E4),
clicar: () async {
Expand Down
125 changes: 71 additions & 54 deletions lib/components/input.dart
Original file line number Diff line number Diff line change
@@ -1,62 +1,79 @@
import 'package:flutter/material.dart';

Widget input(
{dynamic onSaved,
TextEditingController? textController,
String? label,
bool senha = false,
bool readOnly = false,
String? placeholder = '',
bool excluir = false,
Function? funcao}) {
return Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
label!,
style: const TextStyle(
color: Colors.black,
fontSize: 16,
fontWeight: FontWeight.w400,
class input extends StatelessWidget {
const input(
{Key? key,
this.onSaved,
this.textController,
this.label,
this.funcao,
this.senha = false,
this.excluir = false,
this.readOnly = false,
this.placeholder = ''})
: super(key: key);

final dynamic onSaved;
final TextEditingController? textController;
final String? label;
final bool? senha;
final bool? readOnly;
final String? placeholder;
final bool? excluir;
final Function? funcao;

@override
Widget build(BuildContext context) {
return Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
label!,
style: const TextStyle(
color: Colors.black,
fontSize: 16,
fontWeight: FontWeight.w400,
),
),
),
Material(
color: Colors.white.withOpacity(0),
child: TextFormField(
obscureText: senha,
readOnly: readOnly,
onSaved: onSaved,
controller: textController,
decoration: InputDecoration(
suffixIcon: excluir
? GestureDetector(
onTap: () {
funcao!();
},
child: const Icon(Icons.close))
: null,
hintText: placeholder,
fillColor: Colors.white,
filled: true,
enabledBorder: OutlineInputBorder(
borderSide: const BorderSide(
color: Colors.black,
width: 3.0,
Material(
color: Colors.white.withOpacity(0),
child: TextFormField(
//key: key ?? Key("keyTesteButton"),
obscureText: senha!,
readOnly: readOnly!,
onSaved: onSaved,
controller: textController,
decoration: InputDecoration(
suffixIcon: excluir!
? GestureDetector(
onTap: () {
funcao!();
},
child: const Icon(Icons.close))
: null,
hintText: placeholder,
fillColor: Colors.white,
filled: true,
enabledBorder: OutlineInputBorder(
borderSide: const BorderSide(
color: Colors.black,
width: 3.0,
),
borderRadius: BorderRadius.circular(16.0),
),
borderRadius: BorderRadius.circular(16.0),
),
focusedBorder: OutlineInputBorder(
borderSide: const BorderSide(
color: Colors.black,
width: 3.0,
focusedBorder: OutlineInputBorder(
borderSide: const BorderSide(
color: Colors.black,
width: 3.0,
),
borderRadius: BorderRadius.circular(16.0),
),
borderRadius: BorderRadius.circular(16.0),
),

//labelText: 'Password',
//labelText: 'Password',
),
),
),
)
]);
)
]);
}
}
89 changes: 0 additions & 89 deletions test/empresa_test.dart

This file was deleted.

91 changes: 91 additions & 0 deletions test/login_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:organizei/components/botao.dart';
import 'package:organizei/components/dialogs/login/entrarDialog.dart';

void main() {
group('LOGIN', () {
testWidgets('E-mail e senha vazios', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
home: Material(
child: Builder(
builder: (BuildContext context) {
return Botao(
key: Key("keyTesteButton"),
texto: 'Entrar',
cor: const Color(0xFF74C198),
clicar: () {
entrar(context);
});
},
),
),
),
);

await tester.tap(find.byKey(ValueKey("keyTesteButton")));
await tester.pump();
await tester.ensureVisible(find.byKey(Key("keyEntrarButton")));
await tester.pumpAndSettle();
await tester.tap(find.byKey(ValueKey("keyEntrarButton")));
});

testWidgets('E-mail vazio', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(
home: Material(
child: Builder(
builder: (BuildContext context) {
return Botao(
key: Key("keyTesteButton"),
texto: 'clicar',
cor: const Color(0xFF74C198),
clicar: () {
entrar(context);
});
},
),
),
));

await tester.tap(find.byKey(ValueKey("keyTesteButton")));
await tester.pump();

await tester.ensureVisible(find.byKey(Key("keyEntrarButton")));
await tester.pumpAndSettle();

await tester.enterText(find.byKey(ValueKey("keyTextSenha")), "senha");

await tester.tap(find.byKey(ValueKey("keyEntrarButton")));
});

testWidgets('Senha vazia', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(
home: Material(
child: Builder(
builder: (BuildContext context) {
return Botao(
key: Key("keyTesteButton"),
texto: 'clicar',
cor: const Color(0xFF74C198),
clicar: () {
entrar(context);
});
},
),
),
));

await tester.tap(find.byKey(ValueKey("keyTesteButton")));
await tester.pump();

await tester.ensureVisible(find.byKey(Key("keyEntrarButton")));
await tester.pumpAndSettle();

await tester.enterText(
find.byKey(ValueKey("keyTextEmail")), "[email protected]");

await tester.tap(find.byKey(ValueKey("keyEntrarButton")));
});
});
}

0 comments on commit 0a7b6f4

Please sign in to comment.