mirror of
https://github.com/Microsoft/calculator.git
synced 2025-07-16 02:02:51 -07:00
Optimize BitFlipPanel to suppress flicker when users switch between bit lengths (#640)
* Optimize BitFlipPanel * remove namespace in cpp file * improve localization + add tests * add helper to compare ivector * Modify how the control manages AutomationProperties::Name
This commit is contained in:
parent
eb24c085bc
commit
41e2e97591
26 changed files with 793 additions and 621 deletions
|
@ -16,9 +16,22 @@ using namespace CalculatorApp::Common;
|
|||
using namespace CalculatorApp::ViewModel;
|
||||
using namespace Platform;
|
||||
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
|
||||
using namespace Windows::Foundation::Collections;
|
||||
|
||||
namespace CalculatorUnitTests
|
||||
{
|
||||
template <typename T>
|
||||
void CompareVector(IVector<T> ^ vecA, IVector<T> ^ vecB)
|
||||
{
|
||||
if (vecA->Size != vecB->Size)
|
||||
Assert::Fail();
|
||||
|
||||
for (unsigned int i = 0; i < vecA->Size; ++i)
|
||||
{
|
||||
VERIFY_ARE_EQUAL(vecA->GetAt(i), vecB->GetAt(i));
|
||||
}
|
||||
}
|
||||
|
||||
void ChangeMode(StandardCalculatorViewModel ^ viewModel, int mode)
|
||||
{
|
||||
if (mode == 0)
|
||||
|
@ -496,6 +509,12 @@ namespace CalculatorUnitTests
|
|||
VERIFY_ARE_EQUAL(Utils::GetStringValue(m_viewModel->DecimalDisplayValue), StringReference(L"15"));
|
||||
VERIFY_ARE_EQUAL(Utils::GetStringValue(m_viewModel->OctalDisplayValue), StringReference(L"17"));
|
||||
VERIFY_ARE_EQUAL(Utils::GetStringValue(m_viewModel->BinaryDisplayValue), StringReference(L"1111"));
|
||||
auto val = ref new PC::Vector<bool>(64, false);
|
||||
val->SetAt(0, true);
|
||||
val->SetAt(1, true);
|
||||
val->SetAt(2, true);
|
||||
val->SetAt(3, true);
|
||||
CompareVector<bool>(m_viewModel->BinaryDigits, val);
|
||||
}
|
||||
|
||||
// Test Button disabling in different Radixes
|
||||
|
@ -543,6 +562,24 @@ namespace CalculatorUnitTests
|
|||
VERIFY_ARE_EQUAL(Utils::GetStringValue(m_viewModel->DecimalDisplayValue), StringReference(L"123,456,789"));
|
||||
VERIFY_ARE_EQUAL(Utils::GetStringValue(m_viewModel->OctalDisplayValue), StringReference(L"726 746 425"));
|
||||
VERIFY_ARE_EQUAL(Utils::GetStringValue(m_viewModel->BinaryDisplayValue), StringReference(L"0111 0101 1011 1100 1101 0001 0101"));
|
||||
auto val = ref new PC::Vector<bool>(64, false);
|
||||
val->SetAt(0, true);
|
||||
val->SetAt(2, true);
|
||||
val->SetAt(4, true);
|
||||
val->SetAt(8, true);
|
||||
val->SetAt(10, true);
|
||||
val->SetAt(11, true);
|
||||
val->SetAt(14, true);
|
||||
val->SetAt(15, true);
|
||||
val->SetAt(16, true);
|
||||
val->SetAt(17, true);
|
||||
val->SetAt(19, true);
|
||||
val->SetAt(20, true);
|
||||
val->SetAt(22, true);
|
||||
val->SetAt(24, true);
|
||||
val->SetAt(25, true);
|
||||
val->SetAt(26, true);
|
||||
CompareVector<bool>(m_viewModel->BinaryDigits, val);
|
||||
}
|
||||
|
||||
// Test Not functionality
|
||||
|
@ -562,6 +599,9 @@ namespace CalculatorUnitTests
|
|||
Utils::GetStringValue(m_viewModel->BinaryDisplayValue),
|
||||
StringReference(L"1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1110"));
|
||||
VERIFY_ARE_EQUAL(m_viewModel->DisplayValue, StringReference(L"-2"));
|
||||
auto val = ref new PC::Vector<bool>(64, true);
|
||||
val->SetAt(0, false);
|
||||
CompareVector<bool>(m_viewModel->BinaryDigits, val);
|
||||
}
|
||||
|
||||
// Test And Or functionality
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue