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

Side by Side Diff: native_client_sdk/src/libraries/nacl_io_test/mount_html5fs_test.cc

Issue 15800004: [NaCl SDK] nacl_io: Added support for access() syscall. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Misc fixes. Created 7 years, 6 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
OLDNEW
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 5
6 #include <errno.h> 6 #include <errno.h>
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <string.h> 8 #include <string.h>
9 #include <gmock/gmock.h> 9 #include <gmock/gmock.h>
10 #include <ppapi/c/ppb_file_io.h> 10 #include <ppapi/c/ppb_file_io.h>
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 312
313 TEST_F(MountHtml5FsTest, FilesystemType) { 313 TEST_F(MountHtml5FsTest, FilesystemType) {
314 SetUpFilesystemExpectations(PP_FILESYSTEMTYPE_LOCALPERSISTENT, 100); 314 SetUpFilesystemExpectations(PP_FILESYSTEMTYPE_LOCALPERSISTENT, 100);
315 315
316 StringMap_t map; 316 StringMap_t map;
317 map["type"] = "PERSISTENT"; 317 map["type"] = "PERSISTENT";
318 map["expected_size"] = "100"; 318 map["expected_size"] = "100";
319 MountHtml5FsMock mnt(map, ppapi_); 319 MountHtml5FsMock mnt(map, ppapi_);
320 } 320 }
321 321
322 TEST_F(MountHtml5FsTest, Access) {
323 const char path[] = "/foo";
324 const PP_Resource fileref_resource = 235;
325 const PP_Resource fileio_resource = 236;
326
327 // These are the default values.
328 SetUpFilesystemExpectations(PP_FILESYSTEMTYPE_LOCALPERSISTENT, 0);
329
330 FileRefInterfaceMock* fileref = ppapi_->GetFileRefInterface();
331 FileIoInterfaceMock* fileio = ppapi_->GetFileIoInterface();
332
333 // First, report the file as missing. Then, report the file as present.
334 EXPECT_CALL(*fileref, Create(filesystem_resource_, StrEq(&path[0])))
335 .WillOnce(Return(0))
Matt Giuca 2013/06/20 22:58:22 Ah, I just realised (due to your explanation on th
Matt Giuca 2013/06/21 01:57:42 Done.
336 .WillOnce(Return(fileref_resource));
337 PP_FileInfo info;
338 memset(&info, 0, sizeof(PP_FileInfo));
339 info.type = PP_FILETYPE_REGULAR;
340 EXPECT_CALL(*fileref, Query(fileref_resource, _, _))
341 .WillOnce(DoAll(SetArgPointee<1>(info),
342 Return(int32_t(PP_OK))));
343 EXPECT_CALL(*fileio, Create(instance_)).WillOnce(Return(fileio_resource));
344 int32_t open_flags = PP_FILEOPENFLAG_READ;
345 EXPECT_CALL(*fileio,
346 Open(fileio_resource, fileref_resource, open_flags, _))
347 .WillOnce(Return(int32_t(PP_OK)));
348 EXPECT_CALL(*fileio, Close(fileio_resource));
349 EXPECT_CALL(*fileio, Flush(fileio_resource, _));
350 EXPECT_CALL(*ppapi_, ReleaseResource(fileio_resource));
351 EXPECT_CALL(*ppapi_, ReleaseResource(fileref_resource));
352
353 StringMap_t map;
354 MountHtml5FsMock mnt(map, ppapi_);
355
356 // The first time, the mock will report the file as missing.
357 ASSERT_EQ(ENOENT, mnt.Access(Path(path), F_OK));
358 // The second time, the mock will report the file as present.
359 ASSERT_EQ(0, mnt.Access(Path(path), R_OK | W_OK | X_OK));
360 }
361
322 TEST_F(MountHtml5FsTest, Mkdir) { 362 TEST_F(MountHtml5FsTest, Mkdir) {
323 const char path[] = "/foo"; 363 const char path[] = "/foo";
324 const PP_Resource fileref_resource = 235; 364 const PP_Resource fileref_resource = 235;
325 365
326 // These are the default values. 366 // These are the default values.
327 SetUpFilesystemExpectations(PP_FILESYSTEMTYPE_LOCALPERSISTENT, 0); 367 SetUpFilesystemExpectations(PP_FILESYSTEMTYPE_LOCALPERSISTENT, 0);
328 368
329 FileRefInterfaceMock* fileref = ppapi_->GetFileRefInterface(); 369 FileRefInterfaceMock* fileref = ppapi_->GetFileRefInterface();
330 370
331 EXPECT_CALL(*fileref, Create(filesystem_resource_, StrEq(&path[0]))) 371 EXPECT_CALL(*fileref, Create(filesystem_resource_, StrEq(&path[0])))
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 ASSERT_EQ(sizeof(dirent) * 2, result_bytes); 591 ASSERT_EQ(sizeof(dirent) * 2, result_bytes);
552 EXPECT_LT(0, dirents[0].d_ino); // 0 is an invalid inode number. 592 EXPECT_LT(0, dirents[0].d_ino); // 0 is an invalid inode number.
553 EXPECT_EQ(sizeof(dirent), dirents[0].d_off); 593 EXPECT_EQ(sizeof(dirent), dirents[0].d_off);
554 EXPECT_EQ(sizeof(dirent), dirents[0].d_reclen); 594 EXPECT_EQ(sizeof(dirent), dirents[0].d_reclen);
555 EXPECT_STREQ(fileref_name_cstr_1, dirents[0].d_name); 595 EXPECT_STREQ(fileref_name_cstr_1, dirents[0].d_name);
556 EXPECT_LT(0, dirents[1].d_ino); // 0 is an invalid inode number. 596 EXPECT_LT(0, dirents[1].d_ino); // 0 is an invalid inode number.
557 EXPECT_EQ(sizeof(dirent), dirents[1].d_off); 597 EXPECT_EQ(sizeof(dirent), dirents[1].d_off);
558 EXPECT_EQ(sizeof(dirent), dirents[1].d_reclen); 598 EXPECT_EQ(sizeof(dirent), dirents[1].d_reclen);
559 EXPECT_STREQ(fileref_name_cstr_2, dirents[1].d_name); 599 EXPECT_STREQ(fileref_name_cstr_2, dirents[1].d_name);
560 } 600 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698