summaryrefslogtreecommitdiffstats
path: root/base/test
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-16 04:18:41 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-16 04:18:41 +0000
commit6fa18d1c50a9fda0462eec8da70190504bfec520 (patch)
tree00af6f00a9c7c75e364a6ad3736c2d8766a7adf5 /base/test
parent9924bf0c7641495b6e27195b088ebbab1c1afc4f (diff)
downloadchromium_src-6fa18d1c50a9fda0462eec8da70190504bfec520.zip
chromium_src-6fa18d1c50a9fda0462eec8da70190504bfec520.tar.gz
chromium_src-6fa18d1c50a9fda0462eec8da70190504bfec520.tar.bz2
Separate out the constructor and Run from test_suite.cc. This is an isolated
part of r55416 to test that the files that use test_suite have the proper project dependencies. TEST=everything compiles BUG=none git-svn-id: svn://svn.chromium.org/chrome/trunk/src@56182 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/test')
-rw-r--r--base/test/test_suite.cc79
-rw-r--r--base/test/test_suite.h54
2 files changed, 81 insertions, 52 deletions
diff --git a/base/test/test_suite.cc b/base/test/test_suite.cc
new file mode 100644
index 0000000..a374034
--- /dev/null
+++ b/base/test/test_suite.cc
@@ -0,0 +1,79 @@
+// Copyright (c) 2009 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 "base/test/test_suite.h"
+
+#include "base/at_exit.h"
+#include "base/base_paths.h"
+#include "base/debug_on_start.h"
+#include "base/debug_util.h"
+#include "base/file_path.h"
+#include "base/i18n/icu_util.h"
+#include "base/multiprocess_test.h"
+#include "base/nss_util.h"
+#include "base/path_service.h"
+#include "base/process_util.h"
+#include "base/scoped_nsautorelease_pool.h"
+#include "base/scoped_ptr.h"
+#include "base/time.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "testing/multiprocess_func_list.h"
+
+#if defined(TOOLKIT_USES_GTK)
+#include <gtk/gtk.h>
+#endif
+
+TestSuite::TestSuite(int argc, char** argv) {
+ base::EnableTerminationOnHeapCorruption();
+ CommandLine::Init(argc, argv);
+ testing::InitGoogleTest(&argc, argv);
+#if defined(TOOLKIT_USES_GTK)
+ g_thread_init(NULL);
+ gtk_init_check(&argc, &argv);
+#endif // defined(TOOLKIT_USES_GTK)
+ // Don't add additional code to this constructor. Instead add it to
+ // Initialize(). See bug 6436.
+}
+
+// Don't add additional code to this method. Instead add it to
+// Initialize(). See bug 6436.
+int TestSuite::Run() {
+ base::ScopedNSAutoreleasePool scoped_pool;
+
+ Initialize();
+ std::string client_func =
+ CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
+ kRunClientProcess);
+ // Check to see if we are being run as a client process.
+ if (!client_func.empty())
+ return multi_process_function_list::InvokeChildProcessTest(client_func);
+ int result = RUN_ALL_TESTS();
+
+ // If there are failed tests, see if we should ignore the failures.
+ if (result != 0 && GetTestCount(&TestSuite::NonIgnoredFailures) == 0)
+ result = 0;
+
+ // Display the number of flaky tests.
+ int flaky_count = GetTestCount(&TestSuite::IsMarkedFlaky);
+ if (flaky_count) {
+ printf(" YOU HAVE %d FLAKY %s\n\n", flaky_count,
+ flaky_count == 1 ? "TEST" : "TESTS");
+ }
+
+ // Display the number of tests with ignored failures (FAILS).
+ int failing_count = GetTestCount(&TestSuite::IsMarkedFailing);
+ if (failing_count) {
+ printf(" YOU HAVE %d %s with ignored failures (FAILS prefix)\n\n",
+ failing_count, failing_count == 1 ? "test" : "tests");
+ }
+
+ // This MUST happen before Shutdown() since Shutdown() tears down
+ // objects (such as NotificationService::current()) that Cocoa
+ // objects use to remove themselves as observers.
+ scoped_pool.Recycle();
+
+ Shutdown();
+
+ return result;
+}
diff --git a/base/test/test_suite.h b/base/test/test_suite.h
index eb688f4..3cfc7ec 100644
--- a/base/test/test_suite.h
+++ b/base/test/test_suite.h
@@ -58,17 +58,7 @@ class TestIsolationEnforcer : public testing::EmptyTestEventListener {
class TestSuite {
public:
- TestSuite(int argc, char** argv) {
- base::EnableTerminationOnHeapCorruption();
- CommandLine::Init(argc, argv);
- testing::InitGoogleTest(&argc, argv);
-#if defined(TOOLKIT_USES_GTK)
- g_thread_init(NULL);
- gtk_init_check(&argc, &argv);
-#endif // defined(TOOLKIT_USES_GTK)
- // Don't add additional code to this constructor. Instead add it to
- // Initialize(). See bug 6436.
- }
+ TestSuite(int argc, char** argv);
virtual ~TestSuite() {
CommandLine::Reset();
@@ -134,47 +124,7 @@ class TestSuite {
listeners.Append(new MaybeTestDisabler);
}
- // Don't add additional code to this method. Instead add it to
- // Initialize(). See bug 6436.
- int Run() {
- base::ScopedNSAutoreleasePool scoped_pool;
-
- Initialize();
- std::string client_func =
- CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
- kRunClientProcess);
- // Check to see if we are being run as a client process.
- if (!client_func.empty())
- return multi_process_function_list::InvokeChildProcessTest(client_func);
- int result = RUN_ALL_TESTS();
-
- // If there are failed tests, see if we should ignore the failures.
- if (result != 0 && GetTestCount(&TestSuite::NonIgnoredFailures) == 0)
- result = 0;
-
- // Display the number of flaky tests.
- int flaky_count = GetTestCount(&TestSuite::IsMarkedFlaky);
- if (flaky_count) {
- printf(" YOU HAVE %d FLAKY %s\n\n", flaky_count,
- flaky_count == 1 ? "TEST" : "TESTS");
- }
-
- // Display the number of tests with ignored failures (FAILS).
- int failing_count = GetTestCount(&TestSuite::IsMarkedFailing);
- if (failing_count) {
- printf(" YOU HAVE %d %s with ignored failures (FAILS prefix)\n\n",
- failing_count, failing_count == 1 ? "test" : "tests");
- }
-
- // This MUST happen before Shutdown() since Shutdown() tears down
- // objects (such as NotificationService::current()) that Cocoa
- // objects use to remove themselves as observers.
- scoped_pool.Recycle();
-
- Shutdown();
-
- return result;
- }
+ int Run();
protected:
class MaybeTestDisabler : public testing::EmptyTestEventListener {