[Dev] Content item initialization

Bryan Stearns stearns at osafoundation.org
Mon Jan 24 11:11:10 PST 2005


I recently added a couple of (boolean) attributes to CalendarEventMixin, 
and I'm confused about the way they're being initialized:

- None of the existing attributes have initialValues in the 
content-model parcel.xml, though that seems to be to be the right place 
to define them.
- I saw other attributes being initialized in CalendarEventMixin's 
_initMixin(), so I defined mine there; _initMixin() is called by 
InitOutgoingAttributes(), which is called by MainView's onNewEvent(), so 
this worked.
- When I ran the unit tests, however, the calendar tests failed: simply 
creating a CalendarEvent() (that is, just using its constructor) doesn't 
call InitOutgoingAttributes(), so I had to initialize my new attributes 
in the unit tests separately (just like other attributes were being 
explicitly initialized in the unit tests). This allowed the unit tests 
to succeed.

It bothers me that I need to remember to initialize attributes in two 
different places (especially since one place is solely to support unit 
testing; this seems to make our unit tests less rigorous). Shouldn't we 
use initialValues?

...Bryan



More information about the Dev mailing list