我正在编写Flutter应用,该应用仅具有基于firebase_auth和google_sign_in的Google登录。我找不到如何在Flutter中模拟依赖项或如何单击Google身份验证对话框或绕过整个身份验证工作流程的标准工作示例。
我正在使用flutter_driver
来编写集成测试,如下所述。
app_test.dart
import 'package:flutter_driver/driver_extension.dart';
import 'package:pruoo_app/main.dart' as app;
void main() {
enableFlutterDriverExtension();
app.main();
}
login.dart
//...imports
class LoginView extends StatefulWidget {
@override
_LoginViewState createState() => _LoginViewState();
}
class _LoginViewState extends State<LoginView> {
StreamSubscription<AuthenticationState> x;
void getStream(AuthenticationState state, BuildContext context) async {
if (state.toString() == 'AuthenticationAuthenticated') {
print("Navigate to Main Page");
);
}
}
Widget build(BuildContext context) {
final AuthenticationBloc authenticationBloc =
BlocProvider.of<AuthenticationBloc>(context);
x = authenticationBloc.state.listen((state) {
getStream(state, context);
});
return Scaffold(
body: Center(
child: GoogleSignInButton(
onPressed: () {
authenticationBloc.dispatch(LoggedIn());
},
)));
}
}