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.
5 #include "gtest/gtest.h"
6 #include "ppapi/cpp/instance.h"
7 #include "ppapi/cpp/var.h"
8 #include "ppapi_simple/ps_main.h"
15 TEST(TestCase
, SimpleTest
) {
19 TEST(TestCase
, AnotherTest
) {
20 EXPECT_EQ(1, sizeof(char));
23 class GTestEventListener
: public ::testing::EmptyTestEventListener
{
25 // TestEventListener overrides.
26 virtual void OnTestStart(const ::testing::TestInfo
& test_info
) {
27 std::stringstream msg
;
28 msg
<< "start:" << test_info
.test_case_name() << "." << test_info
.name();
29 pp::Instance(PSGetInstanceId()).PostMessage(msg
.str());
32 virtual void OnTestPartResult(
33 const ::testing::TestPartResult
& test_part_result
) {
34 if (test_part_result
.failed()) {
35 std::stringstream msg
;
36 msg
<< "fail:" << test_part_result
.file_name() << ","
37 << test_part_result
.line_number() << ","
38 << test_part_result
.summary();
39 pp::Instance(PSGetInstanceId()).PostMessage(msg
.str());
43 virtual void OnTestEnd(const ::testing::TestInfo
& test_info
) {
44 std::stringstream msg
;
45 msg
<< "end:" << test_info
.test_case_name() << "." << test_info
.name()
46 << "," << (test_info
.result()->Failed() ? "failed" : "ok");
47 pp::Instance(PSGetInstanceId()).PostMessage(msg
.str());
51 int example_main(int argc
, char* argv
[]) {
52 setenv("TERM", "xterm-256color", 0);
53 ::testing::InitGoogleTest(&argc
, argv
);
54 if (PSGetInstanceId() != 0) {
55 ::testing::UnitTest::GetInstance()->listeners()
56 .Append(new GTestEventListener());
58 return RUN_ALL_TESTS();
61 // Register the function to call once the Instance Object is initialized.
62 // see: pappi_simple/ps_main.h
63 PPAPI_SIMPLE_REGISTER_MAIN(example_main
);