Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "native_client/tests/ppapi_test_lib/test_interface.h" | 5 #include "native_client/tests/ppapi_test_lib/test_interface.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <new> | 9 #include <new> |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 #include "ppapi/c/ppb_image_data.h" | 23 #include "ppapi/c/ppb_image_data.h" |
| 24 #include "ppapi/c/ppb_instance.h" | 24 #include "ppapi/c/ppb_instance.h" |
| 25 #include "ppapi/c/ppb_messaging.h" | 25 #include "ppapi/c/ppb_messaging.h" |
| 26 #include "ppapi/c/ppb_var.h" | 26 #include "ppapi/c/ppb_var.h" |
| 27 #include "ppapi/c/dev/ppb_testing_dev.h" | 27 #include "ppapi/c/dev/ppb_testing_dev.h" |
| 28 | 28 |
| 29 void PostTestMessage(nacl::string test_name, nacl::string message) { | 29 void PostTestMessage(nacl::string test_name, nacl::string message) { |
| 30 nacl::string test_message = test_name; | 30 nacl::string test_message = test_name; |
| 31 test_message += ":"; | 31 test_message += ":"; |
| 32 test_message += message; | 32 test_message += message; |
| 33 PP_Var post_var = PPBVar()->VarFromUtf8(pp_instance(), | 33 PP_Var post_var = PPBVar()->VarFromUtf8(test_message.c_str(), |
|
bbudge
2011/12/07 15:53:28
This was passing the instance instead of the modul
dmichael (off chromium)
2011/12/07 18:07:38
Yep! Fortunately(?) we didn't really use the modul
| |
| 34 test_message.c_str(), | |
| 35 test_message.size()); | 34 test_message.size()); |
| 36 PPBMessaging()->PostMessage(pp_instance(), post_var); | 35 PPBMessaging()->PostMessage(pp_instance(), post_var); |
| 37 PPBVar()->Release(post_var); | 36 PPBVar()->Release(post_var); |
| 38 } | 37 } |
| 39 | 38 |
| 40 PP_Var PP_MakeString(const char* s) { | 39 PP_Var PP_MakeString(const char* s) { |
| 41 return PPBVar()->VarFromUtf8(pp_module(), s, strlen(s)); | 40 return PPBVar()->VarFromUtf8(s, strlen(s)); |
| 42 } | 41 } |
| 43 | 42 |
| 44 nacl::string StringifyVar(const PP_Var& var) { | 43 nacl::string StringifyVar(const PP_Var& var) { |
| 45 uint32_t dummy_size; | 44 uint32_t dummy_size; |
| 46 switch (var.type) { | 45 switch (var.type) { |
| 47 default: | 46 default: |
| 48 return "<UNKNOWN>" + toString(var.type); | 47 return "<UNKNOWN>" + toString(var.type); |
| 49 case PP_VARTYPE_NULL: | 48 case PP_VARTYPE_NULL: |
| 50 return "<NULL>"; | 49 return "<NULL>"; |
| 51 case PP_VARTYPE_BOOL: | 50 case PP_VARTYPE_BOOL: |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 113 //////////////////////////////////////////////////////////////////////////////// | 112 //////////////////////////////////////////////////////////////////////////////// |
| 114 | 113 |
| 115 namespace { | 114 namespace { |
| 116 | 115 |
| 117 struct CallbackInfo { | 116 struct CallbackInfo { |
| 118 nacl::string callback_name; | 117 nacl::string callback_name; |
| 119 PP_CompletionCallback user_callback; | 118 PP_CompletionCallback user_callback; |
| 120 }; | 119 }; |
| 121 | 120 |
| 122 void ReportCallbackInvocationToJS(const char* callback_name) { | 121 void ReportCallbackInvocationToJS(const char* callback_name) { |
| 123 PP_Var callback_var = PPBVar()->VarFromUtf8(pp_module(), | 122 PP_Var callback_var = PPBVar()->VarFromUtf8(callback_name, |
| 124 callback_name, | |
| 125 strlen(callback_name)); | 123 strlen(callback_name)); |
| 126 // Report using postmessage for async tests. | 124 // Report using postmessage for async tests. |
| 127 PPBMessaging()->PostMessage(pp_instance(), callback_var); | 125 PPBMessaging()->PostMessage(pp_instance(), callback_var); |
| 128 PPBVar()->Release(callback_var); | 126 PPBVar()->Release(callback_var); |
| 129 } | 127 } |
| 130 | 128 |
| 131 void CallbackWrapper(void* user_data, int32_t result) { | 129 void CallbackWrapper(void* user_data, int32_t result) { |
| 132 CallbackInfo* callback_info = reinterpret_cast<CallbackInfo*>(user_data); | 130 CallbackInfo* callback_info = reinterpret_cast<CallbackInfo*>(user_data); |
| 133 PP_RunCompletionCallback(&callback_info->user_callback, result); | 131 PP_RunCompletionCallback(&callback_info->user_callback, result); |
| 134 ReportCallbackInvocationToJS(callback_info->callback_name.c_str()); | 132 ReportCallbackInvocationToJS(callback_info->callback_name.c_str()); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 230 for (int y = origin.y; y < origin.y + size.height && !found_error; y++) { | 228 for (int y = origin.y; y < origin.y + size.height && !found_error; y++) { |
| 231 for (int x = origin.x; x < origin.x + size.width && !found_error; x++) { | 229 for (int x = origin.x; x < origin.x + size.width && !found_error; x++) { |
| 232 uint32_t pixel_color = static_cast<uint32_t*>(bitmap)[stride * y + x]; | 230 uint32_t pixel_color = static_cast<uint32_t*>(bitmap)[stride * y + x]; |
| 233 found_error = (pixel_color != expected_color); | 231 found_error = (pixel_color != expected_color); |
| 234 } | 232 } |
| 235 } | 233 } |
| 236 | 234 |
| 237 PPBCore()->ReleaseResource(image); | 235 PPBCore()->ReleaseResource(image); |
| 238 return !found_error; | 236 return !found_error; |
| 239 } | 237 } |
| OLD | NEW |