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

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

Issue 16232016: [NaCl SDK] nacl_io: big refactor to return error value (errno). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 | Annotate | Revision Log
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 <fcntl.h> 6 #include <fcntl.h>
7 #include <string.h> 7 #include <string.h>
8 #include <gmock/gmock.h> 8 #include <gmock/gmock.h>
9 #include <ppapi/c/ppb_file_io.h> 9 #include <ppapi/c/ppb_file_io.h>
10 #include <ppapi/c/pp_directory_entry.h> 10 #include <ppapi/c/pp_directory_entry.h>
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 EXPECT_CALL(*ppapi_, ReleaseResource(fileio_resource_)); 148 EXPECT_CALL(*ppapi_, ReleaseResource(fileio_resource_));
149 EXPECT_CALL(*fileio_, Flush(fileio_resource_, _)); 149 EXPECT_CALL(*fileio_, Flush(fileio_resource_, _));
150 } 150 }
151 151
152 void MountHtml5FsNodeTest::InitFilesystem() { 152 void MountHtml5FsNodeTest::InitFilesystem() {
153 StringMap_t map; 153 StringMap_t map;
154 mnt_ = new MountHtml5FsMock(map, ppapi_); 154 mnt_ = new MountHtml5FsMock(map, ppapi_);
155 } 155 }
156 156
157 void MountHtml5FsNodeTest::InitNode() { 157 void MountHtml5FsNodeTest::InitNode() {
158 node_ = mnt_->Open(Path(path_), O_CREAT | O_RDWR); 158 ASSERT_EQ(0, mnt_->Open(Path(path_), O_CREAT | O_RDWR, &node_));
159 ASSERT_NE((MountNode*)NULL, node_); 159 ASSERT_NE((MountNode*)NULL, node_);
160 } 160 }
161 161
162 // Node test where the filesystem is opened synchronously; that is, the 162 // Node test where the filesystem is opened synchronously; that is, the
163 // creation of the mount blocks until the filesystem is ready. 163 // creation of the mount blocks until the filesystem is ready.
164 class MountHtml5FsNodeSyncTest : public MountHtml5FsNodeTest { 164 class MountHtml5FsNodeSyncTest : public MountHtml5FsNodeTest {
165 public: 165 public:
166 virtual void SetUp(); 166 virtual void SetUp();
167 }; 167 };
168 168
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 } 343 }
344 344
345 TEST_F(MountHtml5FsNodeSyncTest, Write) { 345 TEST_F(MountHtml5FsNodeSyncTest, Write) {
346 const int offset = 10; 346 const int offset = 10;
347 const int count = 20; 347 const int count = 20;
348 const char buffer[30] = {0}; 348 const char buffer[30] = {0};
349 349
350 EXPECT_CALL(*fileio_, Write(fileio_resource_, offset, &buffer[0], count, _)) 350 EXPECT_CALL(*fileio_, Write(fileio_resource_, offset, &buffer[0], count, _))
351 .WillOnce(Return(count)); 351 .WillOnce(Return(count));
352 352
353 int result = node_->Write(offset, &buffer, count); 353 int result = 0;
354 EXPECT_EQ(0, node_->Write(offset, &buffer, count, &result));
354 EXPECT_EQ(count, result); 355 EXPECT_EQ(count, result);
355 } 356 }
356 357
357 TEST_F(MountHtml5FsNodeSyncTest, Read) { 358 TEST_F(MountHtml5FsNodeSyncTest, Read) {
358 const int offset = 10; 359 const int offset = 10;
359 const int count = 20; 360 const int count = 20;
360 char buffer[30] = {0}; 361 char buffer[30] = {0};
361 362
362 EXPECT_CALL(*fileio_, Read(fileio_resource_, offset, &buffer[0], count, _)) 363 EXPECT_CALL(*fileio_, Read(fileio_resource_, offset, &buffer[0], count, _))
363 .WillOnce(Return(count)); 364 .WillOnce(Return(count));
364 365
365 int result = node_->Read(offset, &buffer, count); 366 int result = 0;
367 EXPECT_EQ(0, node_->Read(offset, &buffer, count, &result));
366 EXPECT_EQ(count, result); 368 EXPECT_EQ(count, result);
367 } 369 }
368 370
369 TEST_F(MountHtml5FsNodeSyncTest, GetStat) { 371 TEST_F(MountHtml5FsNodeSyncTest, GetStat) {
370 const int size = 123; 372 const int size = 123;
371 const int creation_time = 1000; 373 const int creation_time = 1000;
372 const int access_time = 2000; 374 const int access_time = 2000;
373 const int modified_time = 3000; 375 const int modified_time = 3000;
374 376
375 PP_FileInfo info; 377 PP_FileInfo info;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 EXPECT_CALL(*var, VarToUtf8(IsEqualToVar(fileref_name_1), _)) 436 EXPECT_CALL(*var, VarToUtf8(IsEqualToVar(fileref_name_1), _))
435 .WillOnce(Return(fileref_name_cstr_1)); 437 .WillOnce(Return(fileref_name_cstr_1));
436 EXPECT_CALL(*var, VarToUtf8(IsEqualToVar(fileref_name_2), _)) 438 EXPECT_CALL(*var, VarToUtf8(IsEqualToVar(fileref_name_2), _))
437 .WillOnce(Return(fileref_name_cstr_2)); 439 .WillOnce(Return(fileref_name_cstr_2));
438 440
439 EXPECT_CALL(*ppapi_, ReleaseResource(fileref_resource_1)); 441 EXPECT_CALL(*ppapi_, ReleaseResource(fileref_resource_1));
440 EXPECT_CALL(*ppapi_, ReleaseResource(fileref_resource_2)); 442 EXPECT_CALL(*ppapi_, ReleaseResource(fileref_resource_2));
441 443
442 struct dirent dirents[2]; 444 struct dirent dirents[2];
443 memset(&dirents[0], 0, sizeof(dirents)); 445 memset(&dirents[0], 0, sizeof(dirents));
444 int result = node_->GetDents(0, &dirents[0], sizeof(dirent) * 2); 446 int result = 0;
447 EXPECT_EQ(0, node_->GetDents(0, &dirents[0], sizeof(dirent) * 2, &result));
445 448
446 EXPECT_EQ(0, result); 449 EXPECT_EQ(0, result);
447 EXPECT_STREQ(&fileref_name_cstr_1[0], &dirents[0].d_name[0]); 450 EXPECT_STREQ(&fileref_name_cstr_1[0], &dirents[0].d_name[0]);
448 EXPECT_STREQ(&fileref_name_cstr_2[0], &dirents[1].d_name[0]); 451 EXPECT_STREQ(&fileref_name_cstr_2[0], &dirents[1].d_name[0]);
449 } 452 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698