Skip to content

Commit 0092845

Browse files
domydtjarvstrand
authored andcommitted
ci: add integration tests for Windows
1 parent 42428f8 commit 0092845

File tree

4 files changed

+87
-0
lines changed

4 files changed

+87
-0
lines changed

.github/workflows/test.yml

+13
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,16 @@ jobs:
3030
- run: flutter test
3131
- run: flutter test
3232
working-directory: example
33+
34+
integration-test-windows:
35+
name: 'Integration Test on windows-latest'
36+
runs-on: windows-latest
37+
steps:
38+
- uses: actions/checkout@v4
39+
- uses: subosito/flutter-action@v2
40+
with:
41+
channel: stable
42+
43+
- name: run integration test
44+
run: .\run_integration_test_windows.ps1
45+
working-directory: example
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:flutter_test/flutter_test.dart';
3+
import 'package:flutter_timezone_example/main.dart';
4+
import 'package:integration_test/integration_test.dart';
5+
6+
void main() {
7+
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
8+
9+
group('getLocalTimezone', () {
10+
final expected = const String.fromEnvironment('EXPECTED_TZ');
11+
12+
testWidgets('check that the local timezone is $expected', (tester) async {
13+
await tester.pumpWidget(MyApp());
14+
await tester.pumpAndSettle();
15+
16+
Text tzTextWidget = find
17+
.byKey(const ValueKey('timeZoneLabel'))
18+
.evaluate()
19+
.first
20+
.widget as Text;
21+
22+
expect(tzTextWidget.data, expected);
23+
});
24+
});
25+
}

example/pubspec.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ dependencies:
1616
dev_dependencies:
1717
flutter_test:
1818
sdk: flutter
19+
integration_test:
20+
sdk: flutter
1921

2022
flutter:
2123
uses-material-design: true
+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Runs the integration tests for this plugin on Windows.
2+
#
3+
# This script modifies the current system's time zone and region, and then runs
4+
# `integration_test/local_timezone_test.dart` with the expected IANA time zone as a parameter.
5+
#
6+
# See https://learn.microsoft.com/en-us/windows/win32/intl/table-of-geographical-locations for the
7+
# list of region integer codes.
8+
9+
$json = @"
10+
[
11+
{
12+
"tz": "W. Europe Standard Time",
13+
"region": 14, // Austria
14+
"expected": "Europe/Vienna"
15+
},
16+
{
17+
"tz": "W. Europe Standard Time",
18+
"region": 223, // Switzerland
19+
"expected": "Europe/Zurich"
20+
},
21+
{
22+
"tz": "W. Europe Standard Time",
23+
"region": 244, // United States
24+
"expected": "Europe/Berlin"
25+
},
26+
{
27+
"tz": "Tokyo Standard Time",
28+
"region": 122,
29+
"expected": "Asia/Tokyo"
30+
}
31+
]
32+
"@;
33+
34+
$inputJson = ConvertFrom-Json $json;
35+
36+
foreach ($input in $inputJson) {
37+
Write-Output "tz: $($input.tz), region: $($input.region), expected: $($input.expected)";
38+
39+
# set time zone
40+
tzutil /s "$($input.tz)"
41+
42+
# set region
43+
Set-WinHomeLocation $input.region
44+
45+
# test
46+
flutter test integration_test/local_timezone_test.dart -d windows --dart-define EXPECTED_TZ="$($input.expected)"
47+
}

0 commit comments

Comments
 (0)