| 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 "ppapi/tests/test_utils.h" | 5 #include "ppapi/tests/test_utils.h" |
| 6 | 6 |
| 7 #include <stdio.h> | 7 #include <stdio.h> |
| 8 | 8 |
| 9 #include "ppapi/c/pp_errors.h" | 9 #include "ppapi/c/pp_errors.h" |
| 10 #include "ppapi/cpp/module.h" | 10 #include "ppapi/cpp/module.h" |
| 11 | 11 |
| 12 const PPB_Testing_Dev* GetTestingInterface() { | 12 const PPB_Testing_Dev* GetTestingInterface() { |
| 13 static const PPB_Testing_Dev* g_testing_interface = | 13 static const PPB_Testing_Dev* g_testing_interface = |
| 14 reinterpret_cast<PPB_Testing_Dev const*>( | 14 reinterpret_cast<PPB_Testing_Dev const*>( |
| 15 pp::Module::Get()->GetBrowserInterface(PPB_TESTING_DEV_INTERFACE)); | 15 pp::Module::Get()->GetBrowserInterface(PPB_TESTING_DEV_INTERFACE)); |
| 16 return g_testing_interface; | 16 return g_testing_interface; |
| 17 } | 17 } |
| 18 | 18 |
| 19 std::string ReportError(const char* method, int32_t error) { | 19 std::string ReportError(const char* method, int32_t error) { |
| 20 char error_as_string[12]; | 20 char error_as_string[12]; |
| 21 sprintf(error_as_string, "%d", error); | 21 sprintf(error_as_string, "%d", static_cast<int>(error)); |
| 22 std::string result = method + std::string(" failed with error: ") + | 22 std::string result = method + std::string(" failed with error: ") + |
| 23 error_as_string; | 23 error_as_string; |
| 24 if (error == PP_ERROR_NOSPACE) | 24 if (error == PP_ERROR_NOSPACE) |
| 25 result += ". Did you run the test with --unlimited-quota-for-files?"; | 25 result += ". Did you run the test with --unlimited-quota-for-files?"; |
| 26 return result; | 26 return result; |
| 27 } | 27 } |
| 28 | 28 |
| 29 TestCompletionCallback::TestCompletionCallback(PP_Instance instance) | 29 TestCompletionCallback::TestCompletionCallback(PP_Instance instance) |
| 30 : have_result_(false), | 30 : have_result_(false), |
| 31 result_(PP_OK_COMPLETIONPENDING), | 31 result_(PP_OK_COMPLETIONPENDING), |
| (...skipping 22 matching lines...) Expand all Loading... |
| 54 TestCompletionCallback* callback = | 54 TestCompletionCallback* callback = |
| 55 static_cast<TestCompletionCallback*>(user_data); | 55 static_cast<TestCompletionCallback*>(user_data); |
| 56 callback->result_ = result; | 56 callback->result_ = result; |
| 57 callback->have_result_ = true; | 57 callback->have_result_ = true; |
| 58 callback->run_count_++; | 58 callback->run_count_++; |
| 59 if (callback->post_quit_task_) { | 59 if (callback->post_quit_task_) { |
| 60 callback->post_quit_task_ = false; | 60 callback->post_quit_task_ = false; |
| 61 GetTestingInterface()->QuitMessageLoop(callback->instance_); | 61 GetTestingInterface()->QuitMessageLoop(callback->instance_); |
| 62 } | 62 } |
| 63 } | 63 } |
| OLD | NEW |