Compare commits
2 Commits
improve-lo
...
fix-logger
Author | SHA1 | Date | |
---|---|---|---|
3fd6671048
|
|||
a08f6167b3
|
8
.gitignore
vendored
8
.gitignore
vendored
@@ -1,9 +1,13 @@
|
||||
# Folder
|
||||
builddir/
|
||||
ptouch-print/
|
||||
subprojects/*
|
||||
!subprojects/*.wrap
|
||||
.cache/
|
||||
coverageReport/
|
||||
|
||||
# Files
|
||||
!subprojects/*.wrap
|
||||
.vscode/*
|
||||
!.vscode/c_cpp_properties.json
|
||||
!.vscode/settings.json
|
||||
!.vscode/launch.json
|
||||
ptouch-print/
|
21
generate_coverage.sh
Executable file
21
generate_coverage.sh
Executable file
@@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
|
||||
SCRIPT_PATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
|
||||
HTML_COV_PATH="coverageReport/html"
|
||||
HTML_START_FILE="index.html"
|
||||
|
||||
echo "Generating Coverage report for ptouch-prnt"
|
||||
|
||||
ninja -C builddir
|
||||
ninja -C builddir test
|
||||
|
||||
mkdir -p ${HTML_COV_PATH}
|
||||
gcovr --html --html-details --html-syntax-highlighting --filter src --output ${HTML_COV_PATH}/${HTML_START_FILE}
|
||||
|
||||
if [ $? ]
|
||||
then
|
||||
echo "Coverage report successful generated!"
|
||||
echo "Open: file://${SCRIPT_PATH}/${HTML_COV_PATH}/${HTML_START_FILE}"
|
||||
else
|
||||
echo "Error generating coverage report!"
|
||||
fi
|
38
meson.build
38
meson.build
@@ -17,45 +17,15 @@ endif
|
||||
|
||||
incdir = include_directories('src')
|
||||
|
||||
ptprnt_hpps = [
|
||||
'src/libusbwrap/interface/IUsbDeviceFactory.hpp',
|
||||
'src/libusbwrap/interface/IUsbDevice.hpp',
|
||||
'src/libusbwrap/UsbDeviceFactory.hpp',
|
||||
'src/libusbwrap/LibUsbTypes.hpp',
|
||||
'src/libusbwrap/UsbDevice.hpp',
|
||||
'src/interface/IPrinterDriver.hpp',
|
||||
'src/interface/IPrinterTypes.hpp',
|
||||
'src/P700Printer.hpp',
|
||||
'src/PtouchPrint.hpp',
|
||||
'src/graphics/Bitmap.hpp',
|
||||
'src/graphics/Image.hpp',
|
||||
'src/graphics/Monochrome.hpp'
|
||||
]
|
||||
|
||||
ptprnt_srcs = [
|
||||
'src/PtouchPrint.cpp',
|
||||
'src/P700Printer.cpp',
|
||||
'src/graphics/Image.cpp',
|
||||
'src/graphics/Bitmap.cpp',
|
||||
'src/graphics/Monochrome.cpp',
|
||||
'src/libusbwrap/UsbDeviceFactory.cpp',
|
||||
'src/libusbwrap/UsbDevice.cpp',
|
||||
]
|
||||
|
||||
ptprnt_lib = library('ptprnt',
|
||||
include_directories: incdir,
|
||||
install: true,
|
||||
dependencies: [usb_dep, log_dep, pangocairo_dep, cli11_dep],
|
||||
sources: [ptprnt_hpps, ptprnt_srcs])
|
||||
|
||||
ptprnt_dep = declare_dependency(include_directories: incdir,
|
||||
link_with: ptprnt_lib)
|
||||
subdir('src')
|
||||
|
||||
ptprnt_exe = executable(
|
||||
'ptprnt',
|
||||
'src/main.cpp',
|
||||
install: true,
|
||||
dependencies : [usb_dep, log_dep, cli11_dep, ptprnt_dep],
|
||||
dependencies : [usb_dep, log_dep, pangocairo_dep, cli11_dep],
|
||||
include_directories: incdir,
|
||||
sources: [ptprnt_srcs],
|
||||
cpp_args : ['-DPROJ_VERSION="'+meson.project_version()+'"'],
|
||||
)
|
||||
|
||||
|
@@ -52,6 +52,11 @@ bool Bitmap<T>::setPixels(const std::vector<T>& pixels) {
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
std::vector<T> Bitmap<T>::getPixelsCpy() {
|
||||
return mPixels;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
std::optional<std::vector<T>> Bitmap<T>::getLine(uint16_t line) {
|
||||
if (line >= mHeight) {
|
||||
|
@@ -22,6 +22,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
|
||||
@@ -41,6 +42,7 @@ class Bitmap {
|
||||
uint16_t getWidth();
|
||||
uint16_t getHeight();
|
||||
bool setPixels(const std::vector<T>& pixels);
|
||||
std::vector<T> getPixelsCpy();
|
||||
std::optional<std::vector<T>> getLine(uint16_t line);
|
||||
std::optional<std::vector<T>> getCol(uint16_t col);
|
||||
|
||||
|
@@ -16,10 +16,6 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
|
||||
#include <spdlog/common.h>
|
||||
#include <spdlog/spdlog.h>
|
||||
|
||||
#include "PtouchPrint.hpp"
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
|
24
src/meson.build
Normal file
24
src/meson.build
Normal file
@@ -0,0 +1,24 @@
|
||||
ptprnt_hpps = files (
|
||||
'libusbwrap/interface/IUsbDeviceFactory.hpp',
|
||||
'libusbwrap/interface/IUsbDevice.hpp',
|
||||
'libusbwrap/UsbDeviceFactory.hpp',
|
||||
'libusbwrap/LibUsbTypes.hpp',
|
||||
'libusbwrap/UsbDevice.hpp',
|
||||
'interface/IPrinterDriver.hpp',
|
||||
'interface/IPrinterTypes.hpp',
|
||||
'P700Printer.hpp',
|
||||
'PtouchPrint.hpp',
|
||||
'graphics/Bitmap.hpp',
|
||||
'graphics/Image.hpp',
|
||||
'graphics/Monochrome.hpp'
|
||||
)
|
||||
|
||||
ptprnt_srcs = files (
|
||||
'PtouchPrint.cpp',
|
||||
'P700Printer.cpp',
|
||||
'graphics/Image.cpp',
|
||||
'graphics/Bitmap.cpp',
|
||||
'graphics/Monochrome.cpp',
|
||||
'libusbwrap/UsbDeviceFactory.cpp',
|
||||
'libusbwrap/UsbDevice.cpp',
|
||||
)
|
@@ -21,7 +21,9 @@
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
|
||||
TEST(basic_test, Bitmap_createBitmapWithCertainSize_yieldsSpecifiedSize) {
|
||||
auto bm = ptprnt::graphics::Bitmap<ptprnt::graphics::ALPHA8>(16, 8);
|
||||
@@ -64,3 +66,36 @@ TEST(basic_test, Bitmap_getBitmapColInsideOfImage_yieldsValidColSize) {
|
||||
auto colSize = col->size();
|
||||
ASSERT_EQ(8, colSize);
|
||||
}
|
||||
|
||||
TEST(basic_test, Bitmap_setPixels_setsGivenPixels) {
|
||||
auto bm = ptprnt::graphics::Bitmap<ptprnt::graphics::ALPHA8>(16, 8);
|
||||
std::vector<uint8_t> pix(16 * 8);
|
||||
|
||||
bm.setPixels(pix);
|
||||
auto pixCpy = bm.getPixelsCpy();
|
||||
|
||||
ASSERT_EQ(pix, pixCpy);
|
||||
}
|
||||
|
||||
TEST(basic_test, Bitmap_setPixels_isSuccessfulWithValidPixels) {
|
||||
auto bm = ptprnt::graphics::Bitmap<ptprnt::graphics::ALPHA8>(16, 8);
|
||||
std::vector<uint8_t> pix(16 * 8);
|
||||
|
||||
ASSERT_TRUE(bm.setPixels(pix));
|
||||
}
|
||||
|
||||
TEST(basic_test, Bitmap_setPixels_yieldsSamePixelsBack) {
|
||||
auto bm = ptprnt::graphics::Bitmap<ptprnt::graphics::ALPHA8>(16, 8);
|
||||
std::vector<uint8_t> pix(16 * 8);
|
||||
|
||||
bm.setPixels(pix);
|
||||
auto pixCpy = bm.getPixelsCpy();
|
||||
ASSERT_EQ(pix, pixCpy);
|
||||
}
|
||||
|
||||
TEST(basic_test, Bitmap_setPixelsWithWrongSize_isFailing) {
|
||||
auto bm = ptprnt::graphics::Bitmap<ptprnt::graphics::ALPHA8>(5, 8);
|
||||
std::vector<uint8_t> pix(16 * 8);
|
||||
|
||||
ASSERT_FALSE(bm.setPixels(pix));
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
tests = [['bitmap_test', 'bitmap_test_exe', ['bitmap_test/bitmap_test.cpp']],
|
||||
['image_test', 'image_test_exe', ['image_test/image_test.cpp']],
|
||||
['monochrome_test', 'monochrome_test_exe', ['monochrome_test/monochrome_test.cpp']]
|
||||
tests = [['bitmap_test', 'bitmap_test_exe', ptprnt_srcs + ['bitmap_test/bitmap_test.cpp']],
|
||||
['image_test', 'image_test_exe', ptprnt_srcs +['image_test/image_test.cpp']],
|
||||
['monochrome_test', 'monochrome_test_exe', ptprnt_srcs +['monochrome_test/monochrome_test.cpp']]
|
||||
]
|
||||
|
||||
foreach test : tests
|
||||
@@ -8,8 +8,7 @@ foreach test : tests
|
||||
executable(test.get(1),
|
||||
sources: test.get(2),
|
||||
include_directories: incdir,
|
||||
link_with:[ptprnt_lib],
|
||||
dependencies: [gtest_dep, pangocairo_dep]
|
||||
dependencies: [gtest_dep, usb_dep, log_dep, pangocairo_dep, cli11_dep]
|
||||
)
|
||||
)
|
||||
endforeach
|
Reference in New Issue
Block a user