xref: /haiku/src/tests/kits/storage/EntryTest.h (revision 4a55cc230cf7566cadcbb23b1928eefff8aea9a2)
1 // EntryTest.h
2 
3 #ifndef __sk_entry_test_h__
4 #define __sk_entry_test_h__
5 
6 #include <TestUtils.h>
7 #include "StatableTest.h"
8 
9 class BEntry;
10 struct TestEntry;
11 
12 class EntryTest : public StatableTest
13 {
14 public:
15 	static CppUnit::Test* Suite();
16 
17 	virtual void CreateROStatables(TestStatables& testEntries);
18 	virtual void CreateRWStatables(TestStatables& testEntries);
19 	virtual void CreateUninitializedStatables(TestStatables& testEntries);
20 
21 	// This function called before *each* test added in Suite()
22 	void setUp();
23 
24 	// This function called after *each* test added in Suite()
25 	void tearDown();
26 
27 	//-------------------------------------------------------------------------
28 	// Test functions
29 	//-------------------------------------------------------------------------
30 	void InitTest1Paths(TestEntry &testEntry, status_t error,
31 						bool traverse = false);
32 	void InitTest1Refs(TestEntry &testEntry, status_t error,
33 					   bool traverse = false);
34 	void InitTest1DirPaths(TestEntry &testEntry, status_t error,
35 						   bool traverse = false);
36 	void InitTest1();
37 
38 	void InitTest2Paths(TestEntry &testEntry, status_t error,
39 						bool traverse = false);
40 	void InitTest2Refs(TestEntry &testEntry, status_t error,
41 					   bool traverse = false);
42 	void InitTest2DirPaths(TestEntry &testEntry, status_t error,
43 						   bool traverse = false);
44 	void InitTest2();
45 
46 	void ExistenceTest();
47 	void SpecialGetCasesTest();
48 
49 	void RenameTestEntry(TestEntry *testEntry, TestEntry *newTestEntry,
50 						 string newName, bool existing, bool clobber,
51 						 status_t error, uint32 kind);
52 	void RenameTestEntry(TestEntry *testEntry, TestEntry *newTestEntry,
53 						 bool existing, bool clobber,
54 						 status_t error, uint32 kind);
55 	void RenameTestFile(TestEntry *testEntry, TestEntry *newTestEntry,
56 						bool existing, bool clobber, status_t error);
57 	void RenameTestDir(TestEntry *testEntry, TestEntry *newTestEntry,
58 					   bool existing, bool clobber, status_t error);
59 	void RenameTestLink(TestEntry *testEntry, TestEntry *newTestEntry,
60 						bool existing, bool clobber, status_t error);
61 	void RenameTest();
62 
63 	void MoveToTestEntry(TestEntry *testEntry, TestEntry *testDir,
64 						 string newName, bool existing, bool clobber,
65 						 status_t error, uint32 kind);
66 	void MoveToTestEntry(TestEntry *testEntry, TestEntry *testDir,
67 						 TestEntry *newTestEntry, bool existing, bool clobber,
68 						 status_t error, uint32 kind);
69 	void MoveToTestFile(TestEntry *testEntry, TestEntry *testDir,
70 						TestEntry *newTestEntry, bool existing, bool clobber,
71 						status_t error);
72 	void MoveToTestDir(TestEntry *testEntry, TestEntry *testDir,
73 					   TestEntry *newTestEntry, bool existing, bool clobber,
74 					   status_t error);
75 	void MoveToTestLink(TestEntry *testEntry, TestEntry *testDir,
76 						TestEntry *newTestEntry, bool existing, bool clobber,
77 						status_t error);
78 	void MoveToTest();
79 
80 	void RemoveTest();
81 	void ComparisonTest();
82 	void AssignmentTest();
83 	void MiscTest();
84 	void CFunctionsTest();
85 
86 	//-------------------------------------------------------------------------
87 	// Helper functions
88 	//-------------------------------------------------------------------------
89 	// Creates a symbolic link named link that points to target
90 	void CreateLink(const char *link, const char *target);
91 	// Creates the given file
92 	void CreateFile(const char *file);
93 	// Creates the given file
94 	void CreateDir(const char *dir);
95 	// Removes the given file if it exists
96 	void RemoveFile(const char *file);
97 	// Checks, whether a file exists.
98 	bool PingFile(const char *path, BEntry *entry = NULL);
99 	// Checks, whether a dir exists.
100 	bool PingDir(const char *path, BEntry *entry = NULL);
101 	// Checks, whether a symlink exists.
102 	bool PingLink(const char *path, const char *target = NULL,
103 				  BEntry *entry = NULL);
104 };
105 
106 
107 #endif	// __sk_entry_test_h__
108