From 4ee8a6b78c5fda8e221cf819706883ce26d41467 Mon Sep 17 00:00:00 2001 From: Ammel <77129284+Ammelll@users.noreply.github.com> Date: Tue, 12 Mar 2024 19:27:10 -0700 Subject: [PATCH 1/5] naming convention changes --- lib/pages/project/project_page.dart | 25 ++++++++++++++++++----- test/pages/project/project_page_test.dart | 8 ++++---- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/lib/pages/project/project_page.dart b/lib/pages/project/project_page.dart index 14705406f..3228f0ecf 100644 --- a/lib/pages/project/project_page.dart +++ b/lib/pages/project/project_page.dart @@ -889,9 +889,17 @@ class _ProjectPageState extends State { for (PathPlannerPath path in _paths) { pathNames.add(path.name); } - String pathName = 'Copy of ${_paths[i].name}'; + String pathName = _paths[i].name; + RegExp exp = RegExp(r'\(\d+\)'); + String source = pathName.substring(pathName.length-3); while (pathNames.contains(pathName)) { - pathName = 'Copy of $pathName'; + if(exp.hasMatch(source)){ + RegExpMatch? match = exp.firstMatch(source); + int index = int.parse(match![0]!.substring(1,2))+1; + pathName = '${pathName.substring(0,pathName.length-3)}($index)'; + } else{ + pathName = '$pathName (1)'; + } } setState(() { @@ -1468,11 +1476,18 @@ class _ProjectPageState extends State { for (PathPlannerAuto auto in _autos) { autoNames.add(auto.name); } - String autoName = 'Copy of ${_autos[i].name}'; + String autoName = _autos[i].name; + RegExp exp = RegExp(r'\(\d+\)'); + String source = autoName.substring(autoName.length-3); while (autoNames.contains(autoName)) { - autoName = 'Copy of $autoName'; + if(exp.hasMatch(source)){ + RegExpMatch? match = exp.firstMatch(source); + int index = int.parse(match![0]!.substring(1,2))+1; + autoName = '${autoName.substring(0,autoName.length-3)}($index)'; + } else{ + autoName = '$autoName (1)'; + } } - setState(() { _autos.add(_autos[i].duplicate(autoName)); _sortAutos(_autoSortValue); diff --git a/test/pages/project/project_page_test.dart b/test/pages/project/project_page_test.dart index 5afddc54b..041035e00 100644 --- a/test/pages/project/project_page_test.dart +++ b/test/pages/project/project_page_test.dart @@ -372,7 +372,7 @@ void main() { await widgetTester.tap(find.text('Duplicate')); await widgetTester.pumpAndSettle(); - expect(find.widgetWithText(ProjectItemCard, 'Copy of Example Path'), + expect(find.widgetWithText(ProjectItemCard, 'Example Path (1)'), findsOneWidget); await widgetTester.tap(menuButton); @@ -381,7 +381,7 @@ void main() { await widgetTester.tap(find.text('Duplicate')); await widgetTester.pumpAndSettle(); - expect(find.widgetWithText(ProjectItemCard, 'Copy of Copy of Example Path'), + expect(find.widgetWithText(ProjectItemCard, 'Example Path (2)'), findsOneWidget); }); @@ -436,7 +436,7 @@ void main() { await widgetTester.pumpAndSettle(); expect( - find.widgetWithText(ProjectItemCard, 'Copy of auto1'), findsOneWidget); + find.widgetWithText(ProjectItemCard, 'auto1 (1)'), findsOneWidget); await widgetTester.tap(menuButton); await widgetTester.pumpAndSettle(); @@ -444,7 +444,7 @@ void main() { await widgetTester.tap(find.text('Duplicate')); await widgetTester.pumpAndSettle(); - expect(find.widgetWithText(ProjectItemCard, 'Copy of Copy of auto1'), + expect(find.widgetWithText(ProjectItemCard, 'auto1 (2)'), findsOneWidget); }); From 962e7a3b9c526c44f79207320c895ad8400b13bf Mon Sep 17 00:00:00 2001 From: Ammel <77129284+Ammelll@users.noreply.github.com> Date: Wed, 27 Nov 2024 17:22:28 -0800 Subject: [PATCH 2/5] Formatted changes --- lib/pages/project/project_page.dart | 24 +++++++++++------------ test/pages/project/project_page_test.dart | 6 ++---- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/lib/pages/project/project_page.dart b/lib/pages/project/project_page.dart index c5598da6b..646b42ee8 100644 --- a/lib/pages/project/project_page.dart +++ b/lib/pages/project/project_page.dart @@ -917,14 +917,14 @@ class _ProjectPageState extends State { } String pathName = _paths[i].name; RegExp exp = RegExp(r'\(\d+\)'); - String source = pathName.substring(pathName.length-3); + String source = pathName.substring(pathName.length - 3); while (pathNames.contains(pathName)) { - if(exp.hasMatch(source)){ + if (exp.hasMatch(source)) { RegExpMatch? match = exp.firstMatch(source); - int index = int.parse(match![0]!.substring(1,2))+1; - pathName = '${pathName.substring(0,pathName.length-3)}($index)'; - } else{ - pathName = '$pathName (1)'; + int index = int.parse(match![0]!.substring(1, 2)) + 1; + pathName = '${pathName.substring(0, pathName.length - 3)}($index)'; + } else { + pathName = '$pathName (1)'; } } @@ -1525,14 +1525,14 @@ class _ProjectPageState extends State { } String autoName = _autos[i].name; RegExp exp = RegExp(r'\(\d+\)'); - String source = autoName.substring(autoName.length-3); + String source = autoName.substring(autoName.length - 3); while (autoNames.contains(autoName)) { - if(exp.hasMatch(source)){ + if (exp.hasMatch(source)) { RegExpMatch? match = exp.firstMatch(source); - int index = int.parse(match![0]!.substring(1,2))+1; - autoName = '${autoName.substring(0,autoName.length-3)}($index)'; - } else{ - autoName = '$autoName (1)'; + int index = int.parse(match![0]!.substring(1, 2)) + 1; + autoName = '${autoName.substring(0, autoName.length - 3)}($index)'; + } else { + autoName = '$autoName (1)'; } } setState(() { diff --git a/test/pages/project/project_page_test.dart b/test/pages/project/project_page_test.dart index 6280bcaf8..04954b374 100644 --- a/test/pages/project/project_page_test.dart +++ b/test/pages/project/project_page_test.dart @@ -435,8 +435,7 @@ void main() { await widgetTester.tap(find.text('Duplicate')); await widgetTester.pumpAndSettle(); - expect( - find.widgetWithText(ProjectItemCard, 'auto1 (1)'), findsOneWidget); + expect(find.widgetWithText(ProjectItemCard, 'auto1 (1)'), findsOneWidget); await widgetTester.tap(menuButton); await widgetTester.pumpAndSettle(); @@ -444,8 +443,7 @@ void main() { await widgetTester.tap(find.text('Duplicate')); await widgetTester.pumpAndSettle(); - expect(find.widgetWithText(ProjectItemCard, 'auto1 (2)'), - findsOneWidget); + expect(find.widgetWithText(ProjectItemCard, 'auto1 (2)'), findsOneWidget); }); testWidgets('delete path', (widgetTester) async { From 383cc2438e2117750842ac38fb5cb231de1029fd Mon Sep 17 00:00:00 2001 From: Ammel <77129284+Ammelll@users.noreply.github.com> Date: Fri, 7 Feb 2025 21:00:19 -0800 Subject: [PATCH 3/5] Updating to recent commit --- pubspec.lock | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/pubspec.lock b/pubspec.lock index 9f6f8c9f8..0afd2f11e 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -5,23 +5,23 @@ packages: dependency: transitive description: name: _fe_analyzer_shared - sha256: "16e298750b6d0af7ce8a3ba7c18c69c3785d11b15ec83f6dcd0ad2a0009b3cab" + sha256: f256b0c0ba6c7577c15e2e4e114755640a875e885099367bf6e012b19314c834 url: "https://pub.dev" source: hosted - version: "76.0.0" + version: "72.0.0" _macros: dependency: transitive description: dart source: sdk - version: "0.3.3" + version: "0.3.2" analyzer: dependency: transitive description: name: analyzer - sha256: "1f14db053a8c23e260789e9b0980fa27f2680dd640932cae5e1137cce0e46e1e" + sha256: b652861553cd3990d8ed361f7979dc6d7053a9ac8843fa73820ab68ce5410139 url: "https://pub.dev" source: hosted - version: "6.11.0" + version: "6.7.0" archive: dependency: transitive description: @@ -178,10 +178,10 @@ packages: dependency: "direct main" description: name: collection - sha256: a1ace0a119f20aabc852d165077c036cd864315bd99b7eaa10a60100341941bf + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a url: "https://pub.dev" source: hosted - version: "1.19.0" + version: "1.18.0" console: dependency: transitive description: @@ -561,18 +561,18 @@ packages: dependency: transitive description: name: leak_tracker - sha256: "7bb2830ebd849694d1ec25bf1f44582d6ac531a57a365a803a6034ff751d2d06" + sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05" url: "https://pub.dev" source: hosted - version: "10.0.7" + version: "10.0.5" leak_tracker_flutter_testing: dependency: transitive description: name: leak_tracker_flutter_testing - sha256: "9491a714cca3667b60b5c420da8217e6de0d1ba7a5ec322fab01758f6998f379" + sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806" url: "https://pub.dev" source: hosted - version: "3.0.8" + version: "3.0.5" leak_tracker_testing: dependency: transitive description: @@ -625,10 +625,10 @@ packages: dependency: transitive description: name: macros - sha256: "1d9e801cd66f7ea3663c45fc708450db1fa57f988142c64289142c9b7ee80656" + sha256: "0acaed5d6b7eab89f63350bccd82119e6c602df0f391260d0e32b5e23db79536" url: "https://pub.dev" source: hosted - version: "0.1.3-main.0" + version: "0.1.2-main.4" markdown: dependency: transitive description: @@ -1001,7 +1001,7 @@ packages: dependency: transitive description: flutter source: sdk - version: "0.0.0" + version: "0.0.99" source_gen: dependency: transitive description: @@ -1022,10 +1022,10 @@ packages: dependency: transitive description: name: stack_trace - sha256: "9f47fd3630d76be3ab26f0ee06d213679aa425996925ff3feffdec504931c377" + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" url: "https://pub.dev" source: hosted - version: "1.12.0" + version: "1.11.1" stream_channel: dependency: transitive description: @@ -1046,10 +1046,10 @@ packages: dependency: transitive description: name: string_scanner - sha256: "688af5ed3402a4bde5b3a6c15fd768dbf2621a614950b17f04626c431ab3c4c3" + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" url: "https://pub.dev" source: hosted - version: "1.3.0" + version: "1.2.0" term_glyph: dependency: transitive description: @@ -1062,10 +1062,10 @@ packages: dependency: transitive description: name: test_api - sha256: "664d3a9a64782fcdeb83ce9c6b39e78fd2971d4e37827b9b06c3aa1edc5e760c" + sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb" url: "https://pub.dev" source: hosted - version: "0.7.3" + version: "0.7.2" timing: dependency: transitive description: @@ -1190,10 +1190,10 @@ packages: dependency: transitive description: name: vm_service - sha256: f6be3ed8bd01289b34d679c2b62226f63c0e69f9fd2e50a6b3c1c729a961041b + sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d" url: "https://pub.dev" source: hosted - version: "14.3.0" + version: "14.2.5" watcher: dependency: "direct main" description: From fbfcb82ab7b549830559db84027d14ac7d3d2610 Mon Sep 17 00:00:00 2001 From: Ammel <77129284+Ammelll@users.noreply.github.com> Date: Fri, 7 Feb 2025 23:14:02 -0800 Subject: [PATCH 4/5] Fixed duplicate tests not being passed --- lib/pages/project/project_page.dart | 28 +++++++++++++++++++---- test/main_test.dart | 2 +- test/pages/project/project_page_test.dart | 13 ++++++++++- 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/lib/pages/project/project_page.dart b/lib/pages/project/project_page.dart index 91eb07019..7560c350f 100644 --- a/lib/pages/project/project_page.dart +++ b/lib/pages/project/project_page.dart @@ -922,16 +922,20 @@ class _ProjectPageState extends State { String pathName = _paths[i].name; RegExp exp = RegExp(r'\(\d+\)'); String source = pathName.substring(pathName.length - 3); - while (pathNames.contains(pathName)) { + String originalPathName = pathName; + while (pathNames.contains(pathName) || pathName == '$originalPathName (0)') { + source = pathName.substring(pathName.length - 3); if (exp.hasMatch(source)) { RegExpMatch? match = exp.firstMatch(source); - int index = int.parse(match![0]!.substring(1, 2)) + 1; - pathName = '${pathName.substring(0, pathName.length - 3)}($index)'; + int index = int.parse(match![0]!.substring(1, 2)); + while(pathNames.contains(pathName) || pathName.substring(pathName.length-3) == '(0)'){ + index++; + pathName = '${pathName.substring(0, pathName.length - 3)}($index)'; + } } else { - pathName = '$pathName (1)'; + pathName = '$pathName (0)'; } } - setState(() { _paths.add(_paths[i].duplicate(pathName)); _sortPaths(_pathSortValue); @@ -1477,6 +1481,20 @@ class _ProjectPageState extends State { String autoName = _autos[i].name; RegExp exp = RegExp(r'\(\d+\)'); String source = autoName.substring(autoName.length - 3); + String originalAutoName = autoName; + while (autoNames.contains(autoName) || autoName == '$originalAutoName (0)') { + source = autoName.substring(autoName.length - 3); + if (exp.hasMatch(source)) { + RegExpMatch? match = exp.firstMatch(source); + int index = int.parse(match![0]!.substring(1, 2)); + while(autoNames.contains(autoName) || autoName.substring(autoName.length-3) == '(0)'){ + index++; + autoName = '${autoName.substring(0, autoName.length - 3)}($index)'; + } + } else { + autoName = '$autoName (0)'; + } + } while (autoNames.contains(autoName)) { if (exp.hasMatch(source)) { RegExpMatch? match = exp.firstMatch(source); diff --git a/test/main_test.dart b/test/main_test.dart index 881081f72..87c3631be 100644 --- a/test/main_test.dart +++ b/test/main_test.dart @@ -41,4 +41,4 @@ void main() { )); await widgetTester.pumpAndSettle(); }); -} +} \ No newline at end of file diff --git a/test/pages/project/project_page_test.dart b/test/pages/project/project_page_test.dart index 89a123156..e118548cf 100644 --- a/test/pages/project/project_page_test.dart +++ b/test/pages/project/project_page_test.dart @@ -483,9 +483,20 @@ void main() { await widgetTester.tap(find.text('Duplicate')); await widgetTester.pumpAndSettle(); - + for (var element in widgetTester.allWidgets){ + print("TEXT ELEMENT " + element.toStringDeep()); + } expect(find.widgetWithText(ProjectItemCard, 'Example Path (2)'), findsOneWidget); + + await widgetTester.tap(menuButton); + await widgetTester.pumpAndSettle(); + + await widgetTester.tap(find.text('Duplicate')); + await widgetTester.pumpAndSettle(); + + expect(find.widgetWithText(ProjectItemCard, 'Example Path (3)'), + findsOneWidget); }); testWidgets('duplicate auto', (widgetTester) async { From 0468ede8d39b290c6addccb082f62391f19c4191 Mon Sep 17 00:00:00 2001 From: Ammel <77129284+Ammelll@users.noreply.github.com> Date: Fri, 7 Feb 2025 23:18:04 -0800 Subject: [PATCH 5/5] formatting --- lib/pages/project/project_page.dart | 22 ++++++++++++++-------- test/main_test.dart | 2 +- test/pages/project/project_page_test.dart | 4 ++-- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/lib/pages/project/project_page.dart b/lib/pages/project/project_page.dart index 7560c350f..d9e9c528d 100644 --- a/lib/pages/project/project_page.dart +++ b/lib/pages/project/project_page.dart @@ -923,14 +923,17 @@ class _ProjectPageState extends State { RegExp exp = RegExp(r'\(\d+\)'); String source = pathName.substring(pathName.length - 3); String originalPathName = pathName; - while (pathNames.contains(pathName) || pathName == '$originalPathName (0)') { - source = pathName.substring(pathName.length - 3); + while (pathNames.contains(pathName) || + pathName == '$originalPathName (0)') { + source = pathName.substring(pathName.length - 3); if (exp.hasMatch(source)) { RegExpMatch? match = exp.firstMatch(source); int index = int.parse(match![0]!.substring(1, 2)); - while(pathNames.contains(pathName) || pathName.substring(pathName.length-3) == '(0)'){ + while (pathNames.contains(pathName) || + pathName.substring(pathName.length - 3) == '(0)') { index++; - pathName = '${pathName.substring(0, pathName.length - 3)}($index)'; + pathName = + '${pathName.substring(0, pathName.length - 3)}($index)'; } } else { pathName = '$pathName (0)'; @@ -1482,14 +1485,17 @@ class _ProjectPageState extends State { RegExp exp = RegExp(r'\(\d+\)'); String source = autoName.substring(autoName.length - 3); String originalAutoName = autoName; - while (autoNames.contains(autoName) || autoName == '$originalAutoName (0)') { - source = autoName.substring(autoName.length - 3); + while (autoNames.contains(autoName) || + autoName == '$originalAutoName (0)') { + source = autoName.substring(autoName.length - 3); if (exp.hasMatch(source)) { RegExpMatch? match = exp.firstMatch(source); int index = int.parse(match![0]!.substring(1, 2)); - while(autoNames.contains(autoName) || autoName.substring(autoName.length-3) == '(0)'){ + while (autoNames.contains(autoName) || + autoName.substring(autoName.length - 3) == '(0)') { index++; - autoName = '${autoName.substring(0, autoName.length - 3)}($index)'; + autoName = + '${autoName.substring(0, autoName.length - 3)}($index)'; } } else { autoName = '$autoName (0)'; diff --git a/test/main_test.dart b/test/main_test.dart index 87c3631be..881081f72 100644 --- a/test/main_test.dart +++ b/test/main_test.dart @@ -41,4 +41,4 @@ void main() { )); await widgetTester.pumpAndSettle(); }); -} \ No newline at end of file +} diff --git a/test/pages/project/project_page_test.dart b/test/pages/project/project_page_test.dart index e118548cf..b455a49cc 100644 --- a/test/pages/project/project_page_test.dart +++ b/test/pages/project/project_page_test.dart @@ -483,8 +483,8 @@ void main() { await widgetTester.tap(find.text('Duplicate')); await widgetTester.pumpAndSettle(); - for (var element in widgetTester.allWidgets){ - print("TEXT ELEMENT " + element.toStringDeep()); + for (var element in widgetTester.allWidgets) { + print("TEXT ELEMENT " + element.toStringDeep()); } expect(find.widgetWithText(ProjectItemCard, 'Example Path (2)'), findsOneWidget);