Skip to content

Commit

Permalink
Improved comments and added checks
Browse files Browse the repository at this point in the history
  • Loading branch information
dragoi75 committed Oct 25, 2024
1 parent 4da7298 commit 66bf70c
Showing 1 changed file with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,27 @@ object GenerateTestsTabHelper {
}

/**
* Helper function that removes a test from the cache.
* Helper function that removes a test from the cache if it stored.
*
* @param testCaseName the name of the test
*/
private fun removeTestFromCache(
generatedTestsTabData: GeneratedTestsTabData,
testCaseName: String
) {
// Remove all components from the cache
generatedTestsTabData.cacheTestCaseNameToSelectedCheckbox.remove(testCaseName)
generatedTestsTabData.cacheTestCaseNameToEditorTextField.remove(testCaseName)

generatedTestsTabData.cacheIndexToDeletedTestCaseName.remove(
generatedTestsTabData.allTestCasePanel.getComponentZOrder(
generatedTestsTabData.testCaseNameToPanel[testCaseName]
if (generatedTestsTabData.cacheTestCaseNameToSelectedCheckbox.containsKey(testCaseName)) {
generatedTestsTabData.cacheTestCaseNameToSelectedCheckbox.remove(testCaseName)
}
if (generatedTestsTabData.cacheTestCaseNameToEditorTextField.containsKey(testCaseName)) {
generatedTestsTabData.cacheTestCaseNameToEditorTextField.remove(testCaseName)
}
if (generatedTestsTabData.cacheIndexToDeletedTestCaseName.containsValue(testCaseName)) {
generatedTestsTabData.cacheIndexToDeletedTestCaseName.remove(
generatedTestsTabData.allTestCasePanel.getComponentZOrder(
generatedTestsTabData.testCaseNameToPanel[testCaseName]
)
)
)
}
}

/**
Expand Down Expand Up @@ -92,7 +96,8 @@ object GenerateTestsTabHelper {
generatedTestsTabData.allTestCasePanel.remove(index)

// Add the test back to the original position
val testPanel = generatedTestsTabData.testCaseNameToPanel[generatedTestsTabData.cacheIndexToDeletedTestCaseName[index]]
val testPanel =
generatedTestsTabData.testCaseNameToPanel[generatedTestsTabData.cacheIndexToDeletedTestCaseName[index]]
generatedTestsTabData.allTestCasePanel.add(testPanel, index)

// Restore the checkbox
Expand Down

0 comments on commit 66bf70c

Please sign in to comment.