summaryrefslogtreecommitdiffstats
path: root/remoting/test
diff options
context:
space:
mode:
authorjam <jam@chromium.org>2015-12-10 18:23:27 -0800
committerCommit bot <commit-bot@chromium.org>2015-12-11 02:24:09 +0000
commit5ccf985d5e5b53f9196b85e147e9c290a648d7da (patch)
tree08a7bcdb2a1c2013a9feba742b920c9fbdcb3233 /remoting/test
parent2b9c4739f033034356590ef9b15f58d4fddcd08b (diff)
downloadchromium_src-5ccf985d5e5b53f9196b85e147e9c290a648d7da.zip
chromium_src-5ccf985d5e5b53f9196b85e147e9c290a648d7da.tar.gz
chromium_src-5ccf985d5e5b53f9196b85e147e9c290a648d7da.tar.bz2
Remove the NoAtExitBaseTestSuite anti-pattern.
A bunch of unit tests were deriving from base::TestSuite and telling it to not create an AtExitManager, while at the same time they were creating an AtExitManager. Just use the base::TestSuite directly which creates the AtExitManager. This follows similar cleanup I did in r362157. Review URL: https://codereview.chromium.org/1512053002 Cr-Commit-Position: refs/heads/master@{#364590}
Diffstat (limited to 'remoting/test')
-rw-r--r--remoting/test/app_remoting_test_driver.cc22
-rw-r--r--remoting/test/chromoting_test_driver.cc23
2 files changed, 9 insertions, 36 deletions
diff --git a/remoting/test/app_remoting_test_driver.cc b/remoting/test/app_remoting_test_driver.cc
index 577ea63..e036363 100644
--- a/remoting/test/app_remoting_test_driver.cc
+++ b/remoting/test/app_remoting_test_driver.cc
@@ -143,26 +143,11 @@ void PrintJsonFileInfo() {
switches::kRefreshTokenFileSwitchName);
}
-// This class exists so that we can create a test suite which does not create
-// its own AtExitManager. The problem we are working around occurs when
-// the test suite does not create an AtExitManager (e.g. if no tests are run)
-// and the environment object destroys its MessageLoop, then a crash will occur.
-class NoAtExitBaseTestSuite : public base::TestSuite {
- public:
- NoAtExitBaseTestSuite(int argc, char** argv)
- : base::TestSuite(argc, argv, false) {}
-
- static int RunTestSuite(int argc, char** argv) {
- return NoAtExitBaseTestSuite(argc, argv).Run();
- }
-};
-
} // namespace
int main(int argc, char** argv) {
- base::AtExitManager at_exit;
+ base::TestSuite test_suite(argc, argv);
base::MessageLoopForIO message_loop;
- testing::InitGoogleTest(&argc, argv);
if (!base::CommandLine::InitializedForCurrentProcess()) {
if (!base::CommandLine::Init(argc, argv)) {
@@ -197,7 +182,7 @@ int main(int argc, char** argv) {
PrintAuthCodeInfo();
return base::LaunchUnitTestsSerially(
argc, argv,
- base::Bind(&NoAtExitBaseTestSuite::RunTestSuite, argc, argv));
+ base::Bind(&base::TestSuite::Run, base::Unretained(&test_suite)));
}
remoting::test::AppRemotingTestDriverEnvironment::EnvironmentOptions options;
@@ -265,5 +250,6 @@ int main(int argc, char** argv) {
// Because many tests may access the same remoting host(s), we need to run
// the tests sequentially so they do not interfere with each other.
return base::LaunchUnitTestsSerially(
- argc, argv, base::Bind(&NoAtExitBaseTestSuite::RunTestSuite, argc, argv));
+ argc, argv,
+ base::Bind(&base::TestSuite::Run, base::Unretained(&test_suite)));
}
diff --git a/remoting/test/chromoting_test_driver.cc b/remoting/test/chromoting_test_driver.cc
index c9df6c6..e8c977f 100644
--- a/remoting/test/chromoting_test_driver.cc
+++ b/remoting/test/chromoting_test_driver.cc
@@ -133,26 +133,11 @@ void PrintJsonFileInfo() {
switches::kHostNameSwitchName, switches::kRefreshTokenPathSwitchName);
}
-// This class exists so that we can create a test suite which does not create
-// its own AtExitManager. The problem we are working around occurs when
-// the test suite does not create an AtExitManager (e.g. if no tests are run)
-// and the environment object destroys its MessageLoop, then a crash will occur.
-class NoAtExitBaseTestSuite : public base::TestSuite {
- public:
- NoAtExitBaseTestSuite(int argc, char** argv)
- : base::TestSuite(argc, argv, false) {}
-
- static int RunTestSuite(int argc, char** argv) {
- return NoAtExitBaseTestSuite(argc, argv).Run();
- }
-};
-
} // namespace
int main(int argc, char* argv[]) {
- base::AtExitManager at_exit;
+ base::TestSuite test_suite(argc, argv);
base::MessageLoopForIO message_loop;
- testing::InitGoogleTest(&argc, argv);
if (!base::CommandLine::InitializedForCurrentProcess()) {
if (!base::CommandLine::Init(argc, argv)) {
@@ -180,7 +165,8 @@ int main(int argc, char* argv[]) {
PrintJsonFileInfo();
PrintAuthCodeInfo();
return base::LaunchUnitTestsSerially(
- argc, argv, base::Bind(&NoAtExitBaseTestSuite::RunTestSuite, argc, argv));
+ argc, argv,
+ base::Bind(&base::TestSuite::Run, base::Unretained(&test_suite)));
}
// Update the logging verbosity level if user specified one.
@@ -254,5 +240,6 @@ int main(int argc, char* argv[]) {
// Running the tests serially will avoid clients from connecting to the same
// host.
return base::LaunchUnitTestsSerially(
- argc, argv, base::Bind(&NoAtExitBaseTestSuite::RunTestSuite, argc, argv));
+ argc, argv,
+ base::Bind(&base::TestSuite::Run, base::Unretained(&test_suite)));
}