summaryrefslogtreecommitdiffstats
path: root/ppapi/tests
diff options
context:
space:
mode:
authorviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-25 22:19:28 +0000
committerviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-25 22:19:28 +0000
commitee0abbf1c6190048a158668f43d5e5779b5f65b5 (patch)
tree64f16395e8a817051f21bf28c24b72672b835efc /ppapi/tests
parentb2e600b62f2251f92b45b05db67fd663042fef34 (diff)
downloadchromium_src-ee0abbf1c6190048a158668f43d5e5779b5f65b5.zip
chromium_src-ee0abbf1c6190048a158668f43d5e5779b5f65b5.tar.gz
chromium_src-ee0abbf1c6190048a158668f43d5e5779b5f65b5.tar.bz2
Pepper Flash: Add trivial C++ wrappers for PPB_Flash_File_{ModuleLocal,FileRef}.
Review URL: https://chromiumcodereview.appspot.com/10638007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@144032 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/tests')
-rw-r--r--ppapi/tests/test_flash_file.cc36
-rw-r--r--ppapi/tests/test_flash_file.h5
2 files changed, 17 insertions, 24 deletions
diff --git a/ppapi/tests/test_flash_file.cc b/ppapi/tests/test_flash_file.cc
index b7baeae..f0c4d42 100644
--- a/ppapi/tests/test_flash_file.cc
+++ b/ppapi/tests/test_flash_file.cc
@@ -5,6 +5,7 @@
#include "ppapi/tests/test_flash_file.h"
#include "ppapi/cpp/module.h"
+#include "ppapi/cpp/private/flash_file.h"
#include "ppapi/tests/testing_instance.h"
#include "ppapi/tests/test_utils.h"
@@ -15,6 +16,8 @@
#include <unistd.h>
#endif
+using pp::flash::FileModuleLocal;
+
namespace {
void CloseFileHandle(PP_FileHandle file_handle) {
@@ -76,17 +79,14 @@ bool ReadFile(PP_FileHandle file_handle, std::string* contents) {
REGISTER_TEST_CASE(FlashFile);
TestFlashFile::TestFlashFile(TestingInstance* instance)
- : TestCase(instance), module_local_interface_(NULL) {
+ : TestCase(instance) {
}
TestFlashFile::~TestFlashFile() {
}
bool TestFlashFile::Init() {
- module_local_interface_ = static_cast<const PPB_Flash_File_ModuleLocal*>(
- pp::Module::Get()->GetBrowserInterface(
- PPB_FLASH_FILE_MODULELOCAL_INTERFACE));
- return !!module_local_interface_;
+ return FileModuleLocal::IsAvailable();
}
void TestFlashFile::RunTests(const std::string& filter) {
@@ -94,16 +94,16 @@ void TestFlashFile::RunTests(const std::string& filter) {
}
std::string TestFlashFile::TestCreateTemporaryFile() {
+ ASSERT_TRUE(FileModuleLocal::IsCreateTemporaryFileAvailable());
+
// Make sure that the root directory exists.
- module_local_interface_->CreateDir(instance_->pp_instance(), "");
+ FileModuleLocal::CreateDir(instance_, std::string());
- int32_t before_create = 0;
+ size_t before_create = 0;
ASSERT_SUBTEST_SUCCESS(GetItemCountUnderModuleLocalRoot(&before_create));
- PP_FileHandle file_handle = PP_kInvalidFileHandle;
- int32_t result = module_local_interface_->CreateTemporaryFile(
- instance_->pp_instance(), &file_handle);
- ASSERT_EQ(result, PP_OK);
+ PP_FileHandle file_handle = FileModuleLocal::CreateTemporaryFile(instance_);
+ ASSERT_NE(PP_kInvalidFileHandle, file_handle);
std::string contents = "This is a temp file.";
ASSERT_TRUE(WriteFile(file_handle, contents));
@@ -113,7 +113,7 @@ std::string TestFlashFile::TestCreateTemporaryFile() {
CloseFileHandle(file_handle);
- int32_t after_close = 0;
+ size_t after_close = 0;
ASSERT_SUBTEST_SUCCESS(GetItemCountUnderModuleLocalRoot(&after_close));
ASSERT_EQ(before_create, after_close);
@@ -121,13 +121,9 @@ std::string TestFlashFile::TestCreateTemporaryFile() {
}
std::string TestFlashFile::GetItemCountUnderModuleLocalRoot(
- int32_t* item_count) {
- PP_DirContents_Dev* contents = NULL;
- int32_t result = module_local_interface_->GetDirContents(
- instance_->pp_instance(), "", &contents);
- ASSERT_EQ(result, PP_OK);
-
- *item_count = contents->count;
- module_local_interface_->FreeDirContents(instance_->pp_instance(), contents);
+ size_t* item_count) {
+ std::vector<PP_DirEntry_Dev> contents;
+ ASSERT_TRUE(FileModuleLocal::GetDirContents(instance_, "", &contents));
+ *item_count = contents.size();
PASS();
}
diff --git a/ppapi/tests/test_flash_file.h b/ppapi/tests/test_flash_file.h
index 36adfae..b58890d 100644
--- a/ppapi/tests/test_flash_file.h
+++ b/ppapi/tests/test_flash_file.h
@@ -7,7 +7,6 @@
#include <string>
-#include "ppapi/c/private/ppb_flash_file.h"
#include "ppapi/tests/test_case.h"
class TestFlashFile: public TestCase {
@@ -26,9 +25,7 @@ class TestFlashFile: public TestCase {
// Gets the number of files and directories under the module-local root
// directory.
- std::string GetItemCountUnderModuleLocalRoot(int32_t* item_count);
-
- const PPB_Flash_File_ModuleLocal* module_local_interface_;
+ std::string GetItemCountUnderModuleLocalRoot(size_t* item_count);
};
#endif // PPAPI_TESTS_TEST_FLASH_FILE_H_