andrew@webrtc.org | 19eefdc | 2011-09-14 17:02:44 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
andrew@webrtc.org | b87cc85 | 2013-03-25 16:23:37 +0000 | [diff] [blame] | 11 | #include "webrtc/test/test_suite.h" |
andrew@webrtc.org | c1ffd33 | 2013-03-22 17:13:23 +0000 | [diff] [blame] | 12 | |
andrew@webrtc.org | aa3d1c8 | 2013-09-05 21:16:29 +0000 | [diff] [blame] | 13 | #include "gflags/gflags.h" |
andrew@webrtc.org | c1ffd33 | 2013-03-22 17:13:23 +0000 | [diff] [blame] | 14 | #include "testing/gmock/include/gmock/gmock.h" |
| 15 | #include "testing/gtest/include/gtest/gtest.h" |
andrew@webrtc.org | b87cc85 | 2013-03-25 16:23:37 +0000 | [diff] [blame] | 16 | #include "webrtc/test/testsupport/fileutils.h" |
| 17 | #include "webrtc/test/testsupport/trace_to_stderr.h" |
andrew@webrtc.org | 19eefdc | 2011-09-14 17:02:44 +0000 | [diff] [blame] | 18 | |
andrew@webrtc.org | aa3d1c8 | 2013-09-05 21:16:29 +0000 | [diff] [blame] | 19 | DEFINE_bool(logs, false, "print logs to stderr"); |
| 20 | |
andrew@webrtc.org | 19eefdc | 2011-09-14 17:02:44 +0000 | [diff] [blame] | 21 | namespace webrtc { |
kjellander@webrtc.org | 20a370e | 2011-11-04 01:19:16 +0000 | [diff] [blame] | 22 | namespace test { |
kjellander@webrtc.org | 83b767b | 2012-10-15 18:14:12 +0000 | [diff] [blame] | 23 | |
andrew@webrtc.org | c1ffd33 | 2013-03-22 17:13:23 +0000 | [diff] [blame] | 24 | TestSuite::TestSuite(int argc, char** argv) |
andrew@webrtc.org | b87cc85 | 2013-03-25 16:23:37 +0000 | [diff] [blame] | 25 | : trace_to_stderr_(NULL) { |
kjellander@webrtc.org | 193600b | 2012-10-17 04:39:44 +0000 | [diff] [blame] | 26 | SetExecutablePath(argv[0]); |
kjellander@webrtc.org | 20a370e | 2011-11-04 01:19:16 +0000 | [diff] [blame] | 27 | testing::InitGoogleMock(&argc, argv); // Runs InitGoogleTest() internally. |
andrew@webrtc.org | 15e979b | 2013-09-17 00:54:09 +0000 | [diff] [blame^] | 28 | // AllowCommandLineParsing allows us to ignore flags passed on to us by |
| 29 | // Chromium build bots without having to explicitly disable them. |
| 30 | google::AllowCommandLineReparsing(); |
andrew@webrtc.org | aa3d1c8 | 2013-09-05 21:16:29 +0000 | [diff] [blame] | 31 | google::ParseCommandLineFlags(&argc, &argv, true); |
andrew@webrtc.org | 19eefdc | 2011-09-14 17:02:44 +0000 | [diff] [blame] | 32 | } |
| 33 | |
| 34 | TestSuite::~TestSuite() { |
| 35 | } |
| 36 | |
| 37 | int TestSuite::Run() { |
| 38 | Initialize(); |
| 39 | int result = RUN_ALL_TESTS(); |
| 40 | Shutdown(); |
| 41 | return result; |
| 42 | } |
| 43 | |
| 44 | void TestSuite::Initialize() { |
andrew@webrtc.org | aa3d1c8 | 2013-09-05 21:16:29 +0000 | [diff] [blame] | 45 | if (FLAGS_logs) |
| 46 | trace_to_stderr_.reset(new TraceToStderr); |
andrew@webrtc.org | 19eefdc | 2011-09-14 17:02:44 +0000 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | void TestSuite::Shutdown() { |
| 50 | } |
andrew@webrtc.org | c1ffd33 | 2013-03-22 17:13:23 +0000 | [diff] [blame] | 51 | |
kjellander@webrtc.org | 20a370e | 2011-11-04 01:19:16 +0000 | [diff] [blame] | 52 | } // namespace test |
andrew@webrtc.org | 19eefdc | 2011-09-14 17:02:44 +0000 | [diff] [blame] | 53 | } // namespace webrtc |