Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / native_client_sdk / src / tests / nacl_io_test / main.cc
blob31414e64c5e86d77ff324bd8cc8dcc00dd862005
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 <string>
7 #include "gtest/gtest.h"
8 #include "ppapi/cpp/instance.h"
9 #include "ppapi/cpp/var.h"
10 #include "ppapi_simple/ps_main.h"
12 #if defined(WIN32)
13 #include <Windows.h>
14 #undef PostMessage
15 #endif
17 class GTestEventListener : public ::testing::EmptyTestEventListener {
18 public:
19 // TestEventListener overrides.
20 virtual void OnTestStart(const ::testing::TestInfo& test_info) {
21 std::stringstream msg;
22 msg << "start:" << test_info.test_case_name() << "." << test_info.name();
23 pp::Instance(PSGetInstanceId()).PostMessage(msg.str());
26 virtual void OnTestPartResult(
27 const ::testing::TestPartResult& test_part_result) {
28 if (test_part_result.failed()) {
29 std::stringstream msg;
30 msg << "fail:" << test_part_result.file_name() << ","
31 << test_part_result.line_number() << ","
32 << test_part_result.summary();
33 pp::Instance(PSGetInstanceId()).PostMessage(msg.str());
37 virtual void OnTestEnd(const ::testing::TestInfo& test_info) {
38 std::stringstream msg;
39 msg << "end:" << test_info.test_case_name() << "." << test_info.name()
40 << "," << (test_info.result()->Failed() ? "failed" : "ok");
41 pp::Instance(PSGetInstanceId()).PostMessage(msg.str());
45 int example_main(int argc, char* argv[]) {
46 setenv("TERM", "xterm-256color", 0);
47 ::testing::InitGoogleTest(&argc, argv);
48 if (PSGetInstanceId() != 0) {
49 ::testing::UnitTest::GetInstance()->listeners()
50 .Append(new GTestEventListener());
52 return RUN_ALL_TESTS();
55 // Register the function to call once the Instance Object is initialized.
56 // see: pappi_simple/ps_main.h
57 PPAPI_SIMPLE_REGISTER_MAIN(example_main);