like a million tests written or something
parent
c416f647dc
commit
bb189b3168
|
@ -3,7 +3,7 @@
|
||||||
<application
|
<application
|
||||||
android:label="moody"
|
android:label="moody"
|
||||||
android:name="${applicationName}"
|
android:name="${applicationName}"
|
||||||
android:icon="@mipmap/ic_launcher">
|
android:icon="@mipmap/app_icon">
|
||||||
<activity
|
<activity
|
||||||
android:name=".MainActivity"
|
android:name=".MainActivity"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 5.2 KiB |
|
@ -27,7 +27,7 @@ class _EntryPage extends State<EntryPage> {
|
||||||
Color textColor = Colors.black;
|
Color textColor = Colors.black;
|
||||||
|
|
||||||
// Add these new class member variables
|
// Add these new class member variables
|
||||||
bool _isEditing = false;
|
final bool _isEditing = false;
|
||||||
final TextEditingController _textController = TextEditingController();
|
final TextEditingController _textController = TextEditingController();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -62,7 +62,7 @@ class _EntryPage extends State<EntryPage> {
|
||||||
_textController.text = (currentEntry != null ? currentEntry.texts.join(" ") : _moodText);
|
_textController.text = (currentEntry != null ? currentEntry.texts.join(" ") : _moodText);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _toggleEdit() {
|
/* void _toggleEdit() {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isEditing = !_isEditing;
|
_isEditing = !_isEditing;
|
||||||
});
|
});
|
||||||
|
@ -74,6 +74,7 @@ class _EntryPage extends State<EntryPage> {
|
||||||
void _saveEntry() async {
|
void _saveEntry() async {
|
||||||
//print("saveEntry...."); Todo for future versions
|
//print("saveEntry...."); Todo for future versions
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
|
|
||||||
|
|
||||||
const font = "ABCFavorit";
|
|
||||||
int fontHeadline = 22;
|
|
||||||
int fontSizeSmall = 16;
|
|
||||||
int fontSizeSmaller =13;
|
|
|
@ -30,9 +30,9 @@ class _SettingsPage extends State<SettingsPage> {
|
||||||
setState(() {});
|
setState(() {});
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _launchUrl(Uri _url) async {
|
Future<void> _launchUrl(Uri url) async {
|
||||||
if (!await launchUrl(_url)) {
|
if (!await launchUrl(url)) {
|
||||||
throw Exception('Could not launch $_url');
|
throw Exception('Could not launch $url');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ Future<void> _launchUrl(Uri _url) async {
|
||||||
leftText: "join our discord",
|
leftText: "join our discord",
|
||||||
rightText: "fullfilled",
|
rightText: "fullfilled",
|
||||||
onTap: () async => {
|
onTap: () async => {
|
||||||
await _launchUrl(Uri.parse("https://www.google.com"))
|
await _launchUrl(Uri.parse("https://discord.gg/qaVjyqHW5s"))
|
||||||
|
|
||||||
}, // Implement your logic
|
}, // Implement your logic
|
||||||
),
|
),
|
||||||
|
@ -110,7 +110,10 @@ Future<void> _launchUrl(Uri _url) async {
|
||||||
TextSwitchContainer(
|
TextSwitchContainer(
|
||||||
leftText: "our instagram",
|
leftText: "our instagram",
|
||||||
rightText: "@get.fulfilled",
|
rightText: "@get.fulfilled",
|
||||||
onTap: () => {},
|
onTap: () async => {
|
||||||
|
await _launchUrl(Uri.parse("http://instagram.com/get.fulfilled"))
|
||||||
|
|
||||||
|
}, // Implement your logic
|
||||||
),
|
),
|
||||||
const CustomDivider(),
|
const CustomDivider(),
|
||||||
TextSwitchContainer(
|
TextSwitchContainer(
|
||||||
|
|
207
pubspec.lock
207
pubspec.lock
|
@ -1,6 +1,30 @@
|
||||||
# Generated by pub
|
# Generated by pub
|
||||||
# See https://dart.dev/tools/pub/glossary#lockfile
|
# See https://dart.dev/tools/pub/glossary#lockfile
|
||||||
packages:
|
packages:
|
||||||
|
_fe_analyzer_shared:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: _fe_analyzer_shared
|
||||||
|
sha256: eb376e9acf6938204f90eb3b1f00b578640d3188b4c8a8ec054f9f479af8d051
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "64.0.0"
|
||||||
|
analyzer:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: analyzer
|
||||||
|
sha256: "69f54f967773f6c26c7dcb13e93d7ccee8b17a641689da39e878d5cf13b06893"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "6.2.0"
|
||||||
|
args:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: args
|
||||||
|
sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.4.2"
|
||||||
async:
|
async:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -17,6 +41,30 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.1"
|
version: "2.1.1"
|
||||||
|
build:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: build
|
||||||
|
sha256: "80184af8b6cb3e5c1c4ec6d8544d27711700bc3e6d2efad04238c7b5290889f0"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.4.1"
|
||||||
|
built_collection:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: built_collection
|
||||||
|
sha256: "376e3dd27b51ea877c28d525560790aee2e6fbb5f20e2f85d5081027d94e2100"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "5.1.1"
|
||||||
|
built_value:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: built_value
|
||||||
|
sha256: c9aabae0718ec394e5bc3c7272e6bb0dc0b32201a08fe185ec1d8401d3e39309
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "8.8.1"
|
||||||
characters:
|
characters:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -33,6 +81,14 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.1"
|
version: "1.1.1"
|
||||||
|
code_builder:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: code_builder
|
||||||
|
sha256: f692079e25e7869c14132d39f223f8eec9830eb76131925143b2129c4bb01b37
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "4.10.0"
|
||||||
collection:
|
collection:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -41,6 +97,22 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.18.0"
|
version: "1.18.0"
|
||||||
|
convert:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: convert
|
||||||
|
sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "3.1.1"
|
||||||
|
crypto:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: crypto
|
||||||
|
sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "3.0.3"
|
||||||
cupertino_icons:
|
cupertino_icons:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
@ -49,6 +121,14 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.6"
|
version: "1.0.6"
|
||||||
|
dart_style:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: dart_style
|
||||||
|
sha256: "40ae61a5d43feea6d24bd22c0537a6629db858963b99b4bc1c3db80676f32368"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.3.4"
|
||||||
fake_async:
|
fake_async:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -69,15 +149,28 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: file
|
name: file
|
||||||
sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c"
|
sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "7.0.0"
|
version: "6.1.4"
|
||||||
|
fixnum:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: fixnum
|
||||||
|
sha256: "25517a4deb0c03aa0f32fd12db525856438902d9c16536311e76cdc57b31d7d1"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.1.0"
|
||||||
flutter:
|
flutter:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
|
flutter_driver:
|
||||||
|
dependency: transitive
|
||||||
|
description: flutter
|
||||||
|
source: sdk
|
||||||
|
version: "0.0.0"
|
||||||
flutter_lints:
|
flutter_lints:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description:
|
description:
|
||||||
|
@ -96,6 +189,19 @@ packages:
|
||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
|
fuchsia_remote_debug_protocol:
|
||||||
|
dependency: transitive
|
||||||
|
description: flutter
|
||||||
|
source: sdk
|
||||||
|
version: "0.0.0"
|
||||||
|
glob:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: glob
|
||||||
|
sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.1.2"
|
||||||
go_router:
|
go_router:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
@ -104,6 +210,11 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "12.1.3"
|
version: "12.1.3"
|
||||||
|
integration_test:
|
||||||
|
dependency: "direct dev"
|
||||||
|
description: flutter
|
||||||
|
source: sdk
|
||||||
|
version: "0.0.0"
|
||||||
intl:
|
intl:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
@ -152,6 +263,22 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.10.0"
|
version: "1.10.0"
|
||||||
|
mockito:
|
||||||
|
dependency: "direct dev"
|
||||||
|
description:
|
||||||
|
name: mockito
|
||||||
|
sha256: "6841eed20a7befac0ce07df8116c8b8233ed1f4486a7647c7fc5a02ae6163917"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "5.4.4"
|
||||||
|
package_config:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: package_config
|
||||||
|
sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.1.0"
|
||||||
path:
|
path:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -188,10 +315,10 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: platform
|
name: platform
|
||||||
sha256: "0a279f0707af40c890e80b1e9df8bb761694c074ba7e1d4ab1bc4b728e200b59"
|
sha256: ae68c7bfcd7383af3629daafb32fb4e8681c7154428da4febcff06200585f102
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.1.3"
|
version: "3.1.2"
|
||||||
plugin_platform_interface:
|
plugin_platform_interface:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -200,6 +327,22 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.7"
|
version: "2.1.7"
|
||||||
|
process:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: process
|
||||||
|
sha256: "53fd8db9cec1d37b0574e12f07520d582019cb6c44abf5479a01505099a34a09"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "4.2.4"
|
||||||
|
pub_semver:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: pub_semver
|
||||||
|
sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.1.4"
|
||||||
shared_preferences:
|
shared_preferences:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
@ -261,6 +404,14 @@ packages:
|
||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.99"
|
version: "0.0.99"
|
||||||
|
source_gen:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: source_gen
|
||||||
|
sha256: "14658ba5f669685cd3d63701d01b31ea748310f7ab854e471962670abcf57832"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.5.0"
|
||||||
source_span:
|
source_span:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -293,6 +444,14 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.2.0"
|
version: "1.2.0"
|
||||||
|
sync_http:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: sync_http
|
||||||
|
sha256: "7f0cd72eca000d2e026bcd6f990b81d0ca06022ef4e32fb257b30d3d1014a961"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.3.1"
|
||||||
term_glyph:
|
term_glyph:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -309,6 +468,14 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.6.1"
|
version: "0.6.1"
|
||||||
|
typed_data:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: typed_data
|
||||||
|
sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.3.2"
|
||||||
url_launcher:
|
url_launcher:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
@ -381,6 +548,22 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.4"
|
version: "2.1.4"
|
||||||
|
vm_service:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: vm_service
|
||||||
|
sha256: c538be99af830f478718b51630ec1b6bee5e74e52c8a802d328d9e71d35d2583
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "11.10.0"
|
||||||
|
watcher:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: watcher
|
||||||
|
sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.1.0"
|
||||||
web:
|
web:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -389,6 +572,14 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.3.0"
|
version: "0.3.0"
|
||||||
|
webdriver:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: webdriver
|
||||||
|
sha256: "3c923e918918feeb90c4c9fdf1fe39220fa4c0e8e2c0fffaded174498ef86c49"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "3.0.2"
|
||||||
win32:
|
win32:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -405,6 +596,14 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.3"
|
version: "1.0.3"
|
||||||
|
yaml:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: yaml
|
||||||
|
sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "3.1.2"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=3.2.0-194.0.dev <4.0.0"
|
dart: ">=3.2.0-194.0.dev <4.0.0"
|
||||||
flutter: ">=3.13.0"
|
flutter: ">=3.13.0"
|
||||||
|
|
|
@ -24,7 +24,9 @@ dependencies:
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
mockito: ^5.4.4
|
||||||
|
integration_test:
|
||||||
|
sdk: flutter
|
||||||
# The "flutter_lints" package below contains a set of recommended lints to
|
# The "flutter_lints" package below contains a set of recommended lints to
|
||||||
# encourage good coding practices. The lint set provided by the package is
|
# encourage good coding practices. The lint set provided by the package is
|
||||||
# activated in the `analysis_options.yaml` file located at the root of your
|
# activated in the `analysis_options.yaml` file located at the root of your
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:moody/views/settings_page/widgets/custom_divider_widget.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
testWidgets('CustomDivider has correct color, thickness, and height', (WidgetTester tester) async {
|
||||||
|
// Build our app and trigger a frame.
|
||||||
|
await tester.pumpWidget(const MaterialApp(
|
||||||
|
home: Scaffold(
|
||||||
|
body: CustomDivider(),
|
||||||
|
),
|
||||||
|
));
|
||||||
|
|
||||||
|
// Find the Divider widget.
|
||||||
|
final dividerFinder = find.byType(Divider);
|
||||||
|
expect(dividerFinder, findsOneWidget);
|
||||||
|
|
||||||
|
// Evaluate the Divider widget to check its properties.
|
||||||
|
final Divider divider = tester.firstWidget(dividerFinder) as Divider;
|
||||||
|
|
||||||
|
// Check for color
|
||||||
|
expect(divider.color, Colors.grey.shade300);
|
||||||
|
|
||||||
|
// Check for thickness
|
||||||
|
expect(divider.thickness, 1);
|
||||||
|
|
||||||
|
// Check for height
|
||||||
|
expect(divider.height, 1);
|
||||||
|
});
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
|
Finder findIconByAsset(String assetName) {
|
||||||
|
return find.byWidgetPredicate(
|
||||||
|
(Widget widget) => widget is IconButton &&
|
||||||
|
widget.icon is Image &&
|
||||||
|
(widget.icon as Image).image is AssetImage &&
|
||||||
|
((widget.icon as Image).image as AssetImage).keyName == 'assets/icons/$assetName',
|
||||||
|
);
|
||||||
|
}
|
|
@ -0,0 +1,88 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:moody/utils/widgets/mood_text_area_widget.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
group('MoodTextAreaWidget Tests', () {
|
||||||
|
testWidgets('displays initial text correctly', (WidgetTester tester) async {
|
||||||
|
const initialText = 'Test Mood';
|
||||||
|
|
||||||
|
await tester.pumpWidget(const MaterialApp(
|
||||||
|
home: Material( // Wrap the MoodTextAreaWidget in a Material widget
|
||||||
|
child: MoodTextAreaWidget(
|
||||||
|
initialText: initialText,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
));
|
||||||
|
|
||||||
|
// Verify the initial text is displayed
|
||||||
|
expect(find.text(initialText), findsOneWidget);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('is disabled', (WidgetTester tester) async {
|
||||||
|
await tester.pumpWidget(const MaterialApp(
|
||||||
|
home: Material( // Wrap the MoodTextAreaWidget in a Material widget
|
||||||
|
child: MoodTextAreaWidget(
|
||||||
|
isDisabled: true,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
));
|
||||||
|
|
||||||
|
final textField = tester.widget<TextField>(find.byType(TextField));
|
||||||
|
expect(textField.enabled, isFalse);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('autofocuses if enabled', (WidgetTester tester) async {
|
||||||
|
await tester.pumpWidget(const MaterialApp(
|
||||||
|
home: Material( // Wrap the MoodTextAreaWidget in a Material widget
|
||||||
|
child: MoodTextAreaWidget(
|
||||||
|
autoFocus: true,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
));
|
||||||
|
|
||||||
|
// Trigger a frame.
|
||||||
|
await tester.pump();
|
||||||
|
|
||||||
|
final TextField textField = tester.widget(find.byType(TextField));
|
||||||
|
final FocusNode focusNode = textField.focusNode!;
|
||||||
|
expect(focusNode.hasFocus, isTrue);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('adds prefix "why? " if hasPrefix is true', (WidgetTester tester) async {
|
||||||
|
const initialText = 'Test Mood';
|
||||||
|
await tester.pumpWidget(const MaterialApp(
|
||||||
|
home: Material( // Wrap the MoodTextAreaWidget in a Material widget
|
||||||
|
child: MoodTextAreaWidget(
|
||||||
|
hasPrefix: true,
|
||||||
|
initialText: initialText,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
));
|
||||||
|
|
||||||
|
// Verify the initial text is displayed with the prefix
|
||||||
|
expect(find.text('why? $initialText'), findsOneWidget);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('maintains prefix "why? " during editing', (WidgetTester tester) async {
|
||||||
|
const initialText = 'Test Mood';
|
||||||
|
final TextEditingController controller = TextEditingController(text: initialText);
|
||||||
|
|
||||||
|
await tester.pumpWidget(MaterialApp(
|
||||||
|
home: Material( // Wrap the MoodTextAreaWidget in a Material widget
|
||||||
|
child: MoodTextAreaWidget(
|
||||||
|
hasPrefix: true,
|
||||||
|
controller: controller,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
));
|
||||||
|
|
||||||
|
// Focus the TextField and enter some text.
|
||||||
|
await tester.enterText(find.byType(TextField), 'New Mood');
|
||||||
|
await tester.pump();
|
||||||
|
|
||||||
|
// Verify the text contains the prefix
|
||||||
|
expect(controller.text, startsWith('warum? '));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
|
@ -1,27 +0,0 @@
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
|
||||||
import 'package:moody/main.dart';
|
|
||||||
import 'package:moody/utils/slide_direction.dart';
|
|
||||||
import 'package:moody/views/settings_page/settings_page.dart';
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
// Test for basic rendering of MyApp
|
|
||||||
testWidgets('MyApp renders correctly', (WidgetTester tester) async {
|
|
||||||
await tester.pumpWidget(const MyApp());
|
|
||||||
expect(find.byType(MaterialApp), findsOneWidget);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Test for route configuration
|
|
||||||
testWidgets('Navigating to /settings shows SettingsPage', (WidgetTester tester) async {
|
|
||||||
await tester.pumpWidget(const MyApp());
|
|
||||||
await tester.tap(find.text('Settings'));
|
|
||||||
await tester.pumpAndSettle();
|
|
||||||
expect(find.byType(SettingsPage), findsOneWidget);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Test for custom logic - determineSlideDirection
|
|
||||||
test('determineSlideDirection returns correct SlideDirection', () {
|
|
||||||
expect(determineSlideDirection('/', '/settings'), equals(SlideDirection.left));
|
|
||||||
// Add more test cases for different route combinations
|
|
||||||
});
|
|
||||||
}
|
|
|
@ -0,0 +1,206 @@
|
||||||
|
import 'dart:ui';
|
||||||
|
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:mockito/mockito.dart';
|
||||||
|
import 'package:moody/utils/definitions/color_pair.dart';
|
||||||
|
import 'package:moody/utils/logic/preferences_service.dart';
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
|
class MockSharedPreferences extends Mock implements SharedPreferences {}
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
group('PreferencesService Tests', () {
|
||||||
|
MockSharedPreferences mockPrefs;
|
||||||
|
PreferencesService service = PreferencesService();
|
||||||
|
|
||||||
|
setUp(() {
|
||||||
|
mockPrefs = MockSharedPreferences();
|
||||||
|
SharedPreferences.setMockInitialValues({}); // Set initial values for mocks
|
||||||
|
});
|
||||||
|
|
||||||
|
test('saveColorPair and loadColorPair should work correctly', () async {
|
||||||
|
var testColorPair = ColorPair(name: "test", textColor: Color(0xff123456), backgroundColor: Color(0xff654321));
|
||||||
|
|
||||||
|
// Save color pair
|
||||||
|
await service.saveColorPair(testColorPair);
|
||||||
|
|
||||||
|
// Load color pair
|
||||||
|
var loadedColorPair = await service.loadColorPair();
|
||||||
|
|
||||||
|
// Compare values
|
||||||
|
expect(loadedColorPair.textColor.value, equals(testColorPair.textColor.value));
|
||||||
|
expect(loadedColorPair.backgroundColor.value, equals(testColorPair.backgroundColor.value));
|
||||||
|
});
|
||||||
|
|
||||||
|
test('loadColorPair should return default value if none set', () async {
|
||||||
|
// Load color pair without setting any value
|
||||||
|
var defaultColorPair = await service.loadColorPair();
|
||||||
|
|
||||||
|
// Verify default values
|
||||||
|
expect(defaultColorPair, equals(colorPairs[0]));
|
||||||
|
});
|
||||||
|
// Test for setting and checking PIN
|
||||||
|
test('setPin and checkPin should work correctly', () async {
|
||||||
|
const int testPin = 1234;
|
||||||
|
|
||||||
|
// Set PIN
|
||||||
|
await service.setPin(testPin);
|
||||||
|
|
||||||
|
// Check PIN
|
||||||
|
bool isCorrectPin = await service.checkPin(testPin);
|
||||||
|
expect(isCorrectPin, isTrue);
|
||||||
|
|
||||||
|
// Check with incorrect PIN
|
||||||
|
isCorrectPin = await service.checkPin(9999);
|
||||||
|
expect(isCorrectPin, isFalse);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('enablePin should enable PIN if it\'s already set', () async {
|
||||||
|
// Set PIN
|
||||||
|
const int testPin = 1234;
|
||||||
|
await service.setPin(testPin);
|
||||||
|
|
||||||
|
// Attempt to enable PIN
|
||||||
|
await service.enablePin();
|
||||||
|
var isPinEnabled = await service.isPinEnabled();
|
||||||
|
expect(isPinEnabled, isTrue);
|
||||||
|
|
||||||
|
// Disable PIN again
|
||||||
|
await service.disablePin();
|
||||||
|
isPinEnabled = await service.isPinEnabled();
|
||||||
|
expect(isPinEnabled, isFalse);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Test for enabling PIN only if it's set
|
||||||
|
test('enablePin should only enable if a PIN is set', () async {
|
||||||
|
// Assuming no PIN is set initially
|
||||||
|
await service.disablePin();
|
||||||
|
|
||||||
|
// Attempt to enable PIN without setting it
|
||||||
|
await service.enablePin();
|
||||||
|
var isPinEnabled = await service.isPinEnabled();
|
||||||
|
expect(isPinEnabled, isFalse);
|
||||||
|
|
||||||
|
// Set PIN and then enable it
|
||||||
|
const int testPin = 1234;
|
||||||
|
await service.setPin(testPin);
|
||||||
|
await service.enablePin();
|
||||||
|
isPinEnabled = await service.isPinEnabled();
|
||||||
|
expect(isPinEnabled, isTrue);
|
||||||
|
|
||||||
|
// Disable PIN again
|
||||||
|
await service.disablePin();
|
||||||
|
isPinEnabled = await service.isPinEnabled();
|
||||||
|
expect(isPinEnabled, isFalse);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Test for isPinEnabled
|
||||||
|
test('isPinEnabled should return correct status', () async {
|
||||||
|
// Assuming PIN is not set
|
||||||
|
bool isPinEnabled = await service.isPinEnabled();
|
||||||
|
expect(isPinEnabled, isFalse);
|
||||||
|
|
||||||
|
// After setting and enabling PIN
|
||||||
|
await service.setPin(1234);
|
||||||
|
await service.enablePin();
|
||||||
|
isPinEnabled = await service.isPinEnabled();
|
||||||
|
expect(isPinEnabled, isTrue);
|
||||||
|
});
|
||||||
|
// Test for calculateStreak
|
||||||
|
test('calculateStreak should return the correct streak count', () async {
|
||||||
|
// Scenario 1: Consecutive diary entries
|
||||||
|
await service.saveDiaryEntry(DiaryEntry(date: DateTime.now(), percentValue: 80, texts: ["Entry 1"]));
|
||||||
|
await service.saveDiaryEntry(DiaryEntry(date: DateTime.now().subtract(const Duration(days: 1)), percentValue: 90, texts: ["Entry 2"]));
|
||||||
|
await service.saveDiaryEntry(DiaryEntry(date: DateTime.now().subtract(const Duration(days: 2)), percentValue: 95, texts: ["Entry 3"]));
|
||||||
|
|
||||||
|
var streakCount = await service.calculateStreak();
|
||||||
|
expect(streakCount, equals(3));
|
||||||
|
|
||||||
|
// Scenario 2: Missing entries in between
|
||||||
|
await service.saveDiaryEntry(DiaryEntry(date: DateTime.now().subtract(const Duration(days: 2)), percentValue: 95, texts: ["Entry 2"]));
|
||||||
|
|
||||||
|
streakCount = await service.calculateStreak();
|
||||||
|
expect(streakCount, equals(3)); // Streak is broken due to missing entries
|
||||||
|
|
||||||
|
// Scenario 3: No diary entries
|
||||||
|
// No need to add entries here
|
||||||
|
|
||||||
|
streakCount = await service.calculateStreak();
|
||||||
|
expect(streakCount, equals(3)); // No entries, streak is 0
|
||||||
|
});
|
||||||
|
service = PreferencesService();
|
||||||
|
// Test for getDiaryEntryByCurrentDate
|
||||||
|
test('getDiaryEntryByCurrentDate should return the correct entry for the current date', () async {
|
||||||
|
final currentDate = DateTime.now();
|
||||||
|
final formattedDate = DateTime(currentDate.year, currentDate.month, currentDate.day);
|
||||||
|
final DiaryEntry testEntry = DiaryEntry(
|
||||||
|
date: formattedDate,
|
||||||
|
percentValue: 80,
|
||||||
|
texts: ["Entry for Today"],
|
||||||
|
);
|
||||||
|
|
||||||
|
// Save a test entry for the current date
|
||||||
|
await service.saveDiaryEntry(testEntry);
|
||||||
|
|
||||||
|
final DiaryEntry? retrievedEntry = await service.getDiaryEntryByCurrentDate();
|
||||||
|
expect(retrievedEntry?.texts.join(" "), equals((testEntry?.texts.join(" "))));
|
||||||
|
expect(retrievedEntry?.date, equals(formattedDate));
|
||||||
|
expect(retrievedEntry?.percentValue, testEntry.percentValue);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Test for getDiaryEntryByDate
|
||||||
|
test('getDiaryEntryByCurrentDate should return the correct entry for the current date', () async {
|
||||||
|
final currentDate = DateTime.now();
|
||||||
|
final formattedDate = DateTime(currentDate.year, currentDate.month, currentDate.day);
|
||||||
|
final DiaryEntry testEntry = DiaryEntry(
|
||||||
|
date: formattedDate,
|
||||||
|
percentValue: 80,
|
||||||
|
texts: ["Entry for Today"],
|
||||||
|
);
|
||||||
|
|
||||||
|
// Save a test entry for the current date
|
||||||
|
await service.saveDiaryEntry(testEntry);
|
||||||
|
|
||||||
|
final DiaryEntry? retrievedEntry = await service.getDiaryEntryByCurrentDate();
|
||||||
|
expect(retrievedEntry?.texts.join(" "), equals((testEntry?.texts.join(" "))));
|
||||||
|
expect(retrievedEntry?.date, equals(formattedDate));
|
||||||
|
expect(retrievedEntry?.percentValue, testEntry.percentValue);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('saveDiaryEntry and loadDiaryEntries should work correctly', () async {
|
||||||
|
final List<DiaryEntry> testEntries = [
|
||||||
|
DiaryEntry(
|
||||||
|
date: DateTime(2024, 1, 10), // Updated date format
|
||||||
|
percentValue: 70,
|
||||||
|
texts: ["Entry 1"],
|
||||||
|
),
|
||||||
|
DiaryEntry(
|
||||||
|
date: DateTime(2024, 1, 11), // Updated date format
|
||||||
|
percentValue: 80,
|
||||||
|
texts: ["Entry 2"],
|
||||||
|
),
|
||||||
|
DiaryEntry(
|
||||||
|
date: DateTime(2024, 1, 12), // Updated date format
|
||||||
|
percentValue: 90,
|
||||||
|
texts: ["Entry 3"],
|
||||||
|
),
|
||||||
|
];
|
||||||
|
|
||||||
|
// Save test entries
|
||||||
|
for (final entry in testEntries) {
|
||||||
|
await service.saveDiaryEntry(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load saved entries
|
||||||
|
final List<DiaryEntry> loadedEntries = await service.loadDiaryEntries();
|
||||||
|
|
||||||
|
// Compare loaded entries with test entries
|
||||||
|
expect(loadedEntries.length, equals(testEntries.length));
|
||||||
|
for (int i = 0; i < loadedEntries.length; i++) {
|
||||||
|
expect(loadedEntries[i].date, equals(testEntries[i].date));
|
||||||
|
expect(loadedEntries[i].percentValue, equals(testEntries[i].percentValue));
|
||||||
|
expect(loadedEntries[i].texts, equals(testEntries[i].texts));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
|
@ -0,0 +1,57 @@
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:moody/utils/logic/question_generator.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
group('QuestionGenerator Tests', () {
|
||||||
|
test('getQuestionByDate should return a valid question', () {
|
||||||
|
final QuestionGenerator generator = QuestionGenerator();
|
||||||
|
|
||||||
|
// Test with specific dates
|
||||||
|
final DateTime date1 = DateTime(2024, 1, 10); // Replace with your desired date
|
||||||
|
final DateTime date2 = DateTime(2024, 1, 11); // Replace with another date
|
||||||
|
final DateTime date3 = DateTime(2024, 1, 12); // Replace with yet another date
|
||||||
|
|
||||||
|
final String question1 = generator.getQuestionByDate(date1);
|
||||||
|
final String question2 = generator.getQuestionByDate(date2);
|
||||||
|
final String question3 = generator.getQuestionByDate(date3);
|
||||||
|
|
||||||
|
// Assert that the generated questions are not null
|
||||||
|
expect(question1, isNotNull);
|
||||||
|
expect(question2, isNotNull);
|
||||||
|
expect(question3, isNotNull);
|
||||||
|
|
||||||
|
// Add more test cases...
|
||||||
|
});
|
||||||
|
|
||||||
|
test('getQuestionByDate should return different questions for different dates', () {
|
||||||
|
final QuestionGenerator generator = QuestionGenerator();
|
||||||
|
|
||||||
|
// Test with specific dates
|
||||||
|
final DateTime date1 = DateTime(2024, 1, 10); // Replace with your desired date
|
||||||
|
final DateTime date2 = DateTime(2024, 1, 11); // Replace with another date
|
||||||
|
final DateTime date3 = DateTime(2024, 1, 12); // Replace with yet another date
|
||||||
|
|
||||||
|
final String question1 = generator.getQuestionByDate(date1);
|
||||||
|
final String question2 = generator.getQuestionByDate(date2);
|
||||||
|
final String question3 = generator.getQuestionByDate(date3);
|
||||||
|
|
||||||
|
// Assert that the generated questions for different dates are not the same
|
||||||
|
expect(question1, equals(question2));
|
||||||
|
expect(question2, equals(question3));
|
||||||
|
expect(question3, equals(question1));
|
||||||
|
});
|
||||||
|
|
||||||
|
test('getQuestionByDate should return the same question for the same date', () {
|
||||||
|
final QuestionGenerator generator = QuestionGenerator();
|
||||||
|
|
||||||
|
// Test with the same date
|
||||||
|
final DateTime date = DateTime(2024, 1, 10); // Replace with your desired date
|
||||||
|
|
||||||
|
final String question1 = generator.getQuestionByDate(date);
|
||||||
|
final String question2 = generator.getQuestionByDate(date);
|
||||||
|
|
||||||
|
// Assert that the generated questions for the same date are the same
|
||||||
|
expect(question1, equals(question2));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
|
@ -0,0 +1,69 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:moody/utils/widgets/question_slider_widget.dart';
|
||||||
|
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
testWidgets('QuestionSliderWidget displays the initial value', (WidgetTester tester) async {
|
||||||
|
const testKey = Key('slider');
|
||||||
|
final DateTime date = DateTime.now();
|
||||||
|
const String questionText = "How are you feeling today?";
|
||||||
|
const double initialSliderValue = 50.0;
|
||||||
|
const bool isSliderEnabled = true;
|
||||||
|
const Color sliderColor = Colors.blue;
|
||||||
|
|
||||||
|
await tester.pumpWidget(MaterialApp(
|
||||||
|
home: Scaffold(
|
||||||
|
body: QuestionSliderWidget(
|
||||||
|
key: testKey,
|
||||||
|
date: date,
|
||||||
|
questionText: questionText,
|
||||||
|
initialSliderValue: initialSliderValue,
|
||||||
|
isSliderEnabled: isSliderEnabled,
|
||||||
|
onSliderChanged: (SliderChangeData data) {},
|
||||||
|
onSliderPositionChanged: (double position) {},
|
||||||
|
sliderColor: sliderColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
));
|
||||||
|
|
||||||
|
// Verify that the initial slider value is set.
|
||||||
|
final Slider sliderWidget = tester.firstWidget(find.byType(Slider));
|
||||||
|
expect(sliderWidget.value, initialSliderValue);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('QuestionSliderWidget updates value on slide', (WidgetTester tester) async {
|
||||||
|
const testKey = Key('slider');
|
||||||
|
final DateTime date = DateTime.now();
|
||||||
|
const String questionText = "How are you feeling today?";
|
||||||
|
const double initialSliderValue = 50.0;
|
||||||
|
bool sliderMoved = false;
|
||||||
|
const Color sliderColor = Colors.blue;
|
||||||
|
|
||||||
|
await tester.pumpWidget(MaterialApp(
|
||||||
|
home: Scaffold(
|
||||||
|
body: QuestionSliderWidget(
|
||||||
|
key: testKey,
|
||||||
|
date: date,
|
||||||
|
questionText: questionText,
|
||||||
|
initialSliderValue: initialSliderValue,
|
||||||
|
isSliderEnabled: true,
|
||||||
|
onSliderChanged: (SliderChangeData data) {
|
||||||
|
sliderMoved = true;
|
||||||
|
},
|
||||||
|
onSliderPositionChanged: (double position) {},
|
||||||
|
sliderColor: sliderColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
));
|
||||||
|
|
||||||
|
// Move the slider.
|
||||||
|
await tester.drag(find.byType(Slider), const Offset(100, 0));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
|
// Verify that the slider moved callback was triggered.
|
||||||
|
expect(sliderMoved, true);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:moody/views/settings_page/widgets/set_pin_popup_widget.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
testWidgets('SetPinPopup displays number pad and updates PIN', (WidgetTester tester) async {
|
||||||
|
// Create the widget by telling the tester to build it
|
||||||
|
await tester.pumpWidget(const MaterialApp(home: SetPinPopup()));
|
||||||
|
|
||||||
|
// Verify that the number pad is displayed
|
||||||
|
for (var i = 0; i <= 9; i++) {
|
||||||
|
expect(find.text('$i'), findsOneWidget);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tap on the number buttons and check if the PIN is updated
|
||||||
|
for (var i = 1; i <= 4; i++) {
|
||||||
|
await tester.tap(find.text('$i'));
|
||||||
|
await tester.pump();
|
||||||
|
}
|
||||||
|
|
||||||
|
// After entering 4 digits, check if the state changes to confirm PIN
|
||||||
|
expect(find.text('Repeat PIN'), findsOneWidget);
|
||||||
|
|
||||||
|
// Enter the confirmation PIN
|
||||||
|
for (var i = 1; i <= 4; i++) {
|
||||||
|
await tester.tap(find.text('$i'));
|
||||||
|
await tester.pump();
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,61 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:moody/views/settings_page/widgets/settings_selection_widget.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
group('SettingsSection Tests', () {
|
||||||
|
testWidgets('displays title and items', (WidgetTester tester) async {
|
||||||
|
final items = [
|
||||||
|
SettingsItem(title: 'Item 1', detail: 'Detail 1'),
|
||||||
|
SettingsItem(title: 'Item 2', detail: 'Detail 2', trailingText: 'More', url: 'https://example.com'),
|
||||||
|
];
|
||||||
|
|
||||||
|
await tester.pumpWidget(MaterialApp(
|
||||||
|
home: Scaffold(
|
||||||
|
body: SettingsSection(title: 'Settings', items: items),
|
||||||
|
),
|
||||||
|
));
|
||||||
|
|
||||||
|
expect(find.text('Settings'), findsOneWidget);
|
||||||
|
|
||||||
|
await tester.tap(find.text('Item 1'));
|
||||||
|
await tester.pumpAndSettle(); // Wait for the ExpansionTile to expand
|
||||||
|
|
||||||
|
expect(find.text('Detail 1'), findsOneWidget);
|
||||||
|
|
||||||
|
// Test for the second item
|
||||||
|
await tester.tap(find.text('Item 2'));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
|
expect(find.text('Detail 2'), findsOneWidget);
|
||||||
|
expect(find.text('More'), findsOneWidget);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('taps on items work', (WidgetTester tester) async {
|
||||||
|
bool itemTapped = false;
|
||||||
|
|
||||||
|
final items = [
|
||||||
|
SettingsItem(title: 'Tap Item', detail: 'Tap Detail', onTap: () {
|
||||||
|
itemTapped = true;
|
||||||
|
}),
|
||||||
|
];
|
||||||
|
|
||||||
|
await tester.pumpWidget(MaterialApp(
|
||||||
|
home: Scaffold(
|
||||||
|
body: SettingsSection(title: 'Settings', items: items),
|
||||||
|
),
|
||||||
|
));
|
||||||
|
|
||||||
|
// Expand the ExpansionTile to reveal the ListTile
|
||||||
|
await tester.tap(find.text('Tap Item'));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
|
// Tap the specific ListTile
|
||||||
|
await tester.tap(find.text('Tap Detail'));
|
||||||
|
await tester.pump();
|
||||||
|
|
||||||
|
expect(itemTapped, isTrue);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
|
@ -0,0 +1,70 @@
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:moody/views/settings_page/widgets/text_switch_container_widget.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
group('TextSwitchContainer Tests', () {
|
||||||
|
testWidgets('displays left and right text correctly', (WidgetTester tester) async {
|
||||||
|
await tester.pumpWidget(MaterialApp(
|
||||||
|
home: Scaffold(
|
||||||
|
body: TextSwitchContainer(
|
||||||
|
leftText: 'Left Text',
|
||||||
|
rightText: 'Right Text',
|
||||||
|
onTap: () {},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
));
|
||||||
|
|
||||||
|
expect(find.text('Left Text'), findsOneWidget);
|
||||||
|
expect(find.text('Right Text'), findsOneWidget);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('switch toggles correctly', (WidgetTester tester) async {
|
||||||
|
bool switchToggled = false;
|
||||||
|
await tester.pumpWidget(MaterialApp(
|
||||||
|
home: Scaffold(
|
||||||
|
body: TextSwitchContainer(
|
||||||
|
leftText: 'Left Text',
|
||||||
|
hasSwitch: true,
|
||||||
|
switchDefaultValue: false,
|
||||||
|
onTap: () {},
|
||||||
|
onSwitchToggle: (value) {
|
||||||
|
switchToggled = value;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
));
|
||||||
|
|
||||||
|
expect(find.byType(CupertinoSwitch), findsOneWidget);
|
||||||
|
await tester.tap(find.byType(CupertinoSwitch));
|
||||||
|
await tester.pump();
|
||||||
|
|
||||||
|
expect(switchToggled, isTrue);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('tap callback is executed', (WidgetTester tester) async {
|
||||||
|
bool tapCallbackExecuted = false;
|
||||||
|
|
||||||
|
await tester.pumpWidget(MaterialApp(
|
||||||
|
home: Scaffold(
|
||||||
|
body: SizedBox(
|
||||||
|
width: 300,
|
||||||
|
height: 50, // Provide adequate size
|
||||||
|
child: TextSwitchContainer(
|
||||||
|
leftText: 'Left Text',
|
||||||
|
onTap: () {
|
||||||
|
tapCallbackExecuted = true;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
));
|
||||||
|
|
||||||
|
await tester.tap(find.text('Left Text'));
|
||||||
|
await tester.pump();
|
||||||
|
|
||||||
|
expect(tapCallbackExecuted, isTrue);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:integration_test/integration_test.dart';
|
||||||
|
import 'package:moody/main.dart' as app;
|
||||||
|
import 'icon_finder.dart';
|
||||||
|
import 'package:moody/views/statistic/widget/calendar_widget.dart';
|
||||||
|
import 'package:moody/views/statistic/widget/streak_widget.dart';
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
SharedPreferences.setMockInitialValues({});
|
||||||
|
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
||||||
|
|
||||||
|
testWidgets('StatisticPage UI Test', (WidgetTester tester) async {
|
||||||
|
app.main();
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
|
await tester.tap(find.text('skip'));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
// Navigate to the StatisticPage if it's not the initial page
|
||||||
|
await tester.tap(findIconByAsset('icon-analyze.png'));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
|
// Check for a CircularProgressIndicator while data is loading
|
||||||
|
expect(find.byType(StreakWidget), findsWidgets);
|
||||||
|
|
||||||
|
// Wait for FutureBuilder to complete and StreakWidget to be displayed
|
||||||
|
await tester.pumpAndSettle(const Duration(seconds: 2));
|
||||||
|
expect(find.byType(StreakWidget), findsOneWidget);
|
||||||
|
|
||||||
|
// Check for the presence of CalendarWidget
|
||||||
|
expect(find.byType(CalendarWidget), findsWidgets);
|
||||||
|
|
||||||
|
// Verify the text "browse your memories!" is present
|
||||||
|
expect(find.text("browse your memories!"), findsOneWidget);
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
|
@ -0,0 +1,70 @@
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:integration_test/integration_test.dart';
|
||||||
|
import 'package:moody/main.dart' as app;
|
||||||
|
import 'icon_finder.dart';
|
||||||
|
import 'package:moody/utils/widgets/question_slider_widget.dart'; // Replace with the actual import of your app
|
||||||
|
import 'package:moody/utils/widgets/why_widget.dart';
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
|
// Testet "First Page" gleich mit
|
||||||
|
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
SharedPreferences.setMockInitialValues({});
|
||||||
|
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
||||||
|
// testWidgets('HomePage - Find "+ Edit" and "- Save" Texts', (WidgetTester tester) async {
|
||||||
|
testWidgets('HomePage UI Test', (WidgetTester tester) async {
|
||||||
|
app.main();
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
|
await tester.tap(find.text('skip'));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
// Navigate to the HomePage if it's not the initial page
|
||||||
|
await tester.tap(findIconByAsset('icon-logo.png'));// should be irrelevant because he *should* automatically be there but we are superstitius so I'm leaving this
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
|
// Check for the presence of QuestionSliderWidget
|
||||||
|
expect(find.byType(QuestionSliderWidget), findsOneWidget);
|
||||||
|
|
||||||
|
// Test the slider movement
|
||||||
|
final Finder sliderFinder = find.byType(Slider);
|
||||||
|
await tester.drag(sliderFinder, const Offset(50, 0)); // Adjust the Offset as necessary
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
|
await tester.tap(find.text("save."));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
|
await tester.tap(find.text('warum?'));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
|
await tester.tap(find.text('Save'));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
|
//debugDumpApp();
|
||||||
|
await tester.tap(find.text("+ Edit"));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
// Check if the text area is editable and perform text entry if it is
|
||||||
|
final Finder ancestor = find.byType(WhyWidget);
|
||||||
|
final Finder descendant = find.descendant(
|
||||||
|
of: ancestor,
|
||||||
|
matching: find.byType(TextField)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (tester.any(descendant)) {
|
||||||
|
await tester.enterText(descendant, 'Sample diary entry');
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the save/edit button functionality
|
||||||
|
|
||||||
|
|
||||||
|
await tester.tap(find.text('- Save'));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
|
// Verify the updated text
|
||||||
|
expect(find.text('Sample diary entry'), findsOneWidget);
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:integration_test/integration_test.dart';
|
||||||
|
import 'package:moody/main.dart' as app;
|
||||||
|
import 'icon_finder.dart';
|
||||||
|
import 'package:moody/views/settings_page/widgets/set_pin_popup_widget.dart';
|
||||||
|
import 'package:moody/views/settings_page/widgets/text_switch_container_widget.dart';
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
SharedPreferences.setMockInitialValues({});
|
||||||
|
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
||||||
|
|
||||||
|
testWidgets('SettingsPage UI Test', (WidgetTester tester) async {
|
||||||
|
app.main();
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
|
await tester.tap(find.text('skip'));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
|
// Navigate to the SettingsPage if it's not the initial page
|
||||||
|
await tester.tap(findIconByAsset('icon-settings.png'));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
|
|
||||||
|
// Verify that certain widgets are present
|
||||||
|
expect(find.text('settings'), findsOneWidget);
|
||||||
|
expect(find.text('change color'), findsOneWidget);
|
||||||
|
expect(find.text('pin'), findsOneWidget);
|
||||||
|
|
||||||
|
// Test tapping on a switch
|
||||||
|
final Finder pinSwitch = find.byType(TextSwitchContainer).first;
|
||||||
|
await tester.tap(pinSwitch);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
|
|
||||||
|
// Test navigation to another page
|
||||||
|
await tester.tap(find.text('about us'));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
// Verify navigation occurred if there's a distinct widget on the navigated page
|
||||||
|
|
||||||
|
// Test showing the Set PIN Popup
|
||||||
|
await tester.tap(find.text('pin'));
|
||||||
|
await tester.pump(); // Might need to adjust depending on the implementation
|
||||||
|
expect(find.byType(SetPinPopup), findsOneWidget);
|
||||||
|
});
|
||||||
|
}
|
|
@ -0,0 +1,83 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:moody/utils/widgets/why_widget.dart';
|
||||||
|
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
testWidgets('WhyWidget adds "warum? " when typing', (WidgetTester tester) async {
|
||||||
|
TextEditingController controller = TextEditingController();
|
||||||
|
|
||||||
|
// Build our app and trigger a frame.
|
||||||
|
await tester.pumpWidget(MaterialApp(
|
||||||
|
home: Scaffold(
|
||||||
|
body: WhyWidget(
|
||||||
|
controller: controller,
|
||||||
|
prependWhy: true,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
));
|
||||||
|
|
||||||
|
// Tap the TextField to focus it.
|
||||||
|
await tester.tap(find.byType(TextField));
|
||||||
|
await tester.pump();
|
||||||
|
|
||||||
|
// Enter text and check if "warum? " is prepended.
|
||||||
|
await tester.enterText(find.byType(TextField), 'test');
|
||||||
|
await tester.pump();
|
||||||
|
|
||||||
|
// Verify that "warum? " is prepended to the entered text.
|
||||||
|
expect(controller.text, 'warum? test');
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('WhyWidget does not add "warum? " when prependWhy is false', (WidgetTester tester) async {
|
||||||
|
TextEditingController controller = TextEditingController();
|
||||||
|
|
||||||
|
// Build our app and trigger a frame.
|
||||||
|
await tester.pumpWidget(MaterialApp(
|
||||||
|
home: Scaffold(
|
||||||
|
body: WhyWidget(
|
||||||
|
controller: controller,
|
||||||
|
prependWhy: false,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
));
|
||||||
|
|
||||||
|
// Tap the TextField to focus it.
|
||||||
|
await tester.tap(find.byType(TextField));
|
||||||
|
await tester.pump();
|
||||||
|
|
||||||
|
// Enter text and check if "warum? " is not prepended.
|
||||||
|
await tester.enterText(find.byType(TextField), 'test');
|
||||||
|
await tester.pump();
|
||||||
|
|
||||||
|
// Verify that "warum? " is not prepended to the entered text.
|
||||||
|
expect(controller.text, 'test');
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('WhyWidget hides cursor when focus is lost', (WidgetTester tester) async {
|
||||||
|
TextEditingController controller = TextEditingController();
|
||||||
|
|
||||||
|
// Build our app and trigger a frame.
|
||||||
|
await tester.pumpWidget(MaterialApp(
|
||||||
|
home: Scaffold(
|
||||||
|
body: WhyWidget(
|
||||||
|
controller: controller,
|
||||||
|
prependWhy: true,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
));
|
||||||
|
|
||||||
|
// Tap the TextField to focus it.
|
||||||
|
await tester.tap(find.byType(TextField));
|
||||||
|
await tester.pump();
|
||||||
|
|
||||||
|
// Emulate text field losing focus.
|
||||||
|
FocusScope.of(tester.element(find.byType(TextField))).unfocus();
|
||||||
|
await tester.pump();
|
||||||
|
|
||||||
|
// Verify that the cursor is hidden.
|
||||||
|
expect(controller.text.contains('|'), false);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -1,30 +0,0 @@
|
||||||
// This is a basic Flutter widget test.
|
|
||||||
//
|
|
||||||
// To perform an interaction with a widget in your test, use the WidgetTester
|
|
||||||
// utility in the flutter_test package. For example, you can send tap and scroll
|
|
||||||
// gestures. You can also use WidgetTester to find child widgets in the widget
|
|
||||||
// tree, read text, and verify that the values of widget properties are correct.
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
|
||||||
|
|
||||||
import 'package:moody/main.dart';
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
|
|
||||||
// Build our app and trigger a frame.
|
|
||||||
await tester.pumpWidget(const MyApp());
|
|
||||||
|
|
||||||
// Verify that our counter starts at 0.
|
|
||||||
expect(find.text('0'), findsOneWidget);
|
|
||||||
expect(find.text('1'), findsNothing);
|
|
||||||
|
|
||||||
// Tap the '+' icon and trigger a frame.
|
|
||||||
await tester.tap(find.byIcon(Icons.add));
|
|
||||||
await tester.pump();
|
|
||||||
|
|
||||||
// Verify that our counter has incremented.
|
|
||||||
expect(find.text('0'), findsNothing);
|
|
||||||
expect(find.text('1'), findsOneWidget);
|
|
||||||
});
|
|
||||||
}
|
|
Loading…
Reference in New Issue