-
-
Notifications
You must be signed in to change notification settings - Fork 37
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
1 parent
0c11a04
commit 4167392
Showing
9 changed files
with
273 additions
and
21 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
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
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
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,7 @@ | ||
import 'dark_theme_test.dart' as dark_theme_test; | ||
import 'subnet_tests.dart' as subnet_test; | ||
|
||
void main() { | ||
dark_theme_test.main(); | ||
subnet_test.main(); | ||
} |
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,178 @@ | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:integration_test/integration_test.dart'; | ||
import 'package:vernet/helper/app_settings.dart'; | ||
import 'package:vernet/main.dart'; | ||
import 'package:vernet/values/keys.dart'; | ||
|
||
import 'test_utils.dart'; | ||
|
||
void main() { | ||
IntegrationTestWidgetsFlutterBinding.ensureInitialized(); | ||
final appSettings = AppSettings.instance; | ||
group('subnet tests', () { | ||
testWidgets('set custom subnet test', (tester) async { | ||
await appSettings.load(); | ||
|
||
await tester.pumpWidget(const MyApp(true)); | ||
|
||
await TestUtils.tapSettingsButton(tester, find); | ||
|
||
await TestUtils.scrollUntilVisibleByWidgetKey( | ||
WidgetKey.customSubnetTile, | ||
tester, | ||
find, | ||
200.0, | ||
); | ||
|
||
await TestUtils.tapByWidgetKey(WidgetKey.customSubnetTile, tester, find); | ||
|
||
await TestUtils.enterTextByKey( | ||
WidgetKey.settingsTextField, | ||
'192.168.1.0', | ||
tester, | ||
find, | ||
); | ||
|
||
await TestUtils.tapByWidgetKey( | ||
WidgetKey.settingsSubmitButton, | ||
tester, | ||
find, | ||
); | ||
await appSettings.load(); | ||
|
||
expect(appSettings.customSubnet, '192.168.1.0'); | ||
}); | ||
|
||
testWidgets('First subnet test', (tester) async { | ||
await appSettings.load(); | ||
|
||
await tester.pumpWidget(const MyApp(true)); | ||
|
||
await TestUtils.tapSettingsButton(tester, find); | ||
|
||
await TestUtils.scrollUntilVisibleByWidgetKey( | ||
WidgetKey.firstSubnetTile, | ||
tester, | ||
find, | ||
200.0, | ||
); | ||
|
||
await TestUtils.tapByWidgetKey(WidgetKey.firstSubnetTile, tester, find); | ||
|
||
await TestUtils.enterTextByKey( | ||
WidgetKey.settingsTextField, | ||
'10', | ||
tester, | ||
find, | ||
); | ||
|
||
await TestUtils.tapByWidgetKey( | ||
WidgetKey.settingsSubmitButton, | ||
tester, | ||
find, | ||
); | ||
await appSettings.load(); | ||
|
||
expect(appSettings.firstSubnet, 10); | ||
}); | ||
|
||
testWidgets('Last subnet test', (tester) async { | ||
await appSettings.load(); | ||
|
||
await tester.pumpWidget(const MyApp(true)); | ||
|
||
await TestUtils.tapSettingsButton(tester, find); | ||
|
||
await TestUtils.scrollUntilVisibleByWidgetKey( | ||
WidgetKey.lastSubnetTile, | ||
tester, | ||
find, | ||
200.0, | ||
); | ||
|
||
await TestUtils.tapByWidgetKey(WidgetKey.lastSubnetTile, tester, find); | ||
|
||
await TestUtils.enterTextByKey( | ||
WidgetKey.settingsTextField, | ||
'250', | ||
tester, | ||
find, | ||
); | ||
|
||
await TestUtils.tapByWidgetKey( | ||
WidgetKey.settingsSubmitButton, | ||
tester, | ||
find, | ||
); | ||
await appSettings.load(); | ||
|
||
expect(appSettings.lastSubnet, 250); | ||
}); | ||
|
||
testWidgets('Socket timeout test', (tester) async { | ||
await appSettings.load(); | ||
|
||
await tester.pumpWidget(const MyApp(true)); | ||
|
||
await TestUtils.tapSettingsButton(tester, find); | ||
|
||
await TestUtils.scrollUntilVisibleByWidgetKey( | ||
WidgetKey.socketTimeoutTile, | ||
tester, | ||
find, | ||
200.0, | ||
); | ||
|
||
await TestUtils.tapByWidgetKey(WidgetKey.socketTimeoutTile, tester, find); | ||
|
||
await TestUtils.enterTextByKey( | ||
WidgetKey.settingsTextField, | ||
'250', | ||
tester, | ||
find, | ||
); | ||
|
||
await TestUtils.tapByWidgetKey( | ||
WidgetKey.settingsSubmitButton, | ||
tester, | ||
find, | ||
); | ||
await appSettings.load(); | ||
|
||
expect(appSettings.socketTimeout, 250); | ||
}); | ||
|
||
testWidgets('Ping count test', (tester) async { | ||
await appSettings.load(); | ||
|
||
await tester.pumpWidget(const MyApp(true)); | ||
|
||
await TestUtils.tapSettingsButton(tester, find); | ||
|
||
await TestUtils.scrollUntilVisibleByWidgetKey( | ||
WidgetKey.pingCountTile, | ||
tester, | ||
find, | ||
200.0, | ||
); | ||
|
||
await TestUtils.tapByWidgetKey(WidgetKey.pingCountTile, tester, find); | ||
|
||
await TestUtils.enterTextByKey( | ||
WidgetKey.settingsTextField, | ||
'6', | ||
tester, | ||
find, | ||
); | ||
|
||
await TestUtils.tapByWidgetKey( | ||
WidgetKey.settingsSubmitButton, | ||
tester, | ||
find, | ||
); | ||
await appSettings.load(); | ||
|
||
expect(appSettings.pingCount, 6); | ||
}); | ||
}); | ||
} |
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,57 @@ | ||
import 'package:flutter/widgets.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:vernet/values/keys.dart'; | ||
|
||
class TestUtils { | ||
static Future<void> tapSettingsButton( | ||
WidgetTester tester, | ||
CommonFinders find, | ||
) async { | ||
await tapByWidgetKey(WidgetKey.settingsButton, tester, find); | ||
} | ||
|
||
static Future<void> tapByText( | ||
String text, | ||
WidgetTester tester, | ||
CommonFinders find, | ||
) async { | ||
final widget = find.text(text); | ||
await tester.tap(widget); | ||
await tester.pumpAndSettle(); | ||
} | ||
|
||
static Future<void> enterTextByKey( | ||
WidgetKey widgetKey, | ||
String text, | ||
WidgetTester tester, | ||
CommonFinders find, | ||
) async { | ||
final textField = find.byKey(widgetKey.key); | ||
await tester.enterText(textField, text); | ||
await tester.pumpAndSettle(); | ||
} | ||
|
||
static Future<void> tapByWidgetKey( | ||
WidgetKey widgetKey, | ||
WidgetTester tester, | ||
CommonFinders find, | ||
) async { | ||
final widget = find.byKey(widgetKey.key); | ||
await tester.tap(widget); | ||
await tester.pumpAndSettle(); | ||
} | ||
|
||
static Future<void> scrollUntilVisibleByWidgetKey( | ||
WidgetKey widgetKey, | ||
WidgetTester tester, | ||
CommonFinders find, | ||
double scrollDistance, | ||
) async { | ||
final widget = find.byKey(widgetKey.key); | ||
await tester.scrollUntilVisible( | ||
widget, | ||
scrollDistance, | ||
scrollable: find.byType(Scrollable), | ||
); | ||
} | ||
} |
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
Oops, something went wrong.