OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 The Chromium Authors. All rights reserved. | 2 * Copyright 2014 The Chromium Authors. All rights reserved. |
3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
5 */ | 5 */ |
6 | 6 |
7 // | 7 // |
8 // Test for resource open before PPAPI initialization. | 8 // Test for resource open before PPAPI initialization. |
9 // | 9 // |
10 | 10 |
| 11 #include <pthread.h> |
11 #include <stdio.h> | 12 #include <stdio.h> |
12 #include <string.h> | 13 #include <string.h> |
13 | 14 |
14 #include <sstream> | 15 #include <sstream> |
15 #include <string> | 16 #include <string> |
16 #include <vector> | 17 #include <vector> |
17 | 18 |
18 #include "native_client/src/untrusted/irt/irt.h" | 19 #include "native_client/src/untrusted/irt/irt.h" |
19 #include "native_client/src/untrusted/nacl/nacl_irt.h" | 20 #include "native_client/src/untrusted/nacl/nacl_irt.h" |
20 | 21 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 | 144 |
144 virtual ~TestInstance() {} | 145 virtual ~TestInstance() {} |
145 virtual void HandleMessage(const pp::Var& var_message) { | 146 virtual void HandleMessage(const pp::Var& var_message) { |
146 if (!var_message.is_string()) { | 147 if (!var_message.is_string()) { |
147 return; | 148 return; |
148 } | 149 } |
149 if (var_message.AsString() != "hello") { | 150 if (var_message.AsString() != "hello") { |
150 return; | 151 return; |
151 } | 152 } |
152 | 153 |
| 154 pthread_t thread; |
153 // We test the manifest routines again after PPAPI has initialized to | 155 // We test the manifest routines again after PPAPI has initialized to |
154 // ensure that they still work. | 156 // ensure that they still work. |
155 // | 157 // |
156 // irt_open_resource() isn't allowed to be called on the main thread once | 158 // irt_open_resource() isn't allowed to be called on the main thread once |
157 // pepper starts, so these tests must happen on a background thread. | 159 // pepper starts, so these tests must happen on a background thread. |
158 pthread_create(&thread_, NULL, &RunTestsOnBackgroundThread, NULL); | 160 // |
| 161 // TODO(teravest): Check the return value here. |
| 162 pthread_create(&thread, NULL, &RunTestsOnBackgroundThread, NULL); |
159 } | 163 } |
160 private: | |
161 pthread_t thread_; | |
162 }; | 164 }; |
163 | 165 |
164 class TestModule : public pp::Module { | 166 class TestModule : public pp::Module { |
165 public: | 167 public: |
166 TestModule() : pp::Module() {} | 168 TestModule() : pp::Module() {} |
167 virtual ~TestModule() {} | 169 virtual ~TestModule() {} |
168 | 170 |
169 virtual pp::Instance* CreateInstance(PP_Instance instance) { | 171 virtual pp::Instance* CreateInstance(PP_Instance instance) { |
170 return new TestInstance(instance); | 172 return new TestInstance(instance); |
171 } | 173 } |
172 }; | 174 }; |
173 | 175 |
174 namespace pp { | 176 namespace pp { |
175 Module* CreateModule() { | 177 Module* CreateModule() { |
176 return new TestModule(); | 178 return new TestModule(); |
177 } | 179 } |
178 } | 180 } |
179 | 181 |
180 int main() { | 182 int main() { |
181 RunTests(); | 183 RunTests(); |
182 return PpapiPluginMain(); | 184 return PpapiPluginMain(); |
183 } | 185 } |
OLD | NEW |