b16c2153325a75ac2d61cec7aeccbc7d6263322d
[platform/framework/web/crosswalk.git] / src / native_client_sdk / src / tests / nacl_io_test / dev_fs_for_testing.h
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef TESTS_NACL_IO_TEST_DEV_FS_FOR_TESTING_H_
6 #define TESTS_NACL_IO_TEST_DEV_FS_FOR_TESTING_H_
7
8 #include "fake_ppapi/fake_pepper_interface.h"
9 #include "gmock/gmock.h"
10 #include "nacl_io/devfs/dev_fs.h"
11 #include "nacl_io/filesystem.h"
12
13 #define NULL_NODE ((Node*)NULL)
14
15 class DevFsForTesting : public nacl_io::DevFs {
16  public:
17   explicit DevFsForTesting(nacl_io::PepperInterface* ppapi) {
18     nacl_io::FsInitArgs args(1);
19     args.ppapi = ppapi;
20     Init(args);
21   }
22
23   bool Exists(const char* filename) {
24     nacl_io::ScopedNode node;
25     if (Open(nacl_io::Path(filename), O_RDONLY, &node))
26       return false;
27
28     struct stat buf;
29     return node->GetStat(&buf) == 0;
30   }
31
32   int num_nodes() { return (int)inode_pool_.size(); }
33 };
34
35 #endif  // TESTS_NACL_IO_TEST_DEV_FS_FOR_TESTING_H_