[chromium-dev] Re: Singleton, LazyInstance, and testability

2009-11-04 Thread John Abd-El-Malek
On Tue, Nov 3, 2009 at 11:49 PM, Paweł Hajdan Jr. wrote: > I encountered another problem related to Singletons in unit tests. > PluginService is a Singleton, and it listens to extensions notifications. In > one of my tests when I was using the extensions notifications the > PluginService crashed b

[chromium-dev] Re: Singleton, LazyInstance, and testability

2009-11-04 Thread Aaron Boodman
On Wed, Nov 4, 2009 at 8:17 AM, Paweł Hajdan Jr. wrote: > Oh, indeed. Thanks, after looking at other tests it was easy. It was a bit > annoying that I had to use #ifdefs for FilePath though. You may be able to just specify an empty FilePath() ? I'm not sure. Give it a try. - a --~--~-~

[chromium-dev] Re: Singleton, LazyInstance, and testability

2009-11-04 Thread Paweł Hajdan Jr .
So, the problem with Extensions has been solved (thanks to Aaron), but there's stil the original issue that may bite at any time (please see the first message for context): Is there a big difference between a Singleton and LazyInstance? I was > thinking about making NPAPI::PluginList a Singleton i

[chromium-dev] Re: Singleton, LazyInstance, and testability

2009-11-04 Thread Aaron Boodman
On Wed, Nov 4, 2009 at 12:12 AM, Paweł Hajdan Jr. wrote: > On Wed, Nov 4, 2009 at 08:56, Aaron Boodman wrote: >> >> Why don't you pass an Extension instance? > > It's in a test. Mocking an Extension is not trivial as well. :( Or maybe... > I didn't read all of the extensions unit tests, maybe it

[chromium-dev] Re: Singleton, LazyInstance, and testability

2009-11-04 Thread Paweł Hajdan Jr .
On Wed, Nov 4, 2009 at 08:56, Aaron Boodman wrote: > Why don't you pass an Extension instance? It's in a test. Mocking an Extension is not trivial as well. :( Or maybe... I didn't read all of the extensions unit tests, maybe it's not that hard. > It seems like you are violating the contract o

[chromium-dev] Re: Singleton, LazyInstance, and testability

2009-11-03 Thread Aaron Boodman
Why don't you pass an Extension instance? It seems like you are violating the contract of that notification by not doing so, and even if you solve this problem, other similar problems would be likely to happen again in the future. - a On Tue, Nov 3, 2009 at 11:49 PM, Paweł Hajdan Jr. wrote: > I