Move sync UI packages to material_ui
Some checks failed
dependency freshness / dependencies on newest stable (push) Waiting to run
file length / file-length (push) Waiting to run
md-naming / markdown naming convention (push) Waiting to run
palette drift / palette (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
shared gate tests / gate unit tests (push) Waiting to run
sync_settings_ui tests / test (push) Waiting to run
github_device_auth tests / test (push) Has been cancelled

Flutter 3.50 deprecates package:flutter/material.dart. An app on
material_ui gives flutter/material widgets no MaterialLocalizations,
so sync_settings_ui 0.8.0 and github_device_auth 0.5.0 move first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Krzysztof Rudnicki 2026-11-12 09:03:03 +01:00
parent eb9bdc5796
commit 0ef5461805
20 changed files with 223 additions and 220 deletions

View File

@ -13,7 +13,7 @@ const githubTokenUrl = 'https://github.com/login/oauth/access_token';
/// types on github.com and the URL to type it into. /// types on github.com and the URL to type it into.
class DeviceCodeResponse { class DeviceCodeResponse {
/// Creates a [DeviceCodeResponse] from its stored fields. /// Creates a [DeviceCodeResponse] from its stored fields.
const DeviceCodeResponse({ const new({
required this.deviceCode, required this.deviceCode,
required this.userCode, required this.userCode,
required this.verificationUri, required this.verificationUri,
@ -22,7 +22,7 @@ class DeviceCodeResponse {
}); });
/// Builds a [DeviceCodeResponse] from GitHub's device-code JSON response. /// Builds a [DeviceCodeResponse] from GitHub's device-code JSON response.
factory DeviceCodeResponse.fromJson(Map<String, dynamic> json) { factory fromJson(Map<String, dynamic> json) {
return DeviceCodeResponse( return DeviceCodeResponse(
deviceCode: json['device_code'] as String, deviceCode: json['device_code'] as String,
userCode: json['user_code'] as String, userCode: json['user_code'] as String,
@ -51,7 +51,7 @@ class DeviceCodeResponse {
/// Raised when the device-flow authorization fails or is declined. /// Raised when the device-flow authorization fails or is declined.
class DeviceAuthException implements Exception { class DeviceAuthException implements Exception {
/// Creates a [DeviceAuthException] from GitHub's [code] and [message]. /// Creates a [DeviceAuthException] from GitHub's [code] and [message].
DeviceAuthException(this.code, this.message); new(this.code, this.message);
/// GitHub error code, e.g. `access_denied`, `expired_token`. /// GitHub error code, e.g. `access_denied`, `expired_token`.
final String code; final String code;
@ -75,7 +75,7 @@ class DeviceAuthException implements Exception {
/// - POST https://github.com/login/oauth/access_token /// - POST https://github.com/login/oauth/access_token
class GitHubDeviceAuth { class GitHubDeviceAuth {
/// Creates a [GitHubDeviceAuth] for the given OAuth App [clientId]. /// Creates a [GitHubDeviceAuth] for the given OAuth App [clientId].
GitHubDeviceAuth({ new({
required this.clientId, required this.clientId,
this.scope = 'repo', this.scope = 'repo',
this.deviceCodeUrl = githubDeviceCodeUrl, this.deviceCodeUrl = githubDeviceCodeUrl,

View File

@ -4,9 +4,9 @@ library;
import 'dart:async'; import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:github_device_auth/src/device_auth.dart'; import 'package:github_device_auth/src/device_auth.dart';
import 'package:material_ui/material_ui.dart';
import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher.dart';
/// Dialog shown during the device flow: displays the user code, opens the /// Dialog shown during the device flow: displays the user code, opens the
@ -14,11 +14,7 @@ import 'package:url_launcher/url_launcher.dart';
/// null if cancelled / failed). /// null if cancelled / failed).
class DeviceCodeDialog extends StatefulWidget { class DeviceCodeDialog extends StatefulWidget {
/// Creates the dialog for a pending device-flow grant. /// Creates the dialog for a pending device-flow grant.
const DeviceCodeDialog({ const new({required this.device, required this.auth, super.key});
required this.device,
required this.auth,
super.key,
});
/// The pending grant: user code, verification URL, poll interval. /// The pending grant: user code, verification URL, poll interval.
final DeviceCodeResponse device; final DeviceCodeResponse device;

View File

@ -29,10 +29,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: clock name: clock
sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b sha256: e51d50bca3217c9a9fa2b41a30e4a38971133f5f9ec7a3d57bae095007f1d28e
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.1.2" version: "1.1.3"
collection: collection:
dependency: transitive dependency: transitive
description: description:
@ -41,6 +41,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.19.1" version: "1.19.1"
cupertino_ui:
dependency: transitive
description:
name: cupertino_ui
sha256: "369e39a1c5c030a6212589c3da1809920b1c2cfade7b02aade7695bfa4b88c3a"
url: "https://pub.dev"
source: hosted
version: "1.1.6"
fake_async: fake_async:
dependency: transitive dependency: transitive
description: description:
@ -54,6 +62,11 @@ packages:
description: flutter description: flutter
source: sdk source: sdk
version: "0.0.0" version: "0.0.0"
flutter_localizations:
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
flutter_test: flutter_test:
dependency: "direct dev" dependency: "direct dev"
description: flutter description: flutter
@ -80,6 +93,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "4.1.2" version: "4.1.2"
intl:
dependency: transitive
description:
name: intl
sha256: "1ca20c894b1717686a2319b8548763d812bc0aabdac580420a44c5178c57a867"
url: "https://pub.dev"
source: hosted
version: "0.20.3"
leak_tracker: leak_tracker:
dependency: transitive dependency: transitive
description: description:
@ -104,6 +125,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.0.2" version: "3.0.2"
listen:
dependency: transitive
description:
name: listen
sha256: "47501a08016a43fcad79252439d723f50f14f88fa7bfd8a177e0a417e5c9e1f2"
url: "https://pub.dev"
source: hosted
version: "1.0.1"
matcher: matcher:
dependency: transitive dependency: transitive
description: description:
@ -120,6 +149,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.13.0" version: "0.13.0"
material_ui:
dependency: "direct main"
description:
name: material_ui
sha256: "474c135fd46b56ff1d35ca982155e8863d28fbc6464d1192acf4ee53a738680e"
url: "https://pub.dev"
source: hosted
version: "1.11.0"
meta: meta:
dependency: transitive dependency: transitive
description: description:
@ -161,10 +198,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: stack_trace name: stack_trace
sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1" sha256: "277654b3034d17ac6f9f1cb5595db011b1d5d41e8806866db28e0abaa101c490"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.12.1" version: "1.12.2"
stream_channel: stream_channel:
dependency: transitive dependency: transitive
description: description:
@ -193,10 +230,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: test_api name: test_api
sha256: "2a122cbe059f8b610d3a5415f42e255b6c17b1f21eee1d960f31080237fb4f11" sha256: "0a10344e901e5b2e63819567951cb6a06673ed6b84f40462188ff5a0c41f371f"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.7.12" version: "0.7.14"
typed_data: typed_data:
dependency: transitive dependency: transitive
description: description:
@ -273,10 +310,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: vector_math name: vector_math
sha256: f36f9f3be64c6198714492bb455c11056e33e2f85d9a0b676a48301e44fdcf47 sha256: fa49e1674cb84acb900141714e6c6e1f9ae099827c24d141430ff6819db4e1bc
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.4.2" version: "2.4.4"
very_good_analysis: very_good_analysis:
dependency: "direct dev" dependency: "direct dev"
description: description:
@ -303,4 +340,4 @@ packages:
version: "1.1.1" version: "1.1.1"
sdks: sdks:
dart: ">=3.13.0 <4.0.0" dart: ">=3.13.0 <4.0.0"
flutter: ">=3.44.0" flutter: ">=3.47.0"

View File

@ -4,15 +4,16 @@ description: >-
modal that drives it. Extracted from four apps that each carried a copy, modal that drives it. Extracted from four apps that each carried a copy,
two of them byte-identical. two of them byte-identical.
publish_to: 'none' publish_to: 'none'
version: 0.4.0 version: 0.5.0
environment: environment:
sdk: ^3.12.2 sdk: ^3.13.0
dependencies: dependencies:
flutter: flutter:
sdk: flutter sdk: flutter
http: 1.6.0 http: 1.6.0
material_ui: 1.11.0
url_launcher: 6.3.3 url_launcher: 6.3.3
dev_dependencies: dev_dependencies:

View File

@ -9,15 +9,13 @@ import 'package:http/testing.dart';
/// exercises `slow_down` does not take 15 real seconds. /// exercises `slow_down` does not take 15 real seconds.
Future<void> noDelay(Duration _) async {} Future<void> noDelay(Duration _) async {}
GitHubDeviceAuth authWith( GitHubDeviceAuth authWith(MockClient client, {String scope = 'repo'}) =>
MockClient client, { GitHubDeviceAuth(
String scope = 'repo', clientId: 'cid',
}) => GitHubDeviceAuth( scope: scope,
clientId: 'cid', httpClient: client,
scope: scope, delay: noDelay,
httpClient: client, );
delay: noDelay,
);
void main() { void main() {
group('pollForToken', () { group('pollForToken', () {

View File

@ -9,15 +9,13 @@ import 'package:http/testing.dart';
/// exercises `slow_down` does not take 15 real seconds. /// exercises `slow_down` does not take 15 real seconds.
Future<void> noDelay(Duration _) async {} Future<void> noDelay(Duration _) async {}
GitHubDeviceAuth authWith( GitHubDeviceAuth authWith(MockClient client, {String scope = 'repo'}) =>
MockClient client, { GitHubDeviceAuth(
String scope = 'repo', clientId: 'cid',
}) => GitHubDeviceAuth( scope: scope,
clientId: 'cid', httpClient: client,
scope: scope, delay: noDelay,
httpClient: client, );
delay: noDelay,
);
void main() { void main() {
group('DeviceCodeResponse.fromJson', () { group('DeviceCodeResponse.fromJson', () {

View File

@ -1,7 +1,7 @@
import 'dart:async'; import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'package:flutter/material.dart'; import 'package:material_ui/material_ui.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:github_device_auth/github_device_auth.dart'; import 'package:github_device_auth/github_device_auth.dart';
@ -35,7 +35,8 @@ GitHubDeviceAuth _auth(
/// An auth client that never gets past its first poll delay. /// An auth client that never gets past its first poll delay.
GitHubDeviceAuth _pendingAuth() => _auth( GitHubDeviceAuth _pendingAuth() => _auth(
MockClient( MockClient(
(_) async => http.Response(jsonEncode({'error': 'authorization_pending'}), 200), (_) async =>
http.Response(jsonEncode({'error': 'authorization_pending'}), 200),
), ),
delay: _neverDelay, delay: _neverDelay,
); );

View File

@ -6,7 +6,7 @@ import 'package:data_transfer_flutter/data_transfer_flutter.dart';
/// claiming success or showing an error. /// claiming success or showing an error.
class BackupCancelled implements Exception { class BackupCancelled implements Exception {
/// Creates the signal. /// Creates the signal.
const BackupCancelled(); const new();
} }
/// An injectable local export/import delegate for [SyncSettingsScreen]'s /// An injectable local export/import delegate for [SyncSettingsScreen]'s
@ -22,11 +22,7 @@ class BackupCancelled implements Exception {
class BackupSlot { class BackupSlot {
/// Creates a [BackupSlot] labelled [label] (e.g. `'notes'`, /// Creates a [BackupSlot] labelled [label] (e.g. `'notes'`,
/// `'inventory'`), backed by [export] and [import]. /// `'inventory'`), backed by [export] and [import].
const BackupSlot({ const new({required this.label, required this.export, required this.import});
required this.label,
required this.export,
required this.import,
});
/// A slot whose backup is a JSON file, using `data_transfer_flutter`. /// A slot whose backup is a JSON file, using `data_transfer_flutter`.
/// ///
@ -35,7 +31,7 @@ class BackupSlot {
/// lets the user pick a JSON file and hands the decoded object to /// lets the user pick a JSON file and hands the decoded object to
/// [restore]. A dismissed dialog throws [BackupCancelled] (and a cancelled /// [restore]. A dismissed dialog throws [BackupCancelled] (and a cancelled
/// picker restores nothing). /// picker restores nothing).
factory BackupSlot.json({ factory json({
required String label, required String label,
required String fileName, required String fileName,
required Future<Map<String, Object?>> Function() build, required Future<Map<String, Object?>> Function() build,

View File

@ -29,11 +29,7 @@ enum FirebaseConnectOutcome {
/// [FirebaseSyncController.connectWithGoogle] call. /// [FirebaseSyncController.connectWithGoogle] call.
class FirebaseConnectResult { class FirebaseConnectResult {
/// Creates a [FirebaseConnectResult]. /// Creates a [FirebaseConnectResult].
const FirebaseConnectResult({ const new({required this.outcome, this.email, this.message});
required this.outcome,
this.email,
this.message,
});
/// What happened. /// What happened.
final FirebaseConnectOutcome outcome; final FirebaseConnectOutcome outcome;

View File

@ -21,7 +21,7 @@ class FirebaseSyncController {
/// is optional because Google sign-in itself is optional per /// is optional because Google sign-in itself is optional per
/// app/platform (see `googleAvailable` on `SyncSettingsScreen`) -- /// app/platform (see `googleAvailable` on `SyncSettingsScreen`) --
/// [connectWithGoogle] must not be called when it is null. /// [connectWithGoogle] must not be called when it is null.
FirebaseSyncController({ new({
required this.accountLoader, required this.accountLoader,
required this.accountSaver, required this.accountSaver,
required this.accountClearer, required this.accountClearer,

View File

@ -7,9 +7,9 @@ part of 'sync_settings_screen.dart';
/// A result: a glyph, the old sentence (spoken only), and whether it is a /// A result: a glyph, the old sentence (spoken only), and whether it is a
/// failure. Colour is the second channel: danger hue for failures. /// failure. Colour is the second channel: danger hue for failures.
class _Cue { class _Cue {
const _Cue(this.icon, this.spoken) : error = false; const new(this.icon, this.spoken) : error = false;
const _Cue.error(this.icon, this.spoken) : error = true; const new error(this.icon, this.spoken) : error = true;
final IconData icon; final IconData icon;
final String spoken; final String spoken;
@ -18,7 +18,7 @@ class _Cue {
/// Paints a [_Cue] as a large glyph. /// Paints a [_Cue] as a large glyph.
class _CueView extends StatelessWidget { class _CueView extends StatelessWidget {
const _CueView(this.cue); const new(this.cue);
final _Cue cue; final _Cue cue;
@ -39,7 +39,7 @@ class _CueView extends StatelessWidget {
/// A section heading as a glyph, spoken as [spoken]. /// A section heading as a glyph, spoken as [spoken].
class _Heading extends StatelessWidget { class _Heading extends StatelessWidget {
const _Heading(this.icon, this.spoken); const new(this.icon, this.spoken);
final IconData icon; final IconData icon;
final String spoken; final String spoken;

View File

@ -1,7 +1,7 @@
import 'dart:async'; import 'dart:async';
import 'package:crdt_sync/crdt_sync.dart'; import 'package:crdt_sync/crdt_sync.dart';
import 'package:flutter/material.dart'; import 'package:material_ui/material_ui.dart';
import 'package:sync_settings_ui/src/backup_slot.dart'; import 'package:sync_settings_ui/src/backup_slot.dart';
import 'package:sync_settings_ui/src/firebase_connect_result.dart'; import 'package:sync_settings_ui/src/firebase_connect_result.dart';
import 'package:sync_settings_ui/src/firebase_sync_controller.dart'; import 'package:sync_settings_ui/src/firebase_sync_controller.dart';

View File

@ -6,7 +6,7 @@ part of 'sync_settings_screen.dart';
/// a `part` rather than an import because both sections are /// a `part` rather than an import because both sections are
/// library-private and could not be imported at all. /// library-private and could not be imported at all.
class _FirebaseSection extends StatelessWidget { class _FirebaseSection extends StatelessWidget {
const _FirebaseSection({ const new({
required this.connected, required this.connected,
required this.busy, required this.busy,
required this.googleAvailable, required this.googleAvailable,
@ -139,7 +139,7 @@ class _FirebaseSection extends StatelessWidget {
} }
class _BackupSection extends StatelessWidget { class _BackupSection extends StatelessWidget {
const _BackupSection({ const new({
required this.backup, required this.backup,
required this.onExport, required this.onExport,
required this.onImport, required this.onImport,

View File

@ -11,7 +11,7 @@ part of 'sync_settings_screen.dart';
/// reached via a `ListTile` link to this one. /// reached via a `ListTile` link to this one.
class SyncSettingsScreen extends StatefulWidget { class SyncSettingsScreen extends StatefulWidget {
/// Creates a [SyncSettingsScreen]. /// Creates a [SyncSettingsScreen].
const SyncSettingsScreen({ const new({
required this.accountLoader, required this.accountLoader,
required this.accountSaver, required this.accountSaver,
required this.accountClearer, required this.accountClearer,

View File

@ -5,10 +5,10 @@ description: >-
injected closures -- no keystore or platform plugin access lives in this injected closures -- no keystore or platform plugin access lives in this
package itself. package itself.
publish_to: 'none' publish_to: 'none'
version: 0.7.1 version: 0.8.0
environment: environment:
sdk: ^3.12.2 sdk: ^3.13.0
dependencies: dependencies:
crdt_sync: crdt_sync:
@ -23,6 +23,7 @@ dependencies:
path: data_transfer_flutter path: data_transfer_flutter
flutter: flutter:
sdk: flutter sdk: flutter
material_ui: 1.11.0
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:

View File

@ -53,28 +53,22 @@ void main() {
expect(result.email, 'g@b.com'); expect(result.email, 'g@b.com');
}); });
test( test('reports signedInButNotPersisted with the stale account email when '
'reports signedInButNotPersisted with the stale account email when ' 'the client came back non-null but no session actually stuck -- the '
'the client came back non-null but no session actually stuck -- the ' 'invariant this package exists to centralize', () async {
'invariant this package exists to centralize', final controller = FirebaseSyncController(
() async { accountLoader: () async =>
final controller = FirebaseSyncController( const FirebaseAccount(email: 'stale@b.com', password: ''),
accountLoader: () async => accountSaver: (_) async {},
const FirebaseAccount(email: 'stale@b.com', password: ''), accountClearer: () async {},
accountSaver: (_) async {}, sessionProbe: () async => false,
accountClearer: () async {}, firebaseFactory: () async => null,
sessionProbe: () async => false, googleFirebaseFactory: () async => _fakeClient(),
firebaseFactory: () async => null, );
googleFirebaseFactory: () async => _fakeClient(), final result = await controller.connectWithGoogle();
); expect(result.outcome, FirebaseConnectOutcome.signedInButNotPersisted);
final result = await controller.connectWithGoogle(); expect(result.email, 'stale@b.com');
expect( });
result.outcome,
FirebaseConnectOutcome.signedInButNotPersisted,
);
expect(result.email, 'stale@b.com');
},
);
test( test(
'reports wrongAccount with the error message on FirebaseAuthError', 'reports wrongAccount with the error message on FirebaseAuthError',

View File

@ -42,22 +42,19 @@ void main() {
}, },
); );
test( test('trusts the session probe over account presence -- a marker with no '
'trusts the session probe over account presence -- a marker with no ' 'live session must read as not connected', () async {
'live session must read as not connected', final controller = FirebaseSyncController(
() async { accountLoader: () async =>
final controller = FirebaseSyncController( const FirebaseAccount(email: 'stale@b.com', password: 'x'),
accountLoader: () async => accountSaver: (_) async {},
const FirebaseAccount(email: 'stale@b.com', password: 'x'), accountClearer: () async {},
accountSaver: (_) async {}, sessionProbe: () async => false,
accountClearer: () async {}, firebaseFactory: () async => null,
sessionProbe: () async => false, );
firebaseFactory: () async => null, final status = await controller.loadStatus();
); expect(status.connected, isFalse);
final status = await controller.loadStatus(); });
expect(status.connected, isFalse);
},
);
}); });
group('connectWithPassword', () { group('connectWithPassword', () {
@ -99,52 +96,46 @@ void main() {
}, },
); );
test( test('clears the account and reports rejected with the error message when '
'clears the account and reports rejected with the error message when ' 'firebaseFactory throws FirebaseAuthError -- reproduces the screen '
'firebaseFactory throws FirebaseAuthError -- reproduces the screen ' 'getting stuck on "Signing in..." forever, since nothing here used '
'getting stuck on "Signing in..." forever, since nothing here used ' 'to catch this', () async {
'to catch this', var cleared = false;
() async { final controller = FirebaseSyncController(
var cleared = false; accountLoader: () async => null,
final controller = FirebaseSyncController( accountSaver: (_) async {},
accountLoader: () async => null, accountClearer: () async => cleared = true,
accountSaver: (_) async {}, sessionProbe: () async => false,
accountClearer: () async => cleared = true, firebaseFactory: () async => throw FirebaseAuthError('wrong password'),
sessionProbe: () async => false, );
firebaseFactory: () async => throw FirebaseAuthError('wrong password'), final result = await controller.connectWithPassword(
); email: 'a@b.com',
final result = await controller.connectWithPassword( password: 'wrong',
email: 'a@b.com', );
password: 'wrong', expect(result.outcome, FirebaseConnectOutcome.rejected);
); expect(result.message, 'wrong password');
expect(result.outcome, FirebaseConnectOutcome.rejected); expect(cleared, isTrue);
expect(result.message, 'wrong password'); });
expect(cleared, isTrue);
},
);
test( test('reports failed with the stringified error, and does not clear the '
'reports failed with the stringified error, and does not clear the ' 'account, on any other failure -- a possibly-transient error is not '
'account, on any other failure -- a possibly-transient error is not ' 'proof the credentials are wrong', () async {
'proof the credentials are wrong', var cleared = false;
() async { final controller = FirebaseSyncController(
var cleared = false; accountLoader: () async => null,
final controller = FirebaseSyncController( accountSaver: (_) async {},
accountLoader: () async => null, accountClearer: () async => cleared = true,
accountSaver: (_) async {}, sessionProbe: () async => false,
accountClearer: () async => cleared = true, firebaseFactory: () async => throw StateError('boom'),
sessionProbe: () async => false, );
firebaseFactory: () async => throw StateError('boom'), final result = await controller.connectWithPassword(
); email: 'a@b.com',
final result = await controller.connectWithPassword( password: 'pw',
email: 'a@b.com', );
password: 'pw', expect(result.outcome, FirebaseConnectOutcome.failed);
); expect(result.message, contains('boom'));
expect(result.outcome, FirebaseConnectOutcome.failed); expect(cleared, isFalse);
expect(result.message, contains('boom')); });
expect(cleared, isFalse);
},
);
test('reports progress stages in order on success', () async { test('reports progress stages in order on success', () async {
final stages = <String>[]; final stages = <String>[];

View File

@ -1,7 +1,7 @@
import 'dart:async'; import 'dart:async';
import 'package:crdt_sync/crdt_sync.dart'; import 'package:crdt_sync/crdt_sync.dart';
import 'package:flutter/material.dart'; import 'package:material_ui/material_ui.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:sync_settings_ui/sync_settings_ui.dart'; import 'package:sync_settings_ui/sync_settings_ui.dart';

View File

@ -1,7 +1,7 @@
import 'dart:async'; import 'dart:async';
import 'package:crdt_sync/crdt_sync.dart'; import 'package:crdt_sync/crdt_sync.dart';
import 'package:flutter/material.dart'; import 'package:material_ui/material_ui.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:sync_settings_ui/sync_settings_ui.dart'; import 'package:sync_settings_ui/sync_settings_ui.dart';
@ -38,7 +38,10 @@ void main() {
await tester.tap(find.bySemanticsLabel('Sign in with Google')); await tester.tap(find.bySemanticsLabel('Sign in with Google'));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(find.bySemanticsLabel('Google sign-in was cancelled.'), findsOneWidget); expect(
find.bySemanticsLabel('Google sign-in was cancelled.'),
findsOneWidget,
);
}); });
testWidgets( testWidgets(
@ -63,10 +66,7 @@ void main() {
await tester.tap(find.bySemanticsLabel('Sign in with Google')); await tester.tap(find.bySemanticsLabel('Sign in with Google'));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect( expect(spoken('did not save the session'), findsOneWidget);
spoken('did not save the session'),
findsOneWidget,
);
}, },
); );
@ -119,28 +119,25 @@ void main() {
expect(spoken('Sign-in failed'), findsOneWidget); expect(spoken('Sign-in failed'), findsOneWidget);
}); });
testWidgets( testWidgets('hides the Google button when googleAvailable is true but no '
'hides the Google button when googleAvailable is true but no ' 'googleFirebaseFactory is wired -- a visible button that can never '
'googleFirebaseFactory is wired -- a visible button that can never ' 'succeed must not render', (tester) async {
'succeed must not render', await tester.pumpWidget(
(tester) async { _wrap(
await tester.pumpWidget( SyncSettingsScreen(
_wrap( accountLoader: () async => null,
SyncSettingsScreen( accountSaver: (_) async {},
accountLoader: () async => null, accountClearer: () async {},
accountSaver: (_) async {}, sessionProbe: () async => false,
accountClearer: () async {}, firebaseFactory: () async => null,
sessionProbe: () async => false, googleAvailable: true,
firebaseFactory: () async => null,
googleAvailable: true,
),
), ),
); ),
await tester.pumpAndSettle(); );
await tester.pumpAndSettle();
expect(find.bySemanticsLabel('Sign in with Google'), findsNothing); expect(find.bySemanticsLabel('Sign in with Google'), findsNothing);
}, });
);
testWidgets('a reason renders a disabled button that explains itself', ( testWidgets('a reason renders a disabled button that explains itself', (
tester, tester,
@ -162,7 +159,10 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(find.bySemanticsLabel('Sign in with Google'), findsOneWidget); expect(find.bySemanticsLabel('Sign in with Google'), findsOneWidget);
expect(find.bySemanticsLabel('Not available on this platform.'), findsOneWidget); expect(
find.bySemanticsLabel('Not available on this platform.'),
findsOneWidget,
);
// Disabled, so it cannot report a misleading "cancelled". // Disabled, so it cannot report a misleading "cancelled".
final button = tester.widget<FilledButton>( final button = tester.widget<FilledButton>(
@ -171,9 +171,7 @@ void main() {
expect(button.onPressed, isNull); expect(button.onPressed, isNull);
}); });
testWidgets('no reason keeps the button hidden, as before', ( testWidgets('no reason keeps the button hidden, as before', (tester) async {
tester,
) async {
await tester.pumpWidget( await tester.pumpWidget(
_wrap( _wrap(
SyncSettingsScreen( SyncSettingsScreen(

View File

@ -1,7 +1,7 @@
import 'dart:async'; import 'dart:async';
import 'package:crdt_sync/crdt_sync.dart'; import 'package:crdt_sync/crdt_sync.dart';
import 'package:flutter/material.dart'; import 'package:material_ui/material_ui.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:sync_settings_ui/sync_settings_ui.dart'; import 'package:sync_settings_ui/sync_settings_ui.dart';
@ -24,10 +24,7 @@ void main() {
// lose the Firebase section from the tree entirely. // lose the Firebase section from the tree entirely.
setUp(() { setUp(() {
final binding = TestWidgetsFlutterBinding.ensureInitialized(); final binding = TestWidgetsFlutterBinding.ensureInitialized();
binding.platformDispatcher.views.first.physicalSize = const Size( binding.platformDispatcher.views.first.physicalSize = const Size(800, 2000);
800,
2000,
);
binding.platformDispatcher.views.first.devicePixelRatio = 1.0; binding.platformDispatcher.views.first.devicePixelRatio = 1.0;
addTearDown(binding.platformDispatcher.views.first.resetPhysicalSize); addTearDown(binding.platformDispatcher.views.first.resetPhysicalSize);
addTearDown(binding.platformDispatcher.views.first.resetDevicePixelRatio); addTearDown(binding.platformDispatcher.views.first.resetDevicePixelRatio);
@ -163,7 +160,10 @@ void main() {
await tester.tap(find.bySemanticsLabel('Connect Firebase')); await tester.tap(find.bySemanticsLabel('Connect Firebase'));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(find.bySemanticsLabel('Firebase rejected that account.'), findsOneWidget); expect(
find.bySemanticsLabel('Firebase rejected that account.'),
findsOneWidget,
);
}); });
testWidgets( testWidgets(
@ -178,8 +178,7 @@ void main() {
accountSaver: (_) async {}, accountSaver: (_) async {},
accountClearer: () async {}, accountClearer: () async {},
sessionProbe: () async => false, sessionProbe: () async => false,
firebaseFactory: () async => firebaseFactory: () async => throw FirebaseAuthError('bad creds'),
throw FirebaseAuthError('bad creds'),
), ),
), ),
); );
@ -208,42 +207,39 @@ void main() {
}, },
); );
testWidgets( testWidgets('shows the Google button when googleAvailable, and connecting '
'shows the Google button when googleAvailable, and connecting ' 'succeeds', (tester) async {
'succeeds', var sessionStored = false;
(tester) async { await tester.pumpWidget(
var sessionStored = false; _wrap(
await tester.pumpWidget( SyncSettingsScreen(
_wrap( accountLoader: () async => null,
SyncSettingsScreen( accountSaver: (_) async {},
accountLoader: () async => null, accountClearer: () async {},
accountSaver: (_) async {}, sessionProbe: () async => sessionStored,
accountClearer: () async {}, firebaseFactory: () async => null,
sessionProbe: () async => sessionStored, googleFirebaseFactory: () async {
firebaseFactory: () async => null, sessionStored = true;
googleFirebaseFactory: () async { return _fakeClient();
sessionStored = true; },
return _fakeClient(); googleAvailable: true,
},
googleAvailable: true,
),
), ),
); ),
await tester.pumpAndSettle(); );
await tester.pumpAndSettle();
expect(find.bySemanticsLabel('Sign in with Google'), findsOneWidget); expect(find.bySemanticsLabel('Sign in with Google'), findsOneWidget);
// The password form is collapsed behind its ExpansionTile when // The password form is collapsed behind its ExpansionTile when
// Google is offered -- only the field labels prove that; the tile's // Google is offered -- only the field labels prove that; the tile's
// own title text is present either way. // own title text is present either way.
expect( expect(
find.widgetWithIcon(TextField, Icons.alternate_email), find.widgetWithIcon(TextField, Icons.alternate_email),
findsNothing, findsNothing,
); );
await tester.tap(find.bySemanticsLabel('Sign in with Google')); await tester.tap(find.bySemanticsLabel('Sign in with Google'));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(find.bySemanticsLabel('Connected to Firebase.'), findsOneWidget); expect(find.bySemanticsLabel('Connected to Firebase.'), findsOneWidget);
}, });
);
}); });
} }