diff options
author | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-25 19:04:49 +0000 |
---|---|---|
committer | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-25 19:04:49 +0000 |
commit | d70d82db35eecb586629a05bffc580282c0c30b4 (patch) | |
tree | 05a9b5c78c89d4c32e67c9d873dbdb12369545b1 | |
parent | 88bfc75e6658b3820babff8b4983a93e5f67d5e1 (diff) | |
download | chromium_src-d70d82db35eecb586629a05bffc580282c0c30b4.zip chromium_src-d70d82db35eecb586629a05bffc580282c0c30b4.tar.gz chromium_src-d70d82db35eecb586629a05bffc580282c0c30b4.tar.bz2 |
Revert 202305 "Destroy all Singletons and LazyInstances between ..."
> Destroy all Singletons and LazyInstances between each test.
>
> This modifies base::TestSuite to add a test listener that runs the AtExitManager
> between each test.
>
> BUG=110594, 156433, 238654
> TEST=*unit*tests
> R=apatrick@chromium.org, gspencer@chromium.org, phajdan.jr@chromium.org, pneubeck@chromium.org, rsleevi@chromium.org
>
> Review URL: https://codereview.chromium.org/8947021
TBR=rsesek@chromium.org
Review URL: https://codereview.chromium.org/16063002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@202312 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | base/test/test_suite.cc | 30 | ||||
-rw-r--r-- | chromeos/network/onc/onc_certificate_importer_unittest.cc | 5 | ||||
-rw-r--r-- | crypto/nss_util.cc | 5 | ||||
-rw-r--r-- | gpu/command_buffer/service/shader_translator.cc | 11 |
4 files changed, 7 insertions, 44 deletions
diff --git a/base/test/test_suite.cc b/base/test/test_suite.cc index 2d526927..07b9964 100644 --- a/base/test/test_suite.cc +++ b/base/test/test_suite.cc @@ -76,30 +76,6 @@ class TestClientInitializer : public testing::EmptyTestEventListener { DISALLOW_COPY_AND_ASSIGN(TestClientInitializer); }; -// This class forces the destruction of all Singletons and LazyInstances -// between tests. Deleting singletons between each test prevents state from -// being shared amongst tests, which can lead to subtle bugs in tests. -class SingletonDestructor : public testing::EmptyTestEventListener { - public: - SingletonDestructor() {} - virtual ~SingletonDestructor() {} - - // testing::EmptyTestEventListener: - virtual void OnTestStart( - const testing::TestInfo& test_info) OVERRIDE { - at_exit_manager_.reset(new base::ShadowingAtExitManager); - } - - virtual void OnTestEnd(const testing::TestInfo& test_info) OVERRIDE { - at_exit_manager_.reset(); - } - - private: - scoped_ptr<base::ShadowingAtExitManager> at_exit_manager_; - - DISALLOW_COPY_AND_ASSIGN(SingletonDestructor); -}; - } // namespace TestSuite::TestSuite(int argc, char** argv) : initialized_command_line_(false) { @@ -276,12 +252,6 @@ void TestSuite::Initialize() { CatchMaybeTests(); ResetCommandLine(); - // Add a listener to destroy all Singletons and LazyInstances between each - // test. See SingletonDestructor for more information. - testing::TestEventListeners& listeners = - testing::UnitTest::GetInstance()->listeners(); - listeners.Append(new SingletonDestructor); - TestTimeouts::Initialize(); } diff --git a/chromeos/network/onc/onc_certificate_importer_unittest.cc b/chromeos/network/onc/onc_certificate_importer_unittest.cc index fba0871f..1fbb633 100644 --- a/chromeos/network/onc/onc_certificate_importer_unittest.cc +++ b/chromeos/network/onc/onc_certificate_importer_unittest.cc @@ -12,7 +12,6 @@ #include "base/logging.h" #include "base/string_number_conversions.h" -#include "base/threading/platform_thread.h" #include "base/values.h" #include "chromeos/network/onc/onc_constants.h" #include "chromeos/network/onc/onc_test_utils.h" @@ -81,10 +80,6 @@ class ONCCertificateImporterTest : public testing::Test { void AddCertificatesFromFile( std::string filename, CertificateImporter::ParseResult expected_parse_result) { - // This 1 second sleep is necessary because NSS has a caching bug. This - // can be removed once http://crbug.com/238654 is fixed. - base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(1)); - scoped_ptr<base::DictionaryValue> onc = test_utils::ReadTestDictionary(filename); base::Value* certificates_value = NULL; diff --git a/crypto/nss_util.cc b/crypto/nss_util.cc index b3fe4a2..9cd0cd1 100644 --- a/crypto/nss_util.cc +++ b/crypto/nss_util.cc @@ -746,8 +746,9 @@ ScopedTestNSSDB::ScopedTestNSSDB() } ScopedTestNSSDB::~ScopedTestNSSDB() { - if (NSS_VersionCheck("3.14")) - g_nss_singleton.Get().CloseTestNSSDB(); + // TODO(mattm): Close the dababase once NSS 3.14 is required, + // which fixes https://bugzilla.mozilla.org/show_bug.cgi?id=588269 + // Resource leaks are suppressed. http://crbug.com/156433 . } base::Lock* GetNSSWriteLock() { diff --git a/gpu/command_buffer/service/shader_translator.cc b/gpu/command_buffer/service/shader_translator.cc index b70821e..3bd2a97 100644 --- a/gpu/command_buffer/service/shader_translator.cc +++ b/gpu/command_buffer/service/shader_translator.cc @@ -16,23 +16,20 @@ namespace { using gpu::gles2::ShaderTranslator; -static bool g_shader_initalized = false; - void FinalizeShaderTranslator(void* /* dummy */) { TRACE_EVENT0("gpu", "ShFinalize"); ShFinalize(); - DCHECK(g_shader_initalized); - g_shader_initalized = false; } bool InitializeShaderTranslator() { - if (!g_shader_initalized) { + static bool initialized = false; + if (!initialized) { TRACE_EVENT0("gpu", "ShInitialize"); CHECK(ShInitialize()); base::AtExitManager::RegisterCallback(&FinalizeShaderTranslator, NULL); - g_shader_initalized = true; + initialized = true; } - return g_shader_initalized; + return initialized; } #if !defined(ANGLE_SH_VERSION) || ANGLE_SH_VERSION < 108 |