Skip to content

Commit

Permalink
fix Count:1 messaging when no matches are found (#1065)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamiras authored Feb 10, 2024
1 parent 810b8aa commit 9255dd0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/ui/viewmodels/PointerFinderViewModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,11 +261,15 @@ void PointerFinderViewModel::Find()
{
auto* pPointer = &m_vResults.Add();
pPointer->SetPointerAddress(L"No pointers found.");
SetValue(ResultCountTextProperty, L"0");
}
else
{
SetValue(ResultCountTextProperty, std::to_wstring(m_vResults.Count()));
}

m_vResults.EndUpdate();

SetValue(ResultCountTextProperty, std::to_wstring(m_vResults.Count()));

if (!bPerformedSearch)
ra::ui::viewmodels::MessageBoxViewModel::ShowMessage(L"Cannot find.", L"At least two unique addresses must be captured before potential pointers can be located.");
Expand Down
7 changes: 7 additions & 0 deletions tests/ui/viewmodels/PointerFinderViewModel_Tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ TEST_CLASS(PointerFinderViewModel_Tests)
Assert::IsTrue(bDialogSeen);
Assert::AreEqual({ 0U }, vmPointerFinder.PotentialPointers().Count());
}

TEST_METHOD(TestFindOffsetZero)
{
PointerFinderViewModelHarness vmPointerFinder;
Expand All @@ -281,6 +282,7 @@ TEST_CLASS(PointerFinderViewModel_Tests)
Assert::IsFalse(vmPointerFinder.mockDesktop.WasDialogShown());
Assert::AreEqual({ 1U }, vmPointerFinder.PotentialPointers().Count());
vmPointerFinder.AssertRow(0, L"0x0008", L"+0x00", L"001c", L"0034", L"", L"");
Assert::AreEqual(std::wstring(L"1"), vmPointerFinder.GetResultCountText());
}

TEST_METHOD(TestFindOffsetPositive)
Expand Down Expand Up @@ -309,6 +311,7 @@ TEST_CLASS(PointerFinderViewModel_Tests)
Assert::IsFalse(vmPointerFinder.mockDesktop.WasDialogShown());
Assert::AreEqual({ 1U }, vmPointerFinder.PotentialPointers().Count());
vmPointerFinder.AssertRow(0, L"0x0008", L"+0x04", L"001c", L"0034", L"", L""); // 1c+04=>20, 34+04=>38
Assert::AreEqual(std::wstring(L"1"), vmPointerFinder.GetResultCountText());
}

TEST_METHOD(TestFindOffsetNegative)
Expand Down Expand Up @@ -337,6 +340,7 @@ TEST_CLASS(PointerFinderViewModel_Tests)
Assert::IsFalse(vmPointerFinder.mockDesktop.WasDialogShown());
Assert::AreEqual({ 1U }, vmPointerFinder.PotentialPointers().Count());
vmPointerFinder.AssertRow(0, L"0x0008", L"+0xFFFFFFFC", L"001c", L"0034", L"", L""); // 1c-04=>18, 34-04=>30
Assert::AreEqual(std::wstring(L"1"), vmPointerFinder.GetResultCountText());
}

TEST_METHOD(TestFindOffsetMultiplePointers)
Expand Down Expand Up @@ -371,6 +375,7 @@ TEST_CLASS(PointerFinderViewModel_Tests)
vmPointerFinder.AssertRow(0, L"0x0008", L"+0x04", L"001c", L"0034", L"", L""); // 1c+04=>20, 34+04=>38
vmPointerFinder.AssertRow(1, L"0x0070", L"+0x04", L"001c", L"0034", L"", L""); // 1c+04=>20, 34+04=>38
vmPointerFinder.AssertRow(2, L"0x009c", L"+0x00", L"0020", L"0038", L"", L""); // 20+00=>20, 38+00=>38
Assert::AreEqual(std::wstring(L"3"), vmPointerFinder.GetResultCountText());
}

TEST_METHOD(TestFindOffsetMultipleStates)
Expand Down Expand Up @@ -410,6 +415,7 @@ TEST_CLASS(PointerFinderViewModel_Tests)
Assert::AreEqual({ 2U }, vmPointerFinder.PotentialPointers().Count());
vmPointerFinder.AssertRow(0, L"0x0008", L"+0x04", L"001c", L"001c", L"0034", L"0034"); // 1c+04=>20, 34+04=>38
vmPointerFinder.AssertRow(1, L"0x00a4", L"+0x00", L"0020", L"0020", L"0038", L"0038"); // 20+00=>20, 38+00=>38
Assert::AreEqual(std::wstring(L"2"), vmPointerFinder.GetResultCountText());
}

TEST_METHOD(TestFindOffsetNoMatches)
Expand All @@ -434,6 +440,7 @@ TEST_CLASS(PointerFinderViewModel_Tests)
Assert::IsFalse(vmPointerFinder.mockDesktop.WasDialogShown());
Assert::AreEqual({ 1U }, vmPointerFinder.PotentialPointers().Count());
vmPointerFinder.AssertRow(0, L"No pointers found.", L"", L"", L"", L"", L"");
Assert::AreEqual(std::wstring(L"0"), vmPointerFinder.GetResultCountText());
}

TEST_METHOD(TestBookmarkSelected)
Expand Down

0 comments on commit 9255dd0

Please sign in to comment.