Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Experimental Unit Tests without Display #900

Merged
merged 4 commits into from
Feb 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,9 @@ jobs:

- name: Test libopenshot
run: |
# Allow unit tests which require a display screen
export DISPLAY=:0.0
export QT_QPA_PLATFORM=offscreen
cmake --build build --target coverage -- VERBOSE=1

- name: Install libopenshot
Expand Down
12 changes: 6 additions & 6 deletions src/effects/Caption.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,10 @@ std::shared_ptr<openshot::Frame> Caption::GetFrame(std::shared_ptr<openshot::Fra
// Wrap languages which do not use spaces
bool use_spaces = true;
if (line.length() > 20 && words.length() == 1) {
words = line.split("");
use_spaces = false;
words = line.split("");
use_spaces = false;
}
int words_remaining = words.length();
int words_remaining = words.length();
while (words_remaining > 0) {
bool words_displayed = false;
for(int word_index = words.length(); word_index > 0; word_index--) {
Expand All @@ -222,11 +222,11 @@ std::shared_ptr<openshot::Frame> Caption::GetFrame(std::shared_ptr<openshot::Fra

// Create path and add text to it (for correct border and fill)
QPainterPath path1;
QString fitting_line;
QString fitting_line;
if (use_spaces) {
fitting_line = words.mid(0, word_index).join(" ");
fitting_line = words.mid(0, word_index).join(" ");
} else {
fitting_line = words.mid(0, word_index).join("");
fitting_line = words.mid(0, word_index).join("");
}
path1.addText(p, font, fitting_line);
text_paths.push_back(path1);
Expand Down
9 changes: 9 additions & 0 deletions tests/Caption.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@

TEST_CASE( "caption effect", "[libopenshot][caption]" )
{
// Check for QT Platform Environment variable - and ignore these tests if it's set to offscreen
if (std::getenv("QT_QPA_PLATFORM") != nullptr) {
std::string qt_platform_env = std::getenv("QT_QPA_PLATFORM");
if (qt_platform_env == "offscreen") {
std::cout << "Ignoring Caption unit tests due to invalid QT Platform: offscreen" << std::endl;
return;
}
}

int argc;
char* argv[2];
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
Expand Down