-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: Flutter CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- main # 根据你的默认分支修改 | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up JDK | ||
uses: actions/setup-java@v1 | ||
with: | ||
java-version: "11" | ||
|
||
- name: Install Flutter | ||
uses: subosito/flutter-action@v2 | ||
with: | ||
flutter-version: "3.24.3" # 更新为你的 Flutter 版本 | ||
|
||
- name: Install Dependencies | ||
run: flutter pub get | ||
|
||
- name: Run Tests | ||
run: flutter test | ||
|
||
- name: Build APK | ||
run: flutter build apk --release | ||
|
||
- name: Upload Release APK | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: app-release.apk | ||
path: build/app/outputs/flutter-apk/app-release.apk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:dns_speed_test/main.dart'; // 根据实际项目名更新 | ||
import 'package:shared_preferences/shared_preferences.dart'; | ||
|
||
void main() { | ||
testWidgets('MainPage 有标题和语言按钮', (WidgetTester tester) async { | ||
// 模拟 SharedPreferences | ||
SharedPreferences.setMockInitialValues({}); | ||
final prefs = await SharedPreferences.getInstance(); | ||
|
||
await tester.pumpWidget(MyApp(prefs: prefs)); | ||
|
||
// 检查标题是否存在 | ||
expect(find.text('DNS Speed Test'), findsOneWidget); // 用实际标题替换 | ||
|
||
// 检查语言按钮是否存在 | ||
expect(find.byIcon(Icons.language), findsOneWidget); | ||
}); | ||
|
||
} |