diff options
author | dumi@chromium.org <dumi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-04 00:36:22 +0000 |
---|---|---|
committer | dumi@chromium.org <dumi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-04 00:36:22 +0000 |
commit | de9bdd1e4d2f87f53b1c2d3eacfbe43ef6ca1019 (patch) | |
tree | 7e714193e2f5abad3d3ca54d353b62a7f9ebf7e3 /ppapi/tests/test_file_ref.cc | |
parent | f8ce465c025d457778f8376eca12d94e723965bb (diff) | |
download | chromium_src-de9bdd1e4d2f87f53b1c2d3eacfbe43ef6ca1019.zip chromium_src-de9bdd1e4d2f87f53b1c2d3eacfbe43ef6ca1019.tar.gz chromium_src-de9bdd1e4d2f87f53b1c2d3eacfbe43ef6ca1019.tar.bz2 |
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
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() { |