mirror of
https://github.com/audacity/linuxdeploy.git
synced 2025-12-11 19:56:54 -06:00
Add unit test for AppDir::createBasicStructure
This commit is contained in:
parent
55b6ee19e1
commit
f1e752d452
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,5 +2,4 @@ cmake-build-*/
|
||||
*build*/
|
||||
.idea/
|
||||
squashfs-root/
|
||||
tests/
|
||||
*.AppImage
|
||||
|
||||
@ -12,4 +12,10 @@ set(USE_SYSTEM_CIMG ON CACHE BOOL "Set to OFF to use CImg library bundled in lib
|
||||
|
||||
add_subdirectory(lib)
|
||||
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(src)
|
||||
|
||||
option(BUILD_TEST "Build the tests" ON)
|
||||
if(PACKAGE_TESTS)
|
||||
enable_testing()
|
||||
add_subdirectory(tests)
|
||||
endif()
|
||||
|
||||
72
tests/AppDirUnitTests.cpp
Normal file
72
tests/AppDirUnitTests.cpp
Normal file
@ -0,0 +1,72 @@
|
||||
#include "gtest/gtest.h"
|
||||
#include "linuxdeploy/core/appdir.h"
|
||||
|
||||
using namespace linuxdeploy::core::appdir;
|
||||
using namespace boost::filesystem;
|
||||
namespace AppDirUnitTests {
|
||||
class AppDirUnitTestsFixture : public ::testing::Test {
|
||||
public:
|
||||
AppDirUnitTestsFixture() :
|
||||
tmpAppDir(temp_directory_path() / unique_path("linuxdeploy-tests-%%%%-%%%%-%%%%")),
|
||||
appDir(tmpAppDir) {
|
||||
}
|
||||
|
||||
void SetUp() override {
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
remove_all(tmpAppDir);
|
||||
}
|
||||
|
||||
~AppDirUnitTestsFixture() override = default;
|
||||
|
||||
void listDeployedFiles() {
|
||||
std::cout << "Files deployed in AppDir:";
|
||||
recursive_directory_iterator end_itr; // default construction yields past-the-end
|
||||
for (recursive_directory_iterator itr(tmpAppDir); itr != end_itr; itr++) {
|
||||
std::cout << relative(itr->path(), tmpAppDir).string() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
path tmpAppDir;
|
||||
AppDir appDir;
|
||||
};
|
||||
|
||||
TEST_F(AppDirUnitTestsFixture, createBasicStructure) {
|
||||
std::set<std::string> expected = {
|
||||
"usr",
|
||||
"usr/bin",
|
||||
"usr/share",
|
||||
"usr/share/icons",
|
||||
"usr/share/icons/hicolor",
|
||||
"usr/share/icons/hicolor/scalable",
|
||||
"usr/share/icons/hicolor/scalable/apps",
|
||||
"usr/share/icons/hicolor/32x32",
|
||||
"usr/share/icons/hicolor/32x32/apps",
|
||||
"usr/share/icons/hicolor/256x256",
|
||||
"usr/share/icons/hicolor/256x256/apps",
|
||||
"usr/share/icons/hicolor/16x16",
|
||||
"usr/share/icons/hicolor/16x16/apps",
|
||||
"usr/share/icons/hicolor/128x128",
|
||||
"usr/share/icons/hicolor/128x128/apps",
|
||||
"usr/share/icons/hicolor/64x64",
|
||||
"usr/share/icons/hicolor/64x64/apps",
|
||||
"usr/share/applications",
|
||||
"usr/lib",
|
||||
};
|
||||
|
||||
appDir.createBasicStructure();
|
||||
|
||||
recursive_directory_iterator end_itr; // default construction yields past-the-end
|
||||
for (recursive_directory_iterator itr(tmpAppDir); itr != end_itr; itr++) {
|
||||
std::string path = relative(itr->path(), tmpAppDir).string();
|
||||
if (expected.find(path) == expected.end())
|
||||
FAIL();
|
||||
else
|
||||
expected.erase(path);
|
||||
}
|
||||
if (!expected.empty())
|
||||
FAIL();
|
||||
|
||||
}
|
||||
}
|
||||
9
tests/CMakeLists.txt
Normal file
9
tests/CMakeLists.txt
Normal file
@ -0,0 +1,9 @@
|
||||
if(NOT TARGET gtest)
|
||||
include(AddGoogleTest)
|
||||
endif()
|
||||
|
||||
add_executable(AppDirUnitTests AppDirUnitTests.cpp)
|
||||
target_link_libraries(AppDirUnitTests PRIVATE linuxdeploy_core)
|
||||
target_include_directories(AppDirUnitTests PRIVATE ${PROJECT_SOURCE_DIR}/include)
|
||||
|
||||
add_gtest(AppDirUnitTests)
|
||||
2
tests/simple_library/CMakeLists.txt
Normal file
2
tests/simple_library/CMakeLists.txt
Normal file
@ -0,0 +1,2 @@
|
||||
add_library(simple_library SHARED simple_library.cpp)
|
||||
target_link_libraries(simple_library cairo)
|
||||
8
tests/simple_library/simple_library.cpp
Normal file
8
tests/simple_library/simple_library.cpp
Normal file
@ -0,0 +1,8 @@
|
||||
#include "CImg.h"
|
||||
using namespace cimg_library;
|
||||
|
||||
extern "C" {
|
||||
void hello_world() {
|
||||
cimg::info();
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user