summaryrefslogtreecommitdiffstats
path: root/chrome_frame/chrome_frame_unittest_main.cc
diff options
context:
space:
mode:
authortommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-09 02:56:24 +0000
committertommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-09 02:56:24 +0000
commit7dd06a0131c05212100c81ae88ae07f0757ff4db (patch)
tree8b42ff631ecaa927da86b40d47fe6298f972a8a7 /chrome_frame/chrome_frame_unittest_main.cc
parentd077249e28b8163aabf452604716dba216303207 (diff)
downloadchromium_src-7dd06a0131c05212100c81ae88ae07f0757ff4db.zip
chromium_src-7dd06a0131c05212100c81ae88ae07f0757ff4db.tar.gz
chromium_src-7dd06a0131c05212100c81ae88ae07f0757ff4db.tar.bz2
Temporary workaround to get tests that reference singletons either directly or indirectly to pass.
With the recent Singleton refactoring, these tests started exposing some inherent problems with singletons, namely that one test can reference a state set by a different test, which can cause all sorts of flakiness. Furthermore, some of these tests could reference the registry which may have some user specific settings that could cause the tests to fail To work around these issues, I'm adding a few utility classes for tests (registry virtualization) and exposing a method to reset singletons before a test is run. TEST=Fixes flakiness and a few tests that could fail on the waterfall. BUG=none Review URL: http://codereview.chromium.org/5564009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68701 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame/chrome_frame_unittest_main.cc')
-rw-r--r--chrome_frame/chrome_frame_unittest_main.cc42
1 files changed, 14 insertions, 28 deletions
diff --git a/chrome_frame/chrome_frame_unittest_main.cc b/chrome_frame/chrome_frame_unittest_main.cc
index 70157a4..4050f9b 100644
--- a/chrome_frame/chrome_frame_unittest_main.cc
+++ b/chrome_frame/chrome_frame_unittest_main.cc
@@ -1,31 +1,6 @@
-// Copyright 2009, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
#include <atlbase.h>
#include <atlcom.h>
@@ -38,11 +13,22 @@ class ObligatoryModule: public CAtlExeModuleT<ObligatoryModule> {
ObligatoryModule g_obligatory_atl_module;
+static base::AtExitManager* g_at_exit_manager = NULL;
+
+void DeleteAllSingletons() {
+ if (g_at_exit_manager) {
+ g_at_exit_manager->ProcessCallbacksNow();
+ }
+}
+
int main(int argc, char** argv) {
testing::InitGoogleTest(&argc, argv);
base::AtExitManager at_exit_manager;
+ g_at_exit_manager = &at_exit_manager;
CommandLine::Init(argc, argv);
RUN_ALL_TESTS();
+
+ g_at_exit_manager = NULL;
}