• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
11 #include "webrtc/test/test_suite.h"
12 
13 #include "gflags/gflags.h"
14 #include "testing/gmock/include/gmock/gmock.h"
15 #include "testing/gtest/include/gtest/gtest.h"
16 #include "webrtc/base/logging.h"
17 #include "webrtc/test/testsupport/fileutils.h"
18 #include "webrtc/test/testsupport/trace_to_stderr.h"
19 #include "webrtc/test/field_trial.h"
20 
21 DEFINE_bool(logs, false, "print logs to stderr");
22 
23 DEFINE_string(force_fieldtrials, "",
24     "Field trials control experimental feature code which can be forced. "
25     "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enable/"
26     " will assign the group Enable to field trial WebRTC-FooFeature.");
27 
28 namespace webrtc {
29 namespace test {
30 
TestSuite(int argc,char ** argv)31 TestSuite::TestSuite(int argc, char** argv) {
32   SetExecutablePath(argv[0]);
33   testing::InitGoogleMock(&argc, argv);  // Runs InitGoogleTest() internally.
34   // AllowCommandLineParsing allows us to ignore flags passed on to us by
35   // Chromium build bots without having to explicitly disable them.
36   google::AllowCommandLineReparsing();
37   google::ParseCommandLineFlags(&argc, &argv, true);
38 
39   webrtc::test::InitFieldTrialsFromString(FLAGS_force_fieldtrials);
40 }
41 
~TestSuite()42 TestSuite::~TestSuite() {
43 }
44 
Run()45 int TestSuite::Run() {
46   Initialize();
47   int result = RUN_ALL_TESTS();
48   Shutdown();
49   return result;
50 }
51 
Initialize()52 void TestSuite::Initialize() {
53   rtc::LogMessage::SetLogToStderr(FLAGS_logs);
54   if (FLAGS_logs)
55     trace_to_stderr_.reset(new TraceToStderr);
56 }
57 
Shutdown()58 void TestSuite::Shutdown() {
59 }
60 
61 }  // namespace test
62 }  // namespace webrtc
63