taler-android

Android apps for GNU Taler (wallet, PoS, cashier)
Log | Files | Refs | README | LICENSE

repro_action_buttons_no_a11y_name.py (2954B)


      1 # This file is part of GNU Taler
      2 # (C) 2026 Taler Systems S.A.
      3 #
      4 # GNU Taler is free software; you can redistribute it and/or modify it under the
      5 # terms of the GNU General Public License as published by the Free Software
      6 # Foundation; either version 3, or (at your option) any later version.
      7 #
      8 # GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
      9 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
     10 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
     11 #
     12 # You should have received a copy of the GNU General Public License along with
     13 # GNU Taler; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
     14 """Reproducer: the balance card's action buttons have no accessible name.
     15 
     16 Needs a wallet with a balance, so the action row is on screen; run
     17 `driver/smoke_withdraw.py` first, or pass --fund to do a withdrawal here.
     18 
     19     cd /opt/taler-sim/driver
     20     python3 ../findings/repro_action_buttons_no_a11y_name.py [--fund]
     21 
     22 Exits 0 when the defect is present (unnamed clickable buttons paired with
     23 separate text labels), 1 when every action button has a name.
     24 """
     25 
     26 from __future__ import annotations
     27 
     28 import sys
     29 from pathlib import Path
     30 
     31 sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "driver"))
     32 
     33 from device import Device  # noqa: E402
     34 from stack import Bank, Env  # noqa: E402
     35 from wallet import Wallet  # noqa: E402
     36 
     37 ACTIONS = ("Send", "Request", "Withdraw", "Deposit")
     38 
     39 
     40 def main() -> int:
     41     dev = Device(sys.argv[1] if len(sys.argv) > 1 and sys.argv[1].startswith("emulator")
     42                  else "emulator-5554")
     43     app = Wallet(dev)
     44     if "--fund" in sys.argv:
     45         import scenarios
     46         env = Env.load()
     47         app.fresh_start(dev_mode=True)
     48         scenarios.withdraw(app, Bank(env.bank), "EUR:10")
     49     screen = app.home()
     50 
     51     labels = {name: screen.find(f"^{name}$") for name in ACTIONS}
     52     missing = [name for name, node in labels.items() if node is None]
     53     if missing:
     54         print(f"action row not on screen (missing {missing}); "
     55               f"does the wallet have a balance?\nscreen: {screen.texts()}")
     56         return 2
     57 
     58     unnamed = []
     59     for name, node in labels.items():
     60         button = screen.tap_target(node)
     61         named = bool(button.label.strip())
     62         print(f"{name:10} label node at {node.center}, "
     63               f"clickable={node.clickable} -> button {button.cls.rsplit('.', 1)[-1]} "
     64               f"at {button.center} accessible-name={button.label.strip()!r}")
     65         if not named and button is not node:
     66             unnamed.append(name)
     67 
     68     print(f"\nclickable nodes on this screen with no accessible name: "
     69           f"{len(screen.unnamed_clickables())}")
     70     print(f"action buttons without an accessible name: {unnamed}")
     71     print(f"\nreproduced: {len(unnamed) == len(ACTIONS)}")
     72     return 0 if len(unnamed) == len(ACTIONS) else 1
     73 
     74 
     75 if __name__ == "__main__":
     76     raise SystemExit(main())