| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ppapi/tests/test_file_system.h" | 5 #include "ppapi/tests/test_file_system.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 #include "ppapi/c/pp_errors.h" | 9 #include "ppapi/c/pp_errors.h" |
| 10 #include "ppapi/cpp/file_system.h" | 10 #include "ppapi/cpp/file_system.h" |
| 11 #include "ppapi/tests/test_utils.h" | 11 #include "ppapi/tests/test_utils.h" |
| 12 #include "ppapi/tests/testing_instance.h" | 12 #include "ppapi/tests/testing_instance.h" |
| 13 | 13 |
| 14 REGISTER_TEST_CASE(FileSystem); | 14 REGISTER_TEST_CASE(FileSystem); |
| 15 | 15 |
| 16 bool TestFileSystem::Init() { | 16 bool TestFileSystem::Init() { |
| 17 return CheckTestingInterface() && EnsureRunningOverHTTP(); | 17 return CheckTestingInterface() && EnsureRunningOverHTTP(); |
| 18 } | 18 } |
| 19 | 19 |
| 20 void TestFileSystem::RunTests(const std::string& filter) { | 20 void TestFileSystem::RunTests(const std::string& filter) { |
| 21 RUN_TEST_FORCEASYNC_AND_NOT(Open, filter); | 21 RUN_CALLBACK_TEST(TestFileSystem, Open, filter); |
| 22 RUN_TEST_FORCEASYNC_AND_NOT(MultipleOpens, filter); | 22 RUN_CALLBACK_TEST(TestFileSystem, MultipleOpens, filter); |
| 23 } | 23 } |
| 24 | 24 |
| 25 std::string TestFileSystem::TestOpen() { | 25 std::string TestFileSystem::TestOpen() { |
| 26 TestCompletionCallback callback(instance_->pp_instance(), force_async_); | 26 TestCompletionCallback callback(instance_->pp_instance(), callback_type()); |
| 27 | 27 |
| 28 // Open. | 28 // Open. |
| 29 pp::FileSystem file_system(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY); | 29 pp::FileSystem file_system(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY); |
| 30 callback.WaitForResult(file_system.Open(1024, callback.GetCallback())); | 30 callback.WaitForResult(file_system.Open(1024, callback.GetCallback())); |
| 31 CHECK_CALLBACK_BEHAVIOR(callback); | 31 CHECK_CALLBACK_BEHAVIOR(callback); |
| 32 ASSERT_EQ(PP_OK, callback.result()); | 32 ASSERT_EQ(PP_OK, callback.result()); |
| 33 | 33 |
| 34 // Open aborted (see the DirectoryReader test for comments). | 34 // Open aborted (see the DirectoryReader test for comments). |
| 35 int32_t rv = 0; | 35 int32_t rv = 0; |
| 36 { | 36 { |
| 37 pp::FileSystem fs(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY); | 37 pp::FileSystem fs(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY); |
| 38 rv = fs.Open(1024, callback.GetCallback()); | 38 rv = fs.Open(1024, callback.GetCallback()); |
| 39 } | 39 } |
| 40 callback.WaitForAbortResult(rv); | 40 callback.WaitForAbortResult(rv); |
| 41 CHECK_CALLBACK_BEHAVIOR(callback); | 41 CHECK_CALLBACK_BEHAVIOR(callback); |
| 42 | 42 |
| 43 PASS(); | 43 PASS(); |
| 44 } | 44 } |
| 45 | 45 |
| 46 std::string TestFileSystem::TestMultipleOpens() { | 46 std::string TestFileSystem::TestMultipleOpens() { |
| 47 // Should not allow multiple opens, regardless of whether or not the first | 47 // Should not allow multiple opens, regardless of whether or not the first |
| 48 // open has completed. | 48 // open has completed. |
| 49 TestCompletionCallback callback_1(instance_->pp_instance(), force_async_); | 49 TestCompletionCallback callback_1(instance_->pp_instance(), callback_type()); |
| 50 pp::FileSystem file_system(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY); | 50 pp::FileSystem file_system(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY); |
| 51 int32_t rv_1 = file_system.Open(1024, callback_1.GetCallback()); | 51 int32_t rv_1 = file_system.Open(1024, callback_1.GetCallback()); |
| 52 | 52 |
| 53 TestCompletionCallback callback_2(instance_->pp_instance(), force_async_); | 53 TestCompletionCallback callback_2(instance_->pp_instance(), callback_type()); |
| 54 callback_2.WaitForResult(file_system.Open(1024, callback_2.GetCallback())); | 54 callback_2.WaitForResult(file_system.Open(1024, callback_2.GetCallback())); |
| 55 CHECK_CALLBACK_BEHAVIOR(callback_2); | 55 CHECK_CALLBACK_BEHAVIOR(callback_2); |
| 56 // FileSystem should not allow multiple opens. | 56 // FileSystem should not allow multiple opens. |
| 57 ASSERT_NE(PP_OK, callback_2.result()); | 57 ASSERT_NE(PP_OK, callback_2.result()); |
| 58 | 58 |
| 59 callback_1.WaitForResult(rv_1); | 59 callback_1.WaitForResult(rv_1); |
| 60 CHECK_CALLBACK_BEHAVIOR(callback_1); | 60 CHECK_CALLBACK_BEHAVIOR(callback_1); |
| 61 ASSERT_EQ(PP_OK, callback_1.result()); | 61 ASSERT_EQ(PP_OK, callback_1.result()); |
| 62 | 62 |
| 63 TestCompletionCallback callback_3(instance_->pp_instance(), force_async_); | 63 TestCompletionCallback callback_3(instance_->pp_instance(), callback_type()); |
| 64 callback_3.WaitForResult(file_system.Open(1024, callback_3.GetCallback())); | 64 callback_3.WaitForResult(file_system.Open(1024, callback_3.GetCallback())); |
| 65 CHECK_CALLBACK_BEHAVIOR(callback_3); | 65 CHECK_CALLBACK_BEHAVIOR(callback_3); |
| 66 ASSERT_NE(PP_OK, callback_3.result()); | 66 ASSERT_NE(PP_OK, callback_3.result()); |
| 67 | 67 |
| 68 PASS(); | 68 PASS(); |
| 69 } | 69 } |
| OLD | NEW |