From de9bdd1e4d2f87f53b1c2d3eacfbe43ef6ca1019 Mon Sep 17 00:00:00 2001 From: "dumi@chromium.org" Date: Thu, 4 Nov 2010 00:36:22 +0000 Subject: Pepper's directory reader implementation + test. BUG=none TEST=test_directory_reader.cc Review URL: http://codereview.chromium.org/4107004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65002 0039d316-1c4b-4281-b951-d872f2087c98 --- ppapi/tests/test_file_ref.cc | 60 ++------------------------------------------ 1 file changed, 2 insertions(+), 58 deletions(-) (limited to 'ppapi/tests/test_file_ref.cc') 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(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(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( - 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() { -- cgit v1.1