diff options
Diffstat (limited to 'ppapi/tests/test_file_ref.cc')
| -rw-r--r-- | ppapi/tests/test_file_ref.cc | 60 |
1 files changed, 2 insertions, 58 deletions
diff --git a/ppapi/tests/test_file_ref.cc b/ppapi/tests/test_file_ref.cc index b83a2f4..513f5dd 100644 --- a/ppapi/tests/test_file_ref.cc +++ b/ppapi/tests/test_file_ref.cc @@ -17,6 +17,7 @@ #include "ppapi/cpp/dev/url_response_info_dev.h" #include "ppapi/cpp/instance.h" #include "ppapi/cpp/module.h" +#include "ppapi/tests/test_utils.h" #include "ppapi/tests/testing_instance.h" REGISTER_TEST_CASE(FileRef); @@ -29,33 +30,6 @@ const char* kParentPath = "/foo/bar"; const char* kPersFilePath = "/foo/bar/persistent"; const char* kTempFilePath = "/foo/bar/temporary"; -const PPB_Testing_Dev* g_testing_interface; - -class TestCompletionCallback { - public: - TestCompletionCallback() : result_(PP_ERROR_WOULDBLOCK) { - } - - operator pp::CompletionCallback() const { - return pp::CompletionCallback(&TestCompletionCallback::Handler, - const_cast<TestCompletionCallback*>(this)); - } - - int32_t WaitForResult() { - result_ = PP_ERROR_WOULDBLOCK; // Reset - g_testing_interface->RunMessageLoop(); - return result_; - } - - private: - static void Handler(void* user_data, int32_t result) { - static_cast<TestCompletionCallback*>(user_data)->result_ = result; - g_testing_interface->QuitMessageLoop(); - } - - int32_t result_; -}; - std::string ReportMismatch(const std::string& method_name, const std::string& returned_result, const std::string& expected_result) { @@ -63,40 +37,10 @@ std::string ReportMismatch(const std::string& method_name, expected_result + "' expected."; } -std::string ReportError(const char* method, int32_t error) { - char error_as_string[12]; - sprintf(error_as_string, "%d", error); - std::string result = method + std::string(" failed with error: ") + - error_as_string; - if (error == PP_ERROR_NOSPACE) - result += ". Did you run the test with --unlimited-quota-for-files?"; - return result; -} - } // namespace bool TestFileRef::Init() { - g_testing_interface = reinterpret_cast<PPB_Testing_Dev const*>( - pp::Module::Get()->GetBrowserInterface(PPB_TESTING_DEV_INTERFACE)); - if (!g_testing_interface) { - // Give a more helpful error message for the testing interface being gone - // since that needs special enabling in Chrome. - instance_->AppendError("This test needs the testing interface, which is " - "not currently available. In Chrome, use --enable-pepper-testing when " - "launching."); - return false; - } - - // Make sure we're running over HTTP. - pp::Var window = instance_->GetWindowObject(); - pp::Var location = window.GetProperty("location"); - pp::Var protocol = location.GetProperty("protocol"); - if (!protocol.is_string() || protocol.AsString() != "http:") { - instance_->AppendError("This test needs to be run over HTTP."); - return false; - } - - return true; + return InitTestingInterface() && EnsureRunningOverHTTP(); } void TestFileRef::RunTest() { |
