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 ::testing::InitGoogleTest(&argc
, argv
);
13 return RUN_ALL_TESTS();
18 #include "ppapi/cpp/instance.h"
19 #include "ppapi/cpp/var.h"
20 #include "ppapi_simple/ps_main.h"
27 class GTestEventListener
: public ::testing::EmptyTestEventListener
{
29 // TestEventListener overrides.
30 virtual void OnTestStart(const ::testing::TestInfo
& test_info
) {
31 std::stringstream msg
;
32 msg
<< "start:" << test_info
.test_case_name() << "." << test_info
.name();
33 pp::Instance(PSGetInstanceId()).PostMessage(msg
.str());
36 virtual void OnTestPartResult(
37 const ::testing::TestPartResult
& test_part_result
) {
38 if (test_part_result
.failed()) {
39 std::stringstream msg
;
40 msg
<< "fail:" << test_part_result
.file_name() << ","
41 << test_part_result
.line_number() << ","
42 << test_part_result
.summary();
43 pp::Instance(PSGetInstanceId()).PostMessage(msg
.str());
47 virtual void OnTestEnd(const ::testing::TestInfo
& test_info
) {
48 std::stringstream msg
;
49 msg
<< "end:" << test_info
.test_case_name() << "." << test_info
.name()
50 << "," << (test_info
.result()->Failed() ? "failed" : "ok");
51 pp::Instance(PSGetInstanceId()).PostMessage(msg
.str());
55 int example_main(int argc
, char* argv
[]) {
56 ::testing::InitGoogleTest(&argc
, argv
);
57 ::testing::UnitTest::GetInstance()->listeners()
58 .Append(new GTestEventListener());
59 return RUN_ALL_TESTS();
62 // Register the function to call once the Instance Object is initialized.
63 // see: pappi_simple/ps_main.h
64 PPAPI_SIMPLE_REGISTER_MAIN(example_main
);