TEST(Account, shouldTriggerMemberObserverEvents) { // given Account acc; MockModelObserver obs(acc); { InSequence dummy; EXPECT_CALL(obs, willChange("name")); EXPECT_CALL(obs, didChange("name")); EXPECT_CALL(obs, willChange("descr")); EXPECT_CALL(obs, didChange("descr")); EXPECT_CALL(obs, willChange("type")); EXPECT_CALL(obs, didChange("type")); } // when acc.setName("A name"); acc.setDescr("A descr"); acc.setType(Account::AccountType::Asset); // then // mock expectations implicitly verified }
void VTTCue::setVertical(const String& value, ExceptionCode& ec) { // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-vertical // On setting, the text track cue writing direction must be set to the value given // in the first cell of the row in the table above whose second cell is a // case-sensitive match for the new value, if any. If none of the values match, then // the user agent must instead throw a SyntaxError exception. WritingDirection direction = m_writingDirection; if (value == horizontalKeyword()) direction = Horizontal; else if (value == verticalGrowingLeftKeyword()) direction = VerticalGrowingLeft; else if (value == verticalGrowingRightKeyword()) direction = VerticalGrowingRight; else ec = SYNTAX_ERR; if (direction == m_writingDirection) return; willChange(); m_writingDirection = direction; didChange(); }
void hdLineConnection::addPoint (int posIdx, int x, int y) { willChange(); points[posIdx]->addItem((hdObject *) new hdPoint(x, y) ); //Update handles if(points[posIdx]->count() == 1) { //first point add start handle if(handles->count() == 0) handles->addItem(getStartHandle()); } else if(points[posIdx]->count() == 2) { //second point add end handle if(handles->count() == 1) handles->addItem(getEndHandle()); } else if(points[posIdx]->count() > 2) { //Locate maximum index if there is need for one new handle then added it if( getMaximunIndex() > handles->count() ) { //third and above point, add a polylinehandle before end handle handles->insertAtIndex(new hdPolyLineHandle(this, new hdPolyLineLocator(0), 0), handles->count() - 1); } } updateHandlesIndexes(); changed(posIdx); }
void VTTCue::setAlign(const String& value, ExceptionCode& ec) { // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-align // On setting, the text track cue alignment must be set to the value given in the // first cell of the row in the table above whose second cell is a case-sensitive // match for the new value, if any. If none of the values match, then the user // agent must instead throw a SyntaxError exception. CueAlignment alignment = m_cueAlignment; if (value == startKeyword()) alignment = Start; else if (value == middleKeyword()) alignment = Middle; else if (value == endKeyword()) alignment = End; else if (value == leftKeyword()) alignment = Left; else if (value == rightKeyword()) alignment = Right; else ec = SYNTAX_ERR; if (alignment == m_cueAlignment) return; willChange(); m_cueAlignment = alignment; didChange(); }
TEST(Account, shouldTriggerParentChildrenObserverEvents) { // given AccountPtr parentAcc(new Account()); MockModelObserver parentObs(*parentAcc); AccountPtr childAcc1(new Account()); MockModelObserver childObs1(*childAcc1); AccountPtr childAcc2(new Account()); MockModelObserver childObs2(*childAcc2); { using ChangeType = opencash::core::ObservableModel::ChangeType; InSequence dummy; EXPECT_CALL(childObs1, willChange("parent")); EXPECT_CALL(parentObs, willChangeAtIndex("children", 0, ChangeType::Insertion)); EXPECT_CALL(parentObs, didChangeAtIndex("children", 0, ChangeType::Insertion)); EXPECT_CALL(childObs1, didChange("parent")); EXPECT_CALL(childObs2, willChange("parent")); EXPECT_CALL(parentObs, willChangeAtIndex("children", 1, ChangeType::Insertion)); EXPECT_CALL(parentObs, didChangeAtIndex("children", 1, ChangeType::Insertion)); EXPECT_CALL(childObs2, didChange("parent")); EXPECT_CALL(childObs2, willChange("parent")); EXPECT_CALL(parentObs, willChangeAtIndex("children", 1, ChangeType::Removal)); EXPECT_CALL(parentObs, didChangeAtIndex("children", 1, ChangeType::Removal)); EXPECT_CALL(childObs2, didChange("parent")); EXPECT_CALL(childObs1, willChange("parent")); EXPECT_CALL(parentObs, willChangeAtIndex("children", 0, ChangeType::Removal)); EXPECT_CALL(parentObs, didChangeAtIndex("children", 0, ChangeType::Removal)); EXPECT_CALL(childObs1, didChange("parent")); } // when childAcc1->setParent(parentAcc); childAcc2->setParent(parentAcc); childAcc2->unsetParent(); childAcc1->unsetParent(); // then // mock expectations implicitly verified }
void hdPolyLineFigure::setPointAt (int posIdx, int index, int x, int y) { willChange(); hdPoint *p = (hdPoint *) points[posIdx]->getItemAt(index); p->x = x; p->y = y; changed(posIdx); }
void VTTCue::setRegionId(const String& regionId) { if (m_regionId == regionId) return; willChange(); m_regionId = regionId; didChange(); }
void TextTrackCue::setId(const String& id) { if (m_id == id) return; willChange(); m_id = id; didChange(); }
void Split::setAccount(AccountWeakPtr account) { if(_account.lock() == account.lock()) return; willChange("account"); if(_account.lock()) _account.lock()->removeSplit(shared_from_this()); _account = account; if(_account.lock()) _account.lock()->addSplit(shared_from_this()); didChange("account"); }
void Split::setTransaction(TransactionWeakPtr transaction) { if(_transaction.lock() == transaction.lock()) return; willChange("transaction"); if(_transaction.lock()) _transaction.lock()->removeSplit(shared_from_this()); _transaction = transaction; if(_transaction.lock()) _transaction.lock()->addSplit(shared_from_this()); didChange("transaction"); }
void VTTCue::setSnapToLines(bool value) { if (m_snapToLines == value) return; willChange(); m_snapToLines = value; didChange(); }
void VTTCue::setText(const String& text) { if (m_content == text) return; willChange(); // Clear the document fragment but don't bother to create it again just yet as we can do that // when it is requested. m_webVTTNodeTree = 0; m_content = text; didChange(); }
void hdPolyLineFigure::setEndPoint(int posIdx, hdPoint point) { willChange(); if(points[posIdx]->count() < 2) addPoint(posIdx, point.x, point.y); else { hdPoint *p = (hdPoint *) points[posIdx]->getItemAt(points[posIdx]->count() - 1); p->x = point.x; p->y = point.y; } changed(posIdx); }
void hdPolyLineFigure::addPoint (int posIdx, int x, int y) { willChange(); points[posIdx]->addItem((hdObject *) new hdPoint(x, y) ); if( handles->count() < getMaximunIndex() ) { //Update handles handles->addItem(new hdPolyLineHandle(this, new hdPolyLineLocator(0), 0)); updateHandlesIndexes(); } changed(posIdx); }
void hdPolyLineFigure::removePointAt (int posIdx, int index) { willChange(); hdPoint *p = (hdPoint *) points[posIdx]->getItemAt(index); points[posIdx]->removeItemAt(index); delete p; //Update handles [If there are more handles than maximum points of a line in a view] if( handles->count() > getMaximunIndex() ) { handles->removeItemAt(index); updateHandlesIndexes(); } changed(posIdx); }
void hdPolyLineFigure::insertPointAt (int posIdx, int index, int x, int y) { willChange(); points[posIdx]->insertAtIndex((hdObject *) new hdPoint(x, y), index); if( handles->count() < getMaximunIndex() ) { //Update handles handles->insertAtIndex(new hdPolyLineHandle(this, new hdPolyLineLocator(index), index), index); updateHandlesIndexes(); } changed(posIdx); }
TEST(Account, shouldNotTriggerParentChangedWhenUnsettingParentIfAccountHasNoParent) { AccountPtr accountWithoutParent(new Account()); MockModelObserver accountObserver(*accountWithoutParent); EXPECT_CALL(accountObserver, willChange("parent")) .Times(0); EXPECT_CALL(accountObserver, didChange("parent")) .Times(0); // when accountWithoutParent->unsetParent(); // then // mock expectations implicitly verified }
void TextTrackCue::setEndTime(double value, ExceptionCode& ec) { // NaN, Infinity and -Infinity values should trigger a TypeError. if (std::isinf(value) || std::isnan(value)) { ec = TypeError; return; } // TODO(93143): Add spec-compliant behavior for negative time values. if (m_endTime == value || value < 0) return; willChange(); m_endTime = value; didChange(); }
void VTTCue::setSize(int size, ExceptionCode& ec) { // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-size // On setting, if the new value is negative or greater than 100, then throw an IndexSizeError // exception. Otherwise, set the text track cue size to the new value. if (size < 0 || size > 100) { ec = INDEX_SIZE_ERR; return; } // Otherwise, set the text track cue line position to the new value. if (m_cueSize == size) return; willChange(); m_cueSize = size; didChange(); }
void VTTCue::setPosition(double position, ExceptionCode& ec) { // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-position // On setting, if the new value is negative or greater than 100, then throw an IndexSizeError exception. // Otherwise, set the text track cue text position to the new value. if (position < 0 || position > 100) { ec = INDEX_SIZE_ERR; return; } // Otherwise, set the text track cue line position to the new value. if (m_textPosition == position) return; willChange(); m_textPosition = position; didChange(); }
void VTTCue::setLine(double position, ExceptionCode& ec) { // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-line // On setting, if the text track cue snap-to-lines flag is not set, and the new // value is negative or greater than 100, then throw an IndexSizeError exception. if (!m_snapToLines && (position < 0 || position > 100)) { ec = INDEX_SIZE_ERR; return; } // Otherwise, set the text track cue line position to the new value. if (m_linePosition == position) return; willChange(); m_linePosition = position; m_computedLinePosition = calculateComputedLinePosition(); didChange(); }
TEST(Account, shouldNotTriggerParentChangedWhenSettingToSameParent) { // given AccountPtr parentAcc(new Account()); AccountPtr parentAccRef(parentAcc); AccountPtr childAcc1(new Account()); MockModelObserver childObs1(*childAcc1); { InSequence dummy; EXPECT_CALL(childObs1, willChange("parent")); EXPECT_CALL(childObs1, didChange("parent")); } // when childAcc1->setParent(parentAcc); childAcc1->setParent(parentAccRef); // then // mock expectations implicitly verified }
void ddLineConnection::addPoint (int x, int y){ willChange(); points->addItem((ddObject *) new ddPoint(x,y) ); //Update handles if(points->count()==1) { //first point add start handle handles->addItem(getStartHandle()); } else if(points->count()==2) { //second point add end handle handles->addItem(getEndHandle()); } else if(points->count()>2) { //third and above point, add a polylinehandle before end handle handles->insertAtIndex(new ddPolyLineHandle(this, new ddPolyLineLocator(0), 0),handles->count()-1); } updateHandlesIndexes(); changed(); }
void ddLineConnection::insertPointAt (int index, int x, int y) { willChange(); points->insertAtIndex((ddObject*) new ddPoint(x,y), index); //Update handles if(index==0) { //add a new handle "normal" for a point in next position 0,1 in 1... in 0 startHandle is not moved handles->insertAtIndex(new ddPolyLineHandle(this, new ddPolyLineLocator(index), index),1); } else if(index==(points->count()-1)) //last point { //add a new handle "normal" for a point in before last item position handles->insertAtIndex(new ddPolyLineHandle(this, new ddPolyLineLocator(index), index),(points->count()-1)); } else { //add handle at index handles->insertAtIndex(new ddPolyLineHandle(this, new ddPolyLineLocator(index), index),index); } updateHandlesIndexes(); changed(); }
void hdLineConnection::insertPointAt (int posIdx, int index, int x, int y) { willChange(); points[posIdx]->insertAtIndex((hdObject *) new hdPoint(x, y), index); //Update handles //Is there need of a new handle if is first point if(index == 0 && handles->count() == 0 ) { //add a new handle "normal" for a point in next position 0,1 in 1... in 0 startHandle is not moved handles->insertAtIndex(new hdPolyLineHandle(this, new hdPolyLineLocator(index), index), 1); } else if(index == (points[posIdx]->count() - 1) && handles->count() < getMaximunIndex() ) //last point { //add a new handle "normal" for a point in before last item position handles->insertAtIndex(new hdPolyLineHandle(this, new hdPolyLineLocator(index), index), (points[posIdx]->count() - 1)); } else if(handles->count() < getMaximunIndex()) { //add handle at index handles->insertAtIndex(new hdPolyLineHandle(this, new hdPolyLineLocator(index), index), index); } updateHandlesIndexes(); changed(posIdx); }
void TextTrackCue::setEndTime(const MediaTime& value) { willChange(); m_endTime = value; didChange(); }
void TextTrackCue::setStartTime(const MediaTime& value) { willChange(); m_startTime = value; didChange(); }
void Split::setValue(double value) { willChange("value"); _value = value; didChange("value"); }
void hdAbstractFigure::moveBy(int posIdx, int x, int y) { willChange(); basicMoveBy(posIdx, x, y); changed(posIdx); }
void ddAbstractFigure::moveBy(int x, int y){ willChange(); basicMoveBy(x,y); changed(); }