Move the CalculatorManager instance to be direct member data of the StandardCalculatorViewModel class.
Previously, the CalculatorManager was managed with a unique_ptr that was instantiated in the ViewModel's constructor and was never re-assigned. Objects with long lifetime and larger memory footprint should live in dynamic memory, but the ViewModel itself lives in dynamic memory so that goal is still satisfied by storing the CalculatorManager directly in the class. The change allows the compiler to write a more efficient memory footprint for the same data. - Verified by testing basic app functionality and running unit tests locally.
This commit is contained in:
Родитель
d6917f5664
Коммит
dd79d6fcd3
|
@ -69,7 +69,7 @@ StandardCalculatorViewModel::StandardCalculatorViewModel() :
|
|||
m_HexDisplayValue(L"0"),
|
||||
m_BinaryDisplayValue(L"0"),
|
||||
m_OctalDisplayValue(L"0"),
|
||||
m_standardCalculatorManager(make_unique<CalculatorManager>(&m_calculatorDisplay, &m_resourceProvider)),
|
||||
m_standardCalculatorManager(&m_calculatorDisplay, &m_resourceProvider),
|
||||
m_MemorizedNumbers(ref new Vector<MemoryItemViewModel^>()),
|
||||
m_IsMemoryEmpty(true),
|
||||
m_IsFToEChecked(false),
|
||||
|
@ -110,7 +110,7 @@ StandardCalculatorViewModel::StandardCalculatorViewModel() :
|
|||
CalculationExpressionAutomationName = GetLocalizedStringFormat(m_expressionAutomationNameFormat, L"");
|
||||
|
||||
// Initialize history view model
|
||||
m_HistoryVM = ref new HistoryViewModel(m_standardCalculatorManager.get());
|
||||
m_HistoryVM = ref new HistoryViewModel(&m_standardCalculatorManager);
|
||||
m_HistoryVM->SetCalculatorDisplay(m_calculatorDisplay);
|
||||
|
||||
m_decimalSeparator = LocalizationSettings::GetInstance().GetDecimalSeparator();
|
||||
|
@ -215,7 +215,7 @@ void StandardCalculatorViewModel::SetPrimaryDisplay(_In_ wstring const &displayS
|
|||
|
||||
void StandardCalculatorViewModel::DisplayPasteError()
|
||||
{
|
||||
m_standardCalculatorManager->DisplayPasteError();
|
||||
m_standardCalculatorManager.DisplayPasteError();
|
||||
}
|
||||
|
||||
void StandardCalculatorViewModel::SetParenthesisCount(_In_ const wstring& parenthesisCount)
|
||||
|
@ -285,9 +285,9 @@ void StandardCalculatorViewModel::SetHistoryExpressionDisplay(_Inout_ shared_ptr
|
|||
IsEditingEnabled = false;
|
||||
|
||||
// Setting the History Item Load Mode so that UI does not get updated with recalculation of every token
|
||||
m_standardCalculatorManager->SetInHistoryItemLoadMode(true);
|
||||
m_standardCalculatorManager.SetInHistoryItemLoadMode(true);
|
||||
Recalculate(true);
|
||||
m_standardCalculatorManager->SetInHistoryItemLoadMode(false);
|
||||
m_standardCalculatorManager.SetInHistoryItemLoadMode(false);
|
||||
m_isLastOperationHistoryLoad = true;
|
||||
}
|
||||
|
||||
|
@ -573,7 +573,7 @@ void StandardCalculatorViewModel::OnButtonPressed(Object^ parameter)
|
|||
|
||||
if (IsInError)
|
||||
{
|
||||
m_standardCalculatorManager->SendCommand(Command::CommandCLEAR);
|
||||
m_standardCalculatorManager.SendCommand(Command::CommandCLEAR);
|
||||
|
||||
if (!IsRecoverableCommand((int)numOpEnum))
|
||||
{
|
||||
|
@ -643,7 +643,7 @@ void StandardCalculatorViewModel::OnButtonPressed(Object^ parameter)
|
|||
m_isLastOperationHistoryLoad = false;
|
||||
}
|
||||
|
||||
m_standardCalculatorManager->SendCommand(cmdenum);
|
||||
m_standardCalculatorManager.SendCommand(cmdenum);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -746,7 +746,7 @@ void StandardCalculatorViewModel::OnPaste(String^ pastedString, ViewMode mode)
|
|||
|
||||
TraceLogger::GetInstance().LogValidInputPasted(mode);
|
||||
bool isFirstLegalChar = true;
|
||||
m_standardCalculatorManager->SendCommand(Command::CommandCENTR);
|
||||
m_standardCalculatorManager.SendCommand(Command::CommandCENTR);
|
||||
bool sendNegate = false;
|
||||
bool processedExp = false;
|
||||
bool processedDigit = false;
|
||||
|
@ -836,7 +836,7 @@ void StandardCalculatorViewModel::OnPaste(String^ pastedString, ViewMode mode)
|
|||
{
|
||||
sentEquals = (mappedNumOp == NumbersAndOperatorsEnum::Equals);
|
||||
Command cmdenum = ConvertToOperatorsEnum(mappedNumOp);
|
||||
m_standardCalculatorManager->SendCommand(cmdenum);
|
||||
m_standardCalculatorManager.SendCommand(cmdenum);
|
||||
|
||||
// The CalcEngine state machine won't allow the negate command to be sent before any
|
||||
// other digits, so instead a flag is set and the command is sent after the first appropriate
|
||||
|
@ -846,7 +846,7 @@ void StandardCalculatorViewModel::OnPaste(String^ pastedString, ViewMode mode)
|
|||
if (canSendNegate)
|
||||
{
|
||||
Command cmdNegate = ConvertToOperatorsEnum(NumbersAndOperatorsEnum::Negate);
|
||||
m_standardCalculatorManager->SendCommand(cmdNegate);
|
||||
m_standardCalculatorManager.SendCommand(cmdNegate);
|
||||
}
|
||||
|
||||
// Can't send negate on a leading zero, so wait until the appropriate time to send it.
|
||||
|
@ -865,7 +865,7 @@ void StandardCalculatorViewModel::OnPaste(String^ pastedString, ViewMode mode)
|
|||
if (!(MapCharacterToButtonId(*it, canSendNegate) == NumbersAndOperatorsEnum::Add))
|
||||
{
|
||||
Command cmdNegate = ConvertToOperatorsEnum(NumbersAndOperatorsEnum::Negate);
|
||||
m_standardCalculatorManager->SendCommand(cmdNegate);
|
||||
m_standardCalculatorManager.SendCommand(cmdNegate);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -876,7 +876,7 @@ void StandardCalculatorViewModel::OnPaste(String^ pastedString, ViewMode mode)
|
|||
void StandardCalculatorViewModel::OnClearMemoryCommand(
|
||||
Object^ parameter)
|
||||
{
|
||||
m_standardCalculatorManager->MemorizedNumberClearAll();
|
||||
m_standardCalculatorManager.MemorizedNumberClearAll();
|
||||
|
||||
int windowId = Utils::GetWindowId();
|
||||
TraceLogger::GetInstance().LogMemoryClearAll(windowId);
|
||||
|
@ -1013,7 +1013,7 @@ NumbersAndOperatorsEnum StandardCalculatorViewModel::MapCharacterToButtonId(
|
|||
|
||||
void StandardCalculatorViewModel::OnMemoryButtonPressed()
|
||||
{
|
||||
m_standardCalculatorManager->MemorizeNumber();
|
||||
m_standardCalculatorManager.MemorizeNumber();
|
||||
|
||||
int windowId = Utils::GetWindowId();
|
||||
TraceLogger::GetInstance().InsertIntoMemoryMap(windowId, IsStandard, IsScientific, IsProgrammer);
|
||||
|
@ -1051,7 +1051,7 @@ void StandardCalculatorViewModel::OnMemoryItemPressed(Object^ memoryItemPosition
|
|||
if (MemorizedNumbers && MemorizedNumbers->Size > 0)
|
||||
{
|
||||
auto boxedPosition = safe_cast<Box<int>^>(memoryItemPosition);
|
||||
m_standardCalculatorManager->MemorizedNumberLoad(boxedPosition->Value);
|
||||
m_standardCalculatorManager.MemorizedNumberLoad(boxedPosition->Value);
|
||||
HideMemoryClicked();
|
||||
int windowId = Utils::GetWindowId();
|
||||
TraceLogger::GetInstance().LogMemoryUsed(windowId, boxedPosition->Value, IsStandard, IsScientific, IsProgrammer, MemorizedNumbers->Size);
|
||||
|
@ -1075,7 +1075,7 @@ void StandardCalculatorViewModel::OnMemoryAdd(Object^ memoryItemPosition)
|
|||
{
|
||||
TraceLogger::GetInstance().InsertIntoMemoryMap(windowId, IsStandard, IsScientific, IsProgrammer);
|
||||
}
|
||||
m_standardCalculatorManager->MemorizedNumberAdd(boxedPosition->Value);
|
||||
m_standardCalculatorManager.MemorizedNumberAdd(boxedPosition->Value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1096,7 +1096,7 @@ void StandardCalculatorViewModel::OnMemorySubtract(Object^ memoryItemPosition)
|
|||
{
|
||||
TraceLogger::GetInstance().InsertIntoMemoryMap(windowId, IsStandard, IsScientific, IsProgrammer);
|
||||
}
|
||||
m_standardCalculatorManager->MemorizedNumberSubtract(boxedPosition->Value);
|
||||
m_standardCalculatorManager.MemorizedNumberSubtract(boxedPosition->Value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1110,7 +1110,7 @@ void StandardCalculatorViewModel::OnMemoryClear(_In_ Object^ memoryItemPosition)
|
|||
if (boxedPosition->Value >= 0)
|
||||
{
|
||||
unsigned int unsignedPosition = safe_cast<unsigned int>(boxedPosition->Value);
|
||||
m_standardCalculatorManager->MemorizedNumberClear(unsignedPosition);
|
||||
m_standardCalculatorManager.MemorizedNumberClear(unsignedPosition);
|
||||
|
||||
MemorizedNumbers->RemoveAt(unsignedPosition);
|
||||
for (unsigned int i = 0; i < MemorizedNumbers->Size; i++)
|
||||
|
@ -1145,11 +1145,11 @@ Array<unsigned char>^ StandardCalculatorViewModel::Serialize()
|
|||
writer->WriteUInt32(static_cast<UINT32>(m_CurrentAngleType));
|
||||
writer->WriteBoolean(IsFToEChecked);
|
||||
writer->WriteBoolean(IsCurrentViewPinned);
|
||||
writer->WriteUInt32(static_cast<UINT32>(m_standardCalculatorManager->SerializeSavedDegreeMode()));
|
||||
writer->WriteUInt32(static_cast<UINT32>(m_standardCalculatorManager.SerializeSavedDegreeMode()));
|
||||
|
||||
// Serialize Memory
|
||||
vector<long> serializedMemory;
|
||||
serializedMemory = m_standardCalculatorManager->GetSerializedMemory();
|
||||
serializedMemory = m_standardCalculatorManager.GetSerializedMemory();
|
||||
size_t lengthOfSerializedMemory = serializedMemory.size();
|
||||
writer->WriteUInt32(static_cast<UINT32>(lengthOfSerializedMemory));
|
||||
for (auto data : serializedMemory)
|
||||
|
@ -1158,7 +1158,7 @@ Array<unsigned char>^ StandardCalculatorViewModel::Serialize()
|
|||
}
|
||||
|
||||
// Serialize Primary Display
|
||||
vector<long> serializedPrimaryDisplay = m_standardCalculatorManager->GetSerializedPrimaryDisplay();
|
||||
vector<long> serializedPrimaryDisplay = m_standardCalculatorManager.GetSerializedPrimaryDisplay();
|
||||
writer->WriteUInt32(static_cast<UINT32>(serializedPrimaryDisplay.size()));
|
||||
for (auto data : serializedPrimaryDisplay)
|
||||
{
|
||||
|
@ -1169,7 +1169,7 @@ Array<unsigned char>^ StandardCalculatorViewModel::Serialize()
|
|||
writer->WriteUInt32(static_cast<UINT32>(CurrentRadixType));
|
||||
|
||||
//Serialize commands of calculator manager
|
||||
vector<unsigned char> serializedCommand = m_standardCalculatorManager->SerializeCommands();
|
||||
vector<unsigned char> serializedCommand = m_standardCalculatorManager.SerializeCommands();
|
||||
writer->WriteUInt32(static_cast<UINT32>(serializedCommand.size()));
|
||||
writer->WriteBytes(ref new Array<unsigned char>(serializedCommand.data(), static_cast<unsigned int>(serializedCommand.size())));
|
||||
|
||||
|
@ -1205,7 +1205,7 @@ void StandardCalculatorViewModel::Deserialize(Array<unsigned char>^ state)
|
|||
IsCurrentViewPinned = reader->ReadBoolean();
|
||||
Command serializedDegreeMode = static_cast<Command>(reader->ReadUInt32());
|
||||
|
||||
m_standardCalculatorManager->SendCommand(serializedDegreeMode);
|
||||
m_standardCalculatorManager.SendCommand(serializedDegreeMode);
|
||||
|
||||
// Deserialize Memory
|
||||
UINT32 memoryDataLength = reader->ReadUInt32();
|
||||
|
@ -1214,7 +1214,7 @@ void StandardCalculatorViewModel::Deserialize(Array<unsigned char>^ state)
|
|||
{
|
||||
serializedMemory.push_back(reader->ReadInt32());
|
||||
}
|
||||
m_standardCalculatorManager->DeSerializeMemory(serializedMemory);
|
||||
m_standardCalculatorManager.DeSerializeMemory(serializedMemory);
|
||||
|
||||
// Serialize Primary Display
|
||||
UINT32 serializedPrimaryDisplayLength = reader->ReadUInt32();
|
||||
|
@ -1223,14 +1223,14 @@ void StandardCalculatorViewModel::Deserialize(Array<unsigned char>^ state)
|
|||
{
|
||||
serializedPrimaryDisplay.push_back(reader->ReadInt32());
|
||||
}
|
||||
m_standardCalculatorManager->DeSerializePrimaryDisplay(serializedPrimaryDisplay);
|
||||
m_standardCalculatorManager.DeSerializePrimaryDisplay(serializedPrimaryDisplay);
|
||||
|
||||
CurrentRadixType = reader->ReadUInt32();
|
||||
//Read command data and Deserialize
|
||||
UINT32 modeldatalength = reader->ReadUInt32();
|
||||
Array<unsigned char>^ modelDataAsBytes = ref new Array<unsigned char>(modeldatalength);
|
||||
reader->ReadBytes(modelDataAsBytes);
|
||||
m_standardCalculatorManager->DeSerializeCommands(vector<unsigned char>(modelDataAsBytes->begin(), modelDataAsBytes->end()));
|
||||
m_standardCalculatorManager.DeSerializeCommands(vector<unsigned char>(modelDataAsBytes->begin(), modelDataAsBytes->end()));
|
||||
|
||||
// After recalculation. If there is an error then
|
||||
// IsInError should be set synchronously.
|
||||
|
@ -1326,31 +1326,31 @@ void StandardCalculatorViewModel::ResetDisplay()
|
|||
{
|
||||
AreHEXButtonsEnabled = false;
|
||||
CurrentRadixType = (int)RADIX_TYPE::DEC_RADIX;
|
||||
m_standardCalculatorManager->SetRadix(DEC_RADIX);
|
||||
m_standardCalculatorManager.SetRadix(DEC_RADIX);
|
||||
ProgModeRadixChange();
|
||||
}
|
||||
|
||||
void StandardCalculatorViewModel::SetPrecision(int32_t precision)
|
||||
{
|
||||
m_standardCalculatorManager->SetPrecision(precision);
|
||||
m_standardCalculatorManager.SetPrecision(precision);
|
||||
}
|
||||
|
||||
void StandardCalculatorViewModel::SwitchProgrammerModeBase(RADIX_TYPE radixType)
|
||||
{
|
||||
if (IsInError)
|
||||
{
|
||||
m_standardCalculatorManager->SendCommand(Command::CommandCLEAR);
|
||||
m_standardCalculatorManager.SendCommand(Command::CommandCLEAR);
|
||||
}
|
||||
|
||||
AreHEXButtonsEnabled = (radixType == RADIX_TYPE::HEX_RADIX);
|
||||
CurrentRadixType = (int)radixType;
|
||||
m_standardCalculatorManager->SetRadix(radixType);
|
||||
m_standardCalculatorManager.SetRadix(radixType);
|
||||
ProgModeRadixChange();
|
||||
}
|
||||
|
||||
void StandardCalculatorViewModel::SetMemorizedNumbersString()
|
||||
{
|
||||
m_standardCalculatorManager->SetMemorizedNumbersString();
|
||||
m_standardCalculatorManager.SetMemorizedNumbersString();
|
||||
}
|
||||
|
||||
ANGLE_TYPE GetAngleTypeFromCommand(Command command)
|
||||
|
@ -1384,7 +1384,7 @@ void StandardCalculatorViewModel::SaveEditedCommand(_In_ unsigned int tokenPosit
|
|||
|
||||
if (IsUnaryOp(nOpCode) && command != Command::CommandSIGN)
|
||||
{
|
||||
int angleCmd = static_cast<int>(m_standardCalculatorManager->GetCurrentDegreeMode());
|
||||
int angleCmd = static_cast<int>(m_standardCalculatorManager.GetCurrentDegreeMode());
|
||||
ANGLE_TYPE angleType = GetAngleTypeFromCommand(static_cast<Command>(angleCmd));
|
||||
|
||||
if (IsTrigOp(nOpCode))
|
||||
|
@ -1452,7 +1452,7 @@ void StandardCalculatorViewModel::SaveEditedCommand(_In_ unsigned int tokenPosit
|
|||
{
|
||||
shared_ptr<IOpndCommand> spOpndCommand = dynamic_pointer_cast<IOpndCommand>(tokenCommand);
|
||||
spOpndCommand->ToggleSign();
|
||||
updatedToken = spOpndCommand->GetToken(m_standardCalculatorManager->DecimalSeparator());
|
||||
updatedToken = spOpndCommand->GetToken(m_standardCalculatorManager.DecimalSeparator());
|
||||
}
|
||||
IsOperandUpdatedUsingViewModel = true;
|
||||
}
|
||||
|
@ -1481,7 +1481,7 @@ void StandardCalculatorViewModel::SaveEditedCommand(_In_ unsigned int tokenPosit
|
|||
void StandardCalculatorViewModel::Recalculate(bool fromHistory)
|
||||
{
|
||||
// Recalculate
|
||||
Command currentDegreeMode = m_standardCalculatorManager->GetCurrentDegreeMode();
|
||||
Command currentDegreeMode = m_standardCalculatorManager.GetCurrentDegreeMode();
|
||||
shared_ptr <CalculatorVector<shared_ptr<IExpressionCommand>>> savedCommands = make_shared <CalculatorVector<shared_ptr<IExpressionCommand>>>();
|
||||
|
||||
vector<int> currentCommands;
|
||||
|
@ -1556,29 +1556,29 @@ void StandardCalculatorViewModel::Recalculate(bool fromHistory)
|
|||
savedTokens->Append(currentToken);
|
||||
}
|
||||
|
||||
m_standardCalculatorManager->Reset(false);
|
||||
m_standardCalculatorManager.Reset(false);
|
||||
if (IsScientific)
|
||||
{
|
||||
m_standardCalculatorManager->SendCommand(Command::ModeScientific);
|
||||
m_standardCalculatorManager.SendCommand(Command::ModeScientific);
|
||||
}
|
||||
|
||||
if (IsFToEChecked)
|
||||
{
|
||||
m_standardCalculatorManager->SendCommand(Command::CommandFE);
|
||||
m_standardCalculatorManager.SendCommand(Command::CommandFE);
|
||||
}
|
||||
|
||||
m_standardCalculatorManager->SendCommand(currentDegreeMode);
|
||||
m_standardCalculatorManager.SendCommand(currentDegreeMode);
|
||||
size_t currentCommandsSize = currentCommands.size();
|
||||
for (size_t i = 0; i < currentCommandsSize; i++)
|
||||
{
|
||||
m_standardCalculatorManager->SendCommand(static_cast<CalculationManager::Command>(currentCommands[i]));
|
||||
m_standardCalculatorManager.SendCommand(static_cast<CalculationManager::Command>(currentCommands[i]));
|
||||
}
|
||||
|
||||
if (fromHistory) // This is for the cases where the expression is loaded from history
|
||||
{
|
||||
// To maintain F-E state of the engine, as the last operand hasn't reached engine by now
|
||||
m_standardCalculatorManager->SendCommand(Command::CommandFE);
|
||||
m_standardCalculatorManager->SendCommand(Command::CommandFE);
|
||||
m_standardCalculatorManager.SendCommand(Command::CommandFE);
|
||||
m_standardCalculatorManager.SendCommand(Command::CommandFE);
|
||||
}
|
||||
|
||||
// After recalculation. If there is an error then
|
||||
|
@ -1785,7 +1785,7 @@ void StandardCalculatorViewModel::UpdateProgrammerPanelDisplay()
|
|||
{
|
||||
// we want the precision to be set to maximum value so that the autoconversions result as desired
|
||||
int32_t precision = 64;
|
||||
if (m_standardCalculatorManager->GetResultForRadix(16, precision) == L"")
|
||||
if (m_standardCalculatorManager.GetResultForRadix(16, precision) == L"")
|
||||
{
|
||||
hexDisplayString = DisplayValue->Data();
|
||||
decimalDisplayString = DisplayValue->Data();
|
||||
|
@ -1794,10 +1794,10 @@ void StandardCalculatorViewModel::UpdateProgrammerPanelDisplay()
|
|||
}
|
||||
else
|
||||
{
|
||||
hexDisplayString = m_standardCalculatorManager->GetResultForRadix(16, precision);
|
||||
decimalDisplayString = m_standardCalculatorManager->GetResultForRadix(10, precision);
|
||||
octalDisplayString = m_standardCalculatorManager->GetResultForRadix(8, precision);
|
||||
binaryDisplayString = m_standardCalculatorManager->GetResultForRadix(2, precision);
|
||||
hexDisplayString = m_standardCalculatorManager.GetResultForRadix(16, precision);
|
||||
decimalDisplayString = m_standardCalculatorManager.GetResultForRadix(10, precision);
|
||||
octalDisplayString = m_standardCalculatorManager.GetResultForRadix(8, precision);
|
||||
binaryDisplayString = m_standardCalculatorManager.GetResultForRadix(2, precision);
|
||||
}
|
||||
}
|
||||
const auto& localizer = LocalizationSettings::GetInstance();
|
||||
|
@ -1909,7 +1909,7 @@ void StandardCalculatorViewModel::UpdateOperand(int pos, String^ text)
|
|||
|
||||
void StandardCalculatorViewModel::UpdatecommandsInRecordingMode()
|
||||
{
|
||||
vector<unsigned char> savedCommands = m_standardCalculatorManager->GetSavedCommands();
|
||||
vector<unsigned char> savedCommands = m_standardCalculatorManager.GetSavedCommands();
|
||||
shared_ptr<CalculatorVector<int>> commands = make_shared<CalculatorVector<int>>();
|
||||
bool isDecimal = false;
|
||||
bool isNegative = false;
|
||||
|
|
|
@ -214,7 +214,7 @@ namespace CalculatorApp
|
|||
}
|
||||
|
||||
property bool IsEngineRecording {
|
||||
bool get() { return m_standardCalculatorManager->IsEngineRecording(); }
|
||||
bool get() { return m_standardCalculatorManager.IsEngineRecording(); }
|
||||
}
|
||||
|
||||
property bool IsOperandEnabled {
|
||||
|
@ -311,7 +311,7 @@ namespace CalculatorApp
|
|||
void ResetDisplay();
|
||||
RADIX_TYPE GetCurrentRadixType() { return (RADIX_TYPE)m_CurrentRadixType; }
|
||||
void SetPrecision(int32_t precision);
|
||||
void UpdateMaxIntDigits() { m_standardCalculatorManager->UpdateMaxIntDigits(); }
|
||||
void UpdateMaxIntDigits() { m_standardCalculatorManager.UpdateMaxIntDigits(); }
|
||||
NumbersAndOperatorsEnum GetCurrentAngleType() { return m_CurrentAngleType; }
|
||||
|
||||
private:
|
||||
|
@ -323,7 +323,7 @@ namespace CalculatorApp
|
|||
wchar_t m_decimalSeparator;
|
||||
CalculatorDisplay m_calculatorDisplay;
|
||||
CalculatorApp::EngineResourceProvider m_resourceProvider;
|
||||
std::unique_ptr<CalculationManager::CalculatorManager> m_standardCalculatorManager;
|
||||
CalculationManager::CalculatorManager m_standardCalculatorManager;
|
||||
Platform::String^ m_expressionAutomationNameFormat;
|
||||
Platform::String^ m_localizedCalculationResultAutomationFormat;
|
||||
Platform::String^ m_localizedCalculationResultDecimalAutomationFormat;
|
||||
|
|
|
@ -46,17 +46,17 @@ namespace CalculatorFunctionalTests
|
|||
{
|
||||
m_standardViewModel = ref new StandardCalculatorViewModel();
|
||||
m_standardViewModel->IsStandard = true;
|
||||
m_historyViewModel = ref new HistoryViewModel(m_standardViewModel->m_standardCalculatorManager.get());
|
||||
m_historyViewModel = ref new HistoryViewModel(&(m_standardViewModel->m_standardCalculatorManager));
|
||||
m_historyViewModel->SetCalculatorDisplay(m_standardViewModel->m_calculatorDisplay);
|
||||
}
|
||||
|
||||
void Cleanup(unsigned int windowId = 0)
|
||||
{
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::ModeBasic);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::ModeBasic);
|
||||
m_historyViewModel->OnClearCommand(nullptr);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::ModeScientific);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::ModeScientific);
|
||||
m_historyViewModel->OnClearCommand(nullptr);
|
||||
m_standardViewModel->m_standardCalculatorManager->Reset();
|
||||
m_standardViewModel->m_standardCalculatorManager.Reset();
|
||||
}
|
||||
|
||||
bool IsHistoryContainerEmpty(_In_ String^ historyContainerKey)
|
||||
|
@ -83,12 +83,12 @@ namespace CalculatorFunctionalTests
|
|||
{
|
||||
Initialize(windowId);
|
||||
int initialSize = m_historyViewModel->ItemSize;
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::Command1);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::CommandADD);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::Command8);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::CommandEQU);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::Command1);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandADD);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::Command8);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandEQU);
|
||||
int sizeAfterItemAdd = m_historyViewModel->ItemSize;
|
||||
auto historyItem = m_standardViewModel->m_standardCalculatorManager->GetHistoryItem(0);
|
||||
auto historyItem = m_standardViewModel->m_standardCalculatorManager.GetHistoryItem(0);
|
||||
String^ expression = UtfUtils::LRO + L"1 + 8 =" + UtfUtils::PDF;
|
||||
String ^result = StringReference(L"9");
|
||||
VERIFY_ARE_EQUAL(initialSize + 1, sizeAfterItemAdd);
|
||||
|
@ -101,33 +101,33 @@ namespace CalculatorFunctionalTests
|
|||
{
|
||||
Initialize(windowId);
|
||||
int initialSize = m_historyViewModel->ItemSize;
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::Command1);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::CommandADD);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::Command1);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::CommandEQU);
|
||||
for (int i = 1; i < m_standardViewModel->m_standardCalculatorManager->MaxHistorySize(); i++)
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::Command1);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandADD);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::Command1);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandEQU);
|
||||
for (int i = 1; i < m_standardViewModel->m_standardCalculatorManager.MaxHistorySize(); i++)
|
||||
{
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::Command1);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::CommandADD);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::Command2);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::CommandEQU);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::Command1);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandADD);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::Command2);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandEQU);
|
||||
}
|
||||
VERIFY_ARE_EQUAL(m_historyViewModel->ItemSize, m_standardViewModel->m_standardCalculatorManager->MaxHistorySize());
|
||||
VERIFY_ARE_EQUAL(m_historyViewModel->ItemSize, m_standardViewModel->m_standardCalculatorManager.MaxHistorySize());
|
||||
String ^expression = UtfUtils::LRO + L"1 + 1 =" + UtfUtils::PDF;
|
||||
int output = 2;
|
||||
String ^result = output.ToString();
|
||||
auto historyItem = m_standardViewModel->m_standardCalculatorManager->GetHistoryItem(0);
|
||||
auto historyItem = m_standardViewModel->m_standardCalculatorManager.GetHistoryItem(0);
|
||||
VERIFY_ARE_EQUAL(expression, StringReference(historyItem->historyItemVector.expression.c_str()));
|
||||
VERIFY_ARE_EQUAL(result, StringReference(historyItem->historyItemVector.result.c_str()));
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::Command1);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::CommandADD);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::Command5);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::CommandEQU);
|
||||
VERIFY_ARE_EQUAL(m_historyViewModel->ItemSize, m_standardViewModel->m_standardCalculatorManager->MaxHistorySize());
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::Command1);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandADD);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::Command5);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandEQU);
|
||||
VERIFY_ARE_EQUAL(m_historyViewModel->ItemSize, m_standardViewModel->m_standardCalculatorManager.MaxHistorySize());
|
||||
expression = UtfUtils::LRO + L"1 + 2 =" + UtfUtils::PDF;
|
||||
output = 3;
|
||||
result = output.ToString();
|
||||
historyItem = m_standardViewModel->m_standardCalculatorManager->GetHistoryItem(0);
|
||||
historyItem = m_standardViewModel->m_standardCalculatorManager.GetHistoryItem(0);
|
||||
VERIFY_ARE_EQUAL(expression, StringReference(historyItem->historyItemVector.expression.c_str()));
|
||||
VERIFY_ARE_EQUAL(result, StringReference(historyItem->historyItemVector.result.c_str()));
|
||||
Cleanup(windowId);
|
||||
|
@ -137,30 +137,30 @@ namespace CalculatorFunctionalTests
|
|||
{
|
||||
Initialize(windowId);
|
||||
|
||||
m_standardViewModel->m_standardCalculatorManager->Reset();
|
||||
m_standardViewModel->m_standardCalculatorManager.Reset();
|
||||
int scientificItems = 5;
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::ModeScientific);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::ModeScientific);
|
||||
for (int i = 0; i < scientificItems; i++)
|
||||
{
|
||||
Command nextCommand = Command(130 + i);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::Command1);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::CommandADD);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(nextCommand);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::CommandEQU);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::Command1);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandADD);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(nextCommand);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandEQU);
|
||||
}
|
||||
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::ModeBasic);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::ModeBasic);
|
||||
int standardItems = 2;
|
||||
for (int i = 0; i < standardItems; i++)
|
||||
{
|
||||
Command nextCommand = Command(130 + i);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::Command1);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::CommandADD);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(nextCommand);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::CommandEQU);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::Command1);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandADD);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(nextCommand);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandEQU);
|
||||
}
|
||||
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::ModeScientific);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::ModeScientific);
|
||||
m_historyViewModel->ReloadHistory(ViewMode::Scientific);
|
||||
VERIFY_ARE_EQUAL(scientificItems, m_historyViewModel->ItemSize);
|
||||
for (int i = 0; i < scientificItems; i++)
|
||||
|
@ -169,13 +169,13 @@ namespace CalculatorFunctionalTests
|
|||
expr = UtfUtils::LRO + expr + UtfUtils::PDF;
|
||||
int output = 1 + i;
|
||||
String ^result = output.ToString();
|
||||
auto historyItem = m_standardViewModel->m_standardCalculatorManager->GetHistoryItem(i);
|
||||
auto historyItem = m_standardViewModel->m_standardCalculatorManager.GetHistoryItem(i);
|
||||
VERIFY_ARE_EQUAL(expr, historyItem->historyItemVector.expression);
|
||||
VERIFY_ARE_EQUAL(result, StringReference(historyItem->historyItemVector.result.c_str()));
|
||||
}
|
||||
|
||||
m_historyViewModel->ReloadHistory(ViewMode::Standard);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::ModeBasic);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::ModeBasic);
|
||||
VERIFY_ARE_EQUAL(standardItems, m_historyViewModel->ItemSize);
|
||||
for (int i = 0; i < standardItems; i++)
|
||||
{
|
||||
|
@ -183,7 +183,7 @@ namespace CalculatorFunctionalTests
|
|||
expr = UtfUtils::LRO + expr + UtfUtils::PDF;
|
||||
int output = 1 + i;
|
||||
String ^result = output.ToString();
|
||||
auto historyItem = m_standardViewModel->m_standardCalculatorManager->GetHistoryItem(i);
|
||||
auto historyItem = m_standardViewModel->m_standardCalculatorManager.GetHistoryItem(i);
|
||||
VERIFY_ARE_EQUAL(expr, historyItem->historyItemVector.expression);
|
||||
VERIFY_ARE_EQUAL(result, StringReference(historyItem->historyItemVector.result.c_str()));
|
||||
}
|
||||
|
@ -193,16 +193,16 @@ namespace CalculatorFunctionalTests
|
|||
void ClearHistory(unsigned int windowId = 0)
|
||||
{
|
||||
Initialize(windowId);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::ModeScientific);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::Command1);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::CommandADD);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::Command2);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::CommandEQU);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::ModeBasic);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::Command1);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::CommandADD);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::Command2);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::CommandEQU);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::ModeScientific);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::Command1);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandADD);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::Command2);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandEQU);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::ModeBasic);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::Command1);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandADD);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::Command2);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandEQU);
|
||||
m_historyViewModel->OnClearCommand(nullptr);
|
||||
VERIFY_ARE_EQUAL(0, m_historyViewModel->ItemSize);
|
||||
VERIFY_IS_TRUE(IsHistoryContainerEmpty(GetHistoryContainerKeyHelper(CM_STD)));
|
||||
|
@ -213,15 +213,15 @@ namespace CalculatorFunctionalTests
|
|||
void SerializeDeSerializeHistoryItem(unsigned int windowId = 0)
|
||||
{
|
||||
Initialize(windowId);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::ModeScientific);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::Command1);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::CommandADD);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::Command2);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::CommandEQU);
|
||||
auto itemBeforeSerializeDeserialize = m_standardViewModel->m_standardCalculatorManager->GetHistoryItem(0);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::ModeScientific);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::Command1);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandADD);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::Command2);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandEQU);
|
||||
auto itemBeforeSerializeDeserialize = m_standardViewModel->m_standardCalculatorManager.GetHistoryItem(0);
|
||||
m_historyViewModel->SaveHistory();
|
||||
m_historyViewModel->ReloadHistory(ViewMode::Scientific);
|
||||
auto itemAfterSerializeDeserialize = m_standardViewModel->m_standardCalculatorManager->GetHistoryItem(0);
|
||||
auto itemAfterSerializeDeserialize = m_standardViewModel->m_standardCalculatorManager.GetHistoryItem(0);
|
||||
VERIFY_IS_TRUE((itemBeforeSerializeDeserialize->historyItemVector.expression == itemAfterSerializeDeserialize->historyItemVector.expression) && (itemBeforeSerializeDeserialize->historyItemVector.result == itemAfterSerializeDeserialize->historyItemVector.result) && (itemBeforeSerializeDeserialize->historyItemVector.spCommands == itemAfterSerializeDeserialize->historyItemVector.spCommands) && (itemBeforeSerializeDeserialize->historyItemVector.spTokens == itemAfterSerializeDeserialize->historyItemVector.spTokens));
|
||||
Cleanup(windowId);
|
||||
}
|
||||
|
@ -229,30 +229,30 @@ namespace CalculatorFunctionalTests
|
|||
void SaveAndReloadHistory(unsigned int windowid = 0)
|
||||
{
|
||||
Initialize(windowid);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::ModeScientific);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::Command1);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::CommandADD);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::Command8);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::CommandEQU);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::Command1);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::CommandADD);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::Command2);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::CommandEQU);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::ModeBasic);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::Command1);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::CommandADD);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::Command6);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::CommandEQU);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::ModeScientific);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::Command1);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandADD);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::Command8);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandEQU);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::Command1);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandADD);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::Command2);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandEQU);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::ModeBasic);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::Command1);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandADD);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::Command6);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandEQU);
|
||||
int itemsBeforeSaveAndReload = m_historyViewModel->ItemSize;
|
||||
m_historyViewModel->SaveHistory();
|
||||
m_historyViewModel->ReloadHistory(ViewMode::Scientific);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::ModeScientific);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::ModeScientific);
|
||||
wstring expr = L"1 + 8 =";
|
||||
// add double quotes around the expression
|
||||
expr = UtfUtils::LRO + expr + UtfUtils::PDF;
|
||||
String ^result = StringReference(L"9");
|
||||
int itemsAfterSaveAndReload = m_historyViewModel->ItemSize;
|
||||
auto historyItem = m_standardViewModel->m_standardCalculatorManager->GetHistoryItem(0);
|
||||
auto historyItem = m_standardViewModel->m_standardCalculatorManager.GetHistoryItem(0);
|
||||
|
||||
VERIFY_ARE_EQUAL(expr, historyItem->historyItemVector.expression);
|
||||
VERIFY_ARE_EQUAL(result, StringReference(historyItem->historyItemVector.result.c_str()));
|
||||
|
@ -271,16 +271,16 @@ namespace CalculatorFunctionalTests
|
|||
ResourceLoader^ m_uiResourceLoader = ResourceLoader::GetForViewIndependentUse(L"CEngineStrings");
|
||||
int itemIndex = 0;
|
||||
int commandResource = 67;
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::ModeScientific);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::ModeScientific);
|
||||
for (int index = 0; index < modes; index++)
|
||||
{
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(mode[index]);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(mode[index]);
|
||||
for (int command = 0; command < commandsSize; command++)
|
||||
{
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::Command1);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(commands[command]);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::CommandEQU);
|
||||
auto historyItem = m_standardViewModel->m_standardCalculatorManager->GetHistoryItem(itemIndex);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::Command1);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(commands[command]);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandEQU);
|
||||
auto historyItem = m_standardViewModel->m_standardCalculatorManager.GetHistoryItem(itemIndex);
|
||||
String^ expression = m_uiResourceLoader->GetString(commandResource.ToString());
|
||||
expression += L"( 1 ) =";
|
||||
wstring expr = wstring(expression->Data());
|
||||
|
@ -297,20 +297,20 @@ namespace CalculatorFunctionalTests
|
|||
{
|
||||
Initialize(windowId);
|
||||
ResourceLoader^ m_uiResourceLoader = ResourceLoader::GetForViewIndependentUse(L"CEngineStrings");
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::ModeScientific);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::CommandDEG);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::Command1);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::CommandSIN);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::CommandADD);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::CommandRAD);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::Command1);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::CommandSIN);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::CommandADD);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::CommandGRAD);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::Command1);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::CommandSIN);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::CommandEQU);
|
||||
auto historyItem = m_standardViewModel->m_standardCalculatorManager->GetHistoryItem(0);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::ModeScientific);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandDEG);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::Command1);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandSIN);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandADD);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandRAD);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::Command1);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandSIN);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandADD);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandGRAD);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::Command1);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandSIN);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandEQU);
|
||||
auto historyItem = m_standardViewModel->m_standardCalculatorManager.GetHistoryItem(0);
|
||||
String^ expression = m_uiResourceLoader->GetString(L"67");
|
||||
expression += L"( 1 ) + ";
|
||||
expression += m_uiResourceLoader->GetString(L"73");
|
||||
|
@ -327,14 +327,14 @@ namespace CalculatorFunctionalTests
|
|||
void HistoryItemClicked(unsigned int windowId = 0)
|
||||
{
|
||||
Initialize(windowId);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::ModeScientific);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::Command1);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::CommandADD);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::Command5);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::CommandADD);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::Command3);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::CommandEQU);
|
||||
auto historyItem = m_standardViewModel->m_standardCalculatorManager->GetHistoryItem(0);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::ModeScientific);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::Command1);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandADD);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::Command5);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandADD);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::Command3);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandEQU);
|
||||
auto historyItem = m_standardViewModel->m_standardCalculatorManager.GetHistoryItem(0);
|
||||
String^ expression = StringReference(historyItem->historyItemVector.expression.c_str());
|
||||
String^ result = StringReference(historyItem->historyItemVector.result.c_str());
|
||||
HistoryItemViewModel ^ item = ref new HistoryItemViewModel(expression, result, historyItem->historyItemVector.spTokens, historyItem->historyItemVector.spCommands);
|
||||
|
@ -354,32 +354,32 @@ namespace CalculatorFunctionalTests
|
|||
void HistoryItemLoadAndContinueCalculation(unsigned int windowId = 0)
|
||||
{
|
||||
Initialize(windowId);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::ModeBasic);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::Command1);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::CommandADD);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::Command5);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::CommandADD);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::Command3);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::CommandEQU);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::ModeBasic);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::Command1);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandADD);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::Command5);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandADD);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::Command3);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandEQU);
|
||||
|
||||
auto historyItem = m_standardViewModel->m_standardCalculatorManager->GetHistoryItem(0);
|
||||
auto historyItem = m_standardViewModel->m_standardCalculatorManager.GetHistoryItem(0);
|
||||
String^ expression = StringReference(historyItem->historyItemVector.expression.c_str());
|
||||
String^ result = StringReference(historyItem->historyItemVector.result.c_str());
|
||||
HistoryItemViewModel ^ item = ref new HistoryItemViewModel(expression, result, historyItem->historyItemVector.spTokens, historyItem->historyItemVector.spCommands);
|
||||
MockOnHistoryItemClicked(item);
|
||||
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::CommandADD);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::Command5);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::CommandEQU);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandADD);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::Command5);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandEQU);
|
||||
VERIFY_ARE_EQUAL(StringReference(L"14"), m_standardViewModel->DisplayValue);
|
||||
historyItem = m_standardViewModel->m_standardCalculatorManager->GetHistoryItem(0);
|
||||
historyItem = m_standardViewModel->m_standardCalculatorManager.GetHistoryItem(0);
|
||||
expression = StringReference(historyItem->historyItemVector.expression.c_str());
|
||||
result = StringReference(historyItem->historyItemVector.result.c_str());
|
||||
item = ref new HistoryItemViewModel(expression, result, historyItem->historyItemVector.spTokens, historyItem->historyItemVector.spCommands);
|
||||
MockOnHistoryItemClicked(item);
|
||||
VERIFY_ARE_EQUAL(StringReference(L"9"), m_standardViewModel->DisplayValue);
|
||||
|
||||
historyItem = m_standardViewModel->m_standardCalculatorManager->GetHistoryItem(1);
|
||||
historyItem = m_standardViewModel->m_standardCalculatorManager.GetHistoryItem(1);
|
||||
expression = StringReference(historyItem->historyItemVector.expression.c_str());
|
||||
result = StringReference(historyItem->historyItemVector.result.c_str());
|
||||
item = ref new HistoryItemViewModel(expression, result, historyItem->historyItemVector.spTokens, historyItem->historyItemVector.spCommands);
|
||||
|
@ -391,26 +391,26 @@ namespace CalculatorFunctionalTests
|
|||
void DisplayValueAutomationNames(unsigned int windowId = 0)
|
||||
{
|
||||
Initialize(windowId);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::Command1);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::CommandADD);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::Command8);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::CommandEQU);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::Command1);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandADD);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::Command8);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandEQU);
|
||||
String ^expression = StringReference(L"Display is 9");
|
||||
VERIFY_ARE_EQUAL(expression, m_standardViewModel->CalculationResultAutomationName);
|
||||
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::ModeScientific);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::Command1);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::CommandADD);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::Command5);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::CommandEQU);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::ModeScientific);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::Command1);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandADD);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::Command5);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandEQU);
|
||||
expression = StringReference(L"Display is 6");
|
||||
VERIFY_ARE_EQUAL(expression, m_standardViewModel->CalculationResultAutomationName);
|
||||
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::ModeProgrammer);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::Command1);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::CommandADD);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::Command2);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::CommandEQU);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::ModeProgrammer);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::Command1);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandADD);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::Command2);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandEQU);
|
||||
expression = StringReference(L"Display is 3");
|
||||
VERIFY_ARE_EQUAL(expression, m_standardViewModel->CalculationResultAutomationName);
|
||||
|
||||
|
@ -420,12 +420,12 @@ namespace CalculatorFunctionalTests
|
|||
void RadixAutomationName(unsigned int windowId = 0)
|
||||
{
|
||||
Initialize(windowId);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::ModeProgrammer);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::ModeProgrammer);
|
||||
m_standardViewModel->IsProgrammer = true;
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::Command1);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::CommandADD);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::Command7);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::CommandEQU);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::Command1);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandADD);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::Command7);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandEQU);
|
||||
String ^expression = L"HexaDecimal" + L" 8";
|
||||
String ^result = L"HexaDecimal " + Utils::GetStringValue(m_standardViewModel->HexDisplayValue);
|
||||
VERIFY_ARE_EQUAL(expression, result);
|
||||
|
@ -442,7 +442,7 @@ namespace CalculatorFunctionalTests
|
|||
{
|
||||
Initialize(windowId);
|
||||
VERIFY_ARE_EQUAL(0, m_historyViewModel->ItemSize);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::ModeScientific);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::ModeScientific);
|
||||
VERIFY_ARE_EQUAL(0, m_historyViewModel->ItemSize);
|
||||
Cleanup(windowId);
|
||||
}
|
||||
|
@ -451,7 +451,7 @@ namespace CalculatorFunctionalTests
|
|||
{
|
||||
Initialize(windowId);
|
||||
VERIFY_ARE_EQUAL(0, m_historyViewModel->ItemSize);
|
||||
m_standardViewModel->m_standardCalculatorManager->SendCommand(Command::ModeScientific);
|
||||
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::ModeScientific);
|
||||
m_historyViewModel->OnClearCommand(nullptr);
|
||||
VERIFY_ARE_EQUAL(0, m_historyViewModel->ItemSize);
|
||||
Cleanup(windowId);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#include "pch.h"
|
||||
|
@ -411,7 +411,7 @@ namespace CalculatorUnitTests
|
|||
ChangeMode(viewModels[i], i);
|
||||
|
||||
// Validate that the history items list is initially empty
|
||||
VERIFY_IS_TRUE(0 == viewModels[i]->m_standardCalculatorManager->GetHistoryItems().size());
|
||||
VERIFY_IS_TRUE(0 == viewModels[i]->m_standardCalculatorManager.GetHistoryItems().size());
|
||||
}
|
||||
|
||||
// Perform Calculations on both the instances and check that the History items work independently
|
||||
|
@ -440,9 +440,9 @@ namespace CalculatorUnitTests
|
|||
ValidateViewModelByCommands(viewModels[1], scientificModeTestItems, true);
|
||||
|
||||
// Assert for the history list items of 1st instance
|
||||
VERIFY_IS_TRUE(1 == viewModels[0]->m_standardCalculatorManager->GetHistoryItems().size());
|
||||
VERIFY_IS_TRUE(1 == viewModels[0]->m_standardCalculatorManager.GetHistoryItems().size());
|
||||
|
||||
auto item1 = viewModels[0]->m_standardCalculatorManager->GetHistoryItem(0);
|
||||
auto item1 = viewModels[0]->m_standardCalculatorManager.GetHistoryItem(0);
|
||||
String ^expression1 = UtfUtils::LRO + L"1 + 2 =" + UtfUtils::PDF;
|
||||
String^ result1 = L"3";
|
||||
|
||||
|
@ -450,9 +450,9 @@ namespace CalculatorUnitTests
|
|||
VERIFY_ARE_EQUAL(result1, StringReference(item1->historyItemVector.result.c_str()));
|
||||
|
||||
// Assert for the history list items of 2nd instance
|
||||
VERIFY_IS_TRUE(1 == viewModels[1]->m_standardCalculatorManager->GetHistoryItems().size());
|
||||
VERIFY_IS_TRUE(1 == viewModels[1]->m_standardCalculatorManager.GetHistoryItems().size());
|
||||
|
||||
auto item2 = viewModels[1]->m_standardCalculatorManager->GetHistoryItem(0);
|
||||
auto item2 = viewModels[1]->m_standardCalculatorManager.GetHistoryItem(0);
|
||||
String^ expression2 = UtfUtils::LRO + L"1 + 2 " + UtfUtils::MUL + L" 3 =" + UtfUtils::PDF;
|
||||
String^ result2 = L"7";
|
||||
|
||||
|
@ -474,7 +474,7 @@ namespace CalculatorUnitTests
|
|||
ChangeMode(viewModels[i], 0);
|
||||
|
||||
// Validate that the history items list is initially empty
|
||||
VERIFY_IS_TRUE(0 == viewModels[i]->m_standardCalculatorManager->GetHistoryItems().size());
|
||||
VERIFY_IS_TRUE(0 == viewModels[i]->m_standardCalculatorManager.GetHistoryItems().size());
|
||||
}
|
||||
|
||||
// Perform Calculations on both the instances and check that the History items work independently
|
||||
|
@ -513,9 +513,9 @@ namespace CalculatorUnitTests
|
|||
// Assert for the history list items of the instances
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
VERIFY_IS_TRUE(1 == viewModels[i]->m_standardCalculatorManager->GetHistoryItems().size());
|
||||
VERIFY_IS_TRUE(1 == viewModels[i]->m_standardCalculatorManager.GetHistoryItems().size());
|
||||
|
||||
auto item = viewModels[i]->m_standardCalculatorManager->GetHistoryItem(0);
|
||||
auto item = viewModels[i]->m_standardCalculatorManager.GetHistoryItem(0);
|
||||
|
||||
VERIFY_ARE_EQUAL(expression[i], StringReference(item->historyItemVector.expression.c_str()));
|
||||
VERIFY_ARE_EQUAL(result[i], StringReference(item->historyItemVector.result.c_str()));
|
||||
|
@ -536,7 +536,7 @@ namespace CalculatorUnitTests
|
|||
ChangeMode(viewModels[i], 1);
|
||||
|
||||
// Validate that the history items list is initially empty
|
||||
VERIFY_IS_TRUE(0 == viewModels[i]->m_standardCalculatorManager->GetHistoryItems().size());
|
||||
VERIFY_IS_TRUE(0 == viewModels[i]->m_standardCalculatorManager.GetHistoryItems().size());
|
||||
}
|
||||
|
||||
// Perform Calculations on both the instances and check that the History items work independently
|
||||
|
@ -575,9 +575,9 @@ namespace CalculatorUnitTests
|
|||
// Assert for the history list items of the instances
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
VERIFY_IS_TRUE(1 == viewModels[i]->m_standardCalculatorManager->GetHistoryItems().size());
|
||||
VERIFY_IS_TRUE(1 == viewModels[i]->m_standardCalculatorManager.GetHistoryItems().size());
|
||||
|
||||
auto item = viewModels[i]->m_standardCalculatorManager->GetHistoryItem(0);
|
||||
auto item = viewModels[i]->m_standardCalculatorManager.GetHistoryItem(0);
|
||||
|
||||
VERIFY_ARE_EQUAL(expression[i], StringReference(item->historyItemVector.expression.c_str()));
|
||||
VERIFY_ARE_EQUAL(result[i], StringReference(item->historyItemVector.result.c_str()));
|
||||
|
|
Загрузка…
Ссылка в новой задаче