mirror of
https://github.com/baketnk/frame-yap.git
synced 2026-10-06 08:00:05 +02:00
Add opt-in visible-overlay laser mode setting
This commit is contained in:
1 parent
f80da228b3
commit
a9d6762ebd
12 files changed
+225
-28
No files matched your search
@@ -0,0 +1,35 @@
|
||||
#include "laser_setting.hpp"
|
||||
#include <cassert>
|
||||
#include <cstdlib>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
int main() {
|
||||
using namespace frameyap;
|
||||
const auto pattern = (std::filesystem::temp_directory_path() / "frameyap-laser-test-XXXXXX").string();
|
||||
std::vector<char> buffer(pattern.begin(), pattern.end());
|
||||
buffer.push_back('\0');
|
||||
const char* created = ::mkdtemp(buffer.data());
|
||||
assert(created);
|
||||
const std::filesystem::path root(created);
|
||||
assert(::setenv("XDG_CONFIG_HOME", root.c_str(), 1) == 0);
|
||||
assert(default_laser_settings_path() == root / "frameyap/lasers-anytime");
|
||||
const auto path = default_laser_settings_path();
|
||||
assert(!load_lasers_anytime(path));
|
||||
assert(save_lasers_anytime(path, true));
|
||||
assert(load_lasers_anytime(path));
|
||||
assert((std::filesystem::status(path).permissions() &
|
||||
(std::filesystem::perms::group_all | std::filesystem::perms::others_all)) == std::filesystem::perms::none);
|
||||
assert(save_lasers_anytime(path, false));
|
||||
assert(!load_lasers_anytime(path));
|
||||
{ std::ofstream out(path, std::ios::trunc); out << "anything else\n"; }
|
||||
assert(!load_lasers_anytime(path));
|
||||
const auto link = root / "link";
|
||||
std::filesystem::create_symlink(path, link);
|
||||
assert(!load_lasers_anytime(link));
|
||||
assert(!save_lasers_anytime(link, true));
|
||||
assert(!load_lasers_anytime(path));
|
||||
std::filesystem::remove_all(root);
|
||||
}
|
||||
Reference in new issue
Block a user