Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(433)

Side by Side Diff: ppapi/tests/test_file_system.cc

Issue 7387011: Clean up the file dev interfaces. The combination of some dev and some non (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« ppapi/tests/test_file_io.cc ('K') | « ppapi/tests/test_file_io.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/dev/file_system_dev.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 InitTestingInterface() && EnsureRunningOverHTTP(); 17 return InitTestingInterface() && EnsureRunningOverHTTP();
18 } 18 }
19 19
20 void TestFileSystem::RunTest() { 20 void TestFileSystem::RunTest() {
21 RUN_TEST_FORCEASYNC_AND_NOT(Open); 21 RUN_TEST_FORCEASYNC_AND_NOT(Open);
22 RUN_TEST_FORCEASYNC_AND_NOT(MultipleOpens); 22 RUN_TEST_FORCEASYNC_AND_NOT(MultipleOpens);
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(), force_async_);
27 27
28 // Open. 28 // Open.
29 pp::FileSystem_Dev file_system(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY); 29 pp::FileSystem file_system(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY);
30 int32_t rv = file_system.Open(1024, callback); 30 int32_t rv = file_system.Open(1024, callback);
31 if (rv == PP_OK_COMPLETIONPENDING) 31 if (rv == PP_OK_COMPLETIONPENDING)
32 rv = callback.WaitForResult(); 32 rv = callback.WaitForResult();
33 if (rv != PP_OK) 33 if (rv != PP_OK)
34 return ReportError("FileSystem::Open", rv); 34 return ReportError("FileSystem::Open", rv);
35 35
36 // Open aborted (see the DirectoryReader test for comments). 36 // Open aborted (see the DirectoryReader test for comments).
37 callback.reset_run_count(); 37 callback.reset_run_count();
38 rv = pp::FileSystem_Dev(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY) 38 rv = pp::FileSystem(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY)
39 .Open(1024, callback); 39 .Open(1024, callback);
40 if (callback.run_count() > 0) 40 if (callback.run_count() > 0)
41 return "FileSystem::Open ran callback synchronously."; 41 return "FileSystem::Open ran callback synchronously.";
42 if (force_async_ && rv != PP_OK_COMPLETIONPENDING) 42 if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
43 return ReportError("FileSystem::Open force_async", rv); 43 return ReportError("FileSystem::Open force_async", rv);
44 if (rv == PP_OK_COMPLETIONPENDING) { 44 if (rv == PP_OK_COMPLETIONPENDING) {
45 rv = callback.WaitForResult(); 45 rv = callback.WaitForResult();
46 if (rv != PP_ERROR_ABORTED) 46 if (rv != PP_ERROR_ABORTED)
47 return "FileSystem::Open not aborted."; 47 return "FileSystem::Open not aborted.";
48 } else if (rv != PP_OK) { 48 } else if (rv != PP_OK) {
49 return ReportError("FileSystem::Open", rv); 49 return ReportError("FileSystem::Open", rv);
50 } 50 }
51 51
52 PASS(); 52 PASS();
53 } 53 }
54 54
55 std::string TestFileSystem::TestMultipleOpens() { 55 std::string TestFileSystem::TestMultipleOpens() {
56 // Should not allow multiple opens, no matter the first open has completed or 56 // Should not allow multiple opens, no matter the first open has completed or
57 // not. 57 // not.
58 TestCompletionCallback callback_1(instance_->pp_instance(), force_async_); 58 TestCompletionCallback callback_1(instance_->pp_instance(), force_async_);
59 pp::FileSystem_Dev file_system(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY); 59 pp::FileSystem file_system(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY);
60 int32_t rv_1 = file_system.Open(1024, callback_1); 60 int32_t rv_1 = file_system.Open(1024, callback_1);
61 if (callback_1.run_count() > 0) 61 if (callback_1.run_count() > 0)
62 return "FileSystem::Open1 ran callback synchronously."; 62 return "FileSystem::Open1 ran callback synchronously.";
63 if (force_async_ && rv_1 != PP_OK_COMPLETIONPENDING) 63 if (force_async_ && rv_1 != PP_OK_COMPLETIONPENDING)
64 return ReportError("FileSystem::Open1 force_async", rv_1); 64 return ReportError("FileSystem::Open1 force_async", rv_1);
65 65
66 TestCompletionCallback callback_2(instance_->pp_instance(), force_async_); 66 TestCompletionCallback callback_2(instance_->pp_instance(), force_async_);
67 int32_t rv_2 = file_system.Open(1024, callback_2); 67 int32_t rv_2 = file_system.Open(1024, callback_2);
68 if (force_async_ && rv_2 != PP_OK_COMPLETIONPENDING) 68 if (force_async_ && rv_2 != PP_OK_COMPLETIONPENDING)
69 return ReportError("FileSystem::Open2 force_async", rv_2); 69 return ReportError("FileSystem::Open2 force_async", rv_2);
70 if (rv_2 == PP_OK_COMPLETIONPENDING || rv_2 == PP_OK) 70 if (rv_2 == PP_OK_COMPLETIONPENDING || rv_2 == PP_OK)
71 return "FileSystem::Open2 should not allow multiple opens."; 71 return "FileSystem::Open2 should not allow multiple opens.";
72 72
73 if (rv_1 == PP_OK_COMPLETIONPENDING) 73 if (rv_1 == PP_OK_COMPLETIONPENDING)
74 rv_1 = callback_1.WaitForResult(); 74 rv_1 = callback_1.WaitForResult();
75 if (rv_1 != PP_OK) 75 if (rv_1 != PP_OK)
76 return ReportError("FileSystem::Open1", rv_1); 76 return ReportError("FileSystem::Open1", rv_1);
77 77
78 TestCompletionCallback callback_3(instance_->pp_instance(), force_async_); 78 TestCompletionCallback callback_3(instance_->pp_instance(), force_async_);
79 int32_t rv_3 = file_system.Open(1024, callback_3); 79 int32_t rv_3 = file_system.Open(1024, callback_3);
80 if (force_async_ && rv_3 != PP_OK_COMPLETIONPENDING) 80 if (force_async_ && rv_3 != PP_OK_COMPLETIONPENDING)
81 return ReportError("FileSystem::Open3 force_async", rv_3); 81 return ReportError("FileSystem::Open3 force_async", rv_3);
82 if (rv_3 == PP_OK_COMPLETIONPENDING || rv_3 == PP_OK) 82 if (rv_3 == PP_OK_COMPLETIONPENDING || rv_3 == PP_OK)
83 return "FileSystem::Open3 should not allow multiple opens."; 83 return "FileSystem::Open3 should not allow multiple opens.";
84 84
85 PASS(); 85 PASS();
86 } 86 }
OLDNEW
« ppapi/tests/test_file_io.cc ('K') | « ppapi/tests/test_file_io.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698