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 because I passed NULL as the Extension* - because the
listener I was testing didn't even read that value, but PluginService did
(it was unexpected).

I tried to fix the issue by adding a shadow AtExitManager to the test which
instantiated PluginService (resource_dispatcher_host_unittest.cc). And then
another crash appeared on Windows: NPAPI::PluginList is a LazyInstance,
which means that the shadow AtExitManager destroyed it, but it didn't
re-instantiate itself the next time it was used.

Is there a big difference between a Singleton and LazyInstance? I was
thinking about making NPAPI::PluginList a Singleton instead...

By the way, I have a more general fix in the queue (an unwanted Singleton
detector). If you're interested, please star http://crbug.com/12710. It
seems that the most recent gtest (1.4.0) has necessary support.

--~--~---------~--~----~------------~-------~--~----~
Chromium Developers mailing list: chromium-dev@googlegroups.com 
View archives, change email options, or unsubscribe: 
    http://groups.google.com/group/chromium-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to