diff options
author | landell <landell@opera.com> | 2014-09-23 00:55:40 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-09-23 07:55:58 +0000 |
commit | 3d0670895e15c8e913d8d14322d3eefd9693b92d (patch) | |
tree | b3f52fd85e9411b511cf748777ed94beeb05a7c6 /ppapi | |
parent | 02a50d7b66b351ea282bb8374c980a2d000d17f9 (diff) | |
download | chromium_src-3d0670895e15c8e913d8d14322d3eefd9693b92d.zip chromium_src-3d0670895e15c8e913d8d14322d3eefd9693b92d.tar.gz chromium_src-3d0670895e15c8e913d8d14322d3eefd9693b92d.tar.bz2 |
Fix URLRequest pepper unit test
This patch creates new URLLoaderResource objects for each request
since those objects can't be reused.
Calling Open() on an instance of URLLoaderResource requires that mode_
is set to MODE_WAITING_TO_OPEN. After Open() has been called mode_
will never reach that state again.
BUG=None
Review URL: https://codereview.chromium.org/582623002
Cr-Commit-Position: refs/heads/master@{#296155}
Diffstat (limited to 'ppapi')
-rw-r--r-- | ppapi/tests/test_url_request.cc | 30 | ||||
-rw-r--r-- | ppapi/tests/test_url_request.h | 3 |
2 files changed, 19 insertions, 14 deletions
diff --git a/ppapi/tests/test_url_request.cc b/ppapi/tests/test_url_request.cc index febc867..22b0629 100644 --- a/ppapi/tests/test_url_request.cc +++ b/ppapi/tests/test_url_request.cc @@ -40,8 +40,7 @@ TestURLRequest::TestURLRequest(TestingInstance* instance) ppb_url_loader_interface_(NULL), ppb_url_response_interface_(NULL), ppb_core_interface_(NULL), - ppb_var_interface_(NULL), - url_loader_(kInvalidResource) { + ppb_var_interface_(NULL) { } bool TestURLRequest::Init() { @@ -65,10 +64,6 @@ bool TestURLRequest::Init() { instance_->AppendError("PPB_Var interface not available"); if (!ppb_url_loader_interface_) { instance_->AppendError("PPB_URLLoader interface not available"); - } else { - url_loader_ = ppb_url_loader_interface_->Create(instance_->pp_instance()); - if (url_loader_ == kInvalidResource) - instance_->AppendError("Failed to create URLLoader"); } return EnsureRunningOverHTTP(); } @@ -106,7 +101,14 @@ std::string TestURLRequest::TestCreateAndIsURLRequestInfo() { ppb_url_request_interface_->IsURLRequestInfo(kInvalidResource)); ASSERT_NE(PP_TRUE, ppb_url_request_interface_->IsURLRequestInfo(kNotAResource)); - ASSERT_NE(PP_TRUE, ppb_url_request_interface_->IsURLRequestInfo(url_loader_)); + + PP_Resource url_loader = + ppb_url_loader_interface_->Create(instance_->pp_instance()); + ASSERT_NE(kInvalidResource, url_loader); + + ASSERT_NE(PP_TRUE, ppb_url_request_interface_->IsURLRequestInfo(url_loader)); + ppb_url_loader_interface_->Close(url_loader); + ppb_core_interface_->ReleaseResource(url_loader); // IsURLRequestInfo: Current URLRequestInfo resource -> true. std::string error; @@ -289,15 +291,20 @@ std::string TestURLRequest::TestSetProperty() { std::string TestURLRequest::LoadAndCompareBody( PP_Resource url_request, const std::string& expected_body) { TestCompletionCallback callback(instance_->pp_instance(), PP_REQUIRED); + + PP_Resource url_loader = + ppb_url_loader_interface_->Create(instance_->pp_instance()); + ASSERT_NE(kInvalidResource, url_loader); + callback.WaitForResult(ppb_url_loader_interface_->Open( - url_loader_, url_request, + url_loader, url_request, callback.GetCallback().pp_completion_callback())); CHECK_CALLBACK_BEHAVIOR(callback); ASSERT_EQ(PP_OK, callback.result()); std::string error; PP_Resource url_response = - ppb_url_loader_interface_->GetResponseInfo(url_loader_); + ppb_url_loader_interface_->GetResponseInfo(url_loader); if (url_response == kInvalidResource) { error = "PPB_URLLoader::GetResponseInfo() returned invalid resource"; } else { @@ -311,7 +318,7 @@ std::string TestURLRequest::LoadAndCompareBody( const size_t kBufferSize = 32; char buf[kBufferSize]; callback.WaitForResult(ppb_url_loader_interface_->ReadResponseBody( - url_loader_, buf, kBufferSize, + url_loader, buf, kBufferSize, callback.GetCallback().pp_completion_callback())); if (callback.failed()) error.assign(callback.errors()); @@ -327,7 +334,8 @@ std::string TestURLRequest::LoadAndCompareBody( } ppb_core_interface_->ReleaseResource(url_response); - ppb_url_loader_interface_->Close(url_loader_); + ppb_url_loader_interface_->Close(url_loader); + ppb_core_interface_->ReleaseResource(url_loader); return error; } diff --git a/ppapi/tests/test_url_request.h b/ppapi/tests/test_url_request.h index 8986870..922b1b0 100644 --- a/ppapi/tests/test_url_request.h +++ b/ppapi/tests/test_url_request.h @@ -21,7 +21,6 @@ class FileRef; class TestURLRequest : public TestCase { public: explicit TestURLRequest(TestingInstance* instance); - ~TestURLRequest() { ppb_core_interface_->ReleaseResource(url_loader_); } // TestCase implementation. virtual bool Init(); @@ -44,8 +43,6 @@ class TestURLRequest : public TestCase { const PPB_URLResponseInfo* ppb_url_response_interface_; const PPB_Core* ppb_core_interface_; const PPB_Var* ppb_var_interface_; - - PP_Resource url_loader_; }; #endif // PAPPI_TESTS_TEST_URL_REQUEST_H_ |