OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 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. | |
4 | |
5 #include "c_salt/test/gtest_instance.h" | |
6 #include "c_salt/test/gtest_runner.h" | |
7 #include "ppapi/cpp/var.h" | |
8 | |
9 namespace c_salt { | |
10 | |
11 GTestInstance::GTestInstance(PP_Instance instance) | |
12 : pp::Instance(instance) { | |
13 } | |
14 | |
15 GTestInstance::~GTestInstance() { | |
16 } | |
17 | |
18 bool GTestInstance::Init(uint32_t /* argc */, const char* /* argn */[], | |
19 const char* /* argv */[]) { | |
20 // Create a GTestRunner thread/singleton. | |
21 int local_argc = 0; | |
22 c_salt::GTestRunner::CreateGTestRunnerThread(this, local_argc, NULL); | |
23 return true; | |
24 } | |
25 | |
26 void GTestInstance::HandleMessage(const pp::Var& var_message) { | |
27 if (!var_message.is_string()) { | |
28 PostMessage("Invalid message"); | |
29 return; | |
30 } | |
31 | |
32 std::string message = var_message.AsString(); | |
33 if (message == "RunGTest") { | |
34 // This is our signal to start running the tests. Results from the tests | |
35 // are posted through GTestEventListener. | |
36 c_salt::GTestRunner::gtest_runner()->RunAllTests(); | |
37 } else { | |
38 std::string return_var; | |
39 return_var = "Unknown message "; | |
40 return_var += message; | |
41 PostMessage(return_var); | |
42 } | |
43 } | |
44 | |
45 } // namespace c_salt | |
46 | |
OLD | NEW |