From 75461a26a74a4d9cb60020ccfcb2a5a4ec0961bd Mon Sep 17 00:00:00 2001 From: Jules Clero Date: Fri, 4 Jul 2014 15:51:07 +0200 Subject: Fix test-platform set criterion by Lexical State Bug BZ: 213233 The setCriterionState command of the Test Platform was setting undesired value when asking for multiple states to an InclusiveCriterion. The method used in setCriterionStateByLexicalSpace was to parse arguments before to get numerical value for each of them with the getNumericalValue method from ISelectionCriterionTypeInterface. Then, different masks were aggregated to set the criterion's state. Regarding the getNumericalValue method behaviour which parses automatically value arguments, this method leads to undesired bytes in the mask which leads to undesired criterion's state. The solution is to aggregate the setCriterionState arguments when more than one arg are used. As getNumericalValue use | to split his first parameter, the code has been modified to use this behaviour. getNumericalValue is now called only one time and the returned mask is directly used to set criterion's state. Change-Id: Ie3a1d79a6f66928a2418f11233ff0d1ef5c3e900 Signed-off-by: Jules Clero --- test/test-platform/TestPlatform.cpp | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/test/test-platform/TestPlatform.cpp b/test/test-platform/TestPlatform.cpp index b2b895c..e4b7ee1 100644 --- a/test/test-platform/TestPlatform.cpp +++ b/test/test-platform/TestPlatform.cpp @@ -462,30 +462,35 @@ bool CTestPlatform::setCriterionStateByLexicalSpace(const IRemoteCommand& remote } /// Translate lexical state to numerical state - uint32_t uiNumericalState = 0; + int iNumericalState = 0; uint32_t uiLexicalSubStateIndex; // Parse lexical substates + std::string strLexicalState = ""; for (uiLexicalSubStateIndex = 1; uiLexicalSubStateIndex <= uiNbSubStates; uiLexicalSubStateIndex++) { + /* + * getNumericalValue method from ISelectionCriterionTypeInterface strip his parameter + * first parameter based on | sign. In case that the user uses multiple parameters + * to set InclusiveCriterion value, we aggregate all desired values to be sure + * they will be handled correctly. + */ + if (uiLexicalSubStateIndex != 1) { + strLexicalState += "|"; + } + strLexicalState += remoteCommand.getArgument(uiLexicalSubStateIndex); + } - int iNumericalSubState; - - const std::string& strLexicalSubState = remoteCommand.getArgument(uiLexicalSubStateIndex); - - // Translate lexical to numerical substate - if (!pCriterionType->getNumericalValue(strLexicalSubState, iNumericalSubState)) { - - strResult = "Unable to find lexical state \"" + strLexicalSubState + "\" in criteria " + strCriterionName; + // Translate lexical to numerical substate + if (!pCriterionType->getNumericalValue(strLexicalState, iNumericalState)) { - return false; - } + strResult = "Unable to find lexical state \"" + + strLexicalState + "\" in criteria " + strCriterionName; - // Aggregate numerical substates - uiNumericalState |= iNumericalSubState; + return false; } // Set criterion new state - pCriterion->setCriterionState(uiNumericalState); + pCriterion->setCriterionState(iNumericalState); return true; } -- cgit v1.1