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

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

Issue 6432001: Implement proxy for FlashMenu and Run/QuitMessageLoop (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Handle NULL menus more gracefully Created 9 years, 10 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
« no previous file with comments | « ppapi/tests/test_file_io.cc ('k') | ppapi/tests/test_graphics_2d.cc » ('j') | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_ref.h" 5 #include "ppapi/tests/test_file_ref.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include "ppapi/c/pp_errors.h" 9 #include "ppapi/c/pp_errors.h"
10 #include "ppapi/c/dev/ppb_file_io_dev.h" 10 #include "ppapi/c/dev/ppb_file_io_dev.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 return "file_ref_pers expected to be persistent."; 65 return "file_ref_pers expected to be persistent.";
66 66
67 pp::FileRef_Dev file_ref_temp(file_system_temp, kTempFilePath); 67 pp::FileRef_Dev file_ref_temp(file_system_temp, kTempFilePath);
68 if (file_ref_temp.GetFileSystemType() != PP_FILESYSTEMTYPE_LOCALTEMPORARY) 68 if (file_ref_temp.GetFileSystemType() != PP_FILESYSTEMTYPE_LOCALTEMPORARY)
69 return "file_ref_temp expected to be temporary."; 69 return "file_ref_temp expected to be temporary.";
70 70
71 pp::URLRequestInfo request(instance_); 71 pp::URLRequestInfo request(instance_);
72 request.SetURL("test_url_loader_data/hello.txt"); 72 request.SetURL("test_url_loader_data/hello.txt");
73 request.SetStreamToFile(true); 73 request.SetStreamToFile(true);
74 74
75 TestCompletionCallback callback; 75 TestCompletionCallback callback(instance_->pp_instance());
76 76
77 pp::URLLoader loader(instance_); 77 pp::URLLoader loader(instance_);
78 int32_t rv = loader.Open(request, callback); 78 int32_t rv = loader.Open(request, callback);
79 if (rv == PP_ERROR_WOULDBLOCK) 79 if (rv == PP_ERROR_WOULDBLOCK)
80 rv = callback.WaitForResult(); 80 rv = callback.WaitForResult();
81 if (rv != PP_OK) 81 if (rv != PP_OK)
82 return "URLLoader::Open() failed."; 82 return "URLLoader::Open() failed.";
83 83
84 pp::URLResponseInfo response_info(loader.GetResponseInfo()); 84 pp::URLResponseInfo response_info(loader.GetResponseInfo());
85 if (response_info.is_null()) 85 if (response_info.is_null())
(...skipping 28 matching lines...) Expand all
114 // Test the "/" case. 114 // Test the "/" case.
115 pp::FileRef_Dev file_ref_slash(file_system_temp, "/"); 115 pp::FileRef_Dev file_ref_slash(file_system_temp, "/");
116 name = file_ref_slash.GetName().AsString(); 116 name = file_ref_slash.GetName().AsString();
117 if (name != "/") 117 if (name != "/")
118 return ReportMismatch("FileRef::GetName", name, "/"); 118 return ReportMismatch("FileRef::GetName", name, "/");
119 119
120 pp::URLRequestInfo request(instance_); 120 pp::URLRequestInfo request(instance_);
121 request.SetURL("test_url_loader_data/hello.txt"); 121 request.SetURL("test_url_loader_data/hello.txt");
122 request.SetStreamToFile(true); 122 request.SetStreamToFile(true);
123 123
124 TestCompletionCallback callback; 124 TestCompletionCallback callback(instance_->pp_instance());
125 125
126 pp::URLLoader loader(instance_); 126 pp::URLLoader loader(instance_);
127 int32_t rv = loader.Open(request, callback); 127 int32_t rv = loader.Open(request, callback);
128 if (rv == PP_ERROR_WOULDBLOCK) 128 if (rv == PP_ERROR_WOULDBLOCK)
129 rv = callback.WaitForResult(); 129 rv = callback.WaitForResult();
130 if (rv != PP_OK) 130 if (rv != PP_OK)
131 return "URLLoader::Open() failed."; 131 return "URLLoader::Open() failed.";
132 132
133 pp::URLResponseInfo response_info(loader.GetResponseInfo()); 133 pp::URLResponseInfo response_info(loader.GetResponseInfo());
134 if (response_info.is_null()) 134 if (response_info.is_null())
(...skipping 23 matching lines...) Expand all
158 158
159 pp::FileRef_Dev file_ref_temp(file_system_temp, kTempFilePath); 159 pp::FileRef_Dev file_ref_temp(file_system_temp, kTempFilePath);
160 path = file_ref_temp.GetPath().AsString(); 160 path = file_ref_temp.GetPath().AsString();
161 if (path != kTempFilePath) 161 if (path != kTempFilePath)
162 return ReportMismatch("FileRef::GetPath", path, kTempFilePath); 162 return ReportMismatch("FileRef::GetPath", path, kTempFilePath);
163 163
164 pp::URLRequestInfo request(instance_); 164 pp::URLRequestInfo request(instance_);
165 request.SetURL("test_url_loader_data/hello.txt"); 165 request.SetURL("test_url_loader_data/hello.txt");
166 request.SetStreamToFile(true); 166 request.SetStreamToFile(true);
167 167
168 TestCompletionCallback callback; 168 TestCompletionCallback callback(instance_->pp_instance());
169 169
170 pp::URLLoader loader(instance_); 170 pp::URLLoader loader(instance_);
171 int32_t rv = loader.Open(request, callback); 171 int32_t rv = loader.Open(request, callback);
172 if (rv == PP_ERROR_WOULDBLOCK) 172 if (rv == PP_ERROR_WOULDBLOCK)
173 rv = callback.WaitForResult(); 173 rv = callback.WaitForResult();
174 if (rv != PP_OK) 174 if (rv != PP_OK)
175 return "URLLoader::Open() failed."; 175 return "URLLoader::Open() failed.";
176 176
177 pp::URLResponseInfo response_info(loader.GetResponseInfo()); 177 pp::URLResponseInfo response_info(loader.GetResponseInfo());
178 if (response_info.is_null()) 178 if (response_info.is_null())
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 // Test the "/foo" case (the parent is "/"). 213 // Test the "/foo" case (the parent is "/").
214 pp::FileRef_Dev file_ref_with_root_parent(file_system_temp, "/foo"); 214 pp::FileRef_Dev file_ref_with_root_parent(file_system_temp, "/foo");
215 parent_path = file_ref_with_root_parent.GetParent().GetPath().AsString(); 215 parent_path = file_ref_with_root_parent.GetParent().GetPath().AsString();
216 if (parent_path != "/") 216 if (parent_path != "/")
217 return ReportMismatch("FileRef::GetParent", parent_path, "/"); 217 return ReportMismatch("FileRef::GetParent", parent_path, "/");
218 218
219 pp::URLRequestInfo request(instance_); 219 pp::URLRequestInfo request(instance_);
220 request.SetURL("test_url_loader_data/hello.txt"); 220 request.SetURL("test_url_loader_data/hello.txt");
221 request.SetStreamToFile(true); 221 request.SetStreamToFile(true);
222 222
223 TestCompletionCallback callback; 223 TestCompletionCallback callback(instance_->pp_instance());
224 224
225 pp::URLLoader loader(instance_); 225 pp::URLLoader loader(instance_);
226 int32_t rv = loader.Open(request, callback); 226 int32_t rv = loader.Open(request, callback);
227 if (rv == PP_ERROR_WOULDBLOCK) 227 if (rv == PP_ERROR_WOULDBLOCK)
228 rv = callback.WaitForResult(); 228 rv = callback.WaitForResult();
229 if (rv != PP_OK) 229 if (rv != PP_OK)
230 return "URLLoader::Open() failed."; 230 return "URLLoader::Open() failed.";
231 231
232 pp::URLResponseInfo response_info(loader.GetResponseInfo()); 232 pp::URLResponseInfo response_info(loader.GetResponseInfo());
233 if (response_info.is_null()) 233 if (response_info.is_null())
234 return "URLLoader::GetResponseInfo returned null"; 234 return "URLLoader::GetResponseInfo returned null";
235 int32_t status_code = response_info.GetStatusCode(); 235 int32_t status_code = response_info.GetStatusCode();
236 if (status_code != 200) 236 if (status_code != 200)
237 return "Unexpected HTTP status code"; 237 return "Unexpected HTTP status code";
238 238
239 pp::FileRef_Dev file_ref_ext(response_info.GetBodyAsFileRef()); 239 pp::FileRef_Dev file_ref_ext(response_info.GetBodyAsFileRef());
240 if (!file_ref_ext.GetParent().is_null()) 240 if (!file_ref_ext.GetParent().is_null())
241 return "The parent of an external FileRef should be null."; 241 return "The parent of an external FileRef should be null.";
242 242
243 PASS(); 243 PASS();
244 } 244 }
245 245
246 std::string TestFileRef::TestMakeDirectory() { 246 std::string TestFileRef::TestMakeDirectory() {
247 TestCompletionCallback callback; 247 TestCompletionCallback callback(instance_->pp_instance());
248 248
249 // Open. 249 // Open.
250 pp::FileSystem_Dev file_system(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY); 250 pp::FileSystem_Dev file_system(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY);
251 int32_t rv = file_system.Open(1024, callback); 251 int32_t rv = file_system.Open(1024, callback);
252 if (rv == PP_ERROR_WOULDBLOCK) 252 if (rv == PP_ERROR_WOULDBLOCK)
253 rv = callback.WaitForResult(); 253 rv = callback.WaitForResult();
254 if (rv != PP_OK) 254 if (rv != PP_OK)
255 return ReportError("FileSystem::Open", rv); 255 return ReportError("FileSystem::Open", rv);
256 256
257 // Open aborted (see the DirectoryReader test for comments). 257 // Open aborted (see the DirectoryReader test for comments).
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 rv = callback.WaitForResult(); 321 rv = callback.WaitForResult();
322 if (rv == PP_OK) { 322 if (rv == PP_OK) {
323 return "Calling FileSystem::MakeDirectory() with a nested directory path " 323 return "Calling FileSystem::MakeDirectory() with a nested directory path "
324 "should have failed."; 324 "should have failed.";
325 } 325 }
326 326
327 PASS(); 327 PASS();
328 } 328 }
329 329
330 std::string TestFileRef::TestQueryAndTouchFile() { 330 std::string TestFileRef::TestQueryAndTouchFile() {
331 TestCompletionCallback callback; 331 TestCompletionCallback callback(instance_->pp_instance());
332 pp::FileSystem_Dev file_system(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY); 332 pp::FileSystem_Dev file_system(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY);
333 int32_t rv = file_system.Open(1024, callback); 333 int32_t rv = file_system.Open(1024, callback);
334 if (rv == PP_ERROR_WOULDBLOCK) 334 if (rv == PP_ERROR_WOULDBLOCK)
335 rv = callback.WaitForResult(); 335 rv = callback.WaitForResult();
336 if (rv != PP_OK) 336 if (rv != PP_OK)
337 return ReportError("FileSystem::Open", rv); 337 return ReportError("FileSystem::Open", rv);
338 338
339 pp::FileRef_Dev file_ref(file_system, "/file_touch"); 339 pp::FileRef_Dev file_ref(file_system, "/file_touch");
340 pp::FileIO_Dev file_io(instance_); 340 pp::FileIO_Dev file_io(instance_);
341 rv = file_io.Open(file_ref, 341 rv = file_io.Open(file_ref,
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 if (rv != PP_ERROR_ABORTED) 405 if (rv != PP_ERROR_ABORTED)
406 return "FileSystem::Query not aborted."; 406 return "FileSystem::Query not aborted.";
407 } else if (rv != PP_OK) { 407 } else if (rv != PP_OK) {
408 return ReportError("FileSystem::Query", rv); 408 return ReportError("FileSystem::Query", rv);
409 } 409 }
410 410
411 PASS(); 411 PASS();
412 } 412 }
413 413
414 std::string TestFileRef::TestDeleteFileAndDirectory() { 414 std::string TestFileRef::TestDeleteFileAndDirectory() {
415 TestCompletionCallback callback; 415 TestCompletionCallback callback(instance_->pp_instance());
416 pp::FileSystem_Dev file_system(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY); 416 pp::FileSystem_Dev file_system(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY);
417 int32_t rv = file_system.Open(1024, callback); 417 int32_t rv = file_system.Open(1024, callback);
418 if (rv == PP_ERROR_WOULDBLOCK) 418 if (rv == PP_ERROR_WOULDBLOCK)
419 rv = callback.WaitForResult(); 419 rv = callback.WaitForResult();
420 if (rv != PP_OK) 420 if (rv != PP_OK)
421 return ReportError("FileSystem::Open", rv); 421 return ReportError("FileSystem::Open", rv);
422 422
423 pp::FileRef_Dev file_ref(file_system, "/file_delete"); 423 pp::FileRef_Dev file_ref(file_system, "/file_delete");
424 pp::FileIO_Dev file_io(instance_); 424 pp::FileIO_Dev file_io(instance_);
425 rv = file_io.Open(file_ref, PP_FILEOPENFLAG_CREATE, callback); 425 rv = file_io.Open(file_ref, PP_FILEOPENFLAG_CREATE, callback);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 if (rv != PP_ERROR_ABORTED) 489 if (rv != PP_ERROR_ABORTED)
490 return "FileSystem::Delete not aborted."; 490 return "FileSystem::Delete not aborted.";
491 } else if (rv != PP_OK) { 491 } else if (rv != PP_OK) {
492 return ReportError("FileSystem::Delete", rv); 492 return ReportError("FileSystem::Delete", rv);
493 } 493 }
494 494
495 PASS(); 495 PASS();
496 } 496 }
497 497
498 std::string TestFileRef::TestRenameFileAndDirectory() { 498 std::string TestFileRef::TestRenameFileAndDirectory() {
499 TestCompletionCallback callback; 499 TestCompletionCallback callback(instance_->pp_instance());
500 pp::FileSystem_Dev file_system(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY); 500 pp::FileSystem_Dev file_system(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY);
501 int32_t rv = file_system.Open(1024, callback); 501 int32_t rv = file_system.Open(1024, callback);
502 if (rv == PP_ERROR_WOULDBLOCK) 502 if (rv == PP_ERROR_WOULDBLOCK)
503 rv = callback.WaitForResult(); 503 rv = callback.WaitForResult();
504 if (rv != PP_OK) 504 if (rv != PP_OK)
505 return ReportError("FileSystem::Open", rv); 505 return ReportError("FileSystem::Open", rv);
506 506
507 pp::FileRef_Dev file_ref(file_system, "/file_rename"); 507 pp::FileRef_Dev file_ref(file_system, "/file_rename");
508 pp::FileIO_Dev file_io(instance_); 508 pp::FileIO_Dev file_io(instance_);
509 rv = file_io.Open(file_ref, PP_FILEOPENFLAG_CREATE, callback); 509 rv = file_io.Open(file_ref, PP_FILEOPENFLAG_CREATE, callback);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 if (rv == PP_ERROR_WOULDBLOCK) { 569 if (rv == PP_ERROR_WOULDBLOCK) {
570 rv = callback.WaitForResult(); 570 rv = callback.WaitForResult();
571 if (rv != PP_ERROR_ABORTED) 571 if (rv != PP_ERROR_ABORTED)
572 return "FileSystem::Rename not aborted."; 572 return "FileSystem::Rename not aborted.";
573 } else if (rv != PP_OK) { 573 } else if (rv != PP_OK) {
574 return ReportError("FileSystem::Rename", rv); 574 return ReportError("FileSystem::Rename", rv);
575 } 575 }
576 576
577 PASS(); 577 PASS();
578 } 578 }
OLDNEW
« no previous file with comments | « ppapi/tests/test_file_io.cc ('k') | ppapi/tests/test_graphics_2d.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698