summaryrefslogtreecommitdiffstats
path: root/cc/test/cc_test_suite.cc
blob: d4d15d3e42d423f87e21bc3251987ebadc4be959 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright (c) 2012 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 "cc/test/cc_test_suite.h"

#include <string>

#include "base/command_line.h"
#include "base/debug/trace_event_impl.h"
#include "base/message_loop.h"
#include "base/threading/thread_id_name_manager.h"
#include "cc/base/switches.h"
#include "cc/test/paths.h"

namespace cc {

CCTestSuite::CCTestSuite(int argc, char** argv)
    : base::TestSuite(argc, argv) {}

CCTestSuite::~CCTestSuite() {}

void CCTestSuite::Initialize() {
  base::TestSuite::Initialize();
  RegisterPathProvider();

  if (CommandLine::ForCurrentProcess()->HasSwitch(
        switches::kCCUnittestsTraceEventsToVLOG)) {
    std::string category_string =
        CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
            switches::kCCUnittestsTraceEventsToVLOG);

    if (!category_string.size())
      category_string = "cc";

    base::debug::TraceLog::GetInstance()->SetEnabled(
        base::debug::CategoryFilter(category_string),
        base::debug::TraceLog::ECHO_TO_VLOG);
  }

  message_loop_.reset(new base::MessageLoop);

  base::ThreadIdNameManager::GetInstance()->SetName(
      base::PlatformThread::CurrentId(),
      "Main");
}

void CCTestSuite::Shutdown() {
  message_loop_.reset();

  base::TestSuite::Shutdown();
}

}  // namespace cc