probe_agent: widgets of package:material_ui and cupertino_ui get wrong answers for is enabled/disabled, is checked and the tooltip selector (Flutter 3.50)

Đang mở
#852 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
55/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
dart, flutter
Lĩnh vực
mobile-dev, testing-qa

Hướng nghiên cứu

Start with the type checks in probe_agent/lib/src/executor.dart, finder.dart, and device_view.dart, then review the measured cases in test/measure_test.dart. Compare handling of legacy and standalone Material and Cupertino widgets, especially enabled state, checked state, and tooltip lookup. Done means those cases pass for migrated widgets on a device while the existing legacy behavior and obscured-field protection remain correct.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug

What happens

Flutter 3.50 deprecates package:flutter/material.dart and package:flutter/cupertino.dart in favour of the standalone packages material_ui and cupertino_ui ("Migrate to standalone material_ui and cupertino_ui packages", docs.flutter.dev, page dated 2026-11-09). The agent decides what a widget is by its Dart type, taken from package:flutter/material.dart and package:flutter/cupertino.dart (probe_agent/lib/src/executor.dart, finder.dart, device_view.dart). A widget of material_ui is a different class, so on an app that has migrated, some steps give a wrong answer, one of them a silent false pass.

Measured

A scratch app on Flutter 3.50.0 with material_ui 1.11.1 and cupertino_ui 1.1.7 (what ^1.0.0 resolved to), the agent of main (a path dependency), a widget test that runs the agent's own request handler on a screen of each library's widgets. The control is the same screen built from package:flutter/material.dart. One run, no device.

Step package:flutter/material.dart (control) material_ui / cupertino_ui
see "Submit" (text) and tap "Submit" on an ElevatedButton ok ok
see #go is enabled (enabled button) ok ok
see #off is disabled (button with onPressed: null) ok fails: "#off" is enabled
see #off is enabled (the same disabled button) fails: is disabled passes (false pass)
type "x" into #f and see #f contains "x" on a TextField ok ok
see #cb is checked (Checkbox) and see #sw is checked (Switch) ok fail: "is not a checkable control"
see #cs is checked (CupertinoSwitch) not run fails: "is not a checkable control"
tap "Add item" (an IconButton found by its tooltip) ok fails: Widget not found
type into a CupertinoTextField, contains not run ok
see #pw is filled (obscured TextField) ok ok
see "hunter2" (the value of an obscured field must not be found) not found, as designed not found, as designed
see #f is focused ok ok

So what runs through the widgets library (text, hit testing, EditableText, focus) works, and the obscured-field protection holds (it goes through EditableText). What is decided by a Material or Cupertino class does not: disabled state of buttons, checked state of checkboxes, switches and radios, the tooltip selector.

Not measured

Route handling (a material_ui Scaffold, dialog or bottom sheet: the agent's route code names BottomSheet, CupertinoPageScaffold and others), TextField(enabled: false), chips and list tiles, TextFormField, DropdownButton, the segmented and picker widgets, probe device view and Studio's inspector, and any device (iOS or Android). Whether the standalone packages re-export or wrap the in-framework classes in a way that would let one check cover both was not read in their source.

Why it matters, and what is not known

The in-framework libraries are still in packages/flutter on 3.50 (the page says "formally deprecated" and gives no removal version), so apps that have not migrated are unaffected. An app that migrates and is tested with FlutterProbe gets the answers above, and is enabled on a disabled button passes. The CLI cannot see it.

Not fixed here

This is a report with a measurement (the RELEASES log gets a note). A fix has to recognise both families of classes (by importing material_ui and cupertino_ui, which raises the Flutter floor of the agent to 3.47, by class name, or by another test of the widget) and has to be tested on a device with a migrated fixture; the choice is open.

The measurement test (scratch, test/measure_test.dart of an app that depends on material_ui, cupertino_ui and the agent)
import 'dart:convert';

import 'package:cupertino_ui/cupertino_ui.dart' as cui;
import 'package:flutter/material.dart' as fm; // the legacy in-framework library: the control
import 'package:flutter/widgets.dart';
import 'package:flutter_probe_agent/src/executor.dart';
import 'package:flutter_probe_agent/src/protocol.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:material_ui/material_ui.dart' as mu;

// What the agent does on widgets from package:material_ui / cupertino_ui compared with the same widgets from package:flutter/material.dart.
// Each case prints one line: "<library> | <step> | ok" or the error message.
final results = <String>[];

Future<String> run(ProbeExecutor ex, List<String> sent, String method, Map<String, dynamic> params) async {
  sent.clear();
  await ex.dispatch(ProbeRequest(jsonrpc: '2.0', id: 1, method: method, params: params));
  final m = jsonDecode(sent.last) as Map<String, dynamic>;
  return m.containsKey('error') ? ((m['error'] as Map)['message'] as String).split('\n').first : 'ok';
}

Map<String, dynamic> byText(String t, {String check = '', bool negated = false}) => {
      'selector': {'kind': 'text', 'text': t},
      if (check.isNotEmpty) 'check': check,
      'negated': negated,
    };
Map<String, dynamic> byId(String id, {String check = '', bool negated = false}) => {
      'selector': {'kind': 'id', 'text': '#$id'},
      if (check.isNotEmpty) 'check': check,
      'negated': negated,
    };

Widget muApp(Widget body) => mu.MaterialApp(home: mu.Scaffold(body: body));
Widget fmApp(Widget body) => fm.MaterialApp(home: fm.Scaffold(body: body));

void main() {
  for (final lib in ['flutter/material', 'material_ui']) {
    final isMu = lib == 'material_ui';
    testWidgets('measure $lib', (tester) async {
      final sent = <String>[];
      final ex = ProbeExecutor((m) => sent.add(m));
      bool checked = true;
      bool sw = true;
      final pw = TextEditingController(text: 'hunter2-SECRET');
      final field = TextEditingController();
      final body = Column(children: [
        isMu ? mu.ElevatedButton(key: const ValueKey('go'), onPressed: () {}, child: const Text('Submit')) : fm.ElevatedButton(key: const ValueKey('go'), onPressed: () {}, child: const Text('Submit')),
        isMu ? const mu.ElevatedButton(key: ValueKey('off'), onPressed: null, child: Text('Disabled one')) : const fm.ElevatedButton(key: ValueKey('off'), onPressed: null, child: Text('Disabled one')),
        isMu ? mu.TextField(key: const ValueKey('f'), controller: field) : fm.TextField(key: const ValueKey('f'), controller: field),
        isMu ? mu.TextField(key: const ValueKey('pw'), obscureText: true, controller: pw) : fm.TextField(key: const ValueKey('pw'), obscureText: true, controller: pw),
        isMu ? mu.Checkbox(key: const ValueKey('cb'), value: checked, onChanged: (v) {}) : fm.Checkbox(key: const ValueKey('cb'), value: checked, onChanged: (v) {}),
        isMu ? mu.Switch(key: const ValueKey('sw'), value: sw, onChanged: (v) {}) : fm.Switch(key: const ValueKey('sw'), value: sw, onChanged: (v) {}),
        isMu ? mu.IconButton(key: const ValueKey('ib'), tooltip: 'Add item', icon: const Icon(IconData(0xe047)), onPressed: () {}) : fm.IconButton(key: const ValueKey('ib'), tooltip: 'Add item', icon: const Icon(IconData(0xe047)), onPressed: () {}),
      ]);
      await tester.pumpWidget(isMu ? muApp(body) : fmApp(body));
      await tester.pumpAndSettle();
      Future<void> rec(String step, String method, Map<String, dynamic> p) async => results.add('$lib | $step | ${await run(ex, sent, method, p)}');
      await rec('see "Submit"', ProbeMethods.see, byText('Submit'));
      await rec('tap "Submit"', ProbeMethods.tap, byText('Submit'));
      await rec('see #go is enabled', ProbeMethods.see, byId('go', check: 'enabled'));
      await rec('see #off is disabled', ProbeMethods.see, byId('off', check: 'disabled'));
      await rec('see #off is enabled (should fail)', ProbeMethods.see, byId('off', check: 'enabled'));
      await rec('type "x" into #f', ProbeMethods.type_, {'selector': {'kind': 'id', 'text': '#f'}, 'text': 'x'});
      await rec('see #f contains "x"', ProbeMethods.see, {...byId('f', check: 'contains'), 'check_val': 'x'});
      await rec('see #cb is checked', ProbeMethods.see, byId('cb', check: 'checked'));
      await rec('see #sw is checked', ProbeMethods.see, byId('sw', check: 'checked'));
      await rec('tap "Add item" (tooltip)', ProbeMethods.tap, byText('Add item'));
      await rec('see #pw is filled', ProbeMethods.see, byId('pw', check: 'filled'));
      await rec('see "hunter2" (must NOT find the password)', ProbeMethods.see, byText('hunter2'));
      await rec('see #f is focused', ProbeMethods.see, byId('f', check: 'focused'));
    });
  }
  testWidgets('cupertino_ui', (tester) async {
    final sent = <String>[];
    final ex = ProbeExecutor((m) => sent.add(m));
    await tester.pumpWidget(mu.MaterialApp(home: mu.Scaffold(body: Column(children: [
      cui.CupertinoTextField(key: const ValueKey('ct'), placeholder: 'Type here'),
      cui.CupertinoSwitch(key: const ValueKey('cs'), value: true, onChanged: (v) {}),
    ]))));
    await tester.pumpAndSettle();
    results.add('cupertino_ui | type "x" into #ct | ${await run(ex, sent, ProbeMethods.type_, {'selector': {'kind': 'id', 'text': '#ct'}, 'text': 'x'})}');
    results.add('cupertino_ui | see #ct contains "x" | ${await run(ex, sent, ProbeMethods.see, {...byId('ct', check: 'contains'), 'check_val': 'x'})}');
    results.add('cupertino_ui | see #cs is checked | ${await run(ex, sent, ProbeMethods.see, byId('cs', check: 'checked'))}');
  });
  tearDownAll(() {
    // ignore: avoid_print
    print('\n=== RESULTS ===\n${results.join('\n')}\n=== END ===');
  });
}
Ngôn ngữ chính
Go
Star
6
Fork
3
Merge trung bình
6 giờ 28 phút
Pull request đã merge (30 ngày)
362

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của AlphaWaveSystems/flutter-probe

Tất cả issue của AlphaWaveSystems/flutter-probe

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.