Add FileInfoCollector class
[platform/core/appfw/app-installers.git] / test / smoke_tests / common / smoke_utils.h
index 94f7569..9e1369b 100644 (file)
@@ -152,6 +152,31 @@ struct TestParameters {
   User test_user;
 };
 
+class FileInfoCollector {
+ public:
+  using FileInfo = std::tuple<bf::path, bf::file_type, bf::perms,
+      std::string, std::string, std::string>;
+
+  FileInfoCollector(std::string pkgid, TestParameters params) :
+      pkgid_(pkgid), params_(params) {}
+  bool FileInfoToFile(const bf::path& path) const;
+  bool Init();
+  bool IsEqual(const FileInfoCollector& collector,
+      const std::vector<bf::path>* exception_list = nullptr) const;
+  bool LoadFromFile(const bf::path& path);
+
+ private:
+  void AddPath(const bf::path& path);
+  bool CollectFileInfoRecursive();
+  bool GetFileListTraversal(const bf::path& cur);
+  std::string FileInfoToString(const FileInfo& file_info) const;
+
+  std::string pkgid_;
+  TestParameters params_;
+  std::vector<bf::path> root_paths_;
+  std::vector<FileInfo> FileInfos_;
+};
+
 struct PackageAttributes {
   explicit PackageAttributes(common_installer::PkgQueryInterface pi)
       : is_global(pi.IsGlobalPackage()), is_readonly(pi.IsReadonlyPackage()),
@@ -180,7 +205,8 @@ common_installer::RequestMode ParseRequestMode(int argc,  char** argv);
 
 bool TouchFile(const boost::filesystem::path& path);
 
-void AddDataFiles(const std::string& pkgid, uid_t uid);
+void AddDataFiles(const std::string& pkgid, uid_t uid,
+    std::vector<bf::path>* result = nullptr);
 
 bool AddTestUser(User* test_user);
 
@@ -402,6 +428,9 @@ class StepCrash : public common_installer::Step {
   CrashStepType type_;
 };
 
+bool CompareFileInfo(const std::string& pkgid, const TestParameters& params,
+    const bf::path& file);
+
 }  // namespace smoke_test
 
 #endif  // TEST_SMOKE_TESTS_COMMON_SMOKE_UTILS_H_