Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / native_client_sdk / src / tests / nacl_io_test / main.cc
blob326c18f12c443f48cc76e56cb17f0d4029351b1d
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 setenv("TERM", "xterm-256color", 0);
13 ::testing::InitGoogleTest(&argc, argv);
14 return RUN_ALL_TESTS();
17 #else
19 #include "ppapi/cpp/instance.h"
20 #include "ppapi/cpp/var.h"
21 #include "ppapi_simple/ps_main.h"
23 #if defined(WIN32)
24 #include <Windows.h>
25 #undef PostMessage
26 #endif
28 class GTestEventListener : public ::testing::EmptyTestEventListener {
29 public:
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);
67 #endif