feat(ds-flow): 前端设计系统治理重构(Flutter 五端 + Web 两端) #2
@@ -8,14 +8,23 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pangolin_vpn/bridge/vpn_bridge.dart';
|
||||
import 'package:pangolin_vpn/bridge/vpn_bridge_provider.dart';
|
||||
import 'package:pangolin_vpn/l10n/app_text.dart';
|
||||
import 'package:pangolin_vpn/l10n/strings_zh.dart';
|
||||
import 'package:pangolin_vpn/models/node.dart';
|
||||
import 'package:pangolin_vpn/services/connect_api.dart';
|
||||
import 'package:pangolin_vpn/services/device_identity.dart';
|
||||
import 'package:pangolin_vpn/state/app_providers.dart';
|
||||
import 'package:pangolin_vpn/state/connection_provider.dart';
|
||||
import 'package:pangolin_vpn/state/nodes_provider.dart';
|
||||
import 'package:pangolin_vpn/state/quota_provider.dart';
|
||||
|
||||
// localeProvider 现默认英文;测试硬编码 StringsZh 预期 → 钉死中文 locale。
|
||||
class _FixedLocale extends LocaleNotifier {
|
||||
_FixedLocale(AppLang lang) {
|
||||
state = lang;
|
||||
}
|
||||
}
|
||||
|
||||
// 可控假桥:能手动推 VpnStatus,无内部计时器(避免 pending timer)。
|
||||
class _FakeBridge implements VpnBridge {
|
||||
final _status = StreamController<VpnStatus>.broadcast();
|
||||
@@ -94,6 +103,7 @@ void main() {
|
||||
ProviderContainer makeContainer(_FakeBridge bridge,
|
||||
{NodesNotifier Function()? nodes, DateTime Function()? now}) =>
|
||||
ProviderContainer(overrides: [
|
||||
localeProvider.overrideWith((ref) => _FixedLocale(AppLang.zh)),
|
||||
vpnBridgeProvider.overrideWithValue(bridge),
|
||||
nodesProvider.overrideWith(nodes ?? _StubNodes.new),
|
||||
deviceIdentityProvider.overrideWithValue(DeviceIdentity(store: _MemKV())),
|
||||
|
||||
@@ -8,10 +8,12 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pangolin_vpn/bridge/vpn_bridge.dart';
|
||||
import 'package:pangolin_vpn/bridge/vpn_bridge_mock.dart';
|
||||
import 'package:pangolin_vpn/bridge/vpn_bridge_provider.dart';
|
||||
import 'package:pangolin_vpn/l10n/app_text.dart';
|
||||
import 'package:pangolin_vpn/l10n/strings_zh.dart';
|
||||
import 'package:pangolin_vpn/models/node.dart';
|
||||
import 'package:pangolin_vpn/pangolin_theme.dart';
|
||||
import 'package:pangolin_vpn/screens/nodes_page.dart';
|
||||
import 'package:pangolin_vpn/state/app_providers.dart';
|
||||
import 'package:pangolin_vpn/state/connection_provider.dart';
|
||||
import 'package:pangolin_vpn/state/nodes_provider.dart';
|
||||
import 'package:pangolin_vpn/widgets/smart_select_card.dart';
|
||||
@@ -31,11 +33,19 @@ const _nodes = [
|
||||
Node(code: 'JP', nameZh: '东京', nameEn: 'Tokyo', ping: 35, uuid: 'jp-uuid', host: 'jp', port: 443),
|
||||
];
|
||||
|
||||
// localeProvider 现默认英文;测试硬编码 StringsZh 预期 → 钉死中文 locale。
|
||||
class _FixedLocale extends LocaleNotifier {
|
||||
_FixedLocale(AppLang lang) {
|
||||
state = lang;
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
setUpAll(disableGoogleFontsFetching);
|
||||
const t = StringsZh();
|
||||
|
||||
ProviderContainer makeContainer(VpnBridge bridge) => ProviderContainer(overrides: [
|
||||
localeProvider.overrideWith((ref) => _FixedLocale(AppLang.zh)),
|
||||
nodesProvider.overrideWith(_StubNodes.new),
|
||||
vpnBridgeProvider.overrideWithValue(bridge),
|
||||
]);
|
||||
|
||||
@@ -13,6 +13,7 @@ import 'package:http/http.dart' as http;
|
||||
import 'package:http/testing.dart';
|
||||
import 'package:pangolin_vpn/bridge/vpn_bridge_mock.dart';
|
||||
import 'package:pangolin_vpn/bridge/vpn_bridge_provider.dart';
|
||||
import 'package:pangolin_vpn/l10n/app_text.dart';
|
||||
import 'package:pangolin_vpn/l10n/strings_zh.dart';
|
||||
import 'package:pangolin_vpn/models/node.dart';
|
||||
import 'package:pangolin_vpn/pangolin_theme.dart';
|
||||
@@ -20,6 +21,7 @@ import 'package:pangolin_vpn/screens/stats_page.dart';
|
||||
import 'package:pangolin_vpn/services/api_client.dart';
|
||||
import 'package:pangolin_vpn/services/token_store.dart';
|
||||
import 'package:pangolin_vpn/state/account_providers.dart';
|
||||
import 'package:pangolin_vpn/state/app_providers.dart';
|
||||
import 'package:pangolin_vpn/state/auth_provider.dart';
|
||||
import 'package:pangolin_vpn/state/nodes_provider.dart';
|
||||
import 'package:pangolin_vpn/widgets/period_card.dart';
|
||||
@@ -101,6 +103,13 @@ Finder _metric(String period, int i, String value, String unit) => find.byWidget
|
||||
w.metrics[i].unit == unit,
|
||||
);
|
||||
|
||||
// localeProvider 现默认英文;测试硬编码 StringsZh 预期 → 钉死中文 locale。
|
||||
class _FixedLocale extends LocaleNotifier {
|
||||
_FixedLocale(AppLang lang) {
|
||||
state = lang;
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
setUpAll(disableGoogleFontsFetching);
|
||||
const t = StringsZh();
|
||||
@@ -111,6 +120,7 @@ void main() {
|
||||
|
||||
await tester.pumpWidget(ProviderScope(
|
||||
overrides: [
|
||||
localeProvider.overrideWith((ref) => _FixedLocale(AppLang.zh)),
|
||||
tokenStoreProvider.overrideWithValue(const _LoggedInTokenStore()),
|
||||
apiClientProvider.overrideWithValue(ApiClient(
|
||||
baseUrl: 'http://test.local',
|
||||
|
||||
Reference in New Issue
Block a user