Add PDF writer.
This commit is contained in:
parent
c05b7b6315
commit
9c116b1efd
72 changed files with 1819 additions and 114 deletions
|
@ -10,16 +10,35 @@ target_include_directories(test_utils PUBLIC
|
|||
list(APPEND TestFiles
|
||||
audio/TestAudioWriter.cpp
|
||||
audio/TestMidiReader.cpp
|
||||
graphics/TestOpenGlRendering.cpp)
|
||||
database/TestDatabase.cpp
|
||||
graphics/TestOpenGlRendering.cpp
|
||||
ipc/TestDbus.cpp
|
||||
image/TestPngWriter.cpp
|
||||
publishing/TestPdfWriter.cpp
|
||||
video/TestVideoDecoder.cpp
|
||||
web/TestMarkdownParser.cpp
|
||||
web/TestXmlParser.cpp)
|
||||
|
||||
list(APPEND TestNames
|
||||
TestAudioWriter
|
||||
TestMidiReader
|
||||
TestOpenGlRendering)
|
||||
|
||||
TestDatabase
|
||||
TestOpenGlRendering
|
||||
TestDbus
|
||||
TestPngWriter
|
||||
TestPdfWriter
|
||||
TestVideoDecoder
|
||||
TestMarkdownParser
|
||||
TestXmlParser)
|
||||
|
||||
find_package(PkgConfig)
|
||||
pkg_check_modules(DBUS REQUIRED dbus-1)
|
||||
include_directories(${DBUS_INCLUDE_DIRS})
|
||||
link_directories(${DBUS_LIBRARY_DIRS})
|
||||
|
||||
foreach(TestFile TestName IN ZIP_LISTS TestFiles TestNames)
|
||||
add_executable(${TestName} ${TestFile})
|
||||
target_link_libraries(${TestName} PUBLIC core network database geometry audio graphics web client test_utils)
|
||||
target_link_libraries(${TestName} PUBLIC core network image publishing video database geometry audio graphics web client test_utils ${DBUS_LIBRARIES})
|
||||
endforeach()
|
||||
|
||||
|
||||
|
|
|
@ -8,7 +8,9 @@
|
|||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#include <iostream>
|
||||
|
||||
class TestWriteWav : public TestCase
|
||||
|
@ -32,9 +34,11 @@ class TestAudioRender : public TestCase
|
|||
public:
|
||||
bool Run() override
|
||||
{
|
||||
#ifdef _WIN32
|
||||
WasapiInterface audio_interface;
|
||||
auto device = AudioDevice::Create();
|
||||
audio_interface.Play(device);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
@ -42,8 +46,9 @@ public:
|
|||
//int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow)
|
||||
int main()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
|
||||
|
||||
#endif
|
||||
std::cout << "into entry point" << std::endl;
|
||||
TestCaseRunner runner;
|
||||
//runner.AddTestCase("TestWriteNav", std::make_unique<TestWriteWav>());
|
||||
|
@ -51,6 +56,7 @@ int main()
|
|||
|
||||
const auto testsPassed = runner.Run();
|
||||
return testsPassed ? 0 : -1;
|
||||
|
||||
#ifdef _WIN32
|
||||
CoUninitialize();
|
||||
#endif
|
||||
}
|
||||
|
|
20
test/data/sample_markdown.md
Normal file
20
test/data/sample_markdown.md
Normal file
|
@ -0,0 +1,20 @@
|
|||
# I'm a level one header
|
||||
I'm some text under level one
|
||||
|
||||
## I'm a level two header
|
||||
I'm some text under level two
|
||||
|
||||
```
|
||||
I'm a code block
|
||||
```
|
||||
|
||||
I'm a line under the code block, with some `inline code`.
|
||||
|
||||
### I'm a level three header
|
||||
I'm a bullet point list:
|
||||
|
||||
* First point
|
||||
* Second point
|
||||
* Third point
|
||||
|
||||
With a [hyperlink](www.imahyperlink.com) embedded.
|
12
test/database/TestDatabase.cpp
Normal file
12
test/database/TestDatabase.cpp
Normal file
|
@ -0,0 +1,12 @@
|
|||
#include "DatabaseManager.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
DatabaseManager db_manager;
|
||||
db_manager.CreateDatabase("test.db");
|
||||
|
||||
std::string statement = "CREATE TABLE corporation;";
|
||||
db_manager.Run(statement);
|
||||
|
||||
return 0;
|
||||
}
|
31
test/image/TestPngWriter.cpp
Normal file
31
test/image/TestPngWriter.cpp
Normal file
|
@ -0,0 +1,31 @@
|
|||
#include "Image.h"
|
||||
#include "PngWriter.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
unsigned width = 200;
|
||||
unsigned height = 200;
|
||||
unsigned numChannels = 3;
|
||||
auto image = Image::Create(width, height);
|
||||
image->SetNumChannels(numChannels);
|
||||
|
||||
std::vector<unsigned char> data(image->GetBytesPerRow()*height, 0);
|
||||
for(unsigned jdx=0;jdx<height;jdx++)
|
||||
{
|
||||
const auto heightOffset = jdx*image->GetBytesPerRow();
|
||||
for(unsigned idx=0;idx<width*numChannels;idx+=numChannels)
|
||||
{
|
||||
const auto index = heightOffset + idx;
|
||||
data[index] = (idx%2 == 0) ? 255*jdx/(height+1) : 0;
|
||||
data[index+1] = 0;
|
||||
data[index+2] = 0;
|
||||
}
|
||||
}
|
||||
image->SetData(data);
|
||||
|
||||
PngWriter writer;
|
||||
writer.SetPath("test.png");
|
||||
writer.Write(image);
|
||||
|
||||
return 0;
|
||||
}
|
8
test/ipc/TestDbus.cpp
Normal file
8
test/ipc/TestDbus.cpp
Normal file
|
@ -0,0 +1,8 @@
|
|||
#include <dbus/dbus.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
DBusError err;
|
||||
DBusConnection* conn;
|
||||
return 0;
|
||||
}
|
18
test/publishing/TestPdfWriter.cpp
Normal file
18
test/publishing/TestPdfWriter.cpp
Normal file
|
@ -0,0 +1,18 @@
|
|||
#include "PdfDocument.h"
|
||||
#include "PdfWriter.h"
|
||||
#include "PdfObject.h"
|
||||
#include "File.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
auto document = std::make_unique<PdfDocument>();
|
||||
|
||||
PdfWriter writer;
|
||||
const auto output = writer.ToString(document);
|
||||
|
||||
File pdf_file("TestPdfWriter.pdf");
|
||||
pdf_file.SetAccessMode(File::AccessMode::Write);
|
||||
pdf_file.Open();
|
||||
pdf_file.WriteText(output);
|
||||
return 0;
|
||||
}
|
25
test/video/TestVideoDecoder.cpp
Normal file
25
test/video/TestVideoDecoder.cpp
Normal file
|
@ -0,0 +1,25 @@
|
|||
#include "Video.h"
|
||||
#include "Image.h"
|
||||
#include "FfmpegInterface.h"
|
||||
#include "PngWriter.h"
|
||||
#include <iostream>
|
||||
|
||||
int main()
|
||||
{
|
||||
auto video = Video::Create();
|
||||
video->SetPath("/home/jmsgrogan/test.mp4");
|
||||
|
||||
FfmpegInterface decoder;
|
||||
auto images = decoder.decodeToImages(video, 4);
|
||||
std::cout << "Got " << std::to_string(images.size()) << std::endl;
|
||||
|
||||
PngWriter writer;
|
||||
for(unsigned idx=0; idx<20; idx++)
|
||||
{
|
||||
auto filename = "test_out" + std::to_string(idx) + ".png";
|
||||
writer.SetPath(filename);
|
||||
writer.Write(images[idx]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
25
test/web/TestMarkdownParser.cpp
Normal file
25
test/web/TestMarkdownParser.cpp
Normal file
|
@ -0,0 +1,25 @@
|
|||
#include "MarkdownParser.h"
|
||||
#include "File.h"
|
||||
#include "HtmlWriter.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
File md_file("/home/jmsgrogan/code/MediaTool/test/data/sample_markdown.md");
|
||||
md_file.Open();
|
||||
const auto md_content = md_file.ReadText();
|
||||
|
||||
MarkdownParser parser;
|
||||
parser.Run(md_content);
|
||||
|
||||
auto html = parser.GetHtml();
|
||||
|
||||
HtmlWriter writer;
|
||||
const auto html_string = writer.ToString(html);
|
||||
|
||||
File html_file("TestMarkdownParserOut.html");
|
||||
html_file.SetAccessMode(File::AccessMode::Write);
|
||||
html_file.Open();
|
||||
html_file.WriteText(html_string);
|
||||
return 0;
|
||||
|
||||
}
|
31
test/web/TestXmlParser.cpp
Normal file
31
test/web/TestXmlParser.cpp
Normal file
|
@ -0,0 +1,31 @@
|
|||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
#include "XmlParser.h"
|
||||
#include "XmlWriter.h"
|
||||
#include "File.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
XmlParser parser;
|
||||
|
||||
std::ifstream xml_file;
|
||||
xml_file.open("/home/jmsgrogan/test.xml", std::ifstream::in);
|
||||
while(xml_file.good())
|
||||
{
|
||||
std::string line;
|
||||
std::getline(xml_file, line);
|
||||
parser.ProcessLine(line);
|
||||
}
|
||||
xml_file.close();
|
||||
|
||||
auto outFile = std::make_unique<File>("test_out.xml");
|
||||
outFile->SetAccessMode(File::AccessMode::Write);
|
||||
outFile->Open();
|
||||
|
||||
XmlWriter writer;
|
||||
auto content = writer.ToString(parser.GetDocument().get());
|
||||
outFile->WriteText(content);
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue