blob: 7cfb856f3f7530a8a769b1495afb82586ce09d70 [file] [log] [blame]
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +00001/*
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.org8826e342013-03-25 16:23:37 +000011#include "webrtc/test/test_suite.h"
andrew@webrtc.org4c27c032013-03-22 17:13:23 +000012
andrew@webrtc.orge41c6b22013-09-05 21:16:29 +000013#include "gflags/gflags.h"
andrew@webrtc.org4c27c032013-03-22 17:13:23 +000014#include "testing/gmock/include/gmock/gmock.h"
15#include "testing/gtest/include/gtest/gtest.h"
andrew@webrtc.org8826e342013-03-25 16:23:37 +000016#include "webrtc/test/testsupport/fileutils.h"
17#include "webrtc/test/testsupport/trace_to_stderr.h"
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000018
andrew@webrtc.orge41c6b22013-09-05 21:16:29 +000019DEFINE_bool(logs, false, "print logs to stderr");
20
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000021namespace webrtc {
22namespace test {
23
andrew@webrtc.org221798a2013-10-22 12:50:00 +000024TestSuite::TestSuite(int argc, char** argv) {
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000025 SetExecutablePath(argv[0]);
26 testing::InitGoogleMock(&argc, argv); // Runs InitGoogleTest() internally.
andrew@webrtc.orgb0fb1d62013-09-17 00:54:09 +000027 // AllowCommandLineParsing allows us to ignore flags passed on to us by
28 // Chromium build bots without having to explicitly disable them.
29 google::AllowCommandLineReparsing();
andrew@webrtc.orge41c6b22013-09-05 21:16:29 +000030 google::ParseCommandLineFlags(&argc, &argv, true);
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000031}
32
33TestSuite::~TestSuite() {
34}
35
36int TestSuite::Run() {
37 Initialize();
38 int result = RUN_ALL_TESTS();
39 Shutdown();
40 return result;
41}
42
43void TestSuite::Initialize() {
andrew@webrtc.orge41c6b22013-09-05 21:16:29 +000044 if (FLAGS_logs)
45 trace_to_stderr_.reset(new TraceToStderr);
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000046}
47
48void TestSuite::Shutdown() {
49}
andrew@webrtc.org4c27c032013-03-22 17:13:23 +000050
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000051} // namespace test
52} // namespace webrtc