diff options
author | piman@google.com <piman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-15 18:44:40 +0000 |
---|---|---|
committer | piman@google.com <piman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-15 18:44:40 +0000 |
commit | 7358d57065aaea13a888a3cce3746873b31ec020 (patch) | |
tree | bf75f7445299e7de65400693fadfb79c81a29e51 /ppapi/tests | |
parent | 3b8f6a896382d48b15188e1d0a0522265e93b3f4 (diff) | |
download | chromium_src-7358d57065aaea13a888a3cce3746873b31ec020.zip chromium_src-7358d57065aaea13a888a3cce3746873b31ec020.tar.gz chromium_src-7358d57065aaea13a888a3cce3746873b31ec020.tar.bz2 |
Implement proxy for FlashMenu and Run/QuitMessageLoop
BUG=none
TEST=Pepper Flash
Review URL: http://codereview.chromium.org/6432001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@74981 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/tests')
-rw-r--r-- | ppapi/tests/test_directory_reader.cc | 2 | ||||
-rw-r--r-- | ppapi/tests/test_file_io.cc | 43 | ||||
-rw-r--r-- | ppapi/tests/test_file_ref.cc | 16 | ||||
-rw-r--r-- | ppapi/tests/test_graphics_2d.cc | 4 | ||||
-rw-r--r-- | ppapi/tests/test_url_loader.cc | 14 | ||||
-rw-r--r-- | ppapi/tests/test_utils.cc | 9 | ||||
-rw-r--r-- | ppapi/tests/test_utils.h | 4 |
7 files changed, 50 insertions, 42 deletions
diff --git a/ppapi/tests/test_directory_reader.cc b/ppapi/tests/test_directory_reader.cc index 3ae83f3..45e9a99 100644 --- a/ppapi/tests/test_directory_reader.cc +++ b/ppapi/tests/test_directory_reader.cc @@ -40,7 +40,7 @@ void TestDirectoryReader::RunTest() { } std::string TestDirectoryReader::TestGetNextFile() { - TestCompletionCallback callback; + TestCompletionCallback callback(instance_->pp_instance()); pp::FileSystem_Dev file_system( instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY); int32_t rv = file_system.Open(1024, callback); diff --git a/ppapi/tests/test_file_io.cc b/ppapi/tests/test_file_io.cc index ec0172c..4a7278f 100644 --- a/ppapi/tests/test_file_io.cc +++ b/ppapi/tests/test_file_io.cc @@ -29,10 +29,11 @@ std::string ReportMismatch(const std::string& method_name, expected_result + "' expected."; } -int32_t ReadEntireFile(pp::FileIO_Dev* file_io, +int32_t ReadEntireFile(PP_Instance instance, + pp::FileIO_Dev* file_io, int32_t offset, std::string* data) { - TestCompletionCallback callback; + TestCompletionCallback callback(instance); char buf[256]; int32_t read_offset = offset; @@ -51,10 +52,11 @@ int32_t ReadEntireFile(pp::FileIO_Dev* file_io, return PP_OK; } -int32_t WriteEntireBuffer(pp::FileIO_Dev* file_io, +int32_t WriteEntireBuffer(PP_Instance instance, + pp::FileIO_Dev* file_io, int32_t offset, const std::string& data) { - TestCompletionCallback callback; + TestCompletionCallback callback(instance); int32_t write_offset = offset; const char* buf = data.c_str(); int32_t size = data.size(); @@ -91,7 +93,7 @@ void TestFileIO::RunTest() { } std::string TestFileIO::TestOpen() { - TestCompletionCallback callback; + TestCompletionCallback callback(instance_->pp_instance()); pp::FileSystem_Dev file_system(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY); pp::FileRef_Dev file_ref(file_system, "/file_open"); @@ -122,7 +124,7 @@ std::string TestFileIO::TestOpen() { } std::string TestFileIO::TestReadWriteSetLength() { - TestCompletionCallback callback; + TestCompletionCallback callback(instance_->pp_instance()); pp::FileSystem_Dev file_system(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY); pp::FileRef_Dev file_ref(file_system, "/file_read_write_setlength"); @@ -144,13 +146,13 @@ std::string TestFileIO::TestReadWriteSetLength() { return ReportError("FileIO::Open", rv); // Write something to the file. - rv = WriteEntireBuffer(&file_io, 0, "test_test"); + rv = WriteEntireBuffer(instance_->pp_instance(), &file_io, 0, "test_test"); if (rv != PP_OK) return ReportError("FileIO::Write", rv); // Read the entire file. std::string read_buffer; - rv = ReadEntireFile(&file_io, 0, &read_buffer); + rv = ReadEntireFile(instance_->pp_instance(), &file_io, 0, &read_buffer); if (rv != PP_OK) return ReportError("FileIO::Read", rv); if (read_buffer != "test_test") @@ -165,7 +167,7 @@ std::string TestFileIO::TestReadWriteSetLength() { // Check the file contents. read_buffer.clear(); - rv = ReadEntireFile(&file_io, 0, &read_buffer); + rv = ReadEntireFile(instance_->pp_instance(), &file_io, 0, &read_buffer); if (rv != PP_OK) return ReportError("FileIO::Read", rv); if (read_buffer != "test") @@ -173,20 +175,20 @@ std::string TestFileIO::TestReadWriteSetLength() { // Try to read past the end of the file. read_buffer.clear(); - rv = ReadEntireFile(&file_io, 100, &read_buffer); + rv = ReadEntireFile(instance_->pp_instance(), &file_io, 100, &read_buffer); if (rv != PP_OK) return ReportError("FileIO::Read", rv); if (!read_buffer.empty()) return ReportMismatch("FileIO::Read", read_buffer, "<empty string>"); // Write past the end of the file. The file should be zero-padded. - rv = WriteEntireBuffer(&file_io, 8, "test"); + rv = WriteEntireBuffer(instance_->pp_instance(), &file_io, 8, "test"); if (rv != PP_OK) return ReportError("FileIO::Write", rv); // Check the contents of the file. read_buffer.clear(); - rv = ReadEntireFile(&file_io, 0, &read_buffer); + rv = ReadEntireFile(instance_->pp_instance(), &file_io, 0, &read_buffer); if (rv != PP_OK) return ReportError("FileIO::Read", rv); if (read_buffer != std::string("test\0\0\0\0test", 12)) @@ -202,7 +204,7 @@ std::string TestFileIO::TestReadWriteSetLength() { // Check the contents of the file. read_buffer.clear(); - rv = ReadEntireFile(&file_io, 0, &read_buffer); + rv = ReadEntireFile(instance_->pp_instance(), &file_io, 0, &read_buffer); if (rv != PP_OK) return ReportError("FileIO::Read", rv); if (read_buffer != std::string("test\0\0\0\0test\0\0\0\0", 16)) @@ -210,13 +212,13 @@ std::string TestFileIO::TestReadWriteSetLength() { std::string("test\0\0\0\0test\0\0\0\0", 16)); // Write in the middle of the file. - rv = WriteEntireBuffer(&file_io, 4, "test"); + rv = WriteEntireBuffer(instance_->pp_instance(), &file_io, 4, "test"); if (rv != PP_OK) return ReportError("FileIO::Write", rv); // Check the contents of the file. read_buffer.clear(); - rv = ReadEntireFile(&file_io, 0, &read_buffer); + rv = ReadEntireFile(instance_->pp_instance(), &file_io, 0, &read_buffer); if (rv != PP_OK) return ReportError("FileIO::Read", rv); if (read_buffer != std::string("testtesttest\0\0\0\0", 16)) @@ -225,7 +227,7 @@ std::string TestFileIO::TestReadWriteSetLength() { // Read from the middle of the file. read_buffer.clear(); - rv = ReadEntireFile(&file_io, 4, &read_buffer); + rv = ReadEntireFile(instance_->pp_instance(), &file_io, 4, &read_buffer); if (rv != PP_OK) return ReportError("FileIO::Read", rv); if (read_buffer != std::string("testtest\0\0\0\0", 12)) @@ -236,7 +238,7 @@ std::string TestFileIO::TestReadWriteSetLength() { } std::string TestFileIO::TestTouchQuery() { - TestCompletionCallback callback; + TestCompletionCallback callback(instance_->pp_instance()); pp::FileSystem_Dev file_system(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY); int32_t rv = file_system.Open(1024, callback); @@ -297,7 +299,7 @@ std::string TestFileIO::TestTouchQuery() { } std::string TestFileIO::TestAbortCalls() { - TestCompletionCallback callback; + TestCompletionCallback callback(instance_->pp_instance()); pp::FileSystem_Dev file_system(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY); pp::FileRef_Dev file_ref(file_system, "/file_abort_calls"); @@ -319,7 +321,10 @@ std::string TestFileIO::TestAbortCalls() { return ReportError("FileIO::Open", rv); // N.B.: Should write at least 3 bytes. - rv = WriteEntireBuffer(&file_io, 0, "foobarbazquux"); + rv = WriteEntireBuffer(instance_->pp_instance(), + &file_io, + 0, + "foobarbazquux"); if (rv != PP_OK) return ReportError("FileIO::Write", rv); } diff --git a/ppapi/tests/test_file_ref.cc b/ppapi/tests/test_file_ref.cc index d3f137a..c336548 100644 --- a/ppapi/tests/test_file_ref.cc +++ b/ppapi/tests/test_file_ref.cc @@ -72,7 +72,7 @@ std::string TestFileRef::TestGetFileSystemType() { request.SetURL("test_url_loader_data/hello.txt"); request.SetStreamToFile(true); - TestCompletionCallback callback; + TestCompletionCallback callback(instance_->pp_instance()); pp::URLLoader loader(instance_); int32_t rv = loader.Open(request, callback); @@ -121,7 +121,7 @@ std::string TestFileRef::TestGetName() { request.SetURL("test_url_loader_data/hello.txt"); request.SetStreamToFile(true); - TestCompletionCallback callback; + TestCompletionCallback callback(instance_->pp_instance()); pp::URLLoader loader(instance_); int32_t rv = loader.Open(request, callback); @@ -165,7 +165,7 @@ std::string TestFileRef::TestGetPath() { request.SetURL("test_url_loader_data/hello.txt"); request.SetStreamToFile(true); - TestCompletionCallback callback; + TestCompletionCallback callback(instance_->pp_instance()); pp::URLLoader loader(instance_); int32_t rv = loader.Open(request, callback); @@ -220,7 +220,7 @@ std::string TestFileRef::TestGetParent() { request.SetURL("test_url_loader_data/hello.txt"); request.SetStreamToFile(true); - TestCompletionCallback callback; + TestCompletionCallback callback(instance_->pp_instance()); pp::URLLoader loader(instance_); int32_t rv = loader.Open(request, callback); @@ -244,7 +244,7 @@ std::string TestFileRef::TestGetParent() { } std::string TestFileRef::TestMakeDirectory() { - TestCompletionCallback callback; + TestCompletionCallback callback(instance_->pp_instance()); // Open. pp::FileSystem_Dev file_system(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY); @@ -328,7 +328,7 @@ std::string TestFileRef::TestMakeDirectory() { } std::string TestFileRef::TestQueryAndTouchFile() { - TestCompletionCallback callback; + TestCompletionCallback callback(instance_->pp_instance()); pp::FileSystem_Dev file_system(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY); int32_t rv = file_system.Open(1024, callback); if (rv == PP_ERROR_WOULDBLOCK) @@ -412,7 +412,7 @@ std::string TestFileRef::TestQueryAndTouchFile() { } std::string TestFileRef::TestDeleteFileAndDirectory() { - TestCompletionCallback callback; + TestCompletionCallback callback(instance_->pp_instance()); pp::FileSystem_Dev file_system(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY); int32_t rv = file_system.Open(1024, callback); if (rv == PP_ERROR_WOULDBLOCK) @@ -496,7 +496,7 @@ std::string TestFileRef::TestDeleteFileAndDirectory() { } std::string TestFileRef::TestRenameFileAndDirectory() { - TestCompletionCallback callback; + TestCompletionCallback callback(instance_->pp_instance()); pp::FileSystem_Dev file_system(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY); int32_t rv = file_system.Open(1024, callback); if (rv == PP_ERROR_WOULDBLOCK) diff --git a/ppapi/tests/test_graphics_2d.cc b/ppapi/tests/test_graphics_2d.cc index b673b81..d0e3f20 100644 --- a/ppapi/tests/test_graphics_2d.cc +++ b/ppapi/tests/test_graphics_2d.cc @@ -63,7 +63,7 @@ void TestGraphics2D::RunTest() { } void TestGraphics2D::QuitMessageLoop() { - testing_interface_->QuitMessageLoop(); + testing_interface_->QuitMessageLoop(instance_->pp_instance()); } bool TestGraphics2D::ReadImageData(const pp::Graphics2D& dc, @@ -93,7 +93,7 @@ bool TestGraphics2D::FlushAndWaitForDone(pp::Graphics2D* context) { return true; if (rv != PP_ERROR_WOULDBLOCK) return false; - testing_interface_->RunMessageLoop(); + testing_interface_->RunMessageLoop(instance_->pp_instance()); return true; } diff --git a/ppapi/tests/test_url_loader.cc b/ppapi/tests/test_url_loader.cc index 72e6d40..2b606c2 100644 --- a/ppapi/tests/test_url_loader.cc +++ b/ppapi/tests/test_url_loader.cc @@ -56,7 +56,7 @@ void TestURLLoader::RunTest() { std::string TestURLLoader::ReadEntireFile(pp::FileIO_Dev* file_io, std::string* data) { - TestCompletionCallback callback; + TestCompletionCallback callback(instance_->pp_instance()); char buf[256]; int64_t offset = 0; @@ -77,7 +77,7 @@ std::string TestURLLoader::ReadEntireFile(pp::FileIO_Dev* file_io, std::string TestURLLoader::ReadEntireResponseBody(pp::URLLoader* loader, std::string* body) { - TestCompletionCallback callback; + TestCompletionCallback callback(instance_->pp_instance()); char buf[2]; // Small so that multiple reads are needed. for (;;) { @@ -97,7 +97,7 @@ std::string TestURLLoader::ReadEntireResponseBody(pp::URLLoader* loader, std::string TestURLLoader::LoadAndCompareBody( const pp::URLRequestInfo& request, const std::string& expected_body) { - TestCompletionCallback callback; + TestCompletionCallback callback(instance_->pp_instance()); pp::URLLoader loader(*instance_); int32_t rv = loader.Open(request, callback); @@ -194,7 +194,7 @@ std::string TestURLLoader::TestStreamToFile() { request.SetURL("test_url_loader_data/hello.txt"); request.SetStreamToFile(true); - TestCompletionCallback callback; + TestCompletionCallback callback(instance_->pp_instance()); pp::URLLoader loader(*instance_); int32_t rv = loader.Open(request, callback); @@ -251,7 +251,7 @@ std::string TestURLLoader::TestSameOriginRestriction() { pp::URLRequestInfo request; request.SetURL("http://www.google.com/"); - TestCompletionCallback callback; + TestCompletionCallback callback(instance_->pp_instance()); pp::URLLoader loader(*instance_); int32_t rv = loader.Open(request, callback); @@ -278,7 +278,7 @@ std::string TestURLLoader::TestAuditURLRedirect() { request.SetURL("/server-redirect?www.google.com"); request.SetFollowRedirects(false); - TestCompletionCallback callback; + TestCompletionCallback callback(instance_->pp_instance()); pp::URLLoader loader(*instance_); int32_t rv = loader.Open(request, callback); @@ -305,7 +305,7 @@ std::string TestURLLoader::TestAbortCalls() { pp::URLRequestInfo request; request.SetURL("test_url_loader_data/hello.txt"); - TestCompletionCallback callback; + TestCompletionCallback callback(instance_->pp_instance()); int32_t rv; // Abort |Open()|. diff --git a/ppapi/tests/test_utils.cc b/ppapi/tests/test_utils.cc index 30246ab..fcaff40 100644 --- a/ppapi/tests/test_utils.cc +++ b/ppapi/tests/test_utils.cc @@ -26,16 +26,17 @@ std::string ReportError(const char* method, int32_t error) { return result; } -TestCompletionCallback::TestCompletionCallback() +TestCompletionCallback::TestCompletionCallback(PP_Instance instance) : result_(PP_ERROR_WOULDBLOCK), post_quit_task_(false), - run_count_(0) { + run_count_(0), + instance_(instance) { } int32_t TestCompletionCallback::WaitForResult() { result_ = PP_ERROR_WOULDBLOCK; // Reset post_quit_task_ = true; - GetTestingInterface()->RunMessageLoop(); + GetTestingInterface()->RunMessageLoop(instance_); return result_; } @@ -52,6 +53,6 @@ void TestCompletionCallback::Handler(void* user_data, int32_t result) { callback->run_count_++; if (callback->post_quit_task_) { callback->post_quit_task_ = false; - GetTestingInterface()->QuitMessageLoop(); + GetTestingInterface()->QuitMessageLoop(callback->instance_); } } diff --git a/ppapi/tests/test_utils.h b/ppapi/tests/test_utils.h index 192b239..6fde9bf 100644 --- a/ppapi/tests/test_utils.h +++ b/ppapi/tests/test_utils.h @@ -8,6 +8,7 @@ #include <string> #include "ppapi/c/dev/ppb_testing_dev.h" +#include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/cpp/completion_callback.h" @@ -16,7 +17,7 @@ std::string ReportError(const char* method, int32_t error); class TestCompletionCallback { public: - TestCompletionCallback(); + TestCompletionCallback(PP_Instance instance); int32_t WaitForResult(); @@ -31,6 +32,7 @@ class TestCompletionCallback { int32_t result_; bool post_quit_task_; unsigned run_count_; + PP_Instance instance_; }; #endif // PPAPI_TESTS_TEST_UTILS_H_ |