Fix screen-reader gaps that block accessibility-tree automation (#3693)
What changed, and why it matters
This is a large accessibility and test-automation improvement for the Cake Wallet Flutter app. It adds stable identifiers to buttons, text fields, lists, and dialogs so screen readers and automated UI tests can find them. The patch also removes user data such as wallet names, transaction IDs, and seed words from those identifiers, which reduces the risk of leaking sensitive information through the operating system's accessibility tree. There is no traditional security vulnerability being fixed, but the change hardens privacy in the accessibility layer and improves automated testing coverage.
No urgent security patch is required. Review the new lints and CI workflow to ensure they are enabled in all active branches, and confirm that no remaining `*_key` literals interpolate user data. Consider auditing other identifiers outside lib/ for similar leaks.
Security signals we found
Removed user-data interpolation from accessibility identifiers (tx ids, wallet names, seed words, addresses)
Added stable, index-based or enum-based semantics identifiers across UI components
Added custom lints and CI workflow to prevent future user-data interpolation in test keys
Improved screen-reader semantics for PIN pad, balance cards, checkboxes, alerts, and navigation
Added widget and integration tests covering accessibility identifiers and traversal
No traditional vulnerability class (e.g., injection, buffer overflow, cryptographic flaw) is present in the diff
Evidence from the diff
The commit introduces a TestId helper that maps Flutter ValueKey^[a-z0-9_]+_key$ to Semantics identifiers, making them visible to XCUITest/UIAutomator. It adds two custom lints (require_test_key_semantics_identifier, no_string_interpolation_in_test_key) and a codemod to wrap framework interactive widgets. The diff shows concrete changes to balance cards, PIN pad, picker rows, coin-control rows, theme choices, receive/send/swap sheets, and alert dialogs. Several places that previously interpolated user data (tx ids, wallet names, seed words, addresses) into keys now use list indices or enum names. New widget and integration tests verify the identifiers and semantics behavior.
Changed components
lib/new-ui/widgets/coins_page/cards/balance_card.dartlib/new-ui/widgets/coins_page/cards/cards_view.dartlib/new-ui/widgets/charts_page/range_selector.dartlib/new-ui/widgets/coin_control_page/coin_control_list_item.dartlib/new-ui/widgets/picker.dartlib/new-ui/widgets/receive_page/receive_amount_modal.dartlib/new-ui/widgets/send_page/l2_action_wallet_selector.dartlib/new-ui/widgets/coins_page/top_bar_widget/lightning_switcher.dartlib/src/screens/pin_code/pin_code_widget.dartlib/src/screens/settings/widgets/settings_theme_choice.dartlib/src/widgets/cake_image_widget.dartlib/src/widgets/new_list_row/list_item_checkbox_widget.dartlib/src/widgets/new_list_row/new_simple_checkbox.dartlib/new-ui/pages/wallet_accounts_page.dartintegration_test/core/base_robot.dartintegration_test/suites/tier0/semantics_identifiers_test.dartintegration_test/suites/tier0/show_keys_auth_test.darttest/new-ui/widgets/a11y_gap_fixes_test.darttest/new-ui/widgets/confirm_swiper_test.darttest/new-ui/widgets/copy_wrapper_test.darttest/new-ui/widgets/modern_button_test.darttest/new-ui/widgets/receive_page/modal_top_bar_test.darttest/new-ui/widgets/send_page/floating_icon_button_test.darttest/src/widgets/cake_image_widget_test.darttest/src/widgets/primary_button_test.darttest/src/widgets/rounded_checkbox_test.darttest/utils/address_formatter_test.darttest/utils/semantics_helpers.dartdocs/INTEGRATION_TESTS.mdres/values/strings_*.arbInspect captured patch +2128 / −22
### docs/INTEGRATION_TESTS.md
@@ -114,7 +114,7 @@ stable history. funds_suites run only from the manual funds workflow.
## What is covered today
-Twenty seven suites. Add a line here when you add one.
+Twenty eight suites. Add a line here when you add one.
### tier0, no network needed
@@ -137,6 +137,7 @@ Twenty seven suites. Add a line here when you add one.
| `settings_nav_test` | Every settings row opens its page and backs out of it |
| `language_test` | Changing the language changes what the settings screen shows |
| `fiat_currency_test` | Turning the fiat api off hides the currency setting, turning it back on returns it and the currency can be changed |
+| `semantics_identifiers_test` | Home, settings, receive, set amount and send controls expose the semantics identifiers Appium and UIAutomator select on |
### tier1, needs a node or a provider
### integration_test/core/base_robot.dart
@@ -2,6 +2,7 @@ import "dart:async";
import "package:cake_wallet/src/widgets/picker.dart";
import "package:flutter/material.dart";
+import "package:flutter/semantics.dart";
import "package:flutter_test/flutter_test.dart";
import "package:integration_test/integration_test.dart";
@@ -75,6 +76,59 @@ abstract class BaseRobot {
throw TestFailure("Widget still present after ${timeout.inSeconds}s: $finder");
}
+ Future<void> expectTestId(String id, {Duration timeout = const Duration(seconds: 30)}) async {
+ final handle = tester.ensureSemantics();
+ try {
+ await pumpUntil(() => _exportedNodesWithId(id).isNotEmpty, timeout: timeout);
+ final count = _exportedNodesWithId(id).length;
+ if (count != 1) {
+ await takeScreenshot("${runtimeType}_expect_test_id_$id");
+ }
+ expect(count, 1, reason: "Exported semantics nodes with identifier $id");
+ } finally {
+ handle.dispose();
+ }
+ }
+
+ Future<void> tapTestId(String id) async {
+ final handle = tester.ensureSemantics();
+ try {
+ await tapWhenVisible(find.bySemanticsIdentifier(id));
+ } finally {
+ handle.dispose();
+ }
+ }
+
+ Future<void> enterTextByTestId(String id, String text) async {
+ final handle = tester.ensureSemantics();
+ try {
+ final finder = find.descendant(of: find.bySemanticsIdentifier(id), matching: find.byType(EditableText));
+ await pumpUntilFound(finder);
+ await tester.enterText(finder.first, text);
+ await tester.pump(const Duration(milliseconds: 300));
+ } finally {
+ handle.dispose();
+ }
+ }
+
+ List<SemanticsNode> _exportedNodesWithId(String id) {
+ final result = <SemanticsNode>[];
+ void visit(SemanticsNode node) {
+ if (!node.isMergedIntoParent && node.getSemanticsData().identifier == id) {
+ result.add(node);
+ }
+ node.visitChildren((child) {
+ visit(child);
+ return true;
+ });
+ }
+ final root = tester.binding.renderViews.first.owner?.semanticsOwner?.rootSemanticsNode;
+ if (root != null) {
+ visit(root);
+ }
+ return result;
+ }
+
Future<void> tapByKey(String key, {Duration timeout = const Duration(seconds: 30)}) async {
final finder = find.byKey(ValueKey(key));
### integration_test/suites/tier0/semantics_identifiers_test.dart
@@ -0,0 +1,88 @@
+import "package:cake_wallet/routes.dart";
+import "package:cw_core/wallet_type.dart";
+import "package:integration_test/integration_test.dart";
+
+import "../../core/app_launcher.dart";
+import "../../flows/onboarding_flows.dart";
+import "../../robots/home_page_robot.dart";
+import "../../robots/new_dashboard_robot.dart";
+import "../../robots/new_receive_page_robot.dart";
+import "../../robots/new_send_page_robot.dart";
+import "../../robots/new_settings_page_robot.dart";
+
+void main() {
+ IntegrationTestWidgetsFlutterBinding.ensureInitialized();
+
+ integrationTest("Release-checklist controls expose their semantics identifiers", (tester) async {
+ final onboardingFlows = OnboardingFlows(tester);
+ final dashboardRobot = NewDashboardRobot(tester);
+ final homePageRobot = HomePageRobot(tester);
+ final settingsRobot = NewSettingsPageRobot(tester);
+ final receiveRobot = NewReceivePageRobot(tester);
+ final sendRobot = NewSendPageRobot(tester);
+
+ await AppLauncher(tester).launchApp(testKey: "semantics_identifiers_test_app_key");
+ await onboardingFlows.createFirstWallet(WalletType.solana);
+
+ await dashboardRobot.isDisplayed();
+ await homePageRobot.isDisplayed();
+ for (final id in [
+ "dashboard_page_home_action_button_key",
+ "dashboard_page_wallets_action_button_key",
+ "home_page_send_button_key",
+ "home_page_receive_button_key",
+ "home_page_settings_button_key",
+ ]) {
+ await homePageRobot.expectTestId(id);
+ }
+
+ await homePageRobot.openSettingsSheet();
+ await settingsRobot.isDisplayed();
+ await settingsRobot.expectTestId("settings_page_top_bar_title_key");
+ for (final (route, id) in [
+ (Routes.privacyPage, "settings_page_privacy_row_key"),
+ (Routes.displaySettingsPage, "settings_page_display_settings_row_key"),
+ ]) {
+ await settingsRobot.scrollUntilRowVisible(route);
+ await settingsRobot.expectTestId(id);
+ }
+ await settingsRobot.dismissModal();
+ await homePageRobot.isDisplayed();
+
+ await homePageRobot.openReceiveSheet();
+ await receiveRobot.isDisplayed();
+ for (final id in [
+ "receive_page_top_bar_title_key",
+ "receive_page_copy_button_key",
+ "receive_page_set_amount_button_key",
+ ]) {
+ await receiveRobot.expectTestId(id);
+ }
+ await receiveRobot.tapTestId("receive_page_set_amount_button_key");
+ for (final id in [
+ "receive_amount_modal_title_key",
+ "receive_amount_modal_leading_key",
+ "receive_amount_modal_amount_textfield_key",
+ "receive_amount_modal_continue_button_key",
+ ]) {
+ await receiveRobot.expectTestId(id);
+ }
+ await receiveRobot.enterTextByTestId("receive_amount_modal_amount_textfield_key", "1");
+ await receiveRobot.tapTestId("receive_amount_modal_continue_button_key");
+ await receiveRobot.isDisplayed();
+ await receiveRobot.dismissModal();
+ await homePageRobot.isDisplayed();
+
+ await homePageRobot.openSendSheet();
+ await sendRobot.isDisplayed();
+ for (final id in [
+ "send_page_top_bar_title_key",
+ "send_page_address_input_key",
+ "send_page_amount_input_key",
+ ]) {
+ await sendRobot.expectTestId(id);
+ }
+ await sendRobot.dismissModal();
+ await homePageRobot.isDisplayed();
+ });
+}
### integration_test/suites/tier0/show_keys_auth_test.dart
@@ -1,3 +1,4 @@
+import "package:another_flushbar/flushbar.dart";
import "package:cake_wallet/routes.dart";
import "package:cake_wallet/src/screens/wallet_keys/wallet_keys_page.dart";
import "package:cw_core/wallet_type.dart";
@@ -49,6 +50,7 @@ void main() {
await settingsRobot.settle(max: const Duration(seconds: 3));
expect(find.byType(WalletKeysPage), findsNothing);
expect(authFlows.isPinWidgetShown(), true);
+ await settingsRobot.pumpUntilGone(find.byWidgetPredicate((widget) => widget is Flushbar));
await authFlows.authenticateWithPin();
### lib/new-ui/pages/wallet_accounts_page.dart
@@ -163,6 +163,7 @@ class _WalletAccountsPageState extends State<WalletAccountsPage> {
newItems.add(
AccountCustomizerListItem(
card: BalanceCard(
+ excludeAccountName: true,
accountName: "${account.id + 1}. $accountLabel",
accountBalance: account.balance,
fiatBalance:
@@ -388,6 +389,7 @@ class _WalletAccountsPageState extends State<WalletAccountsPage> {
for (int i = 0; i < _items.length; i++) {
_items[i] = AccountCustomizerListItem(
card: BalanceCard(
+ excludeAccountName: true,
accountName: _items[i].card.accountName,
balance: _items[i].card.balance,
accountIndex: _items[i].card.accountIndex,
@@ -470,6 +472,9 @@ class _AccountCards extends StatelessWidget {
return Container(
key: ValueKey(items[index].accountListItem.id),
child: Semantics(
+ container: true,
+ explicitChildNodes: true,
+ identifier: "wallet_accounts_page_account_${index}_key",
button: true,
selected: selectedItemIndex == index,
label: "${items[index].accountListItem.id + 1}. "
### lib/new-ui/widgets/charts_page/range_selector.dart
@@ -1,4 +1,5 @@
import "package:cake_wallet/new-ui/model/charts/util/chart_range.dart";
+import "package:cake_wallet/utils/test_id.dart";
import "package:flutter/material.dart";
class ChartRangeSelector extends StatelessWidget {
@@ -36,7 +37,9 @@ class ChartRangeSelector extends StatelessWidget {
children: ChartRange.ranges.map((item) {
final selected = selectedRange == item;
final isFirst = ChartRange.ranges.indexOf(item) == 0;
- return GestureDetector(
+ return TestId.merge("chart_range_${ChartRange.ranges.indexOf(item)}_key",
+ child: Semantics(button: true, selected: selected, inMutuallyExclusiveGroup: true,
+ child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
if (!selected) {
@@ -63,6 +66,8 @@ class ChartRangeSelector extends StatelessWidget {
),
),
),
+ ),
+ ),
);
}).toList(),
),
### lib/new-ui/widgets/coin_control_page/coin_control_list_item.dart
@@ -37,7 +37,8 @@ class CoinControlListItem extends StatelessWidget {
@override
Widget build(BuildContext context) {
- return Container(
+ return MergeSemantics(
+ child: Container(
height: 70,
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surfaceContainer,
@@ -121,7 +122,7 @@ class CoinControlListItem extends StatelessWidget {
)
],
),
- ));
+ )));
}
Widget _getLeading(BuildContext context) {
### lib/new-ui/widgets/coins_page/cards/balance_card.dart
@@ -24,12 +24,14 @@ class BalanceCard extends StatelessWidget {
this.capitalizeAssetName = true,
this.onCustomizeTapped,
this.accountIndex,
- this.fiatFirst = false});
+ this.fiatFirst = false,
+ this.excludeAccountName = false});
final double width;
final double borderRadius;
final Gradient? gradient;
final Money? accountBalance;
+ final bool excludeAccountName;
final String accountName;
final String balance;
final String fiatBalance;
@@ -124,7 +126,7 @@ class BalanceCard extends StatelessWidget {
style: Theme.of(context).textTheme.titleMedium!.copyWith(
fontWeight: FontWeight.w500,
color: design.colors.textColor),
- child: Text("$accountIndex."),
+ child: ExcludeSemantics(excluding: excludeAccountName && leadText == accountName, child: Text("$accountIndex.")),
),
),
AnimatedDefaultTextStyle(
@@ -133,7 +135,7 @@ class BalanceCard extends StatelessWidget {
fontWeight: FontWeight.w500,
color: design.colors.textColor
.withAlpha(leadText == accountName ? 255 : 128)),
- child: Text(leadText),
+ child: ExcludeSemantics(excluding: excludeAccountName && leadText == accountName, child: Text(leadText)),
),
],
),
@@ -161,6 +163,9 @@ class BalanceCard extends StatelessWidget {
// may be announced.
child: ExcludeSemantics(
excluding: !selected,
+ child: Semantics(
+ container: true,
+ identifier: fiatFirst ? "balance_card_fiat_balance_key" : "balance_card_crypto_balance_key",
child: AnimatedSwitcher(
duration: designSwitchDuration,
layoutBuilder: (currentChild, previousChildren) {
@@ -203,6 +208,7 @@ class BalanceCard extends StatelessWidget {
],
),
),
+ ),
),
),
AnimatedDefaultTextStyle(
@@ -211,6 +217,9 @@ class BalanceCard extends StatelessWidget {
fontSize: 15,
fontWeight: FontWeight.w400,
color: design.colors.textColorSecondary),
+ child: Semantics(
+ container: true,
+ identifier: !selected ? null : fiatFirst ? "balance_card_crypto_balance_key" : "balance_card_fiat_balance_key",
child: AnimatedSwitcher(
duration: designSwitchDuration,
layoutBuilder: (currentChild, previousChildren) {
@@ -229,6 +238,7 @@ class BalanceCard extends StatelessWidget {
fiatFirst ? "$assetName $balance" : fiatBalance,
),
),
+ ),
),
],
)
### lib/new-ui/widgets/coins_page/cards/cards_view.dart
@@ -128,6 +128,9 @@ class _CardsViewState extends State<CardsView> {
// The card is the tap target; the balances and the card's own buttons stay
// reachable as children of this node.
child: Semantics(
+ container: true,
+ explicitChildNodes: true,
+ identifier: "home_page_balance_card_${realIndex}_key",
button: true,
selected: isSelected,
label: cardLabel,
@@ -191,6 +194,7 @@ class _CardsViewState extends State<CardsView> {
return BalanceCard(
+ excludeAccountName: true,
width: effectiveCardWidth,
accountName: accountName,
accountBalance: accountBalance,
### lib/new-ui/widgets/coins_page/top_bar_widget/lightning_switcher.dart
@@ -16,6 +16,7 @@ class LightningSwitcher extends StatelessWidget {
// One toggle node: the knob position and the coloured glyphs are the only
// visual cue for which mode is active.
return Semantics(
+ identifier: "home_page_lightning_switch_key",
button: true,
toggled: lightningMode,
label: S.of(context).lightning_mode,
### lib/new-ui/widgets/picker.dart
@@ -192,7 +192,7 @@ class PickerSliderButton<Item> extends StatelessWidget {
@override
Widget build(BuildContext context) {
- return GestureDetector(
+ return MergeSemantics(child: GestureDetector(
onTap: () {
onSelected(item.value);
},
@@ -256,7 +256,7 @@ class PickerSliderButton<Item> extends StatelessWidget {
),
),
),
- );
+ ));
}
}
@@ -277,7 +277,7 @@ class PickerRow<Item> extends StatelessWidget {
@override
Widget build(BuildContext context) {
- return GestureDetector(
+ return MergeSemantics(child: GestureDetector(
onTap: () {
onSelected(item.value);
},
@@ -344,7 +344,7 @@ class PickerRow<Item> extends StatelessWidget {
),
),
),
- );
+ ));
}
}
### lib/new-ui/widgets/receive_page/receive_amount_modal.dart
@@ -57,6 +57,7 @@ class _ReceiveAmountModalState extends State<ReceiveAmountModal> {
onTrailingPressed: () {},
leadingIcon: Icon(Icons.close),
leadingSemanticLabel: S.of(context).close,
+ testId: "receive_amount_modal",
),
Padding(
padding: const EdgeInsets.all(18.0),
@@ -149,7 +150,8 @@ class _ReceiveAmountModalState extends State<ReceiveAmountModal> {
),
child: MergeSemantics(
child: Semantics(
- label: S.of(context).amount,
+ identifier: "receive_amount_modal_amount_textfield_key",
+ label: S.of(context).receive_amount,
child: TextField(
textAlign: TextAlign.left,
textAlignVertical: TextAlignVertical.center,
@@ -240,6 +242,7 @@ class _ReceiveAmountModalState extends State<ReceiveAmountModal> {
),
SizedBox(),
NewPrimaryButton(
+ testId: "receive_amount_modal_continue_button_key",
text: S.of(context).continue_text,
onPressed: () {
if (double.tryParse(_amountController.text) != null) {
### lib/new-ui/widgets/send_page/l2_action_wallet_selector.dart
@@ -356,7 +356,7 @@ class WalletRow extends StatelessWidget {
final bool? isSelected;
@override
- Widget build(BuildContext context) => Container(
+ Widget build(BuildContext context) => MergeSemantics(child: Container(
height: isCurrent ? 64 : 48,
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surfaceContainer,
@@ -418,5 +418,5 @@ class WalletRow extends StatelessWidget {
),
),
),
- );
+ ));
}
### lib/src/screens/pin_code/pin_code_widget.dart
@@ -1,6 +1,7 @@
import 'package:cake_wallet/utils/device_info.dart';
import 'package:cake_wallet/utils/responsive_layout_util.dart';
import 'package:cake_wallet/utils/show_bar.dart';
+import "package:cake_wallet/utils/test_id.dart";
import 'package:another_flushbar/flushbar.dart';
import 'package:flutter/material.dart';
import 'package:cake_wallet/generated/i18n.dart';
@@ -155,7 +156,12 @@ class PinCodeState<T extends PinCodeWidget> extends State<T> {
),
),
Spacer(flex: 2),
- Container(
+ Semantics(
+ container: true,
+ liveRegion: true,
+ identifier: "pin_code_progress_key",
+ label: S.of(context).pin_digits_entered("${pin.length}", "$pinLength"),
+ child: Container(
width: 180,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
@@ -175,6 +181,7 @@ class PinCodeState<T extends PinCodeWidget> extends State<T> {
}),
),
),
+ ),
Spacer(flex: 3),
if (widget.hasLengthSwitcher) ...[
TextButton(
@@ -225,6 +232,7 @@ class PinCodeState<T extends PinCodeWidget> extends State<T> {
child: Container(
margin: EdgeInsets.only(left: marginLeft, right: marginRight),
child: Semantics(
+ identifier: "pin_code_delete_button_key",
label: S.of(context).delete,
button: true,
onTap: () => _pop(),
@@ -246,7 +254,7 @@ class PinCodeState<T extends PinCodeWidget> extends State<T> {
return Container(
margin: EdgeInsets.only(left: marginLeft, right: marginRight),
- child: TextButton(
+ child: TestId.merge("pin_code_button_${index}_key", child: TextButton(
key: ValueKey('pin_code_button_${index}_key'),
onPressed: () => {_push(index), HapticFeedback.mediumImpact()},
style: TextButton.styleFrom(
@@ -261,6 +269,7 @@ class PinCodeState<T extends PinCodeWidget> extends State<T> {
color: Theme.of(context).colorScheme.onSurfaceVariant,
)),
),
+ ),
);
}),
),
### lib/src/screens/settings/widgets/settings_theme_choice.dart
@@ -47,7 +47,8 @@ class SettingsThemeChoicesCell extends StatelessWidget {
final isSelected = _displaySettingsViewModel.isThemeSelected(theme);
return Semantics(
- label: theme.toString(),
+ identifier: "display_settings_theme_${(theme.themeFamily ?? theme.type.name).toLowerCase()}_key",
+ label: theme.title,
selected: isSelected,
child: GestureDetector(
onTap: () {
### lib/src/widgets/cake_image_widget.dart
@@ -75,8 +75,7 @@ class CakeImageWidget extends StatelessWidget {
width: width,
errorBuilder: (_, __, ___) => SizedBox(height: height, width: width),
colorFilter: effectiveColorFilter,
- semanticsLabel: semanticsLabel,
- excludeFromSemantics: _isDecorative,
+ excludeFromSemantics: true,
fit: fit ?? BoxFit.contain,
);
});
### lib/src/widgets/new_list_row/list_item_checkbox_widget.dart
@@ -41,8 +41,9 @@ class ListItemCheckboxWidget extends StatefulWidget {
class _ListItemCheckboxWidgetState extends State<ListItemCheckboxWidget> {
@override
Widget build(BuildContext context) {
- return ListItemStyleWrapper(
+ final row = ListItemStyleWrapper(
testId: widget.testId,
+ mergeTestId: widget.onTap == null,
iconPath: widget.iconPath,
onTap: widget.onTap ??
() {
@@ -100,6 +101,7 @@ class _ListItemCheckboxWidgetState extends State<ListItemCheckboxWidget> {
),
NewSimpleCheckbox(
value: widget.value,
+ semanticLabel: widget.onTap == null ? null : widget.label,
onChanged: (newValue) {
widget.onChanged(newValue);
},
@@ -108,5 +110,7 @@ class _ListItemCheckboxWidgetState extends State<ListItemCheckboxWidget> {
);
},
);
+
+ return widget.testId == null && widget.onTap == null ? MergeSemantics(child: row) : row;
}
}
### lib/src/widgets/new_list_row/new_simple_checkbox.dart
@@ -5,14 +5,20 @@ class NewSimpleCheckbox extends StatelessWidget {
super.key,
required this.value,
required this.onChanged,
+ this.semanticLabel,
});
final bool value;
final ValueChanged<bool> onChanged;
+ final String? semanticLabel;
@override
Widget build(BuildContext context) {
- return GestureDetector(
+ return Semantics(
+ container: true,
+ checked: value,
+ label: semanticLabel,
+ child: GestureDetector(
onTap: () {
onChanged(!value);
},
@@ -35,6 +41,7 @@ class NewSimpleCheckbox extends StatelessWidget {
)
: const SizedBox.shrink(),
),
+ ),
);
}
}
### res/values/strings_ar.arb
@@ -864,6 +864,7 @@
"picker_see_all": "شاهد الكل",
"picker_show_less": "عرض أقل",
"pin_at_top": "تثبيت ${token} في الأعلى",
+ "pin_digits_entered": "تم إدخال ${entered} من ${total} أرقام",
"pin_is_incorrect": "رمز PIN غير صحيح",
"pin_number": "رقم PIN",
"placeholder_contacts": "ستُعرض جهات اتصالك هنا",
### res/values/strings_bg.arb
@@ -864,6 +864,7 @@
"picker_see_all": "Вижте всички",
"picker_show_less": "Покажи по-малко",
"pin_at_top": "Закачи ${token} най-отгоре",
+ "pin_digits_entered": "Въведени са ${entered} от ${total} цифри",
"pin_is_incorrect": "PIN кодът е неправилен",
"pin_number": "PIN номер",
"placeholder_contacts": "Вашите контакти ще бъдат показани тук",
### res/values/strings_cs.arb
@@ -864,6 +864,7 @@
"picker_see_all": "Zobrazit vše",
"picker_show_less": "Ukázat méně",
"pin_at_top": "Připnout ${token} nahoru",
+ "pin_digits_entered": "Zadáno ${entered} z ${total} číslic",
"pin_is_incorrect": "PIN je nesprávný",
"pin_number": "PIN",
"placeholder_contacts": "Vaše kontakty se zobrazí zde",
### res/values/strings_de.arb
@@ -910,6 +910,7 @@
"picker_see_all": "Alle anzeigen",
"picker_show_less": "Weniger anzeigen",
"pin_at_top": "${token} oben anheften",
+ "pin_digits_entered": "${entered} von ${total} Ziffern eingegeben",
"pin_is_incorrect": "Die PIN ist falsch.",
"pin_number": "PIN-Nummer",
"placeholder_contacts": "Ihre Kontakte werden hier angezeigt",
### res/values/strings_en.arb
@@ -928,6 +928,7 @@
"picker_see_all": "See All",
"picker_show_less": "Show less",
"pin_at_top": "Pin ${token} at top",
+ "pin_digits_entered": "${entered} of ${total} digits entered",
"pin_is_incorrect": "PIN is incorrect",
"pin_number": "PIN number",
"placeholder_contacts": "Your contacts will be displayed here",
### res/values/strings_es.arb
@@ -865,6 +865,7 @@
"picker_see_all": "Ver todo",
"picker_show_less": "Mostrar menos",
"pin_at_top": "Fijar ${token} arriba",
+ "pin_digits_entered": "${entered} de ${total} dígitos introducidos",
"pin_is_incorrect": "El PIN es incorrecto",
"pin_number": "Número de PIN",
"placeholder_contacts": "Tus contactos se mostrarán aquí",
### res/values/strings_fa.arb
@@ -864,6 +864,7 @@
"picker_see_all": "همه را ببینید",
"picker_show_less": "کمتر نشان دادن",
"pin_at_top": "سنجاق کردن ${token} به بالا",
+ "pin_digits_entered": "${entered} از ${total} رقم وارد شد",
"pin_is_incorrect": "پین نادرست است",
"pin_number": "شماره PIN",
"placeholder_contacts": "مخاطبین شما اینجا نمایش داده میشوند",
### res/values/strings_fr.arb
@@ -864,6 +864,7 @@
"picker_see_all": "Voir tout",
"picker_show_less": "Afficher moins",
"pin_at_top": "Épingler ${token} en haut",
+ "pin_digits_entered": "${entered} chiffres saisis sur ${total}",
"pin_is_incorrect": "Le PIN est incorrect",
"pin_number": "Numéro de PIN",
"placeholder_contacts": "Vos contacts seront affichés ici",
### res/values/strings_gn.arb
@@ -864,6 +864,7 @@
"picker_see_all": "Ehecha opa mba'e",
"picker_show_less": "Ehechauka sa’ive",
"pin_at_top": "Emboja ${token} yvate gotyo",
+ "pin_digits_entered": "Oñemoinge ${entered} papapy ${total} apytégui",
"pin_is_incorrect": "PIN ndoikói hag̃ua",
"pin_number": "PIN papapy",
"placeholder_contacts": "Nde contacto kuéra ojehechaukáta koʼápe.",
### res/values/strings_ha.arb
@@ -866,6 +866,7 @@
"picker_see_all": "Duba duka",
"picker_show_less": "Nuna ƙasa",
"pin_at_top": "Saka ${token} a sama",
+ "pin_digits_entered": "An shigar da lambobi ${entered} cikin ${total}",
"pin_is_incorrect": "PIN ɗin ba daidai ba ne",
"pin_number": "Lambar PIN",
"placeholder_contacts": "Za a nuna abokan hulɗarka a nan",
### res/values/strings_hi.arb
@@ -911,6 +911,7 @@
"picker_see_all": "सभी देखें",
"picker_show_less": "कम दिखाओ",
"pin_at_top": "${token} को शीर्ष पर पिन करें",
+ "pin_digits_entered": "${entered} अंक दर्ज किए गए, कुल ${total} में से",
"pin_is_incorrect": "PIN गलत है",
"pin_number": "पिन नंबर",
"placeholder_contacts": "आपके संपर्क यहां प्रदर्शित होंगे",
### res/values/strings_hr.arb
@@ -864,6 +864,7 @@
"picker_see_all": "Vidi sve",
"picker_show_less": "Prikaži manje",
"pin_at_top": "Prikvači ${token} na vrh",
+ "pin_digits_entered": "Uneseno ${entered} od ${total} znamenki",
"pin_is_incorrect": "PIN je netočan",
"pin_number": "PIN broj",
"placeholder_contacts": "Vaši će kontakti biti prikazani ovdje",
### res/values/strings_hy.arb
@@ -864,6 +864,7 @@
"picker_see_all": "Տես բոլորը",
"picker_show_less": "Ցույց տալ ավելի քիչ",
"pin_at_top": "${token}-ը ամրացնել վերևում",
+ "pin_digits_entered": "Մուտքագրված է ${entered} թվանշան ${total}-ից",
"pin_is_incorrect": "PIN-ը սխալ է",
"pin_number": "PIN համար",
"placeholder_contacts": "Ձեր կոնտակտները կցուցադրվեն այստեղ",
### res/values/strings_id.arb
@@ -866,6 +866,7 @@
"picker_see_all": "Lihat semuanya",
"picker_show_less": "Tampilkan lebih sedikit",
"pin_at_top": "Sematkan ${token} di atas",
+ "pin_digits_entered": "${entered} dari ${total} digit dimasukkan",
"pin_is_incorrect": "PIN tidak benar",
"pin_number": "Nomor PIN",
"placeholder_contacts": "Kontak Anda akan ditampilkan di sini",
### res/values/strings_it.arb
@@ -865,6 +865,7 @@
"picker_see_all": "Vedi tutto",
"picker_show_less": "Mostra meno",
"pin_at_top": "Fissa ${token} in alto",
+ "pin_digits_entered": "${entered} cifre inserite su ${total}",
"pin_is_incorrect": "Il PIN non è corretto",
"pin_number": "Numero PIN",
"placeholder_contacts": "I tuoi contatti verranno visualizzati qui",
### res/values/strings_ja.arb
@@ -865,6 +865,7 @@
"picker_see_all": "全て見る",
"picker_show_less": "表示を少なくする",
"pin_at_top": "${token} を上部にピン留め",
+ "pin_digits_entered": "${entered}/${total}桁を入力済み",
"pin_is_incorrect": "PINが正しくありません",
"pin_number": "PIN番号",
"placeholder_contacts": "連絡先がここに表示されます",
### res/values/strings_ko.arb
@@ -864,6 +864,7 @@
"picker_see_all": "모두 보기",
"picker_show_less": "간략히 보기",
"pin_at_top": "${token}을(를) 상단에 고정",
+ "pin_digits_entered": "${entered}/${total}자리 입력됨",
"pin_is_incorrect": "PIN이 올바르지 않습니다",
"pin_number": "PIN 번호",
"placeholder_contacts": "연락처가 여기에 표시됩니다",
### res/values/strings_my.arb
@@ -864,6 +864,7 @@
"picker_see_all": "အားလုံးကြည့်",
"picker_show_less": "လျှော့ပြပါ။",
"pin_at_top": "${token} ကို အပေါ်ဆုံးတွင် ပင်ထိုးပါ",
+ "pin_digits_entered": "ဂဏန်း ${entered}/${total} လုံး ထည့်ပြီးပါပြီ",
"pin_is_incorrect": "PIN မမှန်ပါ။",
"pin_number": "PIN နံပါတ်",
"placeholder_contacts": "သင့်အဆက်အသွယ်များကို ဤနေရာတွင် ပြသမည်။",
### res/values/strings_nl.arb
@@ -864,6 +864,7 @@
"picker_see_all": "Bekijk alles",
"picker_show_less": "Laat minder zien",
"pin_at_top": "Zet ${token} bovenaan vast",
+ "pin_digits_entered": "${entered} van ${total} cijfers ingevoerd",
"pin_is_incorrect": "PIN is onjuist",
"pin_number": "PIN-nummer",
"placeholder_contacts": "Je contacten worden hier weergegeven",
### res/values/strings_pl.arb
@@ -864,6 +864,7 @@
"picker_see_all": "Zobacz wszystko",
"picker_show_less": "Pokaż mniej",
"pin_at_top": "Przypnij ${token} na górze",
+ "pin_digits_entered": "Wprowadzono ${entered} z ${total} cyfr",
"pin_is_incorrect": "PIN jest nieprawidłowy",
"pin_number": "Numer PIN",
"placeholder_contacts": "Twoje kontakty będą wyświetlane tutaj",
### res/values/strings_pt.arb
@@ -866,6 +866,7 @@
"picker_see_all": "Ver tudo",
"picker_show_less": "Mostrar menos",
"pin_at_top": "Fixar ${token} no topo",
+ "pin_digits_entered": "${entered} de ${total} dígitos introduzidos",
"pin_is_incorrect": "O PIN está incorreto",
"pin_number": "Número do PIN",
"placeholder_contacts": "Seus contatos serão exibidos aqui",
### res/values/strings_pt_BR.arb
@@ -876,6 +876,7 @@
"picker_see_all": "Ver tudo",
"picker_show_less": "Mostrar menos",
"pin_at_top": "Fixar ${token} no topo",
+ "pin_digits_entered": "${entered} de ${total} dígitos inseridos",
"pin_is_incorrect": "O PIN está incorreto",
"pin_number": "Número do PIN",
"placeholder_contacts": "Seus contatos serão exibidos aqui",
### res/values/strings_ru.arb
@@ -865,6 +865,7 @@
"picker_see_all": "Посмотреть все",
"picker_show_less": "Показать меньше",
"pin_at_top": "Закрепить ${token} сверху",
+ "pin_digits_entered": "Введено цифр: ${entered} из ${total}",
"pin_is_incorrect": "PIN неверный",
"pin_number": "PIN-код",
"placeholder_contacts": "Ваши контакты будут отображаться здесь",
### res/values/strings_th.arb
@@ -864,6 +864,7 @@
"picker_see_all": "ดูทั้งหมด",
"picker_show_less": "แสดงน้อยลง",
"pin_at_top": "ปักหมุด ${token} ไว้ด้านบน",
+ "pin_digits_entered": "ป้อนแล้ว ${entered} จาก ${total} หลัก",
"pin_is_incorrect": "PIN ไม่ถูกต้อง",
"pin_number": "หมายเลข PIN",
"placeholder_contacts": "รายชื่อผู้ติดต่อของคุณจะแสดงที่นี่",
### res/values/strings_tl.arb
@@ -864,6 +864,7 @@
"picker_see_all": "Tingnan lahat",
"picker_show_less": "Magpakita ng mas kaunti",
"pin_at_top": "I-pin ang ${token} sa itaas",
+ "pin_digits_entered": "${entered} sa ${total} digit ang nailagay",
"pin_is_incorrect": "Mali ang PIN",
"pin_number": "Numero ng PIN",
"placeholder_contacts": "Ipapakita rito ang iyong mga contact",
### res/values/strings_tr.arb
@@ -864,6 +864,7 @@
"picker_see_all": "Tümünü gör",
"picker_show_less": "Daha az göster",
"pin_at_top": "${token}'ı üste sabitle",
+ "pin_digits_entered": "${entered}/${total} hane girildi",
"pin_is_incorrect": "PIN yanlış",
"pin_number": "PIN numarası",
"placeholder_contacts": "Kişileriniz burada görüntülenecek",
### res/values/strings_uk.arb
@@ -864,6 +864,7 @@
"picker_see_all": "Переглянути всі",
"picker_show_less": "Показувати менше",
"pin_at_top": "Закріпити ${token} зверху",
+ "pin_digits_entered": "Введено цифр: ${entered} з ${total}",
"pin_is_incorrect": "PIN-код неправильний",
"pin_number": "PIN-номер",
"placeholder_contacts": "Ваші контакти будуть відображатися тут",
### res/values/strings_ur.arb
@@ -866,6 +866,7 @@
"picker_see_all": "سب دیکھیں",
"picker_show_less": "کم دکھائیں۔",
"pin_at_top": "${token} کو اوپر پن کریں",
+ "pin_digits_entered": "${entered} ہندسے درج ہو گئے، کل ${total} میں سے",
"pin_is_incorrect": "PIN غلط ہے",
"pin_number": "PIN نمبر",
"placeholder_contacts": "آپ کے رابطے یہاں دکھائے جائیں گے",
### res/values/strings_vi.arb
@@ -865,6 +865,7 @@
"picker_see_all": "Xem tất cả",
"picker_show_less": "Hiển thị ít hơn",
"pin_at_top": "Ghim ${token} lên đầu",
+ "pin_digits_entered": "Đã nhập ${entered}/${total} chữ số",
"pin_is_incorrect": "PIN không đúng",
"pin_number": "Mã PIN",
"placeholder_contacts": "Danh bạ của bạn sẽ được hiển thị ở đây",
### res/values/strings_yo.arb
@@ -865,6 +865,7 @@
"picker_see_all": "Wo gbogbo",
"picker_show_less": "Ṣe afihan kere si",
"pin_at_top": "Fi ${token} mọ́ òkè",
+ "pin_digits_entered": "A ti tẹ nọ́mbà ${entered} nínú ${total}",
"pin_is_incorrect": "PIN kò tọ́",
"pin_number": "Nọ́mbà PIN",
"placeholder_contacts": "Àwọn olùbásọ̀rọ̀ yín yóò hàn níbí",
### res/values/strings_zh.arb
@@ -864,6 +864,7 @@
"picker_see_all": "查看全部",
"picker_show_less": "显示较少",
"pin_at_top": "将 ${token} 置顶",
+ "pin_digits_entered": "已输入 ${entered}/${total} 位数字",
"pin_is_incorrect": "PIN 不正确",
"pin_number": "PIN 码",
"placeholder_contacts": "您的联系人将显示在此处",
### test/new-ui/widgets/a11y_gap_fixes_test.dart
@@ -0,0 +1,587 @@
+import "package:cake_wallet/core/amount_parsing_proxy.dart";
+import "package:cake_wallet/di.dart";
+import "package:cake_wallet/entities/balance_display_mode.dart";
+import "package:cake_wallet/entities/bitcoin_amount_display_mode.dart";
+import "package:cake_wallet/entities/fiat_currency.dart";
+import "package:cake_wallet/generated/i18n.dart";
+import "package:cake_wallet/locales/locale.dart";
+import "package:cake_wallet/new-ui/model/charts/util/chart_range.dart";
+import "package:cake_wallet/new-ui/widgets/charts_page/range_selector.dart";
+import "package:cake_wallet/new-ui/widgets/coins_page/cards/balance_card.dart";
+import "package:cake_wallet/new-ui/widgets/coins_page/cards/cards_view.dart";
+import "package:cake_wallet/new-ui/widgets/coins_page/top_bar_widget/lightning_switcher.dart";
+import "package:cake_wallet/new-ui/widgets/receive_page/receive_address_type_selector.dart";
+import "package:cake_wallet/new-ui/widgets/receive_page/receive_amount_modal.dart";
+import "package:cake_wallet/src/screens/pin_code/pin_code_widget.dart";
+import "package:cake_wallet/src/screens/wallet_list/edit_wallet_button_widget.dart";
+import "package:cake_wallet/src/screens/settings/widgets/settings_choices_cell.dart";
+import "package:cake_wallet/src/screens/settings/widgets/settings_theme_choice.dart";
+import "package:cake_wallet/src/widgets/alert_with_one_action.dart";
+import "package:cake_wallet/src/widgets/alert_with_two_actions.dart";
+import "package:cake_wallet/new-ui/widgets/coin_control_page/coin_control_list_item.dart";
+import "package:cake_wallet/src/widgets/new_list_row/list_item_checkbox_widget.dart";
+import "package:cake_wallet/src/widgets/new_list_row/new_simple_checkbox.dart";
+import "package:cake_wallet/store/app_store.dart";
+import "package:cake_wallet/store/settings_store.dart";
+import "package:cake_wallet/themes/core/theme_store.dart";
+import "package:cake_wallet/themes/theme_classes/black_theme.dart";
+import "package:cake_wallet/themes/theme_classes/dark_theme.dart";
+import "package:cake_wallet/view_model/dashboard/balance_view_model.dart";
+import "package:cake_wallet/view_model/dashboard/dashboard_view_model.dart";
+import "package:cake_wallet/view_model/dashboard/receive_option_view_model.dart";
+import "package:cake_wallet/view_model/settings/choices_list_item.dart";
+import "package:cake_wallet/view_model/settings/display_settings_view_model.dart";
+import "package:cake_wallet/view_model/wallet_address_list/wallet_address_list_view_model.dart";
+import "package:cw_core/balance.dart";
+import "package:cw_core/card_design.dart";
+import "package:cw_core/crypto_currency.dart";
+import "package:cw_core/receive_page_option.dart";
+import "package:cw_core/transaction_history.dart";
+import "package:cw_core/transaction_info.dart";
+import "package:cw_core/wallet_base.dart";
+import "package:cw_core/wallet_type.dart";
+import "package:flutter/material.dart";
+import "package:flutter/semantics.dart";
+import "package:flutter_test/flutter_test.dart";
+import "package:mobx/mobx.dart" show ObservableList, ObservableMap;
+import "package:mocktail/mocktail.dart";
+
+import "../../utils/semantics_helpers.dart";
+
+class _MockWalletAddressListViewModel extends Mock implements WalletAddressListViewModel {}
+
+class _MockDashboardViewModel extends Mock implements DashboardViewModel {}
+
+class _MockBalanceViewModel extends Mock implements BalanceViewModel {}
+
+class _MockAppStore extends Mock implements AppStore {}
+
+class _MockReceiveOptionViewModel extends Mock implements ReceiveOptionViewModel {}
+
+class _MockDisplaySettingsViewModel extends Mock implements DisplaySettingsViewModel {}
+
+class _MockSettingsStore extends Mock implements SettingsStore {}
+
+class _MockWallet extends Mock
+ implements WalletBase<Balance, TransactionHistoryBase<TransactionInfo>, TransactionInfo> {}
+
+void main() {
+ late bool registeredThemeStore;
+
+ setUpAll(() {
+ registeredThemeStore = !getIt.isRegistered<ThemeStore>();
+ if (registeredThemeStore) {
+ getIt.registerSingleton(ThemeStore());
+ }
+ });
+
+ tearDownAll(() async {
+ if (registeredThemeStore) {
+ await getIt.unregister<ThemeStore>();
+ }
+ });
+
+ Widget wrap(Widget child) => MaterialApp(
+ localizationsDelegates: localizationDelegates,
+ supportedLocales: S.delegate.supportedLocales,
+ home: Scaffold(body: Center(child: child)),
+ );
+
+ SemanticsNode one(WidgetTester tester, String id) {
+ final nodes = platformNodesWithId(tester, id);
+ expect(nodes, hasLength(1), reason: "exactly one platform node should carry '$id'");
+ return nodes.single;
+ }
+
+ Future<void> pumpReceiveAmountModal(WidgetTester tester) async {
+ final viewModel = _MockWalletAddressListViewModel();
+ when(() => viewModel.selectedCurrency).thenReturn(CryptoCurrency.btc);
+ when(() => viewModel.displayAmount).thenReturn("");
+ when(() => viewModel.hasTokensList).thenReturn(false);
+ when(() => viewModel.selectedCurrencyDecimals).thenReturn(8);
+ when(() => viewModel.useSatoshi).thenReturn(false);
+ when(() => viewModel.selectedCurrencySymbol).thenReturn("BTC");
+ await tester.pumpWidget(
+ wrap(ReceiveAmountModal(walletAddressListViewModel: viewModel, onSubmitted: (_) {})),
+ );
+ }
+
+ group("receive amount modal", () {
+ testWidgets("field, title and continue button are distinct identified nodes", (tester) async {
+ final handle = tester.ensureSemantics();
+ await pumpReceiveAmountModal(tester);
+
+ expect(
+ one(tester, "receive_amount_modal_amount_textfield_key"),
+ isSemantics(isTextField: true, hasTapAction: true),
+ );
+ expect(
+ one(tester, "receive_amount_modal_title_key"),
+ isSemantics(label: "Set amount", isHeader: true),
+ );
+ expect(
+ one(tester, "receive_amount_modal_continue_button_key"),
+ isSemantics(label: "Continue", isButton: true, hasTapAction: true),
+ );
+ handle.dispose();
+ });
+ });
+
+ group("amount semantics label", () {
+ testWidgets("the Set amount field label has no doubled colon", (tester) async {
+ final handle = tester.ensureSemantics();
+ await pumpReceiveAmountModal(tester);
+
+ final label = one(tester, "receive_amount_modal_amount_textfield_key").label;
+ expect(label, startsWith("Amount\n"));
+ expect(label, isNot(contains(":")));
+ handle.dispose();
+ });
+ });
+
+ group("PIN pad", () {
+ testWidgets("progress is a live region that never exposes the PIN", (tester) async {
+ final handle = tester.ensureSemantics();
+ await tester.pumpWidget(
+ wrap(
+ PinCodeWidget(
+ key: const ValueKey("pin_code_widget"),
+ onFullPin: (_, __) {},
+ initialPinLength: 4,
+ onChangedPin: (_) {},
+ hasLengthSwitcher: false,
+ ),
+ ),
+ );
+ await tester.pumpAndSettle();
+
+ expect(one(tester, "pin_code_progress_key"), isSemantics(label: "0 of 4 digits entered"));
+ await tester.tap(find.byKey(const ValueKey("pin_code_button_7_key")));
+ await tester.tap(find.byKey(const ValueKey("pin_code_button_3_key")));
+ await tester.pump();
+
+ final progress = one(tester, "pin_code_progress_key");
+ expect(progress, isSemantics(label: "2 of 4 digits entered", isLiveRegion: true));
+ expect(progress.value, isEmpty);
+ expect(
+ find.semantics.byPredicate((node) => "${node.label}${node.value}".contains("73")),
+ findsNothing,
+ );
+ expect(one(tester, "pin_code_button_7_key"), isSemantics(label: "7", isButton: true));
+ expect(one(tester, "pin_code_button_0_key"), isSemantics(label: "0", isButton: true));
+ expect(
+ one(tester, "pin_code_delete_button_key"),
+ isSemantics(label: "Delete", isButton: true, hasTapAction: true),
+ );
+ handle.dispose();
+ });
+ });
+
+ Future<void> pumpCardsView(WidgetTester tester) async {
+ final dashboard = _MockDashboardViewModel();
+ final balance = _MockBalanceViewModel();
+ final appStore = _MockAppStore();
+ final settingsStore = _MockSettingsStore();
+ final wallet = _MockWallet();
+ when(() => dashboard.cardOrder).thenReturn(ObservableMap<int, int>.of({0: 0}));
+ when(() => dashboard.cardAccountIndices).thenReturn([0]);
+ when(() => dashboard.cardDesigns).thenReturn(
+ ObservableList.of([CardDesign.genericDefault, CardDesign.genericDefault]),
+ );
+ when(() => dashboard.wallet).thenReturn(wallet);
+ when(() => wallet.type).thenReturn(WalletType.monero);
+ when(() => wallet.currency).thenReturn(CryptoCurrency.xmr);
+ when(() => dashboard.balanceViewModel).thenReturn(balance);
+ when(() => balance.displayMode).thenReturn(BalanceDisplayMode.displayableBalance);
+ when(() => balance.getMainBalanceRecord(any())).thenReturn(null);
+ when(() => balance.showCombinedBalance).thenReturn(false);
+ when(() => dashboard.mwebEnabled).thenReturn(false);
+ when(() => dashboard.hasMweb).thenReturn(false);
+ when(() => dashboard.isEnabledTradeAction).thenReturn(false);
+ when(() => dashboard.settingsStore).thenReturn(settingsStore);
+ when(() => settingsStore.fiatCurrency).thenReturn(FiatCurrency.usd);
+ when(() => dashboard.appStore).thenReturn(appStore);
+ when(() => appStore.amountParsingProxy)
+ .thenReturn(const AmountParsingProxy(BitcoinAmountDisplayMode.bitcoin));
+ await tester.pumpWidget(
+ wrap(
+ CardsView(
+ dashboardViewModel: dashboard,
+ accountListViewModel: null,
+ lightningMode: false,
+ onCompactModeBackgroundCardsTapped: () {},
+ onCustomizeTapped: () {},
+ ),
+ ),
+ );
+ await tester.pumpAndSettle();
+ }
+
+ group("balance cards", () {
+ testWidgets("the home card is a container whose balances stay separate nodes", (tester) async {
+ final handle = tester.ensureSemantics();
+ await pumpCardsView(tester);
+
+ final card = one(tester, "home_page_balance_card_0_key");
+ expect(card, isSemantics(label: "Balance", isButton: true, hasTapAction: true));
+ expect(card.mergeAllDescendantsIntoThisNode, isFalse);
+ final childLabels = <String>[];
+ card.visitChildren((child) {
+ childLabels.add(child.label);
+ return true;
+ });
+ expect(childLabels, contains("Menu"));
+ expect(childLabels.join(), allOf(contains("XMR"), contains("0.00")));
+ handle.dispose();
+ });
+
+ testWidgets("the selected card's balance lines are identified nodes", (tester) async {
+ final handle = tester.ensureSemantics();
+ await pumpCardsView(tester);
+
+ expect(one(tester, "balance_card_crypto_balance_key"), isSemantics(label: "0\nXMR"));
+ expect(one(tester, "balance_card_fiat_balance_key"), isSemantics(label: "0.00"));
+ handle.dispose();
+ });
+
+ for (final excluded in [true, false]) {
+ testWidgets("the account name is announced by the card only when nothing wraps it (excluded: $excluded)", (tester) async {
+ final handle = tester.ensureSemantics();
+ await tester.pumpWidget(
+ wrap(
+ BalanceCard(
+ width: 300,
+ design: CardDesign.genericDefault,
+ accountName: "Savings",
+ accountIndex: 1,
+ selected: true,
+ balance: "1.5",
+ assetName: "BTC",
+ fiatBalance: "USD 90,000.00",
+ excludeAccountName: excluded,
+ ),
+ ),
+ );
+
+ expect(
+ find.bySemanticsLabel(RegExp(r"^(Savings|1\.)$")),
+ excluded ? findsNothing : findsNWidgets(2),
+ );
+ handle.dispose();
+ });
+ }
+
+ testWidgets("an unselected card hides its crypto balance and publishes no balance ids", (tester) async {
+ final handle = tester.ensureSemantics();
+ await tester.pumpWidget(
+ wrap(
+ const BalanceCard(
+ width: 300,
+ design: CardDesign.genericDefault,
+ balance: "1.5",
+ assetName: "BTC",
+ fiatBalance: "USD 90,000.00",
+ ),
+ ),
+ );
+
+ expect(platformNodesWithId(tester, "balance_card_crypto_balance_key"), isEmpty);
+ expect(platformNodesWithId(tester, "balance_card_fiat_balance_key"), isEmpty);
+ expect(find.bySemanticsLabel(RegExp("1.5")), findsNothing);
+ expect(find.bySemanticsLabel("USD 90,000.00"), findsOneWidget);
+ handle.dispose();
+ });
+ });
+
+ group("segmented controls", () {
+ testWidgets("chart range options are selectable buttons in one group", (tester) async {
+ final handle = tester.ensureSemantics();
+ await tester.pumpWidget(
+ wrap(ChartRangeSelector(selectedRange: ChartRange.oneDay, onRangeSelected: (_) {})),
+ );
+
+ for (final (index, range) in ChartRange.ranges.indexed) {
+ expect(
+ one(tester, "chart_range_${index}_key"),
+ isSemantics(
+ label: range.displayText,
+ isButton: true,
+ hasSelectedState: true,
+ isSelected: range == ChartRange.oneDay,
+ isInMutuallyExclusiveGroup: true,
+ hasTapAction: true,
+ ),
+ );
+ }
+ handle.dispose();
+ });
+
+ testWidgets("lightning switch carries its id on the toggle node", (tester) async {
+ final handle = tester.ensureSemantics();
+ await tester.pumpWidget(
+ wrap(LightningSwitcher(lightningMode: true, onLightningSwitchPress: () {})),
+ );
+ expect(
+ one(tester, "home_page_lightning_switch_key"),
+ isSemantics(
+ label: "Lightning mode",
+ isButton: true,
+ hasToggledState: true,
+ isToggled: true,
+ hasTapAction: true,
+ ),
+ );
+ handle.dispose();
+ });
+
+ testWidgets("address type rows carry an index-based id", (tester) async {
+ final handle = tester.ensureSemantics();
+ final viewModel = _MockReceiveOptionViewModel();
+ when(() => viewModel.options)
+ .thenReturn([ReceivePageOption.mainnet, ReceivePageOption.testnet]);
+ when(() => viewModel.walletTypeString).thenReturn("Monero");
+ await tester.pumpWidget(
+ wrap(
+ ReceiveAddressTypeRow(
+ key: const ValueKey("receive_address_type_common_1_key"),
+ option: ReceivePageOption.testnet,
+ roundedTop: true,
+ roundedBottom: true,
+ selected: true,
+ onItemTap: () {},
+ receiveOptionViewModel: viewModel,
+ ),
+ ),
+ );
+ expect(
+ one(tester, "receive_address_type_common_1_key"),
+ isSemantics(
+ label: "testnet",
+ hasSelectedState: true,
+ isSelected: true,
+ isInMutuallyExclusiveGroup: true,
+ hasTapAction: true,
+ ),
+ );
+ handle.dispose();
+ });
+
+ for (final testId in [null, "display_settings_mode"]) {
+ testWidgets("SettingsChoicesCell options expose selection (testId: $testId)", (tester) async {
+ final handle = tester.ensureSemantics();
+ await tester.pumpWidget(
+ wrap(
+ SettingsChoicesCell(
+ ChoicesListItem<String>(title: "", selectedItem: "B", items: ["A", "B"]),
+ testId: testId,
+ ),
+ ),
+ );
+ expect(
+ tester.getSemantics(find.text("A")),
+ isSemantics(label: "A", isButton: true, hasSelectedState: true, isSelected: false),
+ );
+ expect(
+ tester.getSemantics(find.text("B")),
+ isSemantics(
+ label: "B",
+ isButton: true,
+ hasSelectedState: true,
+ isSelected: true,
+ isInMutuallyExclusiveGroup: true,
+ hasTapAction: true,
+ ),
+ );
+ if (testId != null) {
+ expect(one(tester, "display_settings_mode_1_key"), isSemantics(label: "B"));
+ }
+ handle.dispose();
+ });
+ }
+ });
+
+ group("theme choice", () {
+ testWidgets("options are labelled by title and identified by family", (tester) async {
+ final handle = tester.ensureSemantics();
+ final dark = DarkTheme();
+ final black = BlackTheme(BlackThemeAccentColor.cakePrimary);
+ final viewModel = _MockDisplaySettingsViewModel();
+ when(() => viewModel.availableThemes).thenReturn([dark, black]);
+ when(() => viewModel.currentTheme).thenReturn(dark);
+ when(() => viewModel.availableAccentColors).thenReturn([]);
+ when(() => viewModel.isThemeSelected(dark)).thenReturn(true);
+ when(() => viewModel.isThemeSelected(black)).thenReturn(false);
+ for (final theme in [dark, black]) {
+ when(() => viewModel.getImageForTheme(theme)).thenReturn("assets/new-ui/dark.svg");
+ }
+ tester.view.physicalSize = const Size(1170, 2700);
+ tester.view.devicePixelRatio = 3;
+ addTearDown(tester.view.reset);
+ await tester.pumpWidget(wrap(SettingsThemeChoicesCell(viewModel)));
+
+ expect(
+ one(tester, "display_settings_theme_dark_key"),
+ isSemantics(label: "Dark Theme", isSelected: true, hasTapAction: true),
+ );
+ expect(
+ one(tester, "display_settings_theme_blacktheme_key"),
+ isSemantics(label: "Black Theme (Cake Primary)", isSelected: false),
+ );
+ expect(find.bySemanticsLabel(RegExp("Instance of")), findsNothing);
+ handle.dispose();
+ });
+ });
+
+ group("alert actions", () {
+ testWidgets("one- and two-action alerts expose button nodes", (tester) async {
+ final handle = tester.ensureSemantics();
+ await tester.pumpWidget(
+ wrap(
+ AlertWithOneAction(
+ alertTitle: "Title",
+ alertContent: "Content",
+ buttonText: "OK",
+ buttonAction: () {},
+ ),
+ ),
+ );
+ expect(
+ one(tester, "alert_dialog_action_button_key"),
+ isSemantics(label: "OK", isButton: true, hasTapAction: true),
+ );
+
+ await tester.pumpWidget(
+ wrap(
+ AlertWithTwoActions(
+ alertTitle: "Title",
+ alertContent: "Content",
+ leftButtonText: "Cancel",
+ rightButtonText: "Confirm",
+ actionLeftButton: () {},
+ actionRightButton: () {},
+ ),
+ ),
+ );
+ expect(
+ one(tester, "alert_dialog_left_button_key"),
+ isSemantics(label: "Cancel", isButton: true, hasTapAction: true),
+ );
+ expect(
+ one(tester, "alert_dialog_right_button_key"),
+ isSemantics(label: "Confirm", isButton: true, hasTapAction: true),
+ );
+ handle.dispose();
+ });
+ });
+
+ group("unlabelled controls", () {
+ testWidgets("the wallet edit button is a labelled button", (tester) async {
+ final handle = tester.ensureSemantics();
+ await tester.pumpWidget(
+ wrap(EditWalletButtonWidget(key: const ValueKey("wallet_edit_key"), width: 120, onTap: () {})),
+ );
+ expect(
+ one(tester, "wallet_edit_key"),
+ isSemantics(label: "Edit", isButton: true, hasTapAction: true),
+ );
+ handle.dispose();
+ });
+
+ testWidgets("the coin control checkbox exposes its checked state", (tester) async {
+ final handle = tester.ensureSemantics();
+ await tester.pumpWidget(wrap(NewSimpleCheckbox(value: true, onChanged: (_) {})));
+ expect(
+ tester.getSemantics(find.byType(NewSimpleCheckbox)),
+ isSemantics(hasCheckedState: true, isChecked: true, hasTapAction: true),
+ );
+ handle.dispose();
+ });
+
+ for (final testId in [null, "filter_row_key"]) {
+ testWidgets("a checkbox row is one named, checked stop (testId: $testId)", (tester) async {
+ final handle = tester.ensureSemantics();
+ await tester.pumpWidget(
+ wrap(
+ ListItemCheckboxWidget(
+ keyValue: "incoming",
+ label: "Incoming",
+ value: true,
+ onChanged: (_) {},
+ testId: testId,
+ ),
+ ),
+ );
+ expect(
+ testId == null
+ ? tester.getSemantics(find.byType(ListItemCheckboxWidget))
+ : one(tester, testId),
+ isSemantics(label: "Incoming", hasCheckedState: true, isChecked: true, hasTapAction: true),
+ );
+ expect(
+ tester.semantics.simulatedAccessibilityTraversal().where((node) => node.label.isEmpty),
+ isEmpty,
+ );
+ handle.dispose();
+ });
+ }
+
+ testWidgets("a checkbox row with its own onTap can still be toggled", (tester) async {
+ final handle = tester.ensureSemantics();
+ final log = <String>[];
+ await tester.pumpWidget(
+ wrap(
+ ListItemCheckboxWidget(
+ keyValue: "Trocador",
+ label: "Trocador",
+ subtitle: "Manage providers",
+ value: true,
+ onTap: () => log.add("navigate"),
+ onChanged: (value) => log.add("toggle $value"),
+ testId: "provider_row_key",
+ ),
+ ),
+ );
+ final stops = tester.semantics.simulatedAccessibilityTraversal().toList();
+ expect(stops.where((node) => node.label.isEmpty), isEmpty);
+ for (final node in stops) {
+ if (!node.getSemanticsData().hasAction(SemanticsAction.tap)) continue;
+ node.owner!.performAction(node.id, SemanticsAction.tap);
+ await tester.pump();
+ }
+ expect(log, ["navigate", "toggle false"]);
+ expect(one(tester, "provider_row_key"), isSemantics(label: "Trocador\nManage providers", hasTapAction: true));
+ handle.dispose();
+ });
+
+ testWidgets("a coin control row is one stop carrying its address and checked state", (tester) async {
+ final handle = tester.ensureSemantics();
+ await tester.pumpWidget(
+ wrap(
+ CoinControlListItem(
+ note: "",
+ amount: "0.001 BTC",
+ fiatAmount: "65.00 USD",
+ address: "bc1qexampleaddress",
+ isSending: true,
+ isFrozen: false,
+ isChange: false,
+ isSilentPayment: false,
+ isFirst: true,
+ isLast: true,
+ isLoading: false,
+ hasCheckbox: true,
+ onCheckBoxTap: () {},
+ ),
+ ),
+ );
+ final node = tester.getSemantics(find.byType(CoinControlListItem));
+ expect(node, isSemantics(hasCheckedState: true, isChecked: true, hasTapAction: true));
+ expect(node.label, contains("0.001 BTC"));
+ expect(
+ tester.semantics.simulatedAccessibilityTraversal().where((node) => node.label.isEmpty),
+ isEmpty,
+ );
+ handle.dispose();
+ });
+ });
+}
### test/new-ui/widgets/confirm_swiper_test.dart
@@ -0,0 +1,151 @@
+import "package:cake_wallet/new-ui/widgets/confirm_swiper.dart";
+import "package:cake_wallet/new-ui/widgets/new_primary_button.dart";
+import "package:flutter/material.dart";
+import "package:flutter_test/flutter_test.dart";
+
+import "../../utils/semantics_helpers.dart";
+
+const _swiperText = "Swipe to send";
+const _buttonText = "Confirm and send";
+
+Future<void> _pump(
+ WidgetTester tester, {
+ required bool accessibleNavigation,
+ String? accessibleNavigationModeButtonText,
+ VoidCallback? onConfirmed,
+}) async {
+ await tester.pumpWidget(
+ MaterialApp(
+ home: Builder(
+ builder: (context) => MediaQuery(
+ data: MediaQuery.of(context).copyWith(accessibleNavigation: accessibleNavigation),
+ child: Scaffold(
+ body: Center(
+ child: ConfirmSwiper(
+ onConfirmed: onConfirmed ?? () {},
+ swiperText: _swiperText,
+ accessibleNavigationModeButtonText: accessibleNavigationModeButtonText,
+ ),
+ ),
+ ),
+ ),
+ ),
+ ),
+ );
+ await tester.pump();
+}
+
+void main() {
+ group("accessibleNavigation: true", () {
+ testWidgets("renders a plain button instead of the swiper", (tester) async {
+ await _pump(
+ tester,
+ accessibleNavigation: true,
+ accessibleNavigationModeButtonText: _buttonText,
+ );
+
+ expect(find.byType(NewPrimaryButton), findsOneWidget);
+ expect(find.byType(FlowingText), findsNothing);
+ });
+
+ testWidgets("the button is labelled with accessibleNavigationModeButtonText", (tester) async {
+ await _pump(
+ tester,
+ accessibleNavigation: true,
+ accessibleNavigationModeButtonText: _buttonText,
+ );
+
+ expect(find.semantics.byLabel(_buttonText), findsOne);
+ expect(find.semantics.byLabel(_swiperText), findsNothing);
+ expect(
+ screenReaderStops(tester).single,
+ isSemantics(label: _buttonText, isButton: true, hasTapAction: true, isEnabled: true),
+ );
+ });
+
+ testWidgets("falls back to swiperText when no button text is supplied", (tester) async {
+ await _pump(tester, accessibleNavigation: true);
+
+ expect(find.semantics.byLabel(_swiperText), findsOne);
+ expect(
+ screenReaderStops(tester).single,
+ isSemantics(label: _swiperText, isButton: true, hasTapAction: true),
+ );
+ });
+
+ testWidgets("a semantic tap on the button confirms", (tester) async {
+ var confirmed = 0;
+ await _pump(
+ tester,
+ accessibleNavigation: true,
+ accessibleNavigationModeButtonText: _buttonText,
+ onConfirmed: () => confirmed++,
+ );
+
+ tester.semantics.tap(find.semantics.byLabel(_buttonText));
+ await tester.pump();
+
+ expect(confirmed, 1);
+ });
+ });
+
+ group("accessibleNavigation: false", () {
+ testWidgets("exposes exactly one node, labelled with swiperText", (tester) async {
+ await _pump(tester, accessibleNavigation: false);
+
+ expect(find.byType(NewPrimaryButton), findsNothing);
+ expect(screenReaderStops(tester), hasLength(1));
+ expect(screenReaderStops(tester).single.label, _swiperText);
+ });
+
+ testWidgets("the decorative label and knob are not separate stops", (tester) async {
+ await _pump(tester, accessibleNavigation: false);
+
+ expect(find.byType(FlowingText), findsOneWidget);
+ expect(find.semantics.byPredicate((node) => node.label == _swiperText), findsOne);
+ });
+
+ testWidgets("offers no tap action, so a tap cannot confirm", (tester) async {
+ var confirmed = 0;
+ await _pump(tester, accessibleNavigation: false, onConfirmed: () => confirmed++);
+
+ expect(
+ screenReaderStops(tester).single,
+ isSemantics(
+ label: _swiperText,
+ hasTapAction: false,
+ hasScrollLeftAction: false,
+ hasScrollRightAction: false,
+ isButton: false,
+ ),
+ );
+
+ await tester.tap(find.byType(ConfirmSwiper));
+ await tester.pump();
+
+ expect(confirmed, 0);
+ });
+
+ testWidgets("a horizontal drag across the control still confirms", (tester) async {
+ var confirmed = 0;
+ await _pump(tester, accessibleNavigation: false, onConfirmed: () => confirmed++);
+
+ final pill = tester.getTopLeft(find.byType(ConfirmSwiper)) + const Offset(28, 26);
+ await tester.dragFrom(pill, const Offset(760, 0));
+ await tester.pump();
+
+ expect(confirmed, 1);
+ });
+
+ testWidgets("a short drag does not confirm", (tester) async {
+ var confirmed = 0;
+ await _pump(tester, accessibleNavigation: false, onConfirmed: () => confirmed++);
+
+ final pill = tester.getTopLeft(find.byType(ConfirmSwiper)) + const Offset(28, 26);
+ await tester.dragFrom(pill, const Offset(120, 0));
+ await tester.pump();
+
+ expect(confirmed, 0);
+ });
+ });
+}
### test/new-ui/widgets/copy_wrapper_test.dart
@@ -0,0 +1,261 @@
+import "package:cake_wallet/generated/i18n.dart";
+import "package:cake_wallet/new-ui/widgets/copy_wrapper.dart";
+import "package:flutter/material.dart";
+import "package:flutter/semantics.dart";
+import "package:flutter/services.dart";
+import "package:flutter_test/flutter_test.dart";
+
+import "../../utils/semantics_helpers.dart";
+
+const _copyable = ClipboardData(text: "bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq");
+
+const _flash = Duration(milliseconds: 800);
+
+final _actionableNodes = find.semantics.byPredicate(
+ (node) => node.getSemanticsData().customSemanticsActionIds?.isNotEmpty ?? false,
+ describeMatch: (_) => "SemanticsNodes with custom actions",
+);
+
+Future<void> _pump(WidgetTester tester, Widget child) async {
+ await tester.pumpWidget(
+ MaterialApp(
+ localizationsDelegates: const [S.delegate],
+ supportedLocales: S.delegate.supportedLocales,
+ locale: const Locale("en", ""),
+ home: Scaffold(body: Center(child: child)),
+ ),
+ );
+ await tester.pumpAndSettle();
+}
+
+Future<void> _settleCopy(WidgetTester tester) async {
+ await tester.pump();
+ await tester.pump();
+}
+
+void main() {
+ setUpAll(() {
+ S.current = const S();
+ });
+
+ setUp(() {
+ TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
+ .setMockMethodCallHandler(SystemChannels.platform, (call) async => null);
+ });
+
+ tearDown(() {
+ TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
+ .setMockMethodCallHandler(SystemChannels.platform, null);
+ });
+
+ group("builder mode with something to copy", () {
+ testWidgets("exposes one merged button node carrying a copy action", (tester) async {
+ await _pump(
+ tester,
+ CopyWrapper(
+ data: _copyable,
+ duration: _flash,
+ builder: (_, copied) => Text(copied ? S.current.copied : "Address"),
+ ),
+ );
+
+ expect(screenReaderStops(tester), hasLength(1));
+ expect(
+ screenReaderStops(tester).single,
+ isSemantics(
+ label: "Address",
+ hint: S.current.copy,
+ isButton: true,
+ customActions: <CustomSemanticsAction>[CustomSemanticsAction(label: S.current.copy)],
+ ),
+ );
+ });
+
+ testWidgets("the content does not become a second, unactionable node", (tester) async {
+ await _pump(
+ tester,
+ CopyWrapper(
+ data: _copyable,
+ duration: _flash,
+ builder: (_, copied) => Column(
+ children: [Text(copied ? S.current.copied : "Address"), const Text("Bitcoin")],
+ ),
+ ),
+ );
+
+ expect(find.text("Address"), findsOneWidget);
+ expect(find.text("Bitcoin"), findsOneWidget);
+ expect(screenReaderStops(tester), hasLength(1));
+ expect(_actionableNodes, findsOne);
+ });
+
+ testWidgets("a tap copies, flipping the label and marking a live region", (tester) async {
+ await _pump(
+ tester,
+ CopyWrapper(
+ data: _copyable,
+ duration: _flash,
+ builder: (_, copied) => Text(copied ? S.current.copied : "Address"),
+ ),
+ );
+
+ expect(screenReaderStops(tester).single, isSemantics(label: "Address", isLiveRegion: false));
+
+ await tester.tap(find.text("Address"));
+ await _settleCopy(tester);
+
+ expect(
+ screenReaderStops(tester).single,
+ isSemantics(label: S.current.copied, isLiveRegion: true),
+ );
+
+ await tester.pump(_flash * 2);
+ expect(screenReaderStops(tester).single, isSemantics(label: "Address", isLiveRegion: false));
+ });
+ });
+
+ group("builder mode with nothing to copy", () {
+ testWidgets("returns the child with no actionable node at all", (tester) async {
+ await _pump(
+ tester,
+ CopyWrapper(duration: _flash, builder: (_, copied) => const Text("Address")),
+ );
+
+ expect(find.text("Address"), findsOneWidget);
+ expect(find.byType(GestureDetector), findsNothing);
+ expect(_actionableNodes, findsNothing);
+ expect(find.semantics.byFlag(SemanticsFlag.isButton), findsNothing);
+ expect(screenReaderStops(tester).single, isSemantics(label: "Address", isButton: false));
+ });
+
+ testWidgets("offers no copy hint either", (tester) async {
+ await _pump(
+ tester,
+ CopyWrapper(duration: _flash, builder: (_, copied) => const Text("Address")),
+ );
+
+ expect(find.semantics.byHint(S.current.copy), findsNothing);
+ });
+ });
+
+ group("requireLongPress", () {
+ testWidgets("swaps the hint and stops claiming to be a button", (tester) async {
+ await _pump(
+ tester,
+ CopyWrapper(
+ data: _copyable,
+ duration: _flash,
+ requireLongPress: true,
+ builder: (_, copied) => Text(copied ? S.current.copied : "Seed phrase"),
+ ),
+ );
+
+ expect(
+ screenReaderStops(tester).single,
+ isSemantics(
+ label: "Seed phrase",
+ hint: S.current.long_press_to_copy,
+ isButton: false,
+ customActions: <CustomSemanticsAction>[CustomSemanticsAction(label: S.current.copy)],
+ ),
+ );
+ });
+
+ testWidgets("a long press copies, a plain tap does not", (tester) async {
+ await _pump(
+ tester,
+ CopyWrapper(
+ data: _copyable,
+ duration: _flash,
+ requireLongPress: true,
+ builder: (_, copied) => Text(copied ? S.current.copied : "Seed phrase"),
+ ),
+ );
+
+ await tester.tap(find.text("Seed phrase"));
+ await _settleCopy(tester);
+ expect(find.text(S.current.copied), findsNothing);
+
+ await tester.longPress(find.text("Seed phrase"));
+ await _settleCopy(tester);
+ expect(find.text(S.current.copied), findsOneWidget);
+
+ await tester.pump(_flash * 2);
+ });
+ });
+
+ group("controlBuilder mode", () {
+ testWidgets("stacks no extra gesture or action on the caller's control", (tester) async {
+ await _pump(
+ tester,
+ CopyWrapper(
+ data: _copyable,
+ duration: _flash,
+ controlBuilder: (_, copied, onCopy) => TextButton(
+ onPressed: onCopy,
+ child: Text(copied ? S.current.copied : S.current.copy),
+ ),
+ ),
+ );
+
+ expect(screenReaderStops(tester), hasLength(1));
+ expect(_actionableNodes, findsNothing);
+ expect(
+ screenReaderStops(tester).single,
+ isSemantics(
+ label: S.current.copy,
+ isButton: true,
+ isEnabled: true,
+ hasTapAction: true,
+ isLiveRegion: false,
+ ),
+ );
+ });
+
+ testWidgets("hands the control a null onCopy when there is nothing to copy", (tester) async {
+ await _pump(
+ tester,
+ CopyWrapper(
+ duration: _flash,
+ controlBuilder: (_, copied, onCopy) => TextButton(
+ onPressed: onCopy,
+ child: Text(copied ? S.current.copied : S.current.copy),
+ ),
+ ),
+ );
+
+ expect(
+ screenReaderStops(tester).single,
+ isSemantics(label: S.current.copy, isEnabled: false, hasTapAction: false),
+ );
+ });
+
+ testWidgets("marks the control a live region once copied", (tester) async {
+ await _pump(
+ tester,
+ CopyWrapper(
+ data: _copyable,
+ duration: _flash,
+ controlBuilder: (_, copied, onCopy) => TextButton(
+ onPressed: onCopy,
+ child: Text(copied ? S.current.copied : S.current.copy),
+ ),
+ ),
+ );
+
+ await tester.tap(find.text(S.current.copy));
+ await _settleCopy(tester);
+
+ expect(
+ screenReaderStops(tester).single,
+ isSemantics(label: S.current.copied, isLiveRegion: true),
+ );
+
+ await tester.pump(_flash * 2);
+ expect(
+ screenReaderStops(tester).single,
+ isSemantics(label: S.current.copy, isLiveRegion: false),
+ );
+ });
+ });
+}
### test/new-ui/widgets/modern_button_test.dart
@@ -0,0 +1,134 @@
+import "package:cake_wallet/new-ui/widgets/modern_button.dart";
+import "package:flutter/material.dart";
+import "package:flutter_test/flutter_test.dart";
+
+import "../../utils/semantics_helpers.dart";
+
+Future<void> _pump(WidgetTester tester, Widget child) => tester.pumpWidget(
+ MaterialApp(home: Scaffold(body: Center(child: child))),
+ );
+
+void main() {
+ group("ModernButton semantics", () {
+ testWidgets("semanticLabel names the one and only button node", (tester) async {
+ await _pump(
+ tester,
+ ModernButton(
+ size: 40,
+ icon: const Icon(Icons.close),
+ onPressed: () {},
+ semanticLabel: "Close the sheet",
+ ),
+ );
+
+ expect(screenReaderStops(tester), hasLength(1));
+ expect(
+ tester.getSemantics(find.byType(ModernButton)),
+ isSemantics(
+ label: "Close the sheet",
+ isButton: true,
+ isEnabled: true,
+ hasEnabledState: true,
+ hasTapAction: true,
+ ),
+ );
+ });
+
+ testWidgets("falls back to the visible label when semanticLabel is omitted", (tester) async {
+ await _pump(
+ tester,
+ ModernButton(
+ size: 40,
+ icon: const Icon(Icons.send),
+ onPressed: () {},
+ label: "Send",
+ ),
+ );
+
+ expect(screenReaderStops(tester), hasLength(1));
+ expect(find.semantics.byLabel("Send"), findsOne);
+ });
+
+ testWidgets("semanticLabel wins over the visible label", (tester) async {
+ await _pump(
+ tester,
+ ModernButton(
+ size: 40,
+ icon: const Icon(Icons.send),
+ onPressed: () {},
+ label: "Send",
+ semanticLabel: "Send funds",
+ ),
+ );
+
+ expect(find.semantics.byLabel("Send funds"), findsOne);
+ expect(find.semantics.byLabel("Send"), findsNothing);
+ });
+
+ testWidgets("the visible caption does not become a second text node", (tester) async {
+ await _pump(
+ tester,
+ ModernButton(
+ size: 40,
+ icon: const Icon(Icons.send),
+ onPressed: () {},
+ label: "Send",
+ semanticLabel: "Send funds",
+ ),
+ );
+
+ expect(find.text("Send"), findsOneWidget);
+ expect(screenReaderStops(tester), hasLength(1));
+ expect(screenReaderStops(tester).single.label, "Send funds");
+ });
+
+ testWidgets("an empty label adds neither a caption nor a node", (tester) async {
+ await _pump(
+ tester,
+ ModernButton(
+ size: 40,
+ icon: const Icon(Icons.send),
+ onPressed: () {},
+ label: "",
+ semanticLabel: "Send funds",
+ ),
+ );
+
+ expect(find.byType(Text), findsNothing);
+ expect(screenReaderStops(tester), hasLength(1));
+ });
+
+ testWidgets("the icon contributes nothing, even when it names itself", (tester) async {
+ await _pump(
+ tester,
+ ModernButton(
+ size: 40,
+ icon: const Icon(Icons.close, semanticLabel: "chevron"),
+ onPressed: () {},
+ semanticLabel: "Close the sheet",
+ ),
+ );
+
+ expect(find.semantics.byLabel("chevron"), findsNothing);
+ expect(screenReaderStops(tester), hasLength(1));
+ });
+
+ testWidgets("a semantic tap invokes onPressed", (tester) async {
+ var pressed = 0;
+ await _pump(
+ tester,
+ ModernButton(
+ size: 40,
+ icon: const Icon(Icons.close),
+ onPressed: () => pressed++,
+ semanticLabel: "Close the sheet",
+ ),
+ );
+
+ tester.semantics.tap(find.semantics.byLabel("Close the sheet"));
+ await tester.pump();
+
+ expect(pressed, 1);
+ });
+ });
+}
### test/new-ui/widgets/receive_page/modal_top_bar_test.dart
@@ -0,0 +1,161 @@
+import "package:cake_wallet/generated/i18n.dart";
+import "package:cake_wallet/new-ui/widgets/modern_button.dart";
+import "package:cake_wallet/new-ui/widgets/receive_page/receive_top_bar.dart";
+import "package:flutter/material.dart";
+import "package:flutter/semantics.dart";
+import "package:flutter_test/flutter_test.dart";
+
+import "../../../utils/semantics_helpers.dart";
+
+Set<String> _labels(WidgetTester tester) =>
+ screenReaderStops(tester).map((node) => node.label).where((label) => label.isNotEmpty).toSet();
+
+Future<void> _pump(WidgetTester tester, Widget child) async {
+ await tester.pumpWidget(
+ MaterialApp(
+ localizationsDelegates: const [S.delegate],
+ supportedLocales: S.delegate.supportedLocales,
+ locale: const Locale("en", ""),
+ home: Scaffold(body: child),
+ ),
+ );
+ await tester.pumpAndSettle();
+}
+
+void main() {
+ setUpAll(() {
+ S.current = const S();
+ });
+
+ group("ModalTopBar leading button", () {
+ testWidgets("announces the localized label it was given", (tester) async {
+ await _pump(
+ tester,
+ ModalTopBar(
+ title: "Receive",
+ leadingIcon: const Icon(Icons.close),
+ leadingSemanticLabel: S.current.close,
+ ),
+ );
+
+ expect(find.semantics.byLabel(S.current.close), findsOne);
+ });
+
+ testWidgets("announces a back label just as well", (tester) async {
+ await _pump(
+ tester,
+ ModalTopBar(
+ title: "Receive",
+ leadingIcon: const Icon(Icons.arrow_back),
+ leadingSemanticLabel: "Back to wallet",
+ ),
+ );
+
+ expect(find.semantics.byLabel("Back to wallet"), findsOne);
+ expect(find.semantics.byLabel(S.current.close), findsNothing);
+ });
+
+ testWidgets("a semantic tap runs onLeadingPressed", (tester) async {
+ var pressed = 0;
+ await _pump(
+ tester,
+ ModalTopBar(
+ title: "Receive",
+ leadingIcon: const Icon(Icons.close),
+ leadingSemanticLabel: S.current.close,
+ onLeadingPressed: () => pressed++,
+ ),
+ );
+
+ tester.semantics.tap(find.semantics.byLabel(S.current.close));
+ await tester.pump();
+
+ expect(pressed, 1);
+ });
+ });
+
+ group("ModalTopBar trailing button", () {
+ testWidgets("announces trailingSemanticLabel", (tester) async {
+ await _pump(
+ tester,
+ ModalTopBar(
+ title: "Receive",
+ leadingIcon: const Icon(Icons.close),
+ leadingSemanticLabel: S.current.close,
+ trailingIcon: const Icon(Icons.share),
+ trailingSemanticLabel: "Share address",
+ ),
+ );
+
+ expect(find.semantics.byLabel("Share address"), findsOne);
+ expect(
+ tester.getSemantics(
+ find.byWidgetPredicate(
+ (widget) => widget is ModernButton && widget.semanticLabel == "Share address",
+ ),
+ ),
+ isSemantics(label: "Share address", isButton: true, hasTapAction: true),
+ );
+ });
+
+ testWidgets("contributes no node at all when trailingIcon is null", (tester) async {
+ await _pump(
+ tester,
+ ModalTopBar(
+ title: "Receive",
+ leadingIcon: const Icon(Icons.close),
+ leadingSemanticLabel: S.current.close,
+ ),
+ );
+
+ expect(find.byType(ModernButton), findsOneWidget);
+ expect(_labels(tester), {S.current.close, "Receive"});
+ });
+ });
+
+ group("ModalTopBar title", () {
+ testWidgets("a non-empty title is exposed as a header", (tester) async {
+ await _pump(tester, ModalTopBar(title: "Receive"));
+
+ expect(
+ tester.getSemantics(find.text("Receive")),
+ isSemantics(label: "Receive", isHeader: true),
+ );
+ });
+
+ testWidgets("an empty title is not a header", (tester) async {
+ await _pump(tester, ModalTopBar(title: ""));
+
+ expect(find.semantics.byFlag(SemanticsFlag.isHeader), findsNothing);
+ });
+
+ testWidgets("one header node carries the title id beside the chrome button ids",
+ (tester) async {
+ await _pump(
+ tester,
+ ModalTopBar(
+ testId: "receive_page_top_bar",
+ title: "Receive",
+ bottomText: "Bitcoin",
+ leadingIcon: const Icon(Icons.close),
+ leadingSemanticLabel: S.current.close,
+ trailingIcon: const Icon(Icons.share),
+ trailingSemanticLabel: "Share",
+ ),
+ );
+
+ expect(find.semantics.byFlag(SemanticsFlag.isHeader), findsOne);
+ for (final (suffix, label, header) in [
+ ("title", "Receive", true),
+ ("leading", S.current.close, false),
+ ("trailing", "Share", false),
+ ]) {
+ expect(
+ platformNodesWithId(tester, "receive_page_top_bar_${suffix}_key").single,
+ isSemantics(label: label, isHeader: header, isButton: !header),
+ reason: suffix,
+ );
+ }
+ });
+ });
+}
### test/new-ui/widgets/send_page/floating_icon_button_test.dart
@@ -0,0 +1,61 @@
+import "package:cake_wallet/new-ui/widgets/send_page/floating_icon_button.dart";
+import "package:flutter/material.dart";
+import "package:flutter/semantics.dart";
+import "package:flutter_test/flutter_test.dart";
+
+import "../../../utils/semantics_helpers.dart";
+
+const _iconPath = "assets/images/2fa.png";
+
+Future<void> _pump(WidgetTester tester, {VoidCallback? onPressed}) async {
+ await tester.pumpWidget(
+ MaterialApp(
+ home: Scaffold(
+ body: Center(
+ child: FloatingIconButton(
+ iconPath: _iconPath,
+ onPressed: onPressed ?? () {},
+ semanticLabel: "Scan QR code",
+ ),
+ ),
+ ),
+ ),
+ );
+ await tester.pump();
+}
+
+void main() {
+ group("FloatingIconButton semantics", () {
+ testWidgets("exposes a single, named button node", (tester) async {
+ await _pump(tester);
+
+ expect(screenReaderStops(tester), hasLength(1));
+ expect(
+ tester.getSemantics(find.byType(FloatingIconButton)),
+ isSemantics(
+ label: "Scan QR code",
+ isButton: true,
+ hasEnabledState: true,
+ isEnabled: true,
+ hasTapAction: true,
+ ),
+ );
+ });
+
+ testWidgets("the decorative icon adds no node of its own", (tester) async {
+ await _pump(tester);
+
+ expect(find.semantics.byFlag(SemanticsFlag.isImage), findsNothing);
+ });
+
+ testWidgets("a semantic tap invokes onPressed", (tester) async {
+ var pressed = 0;
+ await _pump(tester, onPressed: () => pressed++);
+
+ tester.semantics.tap(find.semantics.byLabel("Scan QR code"));
+ await tester.pump();
+
+ expect(pressed, 1);
+ });
+ });
+}
### test/src/widgets/cake_image_widget_test.dart
@@ -0,0 +1,116 @@
+import "package:cake_wallet/src/widgets/cake_image_widget.dart";
+import "package:flutter/material.dart";
+import "package:flutter/semantics.dart";
+import "package:flutter_test/flutter_test.dart";
+
+import "../../utils/semantics_helpers.dart";
+
+const _assetPath = "assets/images/2fa.png";
+const _svgAssetPath = "assets/images/2fa_warning_dark.svg";
+
+final _imageNodes = find.semantics.byFlag(SemanticsFlag.isImage);
+
+final _labelledNodes = find.semantics.byPredicate(
+ (node) => node.label.isNotEmpty,
+ describeMatch: (_) => "labelled SemanticsNodes",
+);
+
+Future<void> _pump(WidgetTester tester, Widget child) async {
+ await tester.pumpWidget(MaterialApp(home: Scaffold(body: Center(child: child))));
+ await tester.pump();
+}
+
+void main() {
+ group("asset image", () {
+ testWidgets("a null semanticsLabel keeps the image out of the tree", (tester) async {
+ await _pump(tester, const CakeImageWidget(imageUrl: _assetPath, width: 24, height: 24));
+
+ expect(_imageNodes, findsNothing);
+ expect(_labelledNodes, findsNothing);
+ expect(screenReaderStops(tester), isEmpty);
+ });
+
+ testWidgets("a semanticsLabel makes it an announced image", (tester) async {
+ await _pump(
+ tester,
+ const CakeImageWidget(
+ imageUrl: _assetPath,
+ width: 24,
+ height: 24,
+ semanticsLabel: "Two-factor authentication",
+ ),
+ );
+
+ expect(find.semantics.byLabel("Two-factor authentication"), findsOne);
+ expect(screenReaderStops(tester), hasLength(1));
+ expect(
+ screenReaderStops(tester).single,
+ isSemantics(label: "Two-factor authentication", isImage: true),
+ );
+ });
+ });
+
+ group("svg asset", () {
+ testWidgets("a null semanticsLabel keeps the image out of the tree", (tester) async {
+ await _pump(tester, const CakeImageWidget(imageUrl: _svgAssetPath, width: 24, height: 24));
+
+ expect(_imageNodes, findsNothing);
+ expect(_labelledNodes, findsNothing);
+ expect(screenReaderStops(tester), isEmpty);
+ });
+
+ testWidgets("a semanticsLabel makes it an announced image", (tester) async {
+ await _pump(
+ tester,
+ const CakeImageWidget(
+ imageUrl: _svgAssetPath,
+ width: 24,
+ height: 24,
+ semanticsLabel: "Two-factor authentication",
+ ),
+ );
+
+ expect(screenReaderStops(tester), hasLength(1));
+ expect(
+ screenReaderStops(tester).single,
+ isSemantics(label: "Two-factor authentication", isImage: true),
+ );
+ });
+ });
+
+ group("error placeholder", () {
+ testWidgets("a decorative placeholder contributes nothing", (tester) async {
+ await _pump(tester, const CakeImageWidget(width: 24, height: 24));
+
+ expect(_labelledNodes, findsNothing);
+ expect(screenReaderStops(tester), isEmpty);
+ });
+
+ testWidgets("an empty imageUrl is treated the same way", (tester) async {
+ await _pump(tester, const CakeImageWidget(imageUrl: "", width: 24, height: 24));
+
+ expect(_labelledNodes, findsNothing);
+ expect(screenReaderStops(tester), isEmpty);
+ });
+
+ testWidgets("a labelled placeholder is announced as an image", (tester) async {
+ await _pump(
+ tester,
+ const CakeImageWidget(width: 24, height: 24, semanticsLabel: "Wallet avatar"),
+ );
+
+ expect(screenReaderStops(tester), hasLength(1));
+ expect(screenReaderStops(tester).single, isSemantics(label: "Wallet avatar", isImage: true));
+ });
+
+ testWidgets("a caller-supplied errorWidget owns its own semantics", (tester) async {
+ await _pump(
+ tester,
+ const CakeImageWidget(width: 24, height: 24, errorWidget: Text("BTC")),
+ );
+
+ expect(find.semantics.byLabel("BTC"), findsOne);
+ expect(_imageNodes, findsNothing);
+ });
+ });
+}
### test/src/widgets/primary_button_test.dart
@@ -0,0 +1,260 @@
+import "package:cake_wallet/generated/i18n.dart";
+import "package:cake_wallet/src/widgets/primary_button.dart";
+import "package:flutter/material.dart";
+import "package:flutter_test/flutter_test.dart";
+
+import "../../utils/semantics_helpers.dart";
+
+Future<void> _pump(WidgetTester tester, Widget child, {bool settle = true}) async {
+ await tester.pumpWidget(
+ MaterialApp(
+ localizationsDelegates: const [S.delegate],
+ supportedLocales: S.delegate.supportedLocales,
+ locale: const Locale("en", ""),
+ home: Scaffold(body: Center(child: child)),
+ ),
+ );
+ if (settle) {
+ await tester.pumpAndSettle();
+ } else {
+ await tester.pump();
+ await tester.pump();
+ }
+}
+
+void main() {
+ setUpAll(() {
+ S.current = const S();
+ });
+
+ group("PrimaryButton", () {
+ testWidgets("reports one enabled button node named after its text", (tester) async {
+ await _pump(
+ tester,
+ PrimaryButton(
+ text: "Continue",
+ color: Colors.blue,
+ textColor: Colors.white,
+ onPressed: () {},
+ ),
+ );
+
+ expect(screenReaderStops(tester), hasLength(1));
+ expect(
+ screenReaderStops(tester).single,
+ isSemantics(
+ label: "Continue",
+ isButton: true,
+ hasEnabledState: true,
+ isEnabled: true,
+ hasTapAction: true,
+ ),
+ );
+ });
+
+ testWidgets("a semantic tap invokes onPressed", (tester) async {
+ var pressed = 0;
+ await _pump(
+ tester,
+ PrimaryButton(
+ text: "Continue",
+ color: Colors.blue,
+ textColor: Colors.white,
+ onPressed: () => pressed++,
+ ),
+ );
+
+ tester.semantics.tap(find.semantics.byLabel("Continue"));
+ await tester.pump();
+
+ expect(pressed, 1);
+ });
+
+ testWidgets("reports disabled while keeping the label", (tester) async {
+ await _pump(
+ tester,
+ PrimaryButton(
+ text: "Continue",
+ color: Colors.blue,
+ textColor: Colors.white,
+ isDisabled: true,
+ onPressed: () {},
+ ),
+ );
+
+ expect(
+ screenReaderStops(tester).single,
+ isSemantics(
+ label: "Continue",
+ isButton: true,
+ hasEnabledState: true,
+ isEnabled: false,
+ hasTapAction: false,
+ ),
+ );
+ });
+
+ testWidgets("a missing onPressed also reads as disabled", (tester) async {
+ await _pump(
+ tester,
+ const PrimaryButton(text: "Continue", color: Colors.blue, textColor: Colors.white),
+ );
+
+ expect(
+ screenReaderStops(tester).single,
+ isSemantics(label: "Continue", isEnabled: false, hasTapAction: false),
+ );
+ });
+
+ testWidgets("the dotted-border variant is still a single named node", (tester) async {
+ await _pump(
+ tester,
+ PrimaryButton(
+ text: "Continue",
+ color: Colors.blue,
+ textColor: Colors.white,
+ isDottedBorder: true,
+ onPressed: () {},
+ ),
+ );
+
+ expect(screenReaderStops(tester), hasLength(1));
+ expect(screenReaderStops(tester).single, isSemantics(label: "Continue", isButton: true));
+ });
+
+ testWidgets("a disabled button with onDisabledPressed reports enabled", (tester) async {
+ var explained = 0;
+ await _pump(
+ tester,
+ PrimaryButton(
+ text: "Continue",
+ color: Colors.blue,
+ textColor: Colors.white,
+ isDisabled: true,
+ onPressed: () {},
+ onDisabledPressed: () => explained++,
+ ),
+ );
+
+ expect(
+ screenReaderStops(tester).single,
+ isSemantics(label: "Continue", isEnabled: true, hasTapAction: true),
+ );
+
+ tester.semantics.tap(find.semantics.byLabel("Continue"));
+ await tester.pump();
+
+ expect(explained, 1);
+ });
+ });
+
+ group("LoadingPrimaryButton", () {
+ testWidgets("keeps its label and reports disabled while loading", (tester) async {
+ await _pump(
+ tester,
+ LoadingPrimaryButton(
+ text: "Send",
+ color: Colors.blue,
+ textColor: Colors.white,
+ isLoading: true,
+ onPressed: () {},
+ ),
+ settle: false,
+ );
+
+ expect(find.text("Send"), findsNothing);
+ expect(screenReaderStops(tester), hasLength(1));
+ expect(
+ tester.getSemantics(find.byType(LoadingPrimaryButton)),
+ isSemantics(
+ label: "Send",
+ value: S.current.loading,
+ isButton: true,
+ hasEnabledState: true,
+ isEnabled: false,
+ hasTapAction: false,
+ ),
+ );
+ });
+
+ testWidgets("a loading button cannot be activated", (tester) async {
+ var pressed = 0;
+ await _pump(
+ tester,
+ LoadingPrimaryButton(
+ text: "Send",
+ color: Colors.blue,
+ textColor: Colors.white,
+ isLoading: true,
+ onPressed: () => pressed++,
+ ),
+ settle: false,
+ );
+
+ await tester.tap(find.byType(LoadingPrimaryButton));
+ await tester.pump();
+
+ expect(pressed, 0);
+ });
+
+ testWidgets("reports enabled and no value when idle", (tester) async {
+ await _pump(
+ tester,
+ LoadingPrimaryButton(
+ text: "Send",
+ color: Colors.blue,
+ textColor: Colors.white,
+ onPressed: () {},
+ ),
+ );
+
+ expect(
+ tester.getSemantics(find.byType(LoadingPrimaryButton)),
+ isSemantics(
+ label: "Send",
+ value: "",
+ isButton: true,
+ hasEnabledState: true,
+ isEnabled: true,
+ hasTapAction: true,
+ ),
+ );
+ });
+
+ testWidgets("a semantic tap invokes onPressed when idle", (tester) async {
+ var pressed = 0;
+ await _pump(
+ tester,
+ LoadingPrimaryButton(
+ text: "Send",
+ color: Colors.blue,
+ textColor: Colors.white,
+ onPressed: () => pressed++,
+ ),
+ );
+
+ tester.semantics.tap(find.semantics.byLabel("Send"));
+ await tester.pump();
+
+ expect(pressed, 1);
+ });
+
+ testWidgets("isDisabled reports disabled without a loading value", (tester) async {
+ await _pump(
+ tester,
+ LoadingPrimaryButton(
+ text: "Send",
+ color: Colors.blue,
+ textColor: Colors.white,
+ isDisabled: true,
+ onPressed: () {},
+ ),
+ );
+
+ expect(
+ tester.getSemantics(find.byType(LoadingPrimaryButton)),
+ isSemantics(label: "Send", value: "", isEnabled: false, hasTapAction: false),
+ );
+ });
+ });
+}
### test/src/widgets/rounded_checkbox_test.dart
@@ -0,0 +1,41 @@
+import "package:cake_wallet/src/widgets/rounded_checkbox.dart";
+import "package:flutter/material.dart";
+import "package:flutter/semantics.dart";
+import "package:flutter_test/flutter_test.dart";
+
+final _checkableNodes = find.semantics.byFlag(SemanticsFlag.hasCheckedState);
+
+final _labelledNodes = find.semantics.byPredicate(
+ (node) => node.label.isNotEmpty,
+ describeMatch: (_) => "labelled SemanticsNodes",
+);
+
+Future<void> _pump(WidgetTester tester, Widget child) =>
+ tester.pumpWidget(MaterialApp(home: Scaffold(body: Center(child: child))));
+
+void main() {
+ group("RoundedCheckbox semantics", () {
+ testWidgets("a checked box reports the checked state", (tester) async {
+ await _pump(tester, RoundedCheckbox(value: true));
+
+ expect(_checkableNodes, findsOne);
+ expect(
+ tester.getSemantics(find.byType(RoundedCheckbox)),
+ isSemantics(hasCheckedState: true, isChecked: true),
+ );
+ });
+
+ testWidgets("the check glyph does not become its own node", (tester) async {
+ await _pump(tester, RoundedCheckbox(value: true));
+
+ expect(_labelledNodes, findsNothing);
+ expect(_checkableNodes, findsOne);
+ });
+
+ testWidgets("the checked state carries no name of its own", (tester) async {
+ await _pump(tester, RoundedCheckbox(value: true));
+
+ expect(tester.getSemantics(find.byType(RoundedCheckbox)).label, isEmpty);
+ });
+ });
+}
### test/utils/address_formatter_test.dart
@@ -0,0 +1,106 @@
+import "package:cake_wallet/utils/address_formatter.dart";
+import "package:cw_core/wallet_type.dart";
+import "package:flutter/material.dart";
+import "package:flutter_test/flutter_test.dart";
+
+const _btc = "bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq";
+const _xmr = "44AFFq5kSiGBoZ4NMDwYtN18obc8AemS33DBLWs3H7otXft3Xjrp"
+ "DtQGv7SqSsaBYBb98uNbr2VBBEt7f2wfn3RVGQBEP3A";
+const _mweb = "ltcmweb1qqf0kctdmt7xdtnkm2j0mfy2rhr4pl2rwkxq";
+const _bch = "bitcoincash:qzm47qz5ue99y9yl4aca7jnz7dwgdenl85jwvdp424";
+
+const _style = TextStyle(color: Colors.black);
+
+List<String> _labels(WidgetTester tester) =>
+ tester.semantics.simulatedAccessibilityTraversal().map((node) => node.label).toList();
+
+Future<void> _pump(
+ WidgetTester tester, {
+ required String address,
+ WalletType? walletType,
+ bool shouldTruncate = false,
+}) =>
+ tester.pumpWidget(
+ MaterialApp(
+ home: Scaffold(
+ body: Center(
+ child: AddressFormatter.buildSegmentedAddress(
+ address: address,
+ walletType: walletType,
+ evenTextStyle: _style,
+ shouldTruncate: shouldTruncate,
+ ),
+ ),
+ ),
+ ),
+ );
+
+void main() {
+ group("full segmented address", () {
+ testWidgets("announces the whole address as one node", (tester) async {
+ await _pump(tester, address: _btc);
+
+ expect(_labels(tester), [_btc]);
+ });
+
+ testWidgets("the space-separated chunks are not announced", (tester) async {
+ await _pump(tester, address: _btc);
+
+ expect(find.byType(RichText), findsWidgets);
+ expect(find.semantics.byPredicate((node) => node.label.contains(" ")), findsNothing);
+ });
+
+ testWidgets("a Monero address (6-char chunks) is announced in full", (tester) async {
+ await _pump(tester, address: _xmr, walletType: WalletType.monero);
+
+ expect(_labels(tester), [_xmr]);
+ });
+
+ testWidgets("an MWEB address is announced in full", (tester) async {
+ await _pump(tester, address: _mweb);
+
+ expect(_labels(tester), [_mweb]);
+ });
+ });
+
+ group("truncated address", () {
+ testWidgets("announces the whole address, never the ellipsis", (tester) async {
+ await _pump(tester, address: _btc, shouldTruncate: true);
+
+ expect(_labels(tester), [_btc]);
+ expect(find.semantics.byPredicate((node) => node.label.contains("...")), findsNothing);
+ });
+
+ testWidgets("a truncated Monero address is announced in full", (tester) async {
+ await _pump(tester, address: _xmr, walletType: WalletType.monero, shouldTruncate: true);
+
+ expect(_labels(tester), [_xmr]);
+ });
+
+ testWidgets("a truncated MWEB address is announced in full", (tester) async {
+ await _pump(tester, address: _mweb, shouldTruncate: true);
+
+ expect(_labels(tester), [_mweb]);
+ });
+
+ testWidgets("an address too short to truncate is still announced in full", (tester) async {
+ await _pump(tester, address: "abcdefg", shouldTruncate: true);
+
+ expect(_labels(tester), ["abcdefg"]);
+ });
+ });
+
+ group("special forms", () {
+ testWidgets("the bitcoincash: prefix is dropped from the announcement too", (tester) async {
+ await _pump(tester, address: _bch);
+
+ expect(_labels(tester), [_bch.replaceAll("bitcoincash:", "")]);
+ });
+
+ testWidgets("a human-readable name is announced verbatim", (tester) async {
+ await _pump(tester, address: "seth@cakewallet.com");
+
+ expect(_labels(tester), ["seth@cakewallet.com"]);
+ });
+ });
+}
### test/utils/semantics_helpers.dart
@@ -14,6 +14,9 @@ List<SemanticsNode> platformNodesWithId(WidgetTester tester, String identifier)
});
}
- visit(tester.binding.pipelineOwner.semanticsOwner!.rootSemanticsNode!);
+ visit(tester.binding.renderViews.first.owner!.semanticsOwner!.rootSemanticsNode!);
return result;
}
+
+List<SemanticsNode> screenReaderStops(WidgetTester tester) =>
+ tester.semantics.simulatedAccessibilityTraversal().toList();Why this scored 39/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.