Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / native_client_sdk / src / tests / nacl_io_socket_test / main.cc
blobef7b09433a986c2f103014df6a6d9554903e9fbd
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"
9 #if defined(SEL_LDR)
11 int main(int argc, char* argv[]) {
12 ::testing::InitGoogleTest(&argc, argv);
13 return RUN_ALL_TESTS();
16 #else
18 #include "ppapi/cpp/instance.h"
19 #include "ppapi/cpp/var.h"
20 #include "ppapi_simple/ps_main.h"
22 #if defined(WIN32)
23 #include <Windows.h>
24 #undef PostMessage
25 #endif
27 class GTestEventListener : public ::testing::EmptyTestEventListener {
28 public:
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);
66 #endif