Changeset 4a328f for src/Atom/unittests/AtomObserverUnitTest.cpp
- Timestamp:
- Feb 11, 2016, 8:06:49 AM (9 years ago)
- Branches:
- Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
- Children:
- 5d8f4f
- Parents:
- 7f1865d
- git-author:
- Frederik Heber <heber@…> (12/28/15 15:09:49)
- git-committer:
- Frederik Heber <heber@…> (02/11/16 08:06:49)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Atom/unittests/AtomObserverUnitTest.cpp
r7f1865d r4a328f 68 68 // observer checks that we don't receive general updates ... 69 69 observer = new UpdateCountObserver; 70 // but only specific notifications in observer1 and observer2 71 observer1 = new NotificationObserver( 72 AtomObserver::getInstance().getChannel(AtomObservable::PositionChanged) 73 ); 74 observer2 = new NotificationObserver( 75 AtomObserver::getInstance().getChannel(AtomObservable::ElementChanged) 76 ); 70 AtomObserver::getInstance().signOn(observer); 77 71 78 AtomObserver::getInstance().signOn(observer); 79 AtomObserver::getInstance().signOn(observer1, AtomObservable::PositionChanged); 80 AtomObserver::getInstance().signOn(observer2, AtomObservable::ElementChanged); 72 // but only specific notifications in others observers 73 for (int i=0;i<AtomObservable::NotificationType_MAX; ++i) { 74 specific_observers.push_back(new NotificationObserver( 75 AtomObserver::getInstance().getChannel((enum AtomObservable::NotificationType)i) 76 )); 77 AtomObserver::getInstance().signOn( 78 specific_observers.back(), (enum AtomObservable::NotificationType)i); 79 } 80 81 81 82 82 for(int i=0;i<ATOM_COUNT;++i){ … … 89 89 { 90 90 AtomObserver::getInstance().signOff(observer); 91 AtomObserver::getInstance().signOff(observer1, AtomObservable::PositionChanged); 92 AtomObserver::getInstance().signOff(observer2, AtomObservable::ElementChanged); 91 for (int i=0;i<AtomObservable::NotificationType_MAX; ++i) { 92 AtomObserver::getInstance().signOff(specific_observers[i], (enum AtomObservable::NotificationType)i); 93 delete specific_observers[i]; 94 } 95 specific_observers.clear(); 93 96 94 97 delete observer; 95 delete observer1;96 delete observer2;97 98 98 99 World::purgeInstance(); … … 107 108 // check for zero update 108 109 CPPUNIT_ASSERT_EQUAL( (int)0, observer->updates ); 109 CPPUNIT_ASSERT_EQUAL( false, observer1->wasNotified ); 110 CPPUNIT_ASSERT_EQUAL( false, observer2->wasNotified ); 110 for (int i=0;i<AtomObservable::NotificationType_MAX; ++i) { 111 112 CPPUNIT_ASSERT_EQUAL( false, specific_observers[i]->wasNotified ); 113 } 111 114 } 112 115 … … 120 123 121 124 // check for update 122 CPPUNIT_ASSERT_EQUAL( true, observer1->wasNotified ); 123 CPPUNIT_ASSERT_EQUAL( false, observer2->wasNotified ); 125 for (int i=0;i<AtomObservable::NotificationType_MAX; ++i) { 126 CPPUNIT_ASSERT_EQUAL( (enum AtomObservable::NotificationType)i == AtomObservable::PositionChanged, 127 specific_observers[i]->wasNotified ); 128 } 124 129 CPPUNIT_ASSERT_EQUAL( (int)0, observer->updates ); 125 130 } … … 134 139 135 140 // check for update 136 CPPUNIT_ASSERT_EQUAL( false, observer1->wasNotified ); 137 CPPUNIT_ASSERT_EQUAL( true, observer2->wasNotified ); 141 for (int i=0;i<AtomObservable::NotificationType_MAX; ++i) { 142 CPPUNIT_ASSERT_EQUAL( (enum AtomObservable::NotificationType)i == AtomObservable::ElementChanged, 143 specific_observers[i]->wasNotified ); 144 } 138 145 CPPUNIT_ASSERT_EQUAL( (int)0, observer->updates ); 139 146 }
Note:
See TracChangeset
for help on using the changeset viewer.