1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
7 #include "gtest/gtest.h"
11 int main(int argc
, char* argv
[]) {
12 setenv("TERM", "xterm-256color", 0);
13 ::testing::InitGoogleTest(&argc
, argv
);
14 return RUN_ALL_TESTS();
19 #include "ppapi/cpp/instance.h"
20 #include "ppapi/cpp/var.h"
21 #include "ppapi_simple/ps_main.h"
28 class GTestEventListener
: public ::testing::EmptyTestEventListener
{
30 // TestEventListener overrides.
31 virtual void OnTestStart(const ::testing::TestInfo
& test_info
) {
32 std::stringstream msg
;
33 msg
<< "start:" << test_info
.test_case_name() << "." << test_info
.name();
34 pp::Instance(PSGetInstanceId()).PostMessage(msg
.str());
37 virtual void OnTestPartResult(
38 const ::testing::TestPartResult
& test_part_result
) {
39 if (test_part_result
.failed()) {
40 std::stringstream msg
;
41 msg
<< "fail:" << test_part_result
.file_name() << ","
42 << test_part_result
.line_number() << ","
43 << test_part_result
.summary();
44 pp::Instance(PSGetInstanceId()).PostMessage(msg
.str());
48 virtual void OnTestEnd(const ::testing::TestInfo
& test_info
) {
49 std::stringstream msg
;
50 msg
<< "end:" << test_info
.test_case_name() << "." << test_info
.name()
51 << "," << (test_info
.result()->Failed() ? "failed" : "ok");
52 pp::Instance(PSGetInstanceId()).PostMessage(msg
.str());
56 int example_main(int argc
, char* argv
[]) {
57 ::testing::InitGoogleTest(&argc
, argv
);
58 ::testing::UnitTest::GetInstance()->listeners()
59 .Append(new GTestEventListener());
60 return RUN_ALL_TESTS();
63 // Register the function to call once the Instance Object is initialized.
64 // see: pappi_simple/ps_main.h
65 PPAPI_SIMPLE_REGISTER_MAIN(example_main
);