diff --git a/app/common/qtutilsapp.cpp b/app/common/qtutilsapp.cpp index f85e4203b..8c60290fe 100644 --- a/app/common/qtutilsapp.cpp +++ b/app/common/qtutilsapp.cpp @@ -45,7 +45,8 @@ QFrame *QtUtils::create_vertical_line() QString QtUtils::get_formatted_date_time(const QDateTime &dt) { - return dt.toString(Qt::TextDate); + // ISO-style date/time (e.g. "2026-06-03 20:25") per the UI design reference + return dt.toString(QStringLiteral("yyyy-MM-dd HH:mm")); } QStringList QtUtils::word_wrap_string(const QString &s, const QFontMetrics &fm, diff --git a/app/panel/param/param.cpp b/app/panel/param/param.cpp index d0b43565a..6d0ec3850 100644 --- a/app/panel/param/param.cpp +++ b/app/panel/param/param.cpp @@ -64,7 +64,7 @@ void ParamPanel::set_contexts(const QVector &contexts) void ParamPanel::retranslate() { - set_title(tr("Parameter Editor")); + set_title(tr("Inspector")); } } diff --git a/app/ts/zh_CN.ts b/app/ts/zh_CN.ts index 05cf8dbb0..f4898876b 100644 --- a/app/ts/zh_CN.ts +++ b/app/ts/zh_CN.ts @@ -3303,7 +3303,7 @@ This setting is equivalent to the `preset` setting in libx264. History - + 历史记录 @@ -5583,8 +5583,8 @@ This is equivalent to multiplying a video by a number between 0.0 and 1.0.olive::ParamPanel - Parameter Editor - 参数编辑器 + Inspector + 检查器 @@ -5854,6 +5854,14 @@ This is equivalent to multiplying a video by a number between 0.0 and 1.0.Use glFinish 使用glFinish + + Behavior + 行为 + + + Enable hover focus + 启用悬停聚焦 + olive::PreferencesDialog @@ -7290,8 +7298,8 @@ Do you wish to continue? %n minute(s) - - + + %n 分钟 diff --git a/app/widget/nodeparamview/nodeparamviewconnectedlabel.cpp b/app/widget/nodeparamview/nodeparamviewconnectedlabel.cpp index 0dc5ca188..a8ce3ceff 100644 --- a/app/widget/nodeparamview/nodeparamviewconnectedlabel.cpp +++ b/app/widget/nodeparamview/nodeparamviewconnectedlabel.cpp @@ -207,7 +207,10 @@ void NodeParamViewConnectedLabel::update_label() void NodeParamViewConnectedLabel::update_value_tree() { if (value_tree_ && viewer_ && value_tree_->isVisible()) { - value_tree_->set_node(input_, viewer_->get_playhead()); + int64_t pn, pd; + oakengine_viewer_get_playhead( + reinterpret_cast(viewer_), &pn, &pd); + value_tree_->set_node(input_, Rational(pn, pd)); } } diff --git a/app/widget/nodeview/nodeviewtoolbar.cpp b/app/widget/nodeview/nodeviewtoolbar.cpp index 54d377407..e10cbb219 100644 --- a/app/widget/nodeview/nodeviewtoolbar.cpp +++ b/app/widget/nodeview/nodeviewtoolbar.cpp @@ -45,6 +45,22 @@ NodeViewToolBar::NodeViewToolBar(QWidget *parent) &NodeViewToolBar::mini_map_enabled_toggled); layout->addWidget(minimap_btn_); + // Zoom controls per the UI design reference: [+] [-] [Fit] + zoom_out_btn_ = new QPushButton(); + connect(zoom_out_btn_, &QPushButton::clicked, this, + &NodeViewToolBar::zoom_out_clicked); + layout->addWidget(zoom_out_btn_); + + zoom_in_btn_ = new QPushButton(); + connect(zoom_in_btn_, &QPushButton::clicked, this, + &NodeViewToolBar::zoom_in_clicked); + layout->addWidget(zoom_in_btn_); + + fit_btn_ = new QPushButton(); + connect(fit_btn_, &QPushButton::clicked, this, + &NodeViewToolBar::fit_clicked); + layout->addWidget(fit_btn_); + layout->addStretch(); retranslate(); @@ -65,12 +81,18 @@ void NodeViewToolBar::retranslate() { add_node_btn_->setToolTip(tr("Add Node")); minimap_btn_->setToolTip(tr("Toggle Mini-Map")); + zoom_in_btn_->setToolTip(tr("Zoom In")); + zoom_out_btn_->setToolTip(tr("Zoom Out")); + fit_btn_->setToolTip(tr("Fit to Content")); + fit_btn_->setText(tr("Fit")); } void NodeViewToolBar::update_icons() { add_node_btn_->setIcon(icon::add); minimap_btn_->setIcon(icon::mini_map); + zoom_in_btn_->setIcon(icon::zoom_in); + zoom_out_btn_->setIcon(icon::zoom_out); } } diff --git a/app/widget/nodeview/nodeviewtoolbar.h b/app/widget/nodeview/nodeviewtoolbar.h index 9dbe49bbf..da31191dc 100644 --- a/app/widget/nodeview/nodeviewtoolbar.h +++ b/app/widget/nodeview/nodeviewtoolbar.h @@ -41,6 +41,12 @@ signals: void mini_map_enabled_toggled(bool e); + void zoom_in_clicked(); + + void zoom_out_clicked(); + + void fit_clicked(); + protected: virtual void changeEvent(QEvent *e) override; @@ -52,6 +58,12 @@ private: QPushButton *add_node_btn_; QPushButton *minimap_btn_; + + QPushButton *zoom_in_btn_; + + QPushButton *zoom_out_btn_; + + QPushButton *fit_btn_; }; } diff --git a/app/widget/nodeview/nodewidget.cpp b/app/widget/nodeview/nodewidget.cpp index 0f3b62e90..3e29b637f 100644 --- a/app/widget/nodeview/nodewidget.cpp +++ b/app/widget/nodeview/nodewidget.cpp @@ -44,6 +44,12 @@ NodeWidget::NodeWidget(QWidget *parent) &NodeView::set_mini_map_enabled); connect(toolbar_, &NodeViewToolBar::add_node_clicked, node_view_, &NodeView::show_add_menu); + connect(toolbar_, &NodeViewToolBar::zoom_in_clicked, node_view_, + &NodeView::zoom_in); + connect(toolbar_, &NodeViewToolBar::zoom_out_clicked, node_view_, + &NodeView::zoom_out); + connect(toolbar_, &NodeViewToolBar::fit_clicked, node_view_, + &NodeView::center_on_items_bounding_rect); // Set defaults toolbar_->set_mini_map_enabled(true); diff --git a/app/widget/timebased/timebasedview.cpp b/app/widget/timebased/timebasedview.cpp index b061a332f..841f9fe7b 100644 --- a/app/widget/timebased/timebasedview.cpp +++ b/app/widget/timebased/timebasedview.cpp @@ -166,7 +166,7 @@ void TimeBasedView::set_viewer_node(ViewerOutput *v) if (viewer_) { viewer_sub_ = oakengine_event_subscribe( - reinterpret_cast(viewer_), + viewer_, OAKENGINE_EVENT_VIEWER_PLAYHEAD_CHANGED, [](const oakengine_event *, void *userdata) { static_cast(userdata)->viewport()->update(); @@ -280,7 +280,10 @@ bool TimeBasedView::playhead_release(QMouseEvent *) qreal TimeBasedView::get_playhead_x() { if (viewer_) { - return time_to_scene(viewer_->get_playhead()); + int64_t pn, pd; + oakengine_viewer_get_playhead( + reinterpret_cast(viewer_), &pn, &pd); + return time_to_scene(Rational(pn, pd)); } else { return 0; } diff --git a/app/widget/timelinewidget/timelineandtrackview.cpp b/app/widget/timelinewidget/timelineandtrackview.cpp index 8d9b87583..fede8e1f0 100644 --- a/app/widget/timelinewidget/timelineandtrackview.cpp +++ b/app/widget/timelinewidget/timelineandtrackview.cpp @@ -50,7 +50,8 @@ TimelineAndTrackView::TimelineAndTrackView(Qt::Alignment vertical_alignment, connect(track_view_->verticalScrollBar(), &QScrollBar::valueChanged, this, &TimelineAndTrackView::tracks_value_changed); - splitter_->setSizes({ 1, width() }); + // Default track header width: 180px (per UI design reference) + splitter_->setSizes({ 180, width() }); } QSplitter *TimelineAndTrackView::splitter() const diff --git a/app/widget/timelinewidget/timelinewidget.cpp b/app/widget/timelinewidget/timelinewidget.cpp index afab2e2d8..402297c95 100644 --- a/app/widget/timelinewidget/timelinewidget.cpp +++ b/app/widget/timelinewidget/timelinewidget.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -80,6 +81,7 @@ #include "widget/menu/menushared.h" #include "widget/nodeparamview/nodeparamview.h" #include "widget/timeruler/timeruler.h" +#include "widget/toolbar/toolbar.h" #include "widget/viewer/vieweroutpututils.h" namespace olive @@ -159,6 +161,26 @@ QVector get_selected_proxy_footage(const QVector &blocks) return footage; } +// Zoom slider <-> scale mapping (logarithmic: slider 0..1000 -> 0.1..10000 px/s) +constexpr double k_zoom_scale_min = 0.1; +constexpr double k_zoom_scale_max = 10000.0; + +double zoom_slider_to_scale(int v) +{ + return k_zoom_scale_min * + std::pow(k_zoom_scale_max / k_zoom_scale_min, v / 1000.0); +} + +int scale_to_zoom_slider(double s) +{ + if (s <= k_zoom_scale_min) + return 0; + if (s >= k_zoom_scale_max) + return 1000; + return qRound(1000.0 * std::log(s / k_zoom_scale_min) / + std::log(k_zoom_scale_max / k_zoom_scale_min)); +} + } // namespace TimelineWidget::TimelineWidget(QWidget *parent) @@ -173,6 +195,66 @@ TimelineWidget::TimelineWidget(QWidget *parent) vert_layout->setSpacing(0); vert_layout->setContentsMargins(0, 0, 0, 0); + // Application toolbar row (31px) — replaces the dockable ToolPanel by + // default. The dockable ToolPanel remains available via the Window menu. + QHBoxLayout *toolbar_row = new QHBoxLayout(); + toolbar_row->setContentsMargins(0, 0, 0, 0); + toolbar_row->setSpacing(4); + + Toolbar *toolbar = new Toolbar(this); + toolbar->setFixedHeight(31); + toolbar->set_tool(Core::instance()->tool()); + toolbar->set_snapping(Core::instance()->snapping()); + toolbar_row->addWidget(toolbar); + + connect(toolbar, &Toolbar::tool_changed, Core::instance(), + &Core::set_tool); + connect(Core::instance(), &Core::tool_changed, toolbar, + &Toolbar::set_tool); + connect(toolbar, &Toolbar::snapping_changed, Core::instance(), + &Core::set_snapping); + connect(Core::instance(), &Core::snapping_changed, toolbar, + &Toolbar::set_snapping); + connect(toolbar, &Toolbar::selected_transition_changed, Core::instance(), + &Core::set_selected_transition_object); + + toolbar_row->addStretch(); + + // Zoom slider (logarithmic) + zoom_slider_ = new QSlider(Qt::Horizontal, this); + zoom_slider_->setRange(0, 1000); + zoom_slider_->setFixedWidth(120); + zoom_slider_->setToolTip(tr("Zoom")); + zoom_slider_->setValue(scale_to_zoom_slider(get_scale())); + toolbar_row->addWidget(zoom_slider_); + + connect(zoom_slider_, &QSlider::valueChanged, this, [this](int v) { + set_scale(zoom_slider_to_scale(v)); + }); + + // Track height slider + track_height_slider_ = new QSlider(Qt::Horizontal, this); + track_height_slider_->setRange(0, 8); + track_height_slider_->setFixedWidth(80); + track_height_slider_->setToolTip(tr("Track Height")); + track_height_slider_->setValue(3); + toolbar_row->addWidget(track_height_slider_); + + connect(track_height_slider_, &QSlider::valueChanged, this, [this](int v) { + if (!get_connected_node()) { + return; + } + double h = oakengine_track_height_minimum() + + v * oakengine_track_height_interval(); + foreach (Track *t, sequence()->get_tracks()) { + oakengine_track_set_height( + reinterpret_cast(sequence()), t->type(), + t->index(), h); + } + }); + + vert_layout->addLayout(toolbar_row); + QHBoxLayout *ruler_and_time_layout = new QHBoxLayout(); vert_layout->addLayout(ruler_and_time_layout); @@ -396,6 +478,11 @@ void TimelineWidget::ScaleChangedEvent(const double &scale) view->view()->set_scale(scale); } + // Keep zoom slider in sync when scale changes elsewhere (ctrl+wheel etc.) + zoom_slider_->blockSignals(true); + zoom_slider_->setValue(scale_to_zoom_slider(scale)); + zoom_slider_->blockSignals(false); + if (rubberband_.isVisible()) { QMetaObject::invokeMethod(this, &TimelineWidget::force_update_rubber_band, Qt::QueuedConnection); @@ -448,17 +535,20 @@ void TimelineWidget::ConnectNodeEvent(ViewerOutput *n) // Subscribe to track-level events via bridge (subscriptions in add_track) connect(bridge_, &EngineEventBridge::track_index_changed, this, [this](OakEngineTrack *source, int old_index, int new_index) { - Track *track = reinterpret_cast(source); - track_updated(track->type()); - track_index_changed(track, old_index, new_index); + track_updated(static_cast( + oakengine_track_type(source))); + track_index_changed(reinterpret_cast(source), + old_index, new_index); }); connect(bridge_, &EngineEventBridge::track_height_changed, this, [this](OakEngineTrack *source, double) { - track_updated(reinterpret_cast(source)->type()); + track_updated(static_cast( + oakengine_track_type(source))); }); connect(bridge_, &EngineEventBridge::track_blocks_refreshed, this, [this](OakEngineTrack *source) { - track_updated(reinterpret_cast(source)->type()); + track_updated(static_cast( + oakengine_track_type(source))); }); connect(bridge_, &EngineEventBridge::track_block_added, this, [this](OakEngineBlock *block, qint64, qint64) { @@ -519,7 +609,10 @@ void TimelineWidget::ConnectNodeEvent(ViewerOutput *n) { oak_video_params vp; oakengine_viewer_get_video_params(handle, 0, &vp); - SetTimebase(Rational(vp.time_base_den, vp.time_base_num)); + // time_base is the frame duration (e.g. 1/25); reconstruct it as + // Rational(num, den). (Previously num/den were swapped here, which + // produced the frame rate and triggered "INVALID TIMEBASE".) + SetTimebase(Rational(vp.time_base_num, vp.time_base_den)); } for (int i = 0; i < views_.size(); i++) { @@ -1954,9 +2047,15 @@ void TimelineWidget::track_updated(Track::Type type) update_viewports(type); } -void TimelineWidget::block_updated() +void TimelineWidget::block_updated(OakEngineBlock *) { - update_viewports(static_cast(sender())->track()->type()); + // The old implementation used sender() to obtain the Block and then + // queried its track type to update only one viewport. With the bridge + // approach sender() is the EngineEventBridge (not a Block), and the + // OakEngineBlock handle is opaque -- there is no C API to retrieve its + // track type. Simply refresh all viewports; the cost is negligible + // (just a repaint request). + update_viewports(); } void TimelineWidget::update_horizontal_splitters() diff --git a/app/widget/timelinewidget/timelinewidget.h b/app/widget/timelinewidget/timelinewidget.h index 213d0942f..40a98d942 100644 --- a/app/widget/timelinewidget/timelinewidget.h +++ b/app/widget/timelinewidget/timelinewidget.h @@ -25,6 +25,7 @@ #include #include #include +#include #include #include "core.h" @@ -361,6 +362,9 @@ private: QSplitter *view_splitter_; + QSlider *zoom_slider_; + QSlider *track_height_slider_; + void *subtitle_show_command_; OakEngineTrack *subtitle_tentative_track_; @@ -422,7 +426,7 @@ private slots: void track_updated(Track::Type type); - void block_updated(); + void block_updated(OakEngineBlock *block = nullptr); void update_horizontal_splitters(); diff --git a/app/widget/timelinewidget/trackview/trackviewitem.cpp b/app/widget/timelinewidget/trackview/trackviewitem.cpp index fda8c36e8..1833da536 100644 --- a/app/widget/timelinewidget/trackview/trackviewitem.cpp +++ b/app/widget/timelinewidget/trackview/trackviewitem.cpp @@ -161,18 +161,38 @@ void TrackViewItem::line_edit_cancelled() void TrackViewItem::update_label() { + // Per the UI design reference, tracks are identified by an NLE-style + // type+number prefix (V1/V2 for video, A1/A2 for audio, S1 for subtitle) + // followed by the track's custom label or default name. + QString prefix; + switch (track_->type()) { + case Track::k_video: + prefix = QStringLiteral("V%1").arg(track_->index() + 1); + break; + case Track::k_audio: + prefix = QStringLiteral("A%1").arg(track_->index() + 1); + break; + case Track::k_subtitle: + prefix = QStringLiteral("S%1").arg(track_->index() + 1); + break; + } + char label_buf[256]; oakengine_node_get_label( reinterpret_cast(track_), label_buf, sizeof(label_buf)); + QString display; if (label_buf[0]) { - label_->setText(QString::fromUtf8(label_buf)); + display = QString::fromUtf8(label_buf); } else { oakengine_node_get_name( reinterpret_cast(track_), label_buf, sizeof(label_buf)); - label_->setText(QString::fromUtf8(label_buf)); + display = QString::fromUtf8(label_buf); } + + label_->setText(prefix.isEmpty() ? display + : QStringLiteral("%1 %2").arg(prefix, display)); } void TrackViewItem::show_context_menu(const QPoint &p) diff --git a/app/widget/viewer/viewer.cpp b/app/widget/viewer/viewer.cpp index 58c86e2ed..1df900650 100644 --- a/app/widget/viewer/viewer.cpp +++ b/app/widget/viewer/viewer.cpp @@ -176,6 +176,10 @@ ViewerWidget::ViewerWidget(ViewerDisplayWidget *display, QWidget *parent) , multicam_panel_(nullptr) , bridge_(new EngineEventBridge(this)) , audio_processor_(oakengine_audio_processor_create()) + , overlay_(nullptr) + , info_chip_(nullptr) + , safe_frame_btn_(nullptr) + , overlay_zoom_index_(5) { // Set up main layout QVBoxLayout *layout = new QVBoxLayout(this); @@ -224,6 +228,9 @@ ViewerWidget::ViewerWidget(ViewerDisplayWidget *display, QWidget *parent) &ViewerSizer::hand_drag_move); sizer_->set_widget(display_widget_); + // Create the design-reference overlay (info chip + zoom/safe-frame buttons) + create_overlay(); + // Make the display widget the first tabbable widget. While the viewer display cannot actually // be interacted with by tabbing, it prevents the actual first tabbable widget (the playhead // slider in `controls_`) from getting auto-focused any time the panel is maximized (with `) @@ -234,8 +241,13 @@ ViewerWidget::ViewerWidget(ViewerDisplayWidget *display, QWidget *parent) connect_timeline_view(waveform_view_); layout->addWidget(waveform_view_); - // Create time ruler - layout->addWidget(ruler()); + // Per the Oak UI design reference the viewer no longer shows its own time + // ruler: it duplicates the timeline's ruler and clutters the viewer. The + // ruler object still exists (created by TimeBasedWidget) and continues to + // back marker/work-area/snapping logic and the scrollbar; we simply do not + // add it to the visible layout. Scrubbing is provided by the transport + // controls and the scrollbar below. + // layout->addWidget(ruler()); // Create scrollbar layout->addWidget(scrollbar()); @@ -493,6 +505,8 @@ void ViewerWidget::resizeEvent(QResizeEvent *event) super::resizeEvent(event); update_minimum_scale(); + + position_overlay(); } OakEnginePreviewRequest *ViewerWidget::get_single_frame(const Rational &t, @@ -2260,6 +2274,8 @@ void ViewerWidget::set_viewer_resolution(int width, int height) foreach (ViewerWindow *vw, windows_) { vw->set_resolution(width, height); } + + update_info_chip(); } void ViewerWidget::set_viewer_pixel_aspect(const Rational &ratio) @@ -2323,6 +2339,143 @@ void ViewerWidget::set_zoom_from_menu(QAction *action) s.height() / 2); } +void ViewerWidget::create_overlay() +{ + // A thin transparent strip laid over the top of the viewer display. Left + // side carries an info chip (resolution + frame rate); right side carries + // zoom in/out/fit and a safe-frame toggle, per the UI design reference. + overlay_ = new QWidget(sizer_); + overlay_->setAttribute(Qt::WA_TransparentForMouseEvents, false); + overlay_->setAutoFillBackground(false); + + auto *overlay_layout = new QHBoxLayout(overlay_); + overlay_layout->setContentsMargins(6, 4, 6, 4); + overlay_layout->setSpacing(4); + + info_chip_ = new QLabel(overlay_); + info_chip_->setStyleSheet(QStringLiteral( + "QLabel { background-color: rgba(0,0,0,160); color: white; " + "border-radius: 3px; padding: 2px 6px; }")); + info_chip_->setVisible(false); + overlay_layout->addWidget(info_chip_); + + overlay_layout->addStretch(); + + const QString btn_style = QStringLiteral( + "QToolButton { background-color: rgba(0,0,0,160); color: white; " + "border: none; border-radius: 3px; padding: 2px 6px; } " + "QToolButton:hover { background-color: rgba(0,0,0,200); } " + "QToolButton:checked { background-color: rgba(0,120,215,200); }"); + + auto make_btn = [this, &btn_style](const QString &text, + const QString &tooltip) { + auto *b = new QToolButton(overlay_); + b->setText(text); + b->setToolTip(tooltip); + b->setStyleSheet(btn_style); + b->setAutoRaise(false); + return b; + }; + + QToolButton *zoom_out_btn = make_btn(QStringLiteral("\u2212"), tr("Zoom Out")); + QToolButton *zoom_in_btn = make_btn(QStringLiteral("+"), tr("Zoom In")); + QToolButton *zoom_fit_btn = make_btn(QStringLiteral("\u2922"), tr("Fit to Window")); + safe_frame_btn_ = make_btn(QStringLiteral("\u25A2"), tr("Safe Margins")); + safe_frame_btn_->setCheckable(true); + + overlay_layout->addWidget(zoom_out_btn); + overlay_layout->addWidget(zoom_in_btn); + overlay_layout->addWidget(zoom_fit_btn); + overlay_layout->addWidget(safe_frame_btn_); + + connect(zoom_out_btn, &QToolButton::clicked, this, + &ViewerWidget::overlay_zoom_out); + connect(zoom_in_btn, &QToolButton::clicked, this, + &ViewerWidget::overlay_zoom_in); + connect(zoom_fit_btn, &QToolButton::clicked, this, + &ViewerWidget::overlay_zoom_fit); + connect(safe_frame_btn_, &QToolButton::toggled, this, + [this](bool) { overlay_toggle_safe_frame(); }); + + overlay_->raise(); +} + +void ViewerWidget::position_overlay() +{ + if (!overlay_ || !sizer_) { + return; + } + // Span the full width of the sizer, hugging the top edge. + overlay_->setGeometry(0, 0, sizer_->width(), overlay_->sizeHint().height()); + overlay_->raise(); +} + +void ViewerWidget::update_info_chip() +{ + if (!info_chip_) { + return; + } + + if (!get_connected_node()) { + info_chip_->setVisible(false); + return; + } + + VideoParams vp = viewer_output_video_params(get_connected_node()); + if (vp.width() <= 0 || vp.height() <= 0) { + info_chip_->setVisible(false); + return; + } + + const double fps = vp.frame_rate().to_double(); + const double fps_rounded = qRound(fps); + QString fps_str = (qFuzzyCompare(fps, fps_rounded)) + ? QString::number(static_cast(fps_rounded)) + : QString::number(fps, 'f', 2); + + info_chip_->setText(QStringLiteral("%1\u00d7%2 \u00b7 %3 FPS") + .arg(vp.width()) + .arg(vp.height()) + .arg(fps_str)); + info_chip_->setVisible(true); +} + +void ViewerWidget::overlay_zoom_in() +{ + if (overlay_zoom_index_ < ViewerSizer::k_zoom_level_count - 1) { + overlay_zoom_index_++; + } + auto s = sizer_->get_container_size(); + sizer_->set_zoom_anchored(ViewerSizer::k_zoom_levels[overlay_zoom_index_], + s.width() / 2, s.height() / 2); +} + +void ViewerWidget::overlay_zoom_out() +{ + if (overlay_zoom_index_ > 0) { + overlay_zoom_index_--; + } + auto s = sizer_->get_container_size(); + sizer_->set_zoom_anchored(ViewerSizer::k_zoom_levels[overlay_zoom_index_], + s.width() / 2, s.height() / 2); +} + +void ViewerWidget::overlay_zoom_fit() +{ + // The zoom menu uses -1 to mean "fit to window". + auto s = sizer_->get_container_size(); + sizer_->set_zoom_anchored(-1, s.width() / 2, s.height() / 2); +} + +void ViewerWidget::overlay_toggle_safe_frame() +{ + if (!safe_frame_btn_) { + return; + } + display_widget_->set_safe_margins( + ViewerSafeMarginInfo(safe_frame_btn_->isChecked())); +} + void ViewerWidget::viewer_invalidated_video_range(const TimeRange &range) { // If our current frame is within this range, we need to update diff --git a/app/widget/viewer/viewer.h b/app/widget/viewer/viewer.h index 1271f2194..f1dd15b98 100644 --- a/app/widget/viewer/viewer.h +++ b/app/widget/viewer/viewer.h @@ -27,6 +27,7 @@ #include #include #include +#include #include #include "oakengine/audio.h" @@ -219,6 +220,11 @@ protected: return display_widget_; } + // Overlay (info chip + zoom/safe-frame buttons) per the UI design reference + void create_overlay(); + void position_overlay(); + void update_info_chip(); + void IgnoreNextScrubEvent() { ignore_scrub_++; @@ -228,6 +234,12 @@ protected: void set_waveform_mode(WaveformMode wf); +private slots: + void overlay_zoom_in(); + void overlay_zoom_out(); + void overlay_zoom_fit(); + void overlay_toggle_safe_frame(); + private: int64_t get_timestamp() const { @@ -285,6 +297,11 @@ private: ViewerSizer *sizer_; + QWidget *overlay_; + QLabel *info_chip_; + QToolButton *safe_frame_btn_; + int overlay_zoom_index_; + int playback_speed_; Rational last_time_; diff --git a/app/window/mainwindow/mainstatusbar.cpp b/app/window/mainwindow/mainstatusbar.cpp index 633e0b7c4..18d192d47 100644 --- a/app/window/mainwindow/mainstatusbar.cpp +++ b/app/window/mainwindow/mainstatusbar.cpp @@ -44,12 +44,44 @@ MainStatusBar::MainStatusBar(QWidget *parent) bar_->setMaximum(100); bar_->setVisible(false); + // Permanent right-hand sequence info chips (resolution + frame rate) + resolution_label_ = new QLabel(); + fps_label_ = new QLabel(); + resolution_label_->setContentsMargins(6, 0, 6, 0); + fps_label_->setContentsMargins(6, 0, 6, 0); + addPermanentWidget(resolution_label_); + addPermanentWidget(fps_label_); + resolution_label_->setVisible(false); + fps_label_->setVisible(false); + showMessage(tr("Welcome to %1 %2") .arg(QCoreApplication::applicationName(), QCoreApplication::applicationVersion()), 10000); } +void MainStatusBar::set_sequence_info(int width, int height, double fps) +{ + if (width <= 0 || height <= 0) { + resolution_label_->setVisible(false); + fps_label_->setVisible(false); + return; + } + + resolution_label_->setText(QStringLiteral("%1\u00d7%2").arg(width).arg(height)); + + // Show the frame rate as an integer when it is whole, otherwise keep one + // decimal place (e.g. 23.976 FPS). + const double rounded = qRound(fps); + QString fps_str = (qFuzzyCompare(fps, rounded)) + ? QString::number(static_cast(rounded)) + : QString::number(fps, 'f', 2); + fps_label_->setText(tr("%1 FPS").arg(fps_str)); + + resolution_label_->setVisible(true); + fps_label_->setVisible(true); +} + void MainStatusBar::connect_task_manager(EngineEventBridge *bridge) { bridge_ = bridge; diff --git a/app/window/mainwindow/mainstatusbar.h b/app/window/mainwindow/mainstatusbar.h index fe9aff851..3ded491cd 100644 --- a/app/window/mainwindow/mainstatusbar.h +++ b/app/window/mainwindow/mainstatusbar.h @@ -22,6 +22,7 @@ #ifndef OAK_MAINSTATUSBAR_H #define OAK_MAINSTATUSBAR_H +#include #include #include @@ -34,6 +35,10 @@ class EngineEventBridge; /** * @brief Shows abbreviated information from the global TaskManager + * + * Per the Oak UI design reference the status bar is a global information + * strip. The transient task message is shown on the left while the active + * sequence's resolution and frame rate are shown permanently on the right. */ class MainStatusBar : public QStatusBar { Q_OBJECT @@ -42,6 +47,14 @@ public: void connect_task_manager(EngineEventBridge *bridge); + /** + * @brief Update the permanent right-hand sequence info chips. + * + * Plain (non-slot) method taking primitives so no engine C++ type leaks + * into the MOC-processed header. Pass width <= 0 to clear the chips. + */ + void set_sequence_info(int width, int height, double fps); + signals: void double_clicked(); @@ -60,6 +73,9 @@ private: QProgressBar *bar_; + QLabel *resolution_label_; + QLabel *fps_label_; + OakEngineTask *connected_task_; int64_t task_progress_sub_; diff --git a/app/window/mainwindow/mainwindow.cpp b/app/window/mainwindow/mainwindow.cpp index 983aea3d3..490a0b293 100644 --- a/app/window/mainwindow/mainwindow.cpp +++ b/app/window/mainwindow/mainwindow.cpp @@ -25,7 +25,6 @@ #include #include #include -#include #ifdef Q_OS_LINUX #include @@ -44,7 +43,6 @@ #include "oakengine/undo.h" #include "widget/viewer/vieweroutpututils.h" -#include "widget/toolbar/toolbar.h" #include "core.h" namespace olive { @@ -84,34 +82,11 @@ MainWindow::MainWindow(QWidget *parent) // Create and set status bar event_bridge_ = new EngineEventBridge(this); - MainStatusBar *status_bar = new MainStatusBar(this); - status_bar->connect_task_manager(event_bridge_); - connect(status_bar, &MainStatusBar::double_clicked, this, + status_bar_ = new MainStatusBar(this); + status_bar_->connect_task_manager(event_bridge_); + connect(status_bar_, &MainStatusBar::double_clicked, this, &MainWindow::status_bar_double_clicked); - setStatusBar(status_bar); - - // Create application toolbar (31px) — replaces the dockable ToolPanel by default - tool_bar_ = new QToolBar(this); - tool_bar_->setObjectName(QStringLiteral("AppToolbar")); - tool_bar_->setFixedHeight(31); - tool_bar_->setMovable(false); - tool_bar_->setFloatable(false); - Toolbar *toolbar_widget = new Toolbar(tool_bar_); - toolbar_widget->set_tool(Core::instance()->tool()); - toolbar_widget->set_snapping(Core::instance()->snapping()); - tool_bar_->addWidget(toolbar_widget); - addToolBar(Qt::TopToolBarArea, tool_bar_); - - connect(toolbar_widget, &Toolbar::tool_changed, Core::instance(), - &Core::set_tool); - connect(Core::instance(), &Core::tool_changed, toolbar_widget, - &Toolbar::set_tool); - connect(toolbar_widget, &Toolbar::snapping_changed, Core::instance(), - &Core::set_snapping); - connect(Core::instance(), &Core::snapping_changed, toolbar_widget, - &Toolbar::set_snapping); - connect(toolbar_widget, &Toolbar::selected_transition_changed, - Core::instance(), &Core::set_selected_transition_object); + setStatusBar(status_bar_); // Create standard panels node_panel_ = new NodePanel(); @@ -772,6 +747,15 @@ void MainWindow::timeline_focused(ViewerOutput *viewer) multicam_panel_->connect_viewer_node(viewer); param_panel_->connect_viewer_node(viewer); curve_panel_->connect_viewer_node(viewer); + + // Update the global status bar info chips (resolution + frame rate) + if (viewer) { + VideoParams vp = viewer_output_video_params(viewer); + status_bar_->set_sequence_info(vp.width(), vp.height(), + vp.frame_rate().to_double()); + } else { + status_bar_->set_sequence_info(0, 0, 0.0); + } } QString MainWindow::get_custom_shortcuts_file() @@ -947,36 +931,56 @@ void MainWindow::focused_panel_changed(PanelWidget *panel) void MainWindow::set_default_layout() { + // Default layout per the Oak UI design reference (design/*.png): + // + // ┌─────────────┬───────────────────────────┬──────────────┐ + // │ 素材查看器 │ 序列查看器 | 节点编辑器 │ 检查器|历史 │ + // ├─────────────┤ │ │ + // │ 项目 │ │ │ + // ├─────────────┴───────────────────────────┴──────────────┤ + // │ 工具条(31px) + 时间线 (full width) │ + // ├────────────────────────────────────────────────────────┤ + // │ 音频监视器 (26px thin strip) │ + // └────────────────────────────────────────────────────────┘ + KDDockWidgets::InitialOption o; - o.preferredSize = QSize(0, centralAreaGeometry().height()); - // Top left - Tabify footage viewer, param panel, and node panel - addDockWidget(footage_viewer_panel_, KDDockWidgets::Location_OnTop, nullptr, - o); - footage_viewer_panel_->addDockWidgetAsTab(param_panel_); - footage_viewer_panel_->addDockWidgetAsTab(node_panel_); - param_panel_->raise(); - - // Top right - sequence viewer - addDockWidget(sequence_viewer_panel_, KDDockWidgets::Location_OnRight, - footage_viewer_panel_, o); - - // Bottom center - timelines + // Timeline at the very bottom, spanning the full window width addDockWidget(timeline_panels_.first(), KDDockWidgets::Location_OnBottom); - // Right of timeline - audio monitor - o.preferredSize = QSize(320, 0); - addDockWidget(audio_monitor_panel_, KDDockWidgets::Location_OnRight, + // Audio monitor: 26px ultra-thin strip below the timeline + o.preferredSize = QSize(0, 26); + addDockWidget(audio_monitor_panel_, KDDockWidgets::Location_OnBottom, timeline_panels_.first(), o); - // Bottom left - project panel (tool panel is now the top toolbar; - // the dockable ToolPanel remains available via Window menu) - addDockWidget(project_panel_, KDDockWidgets::Location_OnLeft, - timeline_panels_.first()); - project_panel_->addDockWidgetAsTab(history_panel_); + // Three-column workspace above the timeline. Establish the horizontal + // (left -> right) structure first so the column separators span the full + // workspace height, then subdivide the left column vertically. + o = KDDockWidgets::InitialOption(); + o.preferredSize = QSize(0, centralAreaGeometry().height()); + + // Left column - footage viewer (top-left anchor) + addDockWidget(footage_viewer_panel_, KDDockWidgets::Location_OnTop, nullptr, + o); + + // Center column - sequence viewer tabified with node editor + addDockWidget(sequence_viewer_panel_, KDDockWidgets::Location_OnRight, + footage_viewer_panel_, o); + sequence_viewer_panel_->addDockWidgetAsTab(node_panel_); + sequence_viewer_panel_->raise(); + + // Right column - inspector (param panel) with history + addDockWidget(param_panel_, KDDockWidgets::Location_OnRight, + sequence_viewer_panel_, o); + param_panel_->addDockWidgetAsTab(history_panel_); + param_panel_->raise(); + + // Left column bottom - project panel (below footage viewer) + addDockWidget(project_panel_, KDDockWidgets::Location_OnBottom, + footage_viewer_panel_); project_panel_->raise(); - // Hidden panels + // Hidden panels (all remain accessible via the Window menu) tool_panel_->close(); pixel_sampler_panel_->close(); task_man_panel_->close(); @@ -991,9 +995,8 @@ void MainWindow::set_default_layout() } for (auto it = timeline_panels_.cbegin(); it != timeline_panels_.cend(); it++) { - auto p = *it; - if (p != timeline_panels_.first()) { - p->addDockWidgetAsTab(p); + if (*it != timeline_panels_.first()) { + (*it)->close(); } } diff --git a/app/window/mainwindow/mainwindow.h b/app/window/mainwindow/mainwindow.h index 470f307e6..7d35e929a 100644 --- a/app/window/mainwindow/mainwindow.h +++ b/app/window/mainwindow/mainwindow.h @@ -25,8 +25,6 @@ #include #include -#include - #include "node/project/serializer/serializedlayoutinfo.h" #include "node/project.h" #include "panel/multicam/multicampanel.h" @@ -55,6 +53,7 @@ namespace olive { class EngineEventBridge; +class MainStatusBar; /** * @brief Olive's main window responsible for docking widgets and the main menu bar. @@ -154,9 +153,6 @@ private: QByteArray premaximized_state_; - // Application toolbar (31px, replaces the dockable ToolPanel by default) - QToolBar *tool_bar_; - // Standard panels ProjectPanel *project_panel_; NodePanel *node_panel_; @@ -170,6 +166,7 @@ private: AudioMonitorPanel *audio_monitor_panel_; TaskManagerPanel *task_man_panel_; EngineEventBridge *event_bridge_; + MainStatusBar *status_bar_; PixelSamplerPanel *pixel_sampler_panel_; ScopePanel *scope_panel_; QList viewer_panels_; diff --git a/engine/CMakeLists.txt b/engine/CMakeLists.txt index eb7928961..c6039e878 100644 --- a/engine/CMakeLists.txt +++ b/engine/CMakeLists.txt @@ -241,17 +241,22 @@ endif () # and must not depend on OpenGL/Vulkan. if (BUILD_TESTS) enable_testing() + include(GoogleTest) - function(make_oakengine_test name) + function(make_oakengine_gtest name) # oakengine leaves olive::k_app_version to the final executable; the # version object library provides it (same as worker/CMakeLists.txt). + # Each facade test keeps its own binary because the tests have + # heterogeneous oakengine_init() flag requirements; the shared + # gtest_main.cpp only bootstraps Google Test (RUN_ALL_TESTS). add_executable(${name} tests/${name}.cpp + tests/gtest_main.cpp $ ) # Link the object library directly to bypass the version-script # restrictions on liboakengine.so (tests are internal consumers). - target_link_libraries(${name} PRIVATE oakengine-obj) + target_link_libraries(${name} PRIVATE oakengine-obj GTest::gtest) target_include_directories(${name} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/include" ) @@ -261,53 +266,53 @@ if (BUILD_TESTS) if (UNIX AND NOT APPLE) target_link_options(${name} PRIVATE "LINKER:--export-dynamic") endif () - add_test(${name} ${name}) + gtest_discover_tests(${name}) endfunction() - make_oakengine_test(oakengine_ipc_test) + make_oakengine_gtest(oakengine_ipc_test) - make_oakengine_test(oakengine_worker_test) + make_oakengine_gtest(oakengine_worker_test) - make_oakengine_test(oakengine_init_test) + make_oakengine_gtest(oakengine_init_test) - make_oakengine_test(oakengine_app_test) + make_oakengine_gtest(oakengine_app_test) # Resolves the real test assets (tests/demo.mp4, the footage fixture # project) relative to the repository root, like tests/gtest does. target_compile_definitions(oakengine_init_test PRIVATE OAK_TEST_SOURCE_DIR="${CMAKE_SOURCE_DIR}" ) - make_oakengine_test(oakengine_task_test) + make_oakengine_gtest(oakengine_task_test) # The task test creates temporary projects and imports non-existent files, # so it only needs the headless engine services. - make_oakengine_test(oakengine_config_test) + make_oakengine_gtest(oakengine_config_test) # The config test exercises the QSettings-backed key/value store through # the C ABI; it is headless and does not touch the disk cache. - make_oakengine_test(oakengine_audio_test) + make_oakengine_gtest(oakengine_audio_test) # The audio test exercises the AudioManager instance lifecycle, device # get/set round-trips and the output_params_changed event. It is headless # and only needs PortAudio initialization. - make_oakengine_test(oakengine_disk_test) + make_oakengine_gtest(oakengine_disk_test) # The disk test exercises the DiskManager instance lifecycle, default cache # path queries, cache clearing, settings handler dispatch and default path # mutation. It is headless and only touches temporary directories. - make_oakengine_test(oakengine_proxy_test) + make_oakengine_gtest(oakengine_proxy_test) # The proxy test exercises proxy parameter defaults, state string # round-trips and the ProxyManager singleton lifecycle. It is headless. - make_oakengine_test(oakengine_lut_test) + make_oakengine_gtest(oakengine_lut_test) # The LUT test exercises directory/file list queries and the # set_directories round-trip. It is headless. - make_oakengine_test(oakengine_serializer_test) + make_oakengine_gtest(oakengine_serializer_test) # The serializer test exercises compressed-project detection, clipboard # create/free/copy and empty-node copy. It is headless. - make_oakengine_test(oakengine_renderer_test) + make_oakengine_gtest(oakengine_renderer_test) # The renderer test builds sequence content through the engine C++ API # (allowed for engine-internal tests) and probes the dynamic render # backend the same way the gtest harness does, so it needs the internal @@ -338,26 +343,26 @@ if (BUILD_TESTS) add_dependencies(oakengine_renderer_test olive-render-worker) endif () - make_oakengine_test(oakengine_footage_test) + make_oakengine_gtest(oakengine_footage_test) target_compile_definitions(oakengine_footage_test PRIVATE OAK_TEST_SOURCE_DIR="${CMAKE_SOURCE_DIR}" ) - make_oakengine_test(oakengine_timeline_edit_test) + make_oakengine_gtest(oakengine_timeline_edit_test) target_compile_definitions(oakengine_timeline_edit_test PRIVATE OAK_TEST_SOURCE_DIR="${CMAKE_SOURCE_DIR}" ) - make_oakengine_test(oakengine_events_test) + make_oakengine_gtest(oakengine_events_test) target_compile_definitions(oakengine_events_test PRIVATE OAK_TEST_SOURCE_DIR="${CMAKE_SOURCE_DIR}" ) - make_oakengine_test(oakengine_encoding_test) + make_oakengine_gtest(oakengine_encoding_test) - make_oakengine_test(oakengine_color_test) + make_oakengine_gtest(oakengine_color_test) - make_oakengine_test(oakengine_export_test) + make_oakengine_gtest(oakengine_export_test) # The export test builds sequence content through the engine C++ API and # probes the dynamic render backend like oakengine_renderer_test does. target_include_directories(oakengine_export_test PRIVATE @@ -384,29 +389,29 @@ if (BUILD_TESTS) add_dependencies(oakengine_export_test olive-render-worker) endif () - make_oakengine_test(oakengine_node_test) + make_oakengine_gtest(oakengine_node_test) - make_oakengine_test(oakengine_nodevalue_test) + make_oakengine_gtest(oakengine_nodevalue_test) target_compile_definitions(oakengine_node_test PRIVATE OAK_TEST_SOURCE_DIR="${CMAKE_SOURCE_DIR}" ) - make_oakengine_test(oakengine_keyframe_test) + make_oakengine_gtest(oakengine_keyframe_test) target_compile_definitions(oakengine_keyframe_test PRIVATE OAK_TEST_SOURCE_DIR="${CMAKE_SOURCE_DIR}" ) - make_oakengine_test(oakengine_viewer_test) + make_oakengine_gtest(oakengine_viewer_test) target_compile_definitions(oakengine_viewer_test PRIVATE OAK_TEST_SOURCE_DIR="${CMAKE_SOURCE_DIR}" ) - make_oakengine_test(oakengine_traverse_test) + make_oakengine_gtest(oakengine_traverse_test) target_compile_definitions(oakengine_traverse_test PRIVATE OAK_TEST_SOURCE_DIR="${CMAKE_SOURCE_DIR}" ) - make_oakengine_test(oakengine_preview_test) + make_oakengine_gtest(oakengine_preview_test) # The preview test needs audio rendering (RenderManager + workers). target_include_directories(oakengine_preview_test PRIVATE ${CMAKE_SOURCE_DIR}/third_party/openfx/include @@ -429,7 +434,7 @@ if (BUILD_TESTS) add_dependencies(oakengine_preview_test olive-render-worker) endif () - make_oakengine_test(oakengine_playback_test) + make_oakengine_gtest(oakengine_playback_test) # The playback test builds sequence content through the engine C++ API # and pulls frames through the render worker pool (same needs as # oakengine_renderer_test). @@ -457,7 +462,7 @@ if (BUILD_TESTS) add_dependencies(oakengine_playback_test olive-render-worker) endif () - make_oakengine_test(oakengine_sync_test) + make_oakengine_gtest(oakengine_sync_test) # The sync test renders the clips' audio through the worker pool (same # needs as oakengine_playback_test). target_include_directories(oakengine_sync_test PRIVATE diff --git a/engine/tests/oakengine_app_test.cpp b/engine/tests/oakengine_app_test.cpp index fc2345212..e224ab6e6 100644 --- a/engine/tests/oakengine_app_test.cpp +++ b/engine/tests/oakengine_app_test.cpp @@ -32,6 +32,7 @@ // handler is verified through oakengine_app_create_new_project(). #include +#include #include #include #include @@ -74,7 +75,7 @@ static Cb g_cb; static int on_confirm_image_sequence(const char *filename, void *userdata) { (void) filename; - assert(userdata == &g_cb); + EXPECT_TRUE(userdata == &g_cb); g_cb.confirm_image_sequence_calls++; return 1; } @@ -83,22 +84,22 @@ static int on_relink_footage(OakEngineFootage **footage, int count, void *userdata) { (void) footage; - assert(userdata == &g_cb); + EXPECT_TRUE(userdata == &g_cb); g_cb.relink_calls++; - assert(count >= 0); + EXPECT_TRUE(count >= 0); return 1; } static void on_save_project(const char *override_filename, void *userdata) { (void) override_filename; - assert(userdata == &g_cb); + EXPECT_TRUE(userdata == &g_cb); g_cb.save_project_calls++; } static int on_close_project(void *userdata) { - assert(userdata == &g_cb); + EXPECT_TRUE(userdata == &g_cb); g_cb.close_project_calls++; // Mirror the application's close: detach and delete the open project OakEngineProject *p = oakengine_app_open_project(); @@ -112,7 +113,7 @@ static int on_close_project(void *userdata) static void on_load_layout(const void *layout, void *userdata) { (void) layout; - assert(userdata == &g_cb); + EXPECT_TRUE(userdata == &g_cb); g_cb.load_layout_calls++; } @@ -121,7 +122,7 @@ static int on_otio_import(OakEngineSequence **sequences, int count, { (void) sequences; (void) count; - assert(userdata == &g_cb); + EXPECT_TRUE(userdata == &g_cb); g_cb.otio_import_calls++; return 1; } @@ -129,7 +130,7 @@ static int on_otio_import(OakEngineSequence **sequences, int count, static void on_status_message_show(const char *message, int timeout, void *userdata) { - assert(userdata == &g_cb); + EXPECT_TRUE(userdata == &g_cb); g_cb.status_show_calls++; snprintf(g_cb.last_status, sizeof(g_cb.last_status), "%s", message); g_cb.last_timeout = timeout; @@ -137,61 +138,61 @@ static void on_status_message_show(const char *message, int timeout, static void on_status_message_clear(void *userdata) { - assert(userdata == &g_cb); + EXPECT_TRUE(userdata == &g_cb); g_cb.status_clear_calls++; } static void on_cache_full_warning(void *userdata) { - assert(userdata == &g_cb); + EXPECT_TRUE(userdata == &g_cb); g_cb.cache_full_calls++; } static void on_active_project_changed(OakEngineProject *project, void *userdata) { - assert(userdata == &g_cb); + EXPECT_TRUE(userdata == &g_cb); g_cb.active_project_calls++; g_cb.last_project = project; } static void on_tool_changed(int tool, void *userdata) { - assert(userdata == &g_cb); + EXPECT_TRUE(userdata == &g_cb); g_cb.tool_changed_calls++; g_cb.last_tool = tool; } static void on_addable_object_changed(int object, void *userdata) { - assert(userdata == &g_cb); + EXPECT_TRUE(userdata == &g_cb); g_cb.addable_changed_calls++; g_cb.last_addable = object; } static void on_snapping_changed(int snapping, void *userdata) { - assert(userdata == &g_cb); + EXPECT_TRUE(userdata == &g_cb); g_cb.snapping_changed_calls++; g_cb.last_snapping = snapping; } static void on_timecode_display_changed(int display, void *userdata) { - assert(userdata == &g_cb); + EXPECT_TRUE(userdata == &g_cb); g_cb.timecode_changed_calls++; g_cb.last_display = display; } static void on_open_recent_list_changed(void *userdata) { - assert(userdata == &g_cb); + EXPECT_TRUE(userdata == &g_cb); g_cb.recent_changed_calls++; } static void on_color_picker_enabled(int enabled, void *userdata) { - assert(userdata == &g_cb); + EXPECT_TRUE(userdata == &g_cb); g_cb.color_picker_calls++; g_cb.last_color_picker = enabled; } @@ -223,9 +224,9 @@ static OakEngineAppCallbacks make_callbacks(void) static char *query0(int (*fn)(char *, int)) { const int needed = fn(NULL, 0); - assert(needed >= 0); + EXPECT_TRUE(needed >= 0); char *buf = (char *) malloc(size_t(needed) + 1); - assert(fn(buf, needed + 1) == needed); + EXPECT_TRUE(fn(buf, needed + 1) == needed); buf[needed] = '\0'; return buf; } @@ -238,99 +239,99 @@ static void test_create_and_params(void) params.startup_project = "/tmp/startup.ove"; // NULL params would be valid too, but verify the values round-trip - assert(oakengine_app_create(¶ms) == OAKENGINE_OK); - assert(oakengine_app_run_mode() == OAKENGINE_APP_RUN_HEADLESS_PRE_CACHE); - assert(oakengine_app_fullscreen() == 1); + EXPECT_TRUE(oakengine_app_create(¶ms) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_app_run_mode() == OAKENGINE_APP_RUN_HEADLESS_PRE_CACHE); + EXPECT_TRUE(oakengine_app_fullscreen() == 1); char *startup = query0(oakengine_app_startup_project); - assert(strcmp(startup, "/tmp/startup.ove") == 0); + EXPECT_TRUE(strcmp(startup, "/tmp/startup.ove") == 0); free(startup); // Only one application core may exist - assert(oakengine_app_create(NULL) == OAKENGINE_E_STATE); + EXPECT_TRUE(oakengine_app_create(NULL) == OAKENGINE_E_STATE); } static void test_start_stop(void) { // Not started yet - assert(oakengine_app_stop() == OAKENGINE_E_STATE); + EXPECT_TRUE(oakengine_app_stop() == OAKENGINE_E_STATE); // Full engine start (config, managers, autorecovery, recent list) - assert(oakengine_app_start() == OAKENGINE_OK); - assert(oakengine_app_start() == OAKENGINE_E_STATE); + EXPECT_TRUE(oakengine_app_start() == OAKENGINE_OK); + EXPECT_TRUE(oakengine_app_start() == OAKENGINE_E_STATE); - assert(oakengine_app_stop() == OAKENGINE_OK); - assert(oakengine_app_stop() == OAKENGINE_E_STATE); + EXPECT_TRUE(oakengine_app_stop() == OAKENGINE_OK); + EXPECT_TRUE(oakengine_app_stop() == OAKENGINE_E_STATE); } static void test_tool_state(void) { OakEngineAppCallbacks cb = make_callbacks(); - assert(oakengine_app_set_callbacks(&cb) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_app_set_callbacks(&cb) == OAKENGINE_OK); // Tool (k_none=0 .. k_track_select=13, k_count=14) - assert(oakengine_app_set_tool(4) == OAKENGINE_OK); - assert(oakengine_app_tool() == 4); - assert(g_cb.tool_changed_calls == 1 && g_cb.last_tool == 4); - assert(oakengine_app_set_tool(-1) == OAKENGINE_E_INVALID); - assert(oakengine_app_set_tool(999) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_app_set_tool(4) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_app_tool() == 4); + EXPECT_TRUE(g_cb.tool_changed_calls == 1 && g_cb.last_tool == 4); + EXPECT_TRUE(oakengine_app_set_tool(-1) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_app_set_tool(999) == OAKENGINE_E_INVALID); // Addable object - assert(oakengine_app_set_addable_object(2) == OAKENGINE_OK); - assert(oakengine_app_addable_object() == 2); - assert(g_cb.addable_changed_calls == 1 && g_cb.last_addable == 2); - assert(oakengine_app_set_addable_object(999) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_app_set_addable_object(2) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_app_addable_object() == 2); + EXPECT_TRUE(g_cb.addable_changed_calls == 1 && g_cb.last_addable == 2); + EXPECT_TRUE(oakengine_app_set_addable_object(999) == OAKENGINE_E_INVALID); // Snapping - assert(oakengine_app_set_snapping(0) == OAKENGINE_OK); - assert(oakengine_app_snapping() == 0); - assert(g_cb.snapping_changed_calls == 1 && g_cb.last_snapping == 0); - assert(oakengine_app_set_snapping(1) == OAKENGINE_OK); - assert(oakengine_app_snapping() == 1); - assert(g_cb.snapping_changed_calls == 2 && g_cb.last_snapping == 1); + EXPECT_TRUE(oakengine_app_set_snapping(0) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_app_snapping() == 0); + EXPECT_TRUE(g_cb.snapping_changed_calls == 1 && g_cb.last_snapping == 0); + EXPECT_TRUE(oakengine_app_set_snapping(1) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_app_snapping() == 1); + EXPECT_TRUE(g_cb.snapping_changed_calls == 2 && g_cb.last_snapping == 1); // Timecode display (0..4) - assert(oakengine_app_set_timecode_display(3) == OAKENGINE_OK); - assert(oakengine_app_timecode_display() == 3); - assert(g_cb.timecode_changed_calls == 1 && g_cb.last_display == 3); - assert(oakengine_app_set_timecode_display(999) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_app_set_timecode_display(3) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_app_timecode_display() == 3); + EXPECT_TRUE(g_cb.timecode_changed_calls == 1 && g_cb.last_display == 3); + EXPECT_TRUE(oakengine_app_set_timecode_display(999) == OAKENGINE_E_INVALID); // Selected transition - assert(oakengine_app_set_selected_transition("crossdissolve") == + EXPECT_TRUE(oakengine_app_set_selected_transition("crossdissolve") == OAKENGINE_OK); char *transition = query0(oakengine_app_selected_transition); - assert(strcmp(transition, "crossdissolve") == 0); + EXPECT_TRUE(strcmp(transition, "crossdissolve") == 0); free(transition); - assert(oakengine_app_set_selected_transition(NULL) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_app_set_selected_transition(NULL) == OAKENGINE_OK); transition = query0(oakengine_app_selected_transition); - assert(transition[0] == '\0'); + EXPECT_TRUE(transition[0] == '\0'); free(transition); // Magic flag - assert(oakengine_app_set_magic(1) == OAKENGINE_OK); - assert(oakengine_app_is_magic_enabled() == 1); - assert(oakengine_app_set_magic(0) == OAKENGINE_OK); - assert(oakengine_app_is_magic_enabled() == 0); + EXPECT_TRUE(oakengine_app_set_magic(1) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_app_is_magic_enabled() == 1); + EXPECT_TRUE(oakengine_app_set_magic(0) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_app_is_magic_enabled() == 0); } static void test_status_and_pixel_sampling(void) { - assert(oakengine_app_show_status_message("hello", 250) == OAKENGINE_OK); - assert(g_cb.status_show_calls == 1); - assert(strcmp(g_cb.last_status, "hello") == 0); - assert(g_cb.last_timeout == 250); - assert(oakengine_app_show_status_message(NULL, 0) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_app_show_status_message("hello", 250) == OAKENGINE_OK); + EXPECT_TRUE(g_cb.status_show_calls == 1); + EXPECT_TRUE(strcmp(g_cb.last_status, "hello") == 0); + EXPECT_TRUE(g_cb.last_timeout == 250); + EXPECT_TRUE(oakengine_app_show_status_message(NULL, 0) == OAKENGINE_E_INVALID); - assert(oakengine_app_clear_status_message() == OAKENGINE_OK); - assert(g_cb.status_clear_calls == 1); + EXPECT_TRUE(oakengine_app_clear_status_message() == OAKENGINE_OK); + EXPECT_TRUE(g_cb.status_clear_calls == 1); // Pixel sampling ref-count emits only when crossing zero - assert(oakengine_app_request_pixel_sampling(1) == OAKENGINE_OK); - assert(oakengine_app_request_pixel_sampling(1) == OAKENGINE_OK); - assert(g_cb.color_picker_calls == 1 && g_cb.last_color_picker == 1); - assert(oakengine_app_request_pixel_sampling(0) == OAKENGINE_OK); - assert(g_cb.color_picker_calls == 1); - assert(oakengine_app_request_pixel_sampling(0) == OAKENGINE_OK); - assert(g_cb.color_picker_calls == 2 && g_cb.last_color_picker == 0); + EXPECT_TRUE(oakengine_app_request_pixel_sampling(1) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_app_request_pixel_sampling(1) == OAKENGINE_OK); + EXPECT_TRUE(g_cb.color_picker_calls == 1 && g_cb.last_color_picker == 1); + EXPECT_TRUE(oakengine_app_request_pixel_sampling(0) == OAKENGINE_OK); + EXPECT_TRUE(g_cb.color_picker_calls == 1); + EXPECT_TRUE(oakengine_app_request_pixel_sampling(0) == OAKENGINE_OK); + EXPECT_TRUE(g_cb.color_picker_calls == 2 && g_cb.last_color_picker == 0); } static void test_project_lifecycle(void) @@ -339,80 +340,80 @@ static void test_project_lifecycle(void) const int active_before = g_cb.active_project_calls; // New project goes through the close handler and becomes active - assert(oakengine_app_create_new_project() == OAKENGINE_OK); - assert(g_cb.close_project_calls == 1); + EXPECT_TRUE(oakengine_app_create_new_project() == OAKENGINE_OK); + EXPECT_TRUE(g_cb.close_project_calls == 1); OakEngineProject *p = oakengine_app_open_project(); - assert(p != NULL); - assert(g_cb.active_project_calls > active_before); - assert(g_cb.last_project == p); + EXPECT_TRUE(p != NULL); + EXPECT_TRUE(g_cb.active_project_calls > active_before); + EXPECT_TRUE(g_cb.last_project == p); // Replacing it invokes the close handler again - assert(oakengine_app_create_new_project() == OAKENGINE_OK); - assert(g_cb.close_project_calls == 2); + EXPECT_TRUE(oakengine_app_create_new_project() == OAKENGINE_OK); + EXPECT_TRUE(g_cb.close_project_calls == 2); p = oakengine_app_open_project(); - assert(p != NULL); + EXPECT_TRUE(p != NULL); // Saving a project without a filename keeps the recent list unchanged - assert(oakengine_app_clear_recent_projects() == OAKENGINE_OK); - assert(oakengine_app_on_project_saved(p) == OAKENGINE_OK); - assert(oakengine_app_recent_projects_count() == 0); + EXPECT_TRUE(oakengine_app_clear_recent_projects() == OAKENGINE_OK); + EXPECT_TRUE(oakengine_app_on_project_saved(p) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_app_recent_projects_count() == 0); // Detach and free it again - assert(oakengine_app_set_active_project(NULL) == OAKENGINE_OK); - assert(oakengine_app_open_project() == NULL); - assert(g_cb.last_project == NULL); + EXPECT_TRUE(oakengine_app_set_active_project(NULL) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_app_open_project() == NULL); + EXPECT_TRUE(g_cb.last_project == NULL); oakengine_project_free(p); // add_open_project adopts an externally created project p = oakengine_project_create(); - assert(p != NULL); - assert(oakengine_project_new(p) == OAKENGINE_OK); - assert(oakengine_app_add_open_project(p, 0) == OAKENGINE_OK); - assert(oakengine_app_open_project() == p); - assert(oakengine_app_set_active_project(NULL) == OAKENGINE_OK); + EXPECT_TRUE(p != NULL); + EXPECT_TRUE(oakengine_project_new(p) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_app_add_open_project(p, 0) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_app_open_project() == p); + EXPECT_TRUE(oakengine_app_set_active_project(NULL) == OAKENGINE_OK); oakengine_project_free(p); // NULL tolerance - assert(oakengine_app_add_open_project(NULL, 0) == OAKENGINE_E_INVALID); - assert(oakengine_app_on_project_saved(NULL) == OAKENGINE_E_INVALID); - assert(oakengine_app_add_open_project_from_task(NULL, 0) == + EXPECT_TRUE(oakengine_app_add_open_project(NULL, 0) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_app_on_project_saved(NULL) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_app_add_open_project_from_task(NULL, 0) == OAKENGINE_E_INVALID); - assert(oakengine_app_add_recovery_project_from_task(NULL) == + EXPECT_TRUE(oakengine_app_add_recovery_project_from_task(NULL) == OAKENGINE_E_INVALID); } static void test_recent_projects(void) { // Start from a clean list - assert(oakengine_app_clear_recent_projects() == OAKENGINE_OK); - assert(oakengine_app_recent_projects_count() == 0); + EXPECT_TRUE(oakengine_app_clear_recent_projects() == OAKENGINE_OK); + EXPECT_TRUE(oakengine_app_recent_projects_count() == 0); const int changes_before = g_cb.recent_changed_calls; // A saved project lands in the recent list through on_project_saved OakEngineProject *p = oakengine_project_create(); - assert(p != NULL); - assert(oakengine_project_new(p) == OAKENGINE_OK); - assert(oakengine_project_save(p, "oakengine_app_test_recent.ove") == + EXPECT_TRUE(p != NULL); + EXPECT_TRUE(oakengine_project_new(p) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_save(p, "oakengine_app_test_recent.ove") == OAKENGINE_OK); - assert(oakengine_app_on_project_saved(p) == OAKENGINE_OK); - assert(oakengine_app_recent_projects_count() == 1); - assert(g_cb.recent_changed_calls > changes_before); + EXPECT_TRUE(oakengine_app_on_project_saved(p) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_app_recent_projects_count() == 1); + EXPECT_TRUE(g_cb.recent_changed_calls > changes_before); const int needed = oakengine_app_recent_project_at(0, NULL, 0); - assert(needed > 0); + EXPECT_TRUE(needed > 0); char *buf = (char *) malloc(size_t(needed) + 1); - assert(oakengine_app_recent_project_at(0, buf, needed + 1) == needed); + EXPECT_TRUE(oakengine_app_recent_project_at(0, buf, needed + 1) == needed); buf[needed] = '\0'; - assert(strstr(buf, "oakengine_app_test_recent.ove") != NULL); + EXPECT_TRUE(strstr(buf, "oakengine_app_test_recent.ove") != NULL); free(buf); // Out-of-range access is rejected (the engine would assert otherwise) - assert(oakengine_app_recent_project_at(5, NULL, 0) == + EXPECT_TRUE(oakengine_app_recent_project_at(5, NULL, 0) == OAKENGINE_E_NOT_FOUND); - assert(oakengine_app_remove_recent_project(5) == OAKENGINE_E_NOT_FOUND); + EXPECT_TRUE(oakengine_app_remove_recent_project(5) == OAKENGINE_E_NOT_FOUND); - assert(oakengine_app_remove_recent_project(0) == OAKENGINE_OK); - assert(oakengine_app_recent_projects_count() == 0); + EXPECT_TRUE(oakengine_app_remove_recent_project(0) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_app_recent_projects_count() == 0); remove("oakengine_app_test_recent.ove"); oakengine_project_free(p); @@ -420,54 +421,54 @@ static void test_recent_projects(void) static void test_clipboard(void) { - assert(oakengine_app_copy_to_clipboard("hello clipboard") == + EXPECT_TRUE(oakengine_app_copy_to_clipboard("hello clipboard") == OAKENGINE_OK); char *text = query0(oakengine_app_paste_from_clipboard); - assert(strcmp(text, "hello clipboard") == 0); + EXPECT_TRUE(strcmp(text, "hello clipboard") == 0); free(text); - assert(oakengine_app_copy_to_clipboard(NULL) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_app_copy_to_clipboard(NULL) == OAKENGINE_E_INVALID); } static void test_footage_filter(void) { - assert(oakengine_app_is_footage_extension_allowed("movie.mp4") == 1); - assert(oakengine_app_is_footage_extension_allowed("IMAGE.PNG") == 1); - assert(oakengine_app_is_footage_extension_allowed("doc.txt") == 0); - assert(oakengine_app_is_footage_extension_allowed(NULL) == + EXPECT_TRUE(oakengine_app_is_footage_extension_allowed("movie.mp4") == 1); + EXPECT_TRUE(oakengine_app_is_footage_extension_allowed("IMAGE.PNG") == 1); + EXPECT_TRUE(oakengine_app_is_footage_extension_allowed("doc.txt") == 0); + EXPECT_TRUE(oakengine_app_is_footage_extension_allowed(NULL) == OAKENGINE_E_INVALID); char *filter = query0(oakengine_app_footage_file_dialog_filter); - assert(strstr(filter, "*.mp4") != NULL); - assert(strstr(filter, ";;") != NULL); + EXPECT_TRUE(strstr(filter, "*.mp4") != NULL); + EXPECT_TRUE(strstr(filter, ";;") != NULL); free(filter); } static void test_misc(void) { // Unknown locale is reported as "not found" without failing - assert(oakengine_app_set_language("definitely_not_a_locale_xx") == 0); - assert(oakengine_app_set_language(NULL) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_app_set_language("definitely_not_a_locale_xx") == 0); + EXPECT_TRUE(oakengine_app_set_language(NULL) == OAKENGINE_E_INVALID); - assert(oakengine_app_set_autorecovery_interval(5) == OAKENGINE_OK); - assert(oakengine_app_set_use_proxy_media(1) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_app_set_autorecovery_interval(5) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_app_set_use_proxy_media(1) == OAKENGINE_OK); char *index = query0(oakengine_app_auto_recovery_index_filename); - assert(strstr(index, "unrecovered") != NULL); + EXPECT_TRUE(strstr(index, "unrecovered") != NULL); free(index); - assert(oakengine_app_undo_stack() != NULL); + EXPECT_TRUE(oakengine_app_undo_stack() != NULL); } static void test_create_sequence(void) { OakEngineProject *p = oakengine_project_create(); - assert(p != NULL); - assert(oakengine_project_new(p) == OAKENGINE_OK); + EXPECT_TRUE(p != NULL); + EXPECT_TRUE(oakengine_project_new(p) == OAKENGINE_OK); OakEngineSequence *s = oakengine_app_create_sequence(p, "Seq %1"); - assert(s != NULL); + EXPECT_TRUE(s != NULL); - assert(oakengine_app_create_sequence(NULL, NULL) == NULL); + EXPECT_TRUE(oakengine_app_create_sequence(NULL, NULL) == NULL); // The returned sequence is not yet part of the project (owned by the // caller); this test intentionally leaves it unparented. @@ -476,23 +477,23 @@ static void test_create_sequence(void) static void test_callbacks_clear(void) { - assert(oakengine_app_set_callbacks(NULL) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_app_set_callbacks(NULL) == OAKENGINE_OK); // State changes still work, but nothing is delivered anymore const int calls = g_cb.tool_changed_calls; - assert(oakengine_app_set_tool(2) == OAKENGINE_OK); - assert(oakengine_app_tool() == 2); - assert(g_cb.tool_changed_calls == calls); + EXPECT_TRUE(oakengine_app_set_tool(2) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_app_tool() == 2); + EXPECT_TRUE(g_cb.tool_changed_calls == calls); } -int main(void) +TEST(OakEngineApp, Main) { // The facade brings up its own offscreen application object test_create_and_params(); test_start_stop(); // Engine services (incl. renderer manager for set_active_project) - assert(oakengine_init(OAKENGINE_INIT_HEADLESS | OAKENGINE_INIT_RENDER) == + EXPECT_TRUE(oakengine_init(OAKENGINE_INIT_HEADLESS | OAKENGINE_INIT_RENDER) == OAKENGINE_OK); test_tool_state(); @@ -505,6 +506,5 @@ int main(void) test_create_sequence(); test_callbacks_clear(); - assert(oakengine_shutdown() == OAKENGINE_OK); - return 0; + EXPECT_TRUE(oakengine_shutdown() == OAKENGINE_OK); } diff --git a/engine/tests/oakengine_audio_test.cpp b/engine/tests/oakengine_audio_test.cpp index e4c0415e1..3fa368358 100644 --- a/engine/tests/oakengine_audio_test.cpp +++ b/engine/tests/oakengine_audio_test.cpp @@ -24,6 +24,7 @@ // output_params_changed event subscription. No GL or QApplication required. #include +#include #include #include @@ -36,8 +37,8 @@ static void *g_output_params_changed_source; static void on_output_params_changed(const oakengine_event *event, void *) { - assert(event != NULL); - assert(event->id == OAKENGINE_EVENT_AUDIO_MANAGER_OUTPUT_PARAMS_CHANGED); + EXPECT_TRUE(event != NULL); + EXPECT_TRUE(event->id == OAKENGINE_EVENT_AUDIO_MANAGER_OUTPUT_PARAMS_CHANGED); g_output_params_changed_count++; g_output_params_changed_source = event->source; } @@ -45,71 +46,71 @@ static void on_output_params_changed(const oakengine_event *event, void *) static void test_instance_lifecycle(void) { // No instance before create. - assert(oakengine_audio_manager_handle() == NULL); - assert(oakengine_audio_get_output_device() == -1); - assert(oakengine_audio_get_input_device() == -1); - assert(oakengine_audio_clear_buffered_output() == OAKENGINE_E_STATE); - assert(oakengine_audio_stop_recording() == OAKENGINE_E_STATE); + EXPECT_TRUE(oakengine_audio_manager_handle() == NULL); + EXPECT_TRUE(oakengine_audio_get_output_device() == -1); + EXPECT_TRUE(oakengine_audio_get_input_device() == -1); + EXPECT_TRUE(oakengine_audio_clear_buffered_output() == OAKENGINE_E_STATE); + EXPECT_TRUE(oakengine_audio_stop_recording() == OAKENGINE_E_STATE); - assert(oakengine_audio_create_instance() == OAKENGINE_OK); - assert(oakengine_audio_manager_handle() != NULL); + EXPECT_TRUE(oakengine_audio_create_instance() == OAKENGINE_OK); + EXPECT_TRUE(oakengine_audio_manager_handle() != NULL); // Idempotent create is allowed. - assert(oakengine_audio_create_instance() == OAKENGINE_OK); - assert(oakengine_audio_manager_handle() != NULL); + EXPECT_TRUE(oakengine_audio_create_instance() == OAKENGINE_OK); + EXPECT_TRUE(oakengine_audio_manager_handle() != NULL); oakengine_audio_destroy_instance(); - assert(oakengine_audio_manager_handle() == NULL); + EXPECT_TRUE(oakengine_audio_manager_handle() == NULL); // Idempotent destroy is allowed. - assert(oakengine_audio_destroy_instance() == OAKENGINE_OK); - assert(oakengine_audio_manager_handle() == NULL); + EXPECT_TRUE(oakengine_audio_destroy_instance() == OAKENGINE_OK); + EXPECT_TRUE(oakengine_audio_manager_handle() == NULL); } static void test_device_round_trip(void) { - assert(oakengine_audio_create_instance() == OAKENGINE_OK); + EXPECT_TRUE(oakengine_audio_create_instance() == OAKENGINE_OK); void *handle = oakengine_audio_manager_handle(); - assert(handle != NULL); + EXPECT_TRUE(handle != NULL); // Default is usually paNoDevice (-1) in headless environments. const int64_t original_output = oakengine_audio_get_output_device(); const int64_t original_input = oakengine_audio_get_input_device(); // Setting a value should change the returned value. - assert(oakengine_audio_set_output_device(42) == OAKENGINE_OK); - assert(oakengine_audio_get_output_device() == 42); + EXPECT_TRUE(oakengine_audio_set_output_device(42) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_audio_get_output_device() == 42); - assert(oakengine_audio_set_input_device(43) == OAKENGINE_OK); - assert(oakengine_audio_get_input_device() == 43); + EXPECT_TRUE(oakengine_audio_set_input_device(43) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_audio_get_input_device() == 43); // hard_reset re-initializes PortAudio and should not crash. - assert(oakengine_audio_hard_reset() == OAKENGINE_OK); - assert(oakengine_audio_manager_handle() == handle); + EXPECT_TRUE(oakengine_audio_hard_reset() == OAKENGINE_OK); + EXPECT_TRUE(oakengine_audio_manager_handle() == handle); // Restore original values. - assert(oakengine_audio_set_output_device(original_output) == OAKENGINE_OK); - assert(oakengine_audio_set_input_device(original_input) == OAKENGINE_OK); - assert(oakengine_audio_get_output_device() == original_output); - assert(oakengine_audio_get_input_device() == original_input); + EXPECT_TRUE(oakengine_audio_set_output_device(original_output) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_audio_set_input_device(original_input) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_audio_get_output_device() == original_output); + EXPECT_TRUE(oakengine_audio_get_input_device() == original_input); oakengine_audio_destroy_instance(); } static void test_push_to_output_errors(void) { - assert(oakengine_audio_create_instance() == OAKENGINE_OK); + EXPECT_TRUE(oakengine_audio_create_instance() == OAKENGINE_OK); char error_buf[256]; memset(error_buf, 0, sizeof(error_buf)); // NULL params is rejected without crashing. - assert(oakengine_audio_push_to_output(NULL, "x", 1, error_buf, + EXPECT_TRUE(oakengine_audio_push_to_output(NULL, "x", 1, error_buf, sizeof(error_buf)) == OAKENGINE_E_INVALID); // NULL samples is rejected. - assert(oakengine_audio_push_to_output((const OakAudioParams *)1, NULL, 1, + EXPECT_TRUE(oakengine_audio_push_to_output((const OakAudioParams *)1, NULL, 1, error_buf, sizeof(error_buf)) == OAKENGINE_E_INVALID); @@ -118,9 +119,9 @@ static void test_push_to_output_errors(void) static void test_output_params_changed_event(void) { - assert(oakengine_audio_create_instance() == OAKENGINE_OK); + EXPECT_TRUE(oakengine_audio_create_instance() == OAKENGINE_OK); void *handle = oakengine_audio_manager_handle(); - assert(handle != NULL); + EXPECT_TRUE(handle != NULL); g_output_params_changed_count = 0; g_output_params_changed_source = NULL; @@ -128,22 +129,22 @@ static void test_output_params_changed_event(void) const int64_t sub = oakengine_event_subscribe( handle, OAKENGINE_EVENT_AUDIO_MANAGER_OUTPUT_PARAMS_CHANGED, on_output_params_changed, NULL); - assert(sub > 0); + EXPECT_TRUE(sub > 0); const int64_t original_output = oakengine_audio_get_output_device(); - assert(oakengine_audio_set_output_device(84) == OAKENGINE_OK); - assert(g_output_params_changed_count >= 1); - assert(g_output_params_changed_source == handle); + EXPECT_TRUE(oakengine_audio_set_output_device(84) == OAKENGINE_OK); + EXPECT_TRUE(g_output_params_changed_count >= 1); + EXPECT_TRUE(g_output_params_changed_source == handle); - assert(oakengine_event_unsubscribe(sub) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_event_unsubscribe(sub) == OAKENGINE_OK); // No further deliveries after unsubscribe. const int count_after_unsub = g_output_params_changed_count; - assert(oakengine_audio_set_output_device(85) == OAKENGINE_OK); - assert(g_output_params_changed_count == count_after_unsub); + EXPECT_TRUE(oakengine_audio_set_output_device(85) == OAKENGINE_OK); + EXPECT_TRUE(g_output_params_changed_count == count_after_unsub); // Restore original value. - assert(oakengine_audio_set_output_device(original_output) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_audio_set_output_device(original_output) == OAKENGINE_OK); oakengine_audio_destroy_instance(); } @@ -152,43 +153,43 @@ static void test_audio_sync_algorithms(void) { // place_by_waveform_offset: a 1-second positive offset at 48 kHz oak_audio_sync_placement placement; - assert(oakengine_audio_sync_place_by_waveform_offset( + EXPECT_TRUE(oakengine_audio_sync_place_by_waveform_offset( 0, 1, 48000, 48000, &placement) == OAKENGINE_OK); - assert(placement.valid); - assert(placement.timeline_in_num == 1 && placement.timeline_in_den == 1); + EXPECT_TRUE(placement.valid); + EXPECT_TRUE(placement.timeline_in_num == 1 && placement.timeline_in_den == 1); // place_by_source_time: matching source/media in points -> same timeline in oak_audio_sync_source_clip ref = { 0, 1, 0, 1, 1 }; oak_audio_sync_source_clip cand = { 0, 1, 0, 1, 1 }; - assert(oakengine_audio_sync_place_by_source_time( + EXPECT_TRUE(oakengine_audio_sync_place_by_source_time( &ref, &cand, 5, 1, &placement) == OAKENGINE_OK); - assert(placement.valid); - assert(placement.timeline_in_num == 5 && placement.timeline_in_den == 1); + EXPECT_TRUE(placement.valid); + EXPECT_TRUE(placement.timeline_in_num == 5 && placement.timeline_in_den == 1); // estimate_envelope_offset: identical envelopes -> zero offset, high // confidence double envelope[10] = { 0, 1, 2, 3, 4, 5, 4, 3, 2, 1 }; oak_audio_waveform_offset offset; - assert(oakengine_audio_estimate_envelope_offset( + EXPECT_TRUE(oakengine_audio_estimate_envelope_offset( envelope, 10, envelope, 10, NULL, 0, NULL, 0, 1, 5, &offset) == OAKENGINE_OK); - assert(offset.valid); - assert(offset.offset_samples == 0); - assert(offset.confidence > 0.99); + EXPECT_TRUE(offset.valid); + EXPECT_TRUE(offset.offset_samples == 0); + EXPECT_TRUE(offset.confidence > 0.99); // estimate_stretch_and_offset: identical envelopes at rate 1 -> zero offset oak_audio_waveform_stretch_offset stretch; - assert(oakengine_audio_estimate_stretch_and_offset( + EXPECT_TRUE(oakengine_audio_estimate_stretch_and_offset( envelope, 10, envelope, 10, NULL, 0, NULL, 0, 1, 5, 0.9, 1.1, 0.05, &stretch) == OAKENGINE_OK); - assert(stretch.valid); - assert(stretch.offset_samples == 0); - assert(stretch.rate > 0.99 && stretch.rate < 1.01); + EXPECT_TRUE(stretch.valid); + EXPECT_TRUE(stretch.offset_samples == 0); + EXPECT_TRUE(stretch.rate > 0.99 && stretch.rate < 1.01); } -int main(void) +TEST(OakEngineAudio, Main) { - assert(oakengine_init(OAKENGINE_INIT_HEADLESS) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_init(OAKENGINE_INIT_HEADLESS) == OAKENGINE_OK); test_instance_lifecycle(); test_device_round_trip(); @@ -199,5 +200,4 @@ int main(void) oakengine_shutdown(); printf("oakengine_audio_test: OK\n"); - return 0; } diff --git a/engine/tests/oakengine_color_test.cpp b/engine/tests/oakengine_color_test.cpp index af66bf43c..1e6b065f1 100644 --- a/engine/tests/oakengine_color_test.cpp +++ b/engine/tests/oakengine_color_test.cpp @@ -29,6 +29,7 @@ // robustness checks (NULL handling, error paths) still run. #include +#include #include #include #include @@ -53,13 +54,13 @@ static void make_tmpdir(void) #if defined(_WIN32) char base[MAX_PATH]; const DWORD len = GetTempPathA(MAX_PATH, base); - assert(len > 0 && len < MAX_PATH); + EXPECT_TRUE(len > 0 && len < MAX_PATH); snprintf(g_tmpdir, sizeof(g_tmpdir), "%soakengine_color_test_%lu", base, (unsigned long)GetCurrentProcessId()); - assert(_mkdir(g_tmpdir) == 0); + EXPECT_TRUE(_mkdir(g_tmpdir) == 0); #else strcpy(g_tmpdir, "/tmp/oakengine_color_test_XXXXXX"); - assert(mkdtemp(g_tmpdir) != NULL); + EXPECT_TRUE(mkdtemp(g_tmpdir) != NULL); #endif } @@ -71,59 +72,59 @@ static void test_null_robustness(void) double rgb[3]; double rgba[4] = { 0, 0, 0, 0 }; - assert(oakengine_color_manager_from_project(NULL) == NULL); - assert(oakengine_color_manager_get_config_filename(NULL, buf, + EXPECT_TRUE(oakengine_color_manager_from_project(NULL) == NULL); + EXPECT_TRUE(oakengine_color_manager_get_config_filename(NULL, buf, sizeof(buf)) == OAKENGINE_E_INVALID); - assert(oakengine_color_manager_set_config_filename(NULL, "x") == + EXPECT_TRUE(oakengine_color_manager_set_config_filename(NULL, "x") == OAKENGINE_E_INVALID); - assert(oakengine_color_manager_colorspace_count(NULL) == 0); - assert(oakengine_color_manager_colorspace_at(NULL, 0, buf, sizeof(buf)) == + EXPECT_TRUE(oakengine_color_manager_colorspace_count(NULL) == 0); + EXPECT_TRUE(oakengine_color_manager_colorspace_at(NULL, 0, buf, sizeof(buf)) == OAKENGINE_E_INVALID); - assert(oakengine_color_manager_display_count(NULL) == 0); - assert(oakengine_color_manager_display_at(NULL, 0, buf, sizeof(buf)) == + EXPECT_TRUE(oakengine_color_manager_display_count(NULL) == 0); + EXPECT_TRUE(oakengine_color_manager_display_at(NULL, 0, buf, sizeof(buf)) == OAKENGINE_E_INVALID); - assert(oakengine_color_manager_view_count(NULL, NULL) == 0); - assert(oakengine_color_manager_view_at(NULL, NULL, 0, buf, sizeof(buf)) == + EXPECT_TRUE(oakengine_color_manager_view_count(NULL, NULL) == 0); + EXPECT_TRUE(oakengine_color_manager_view_at(NULL, NULL, 0, buf, sizeof(buf)) == OAKENGINE_E_INVALID); - assert(oakengine_color_manager_look_count(NULL) == 0); - assert(oakengine_color_manager_look_at(NULL, 0, buf, sizeof(buf)) == + EXPECT_TRUE(oakengine_color_manager_look_count(NULL) == 0); + EXPECT_TRUE(oakengine_color_manager_look_at(NULL, 0, buf, sizeof(buf)) == OAKENGINE_E_INVALID); - assert(oakengine_color_manager_default_display(NULL, buf, sizeof(buf)) == + EXPECT_TRUE(oakengine_color_manager_default_display(NULL, buf, sizeof(buf)) == OAKENGINE_E_INVALID); - assert(oakengine_color_manager_default_view(NULL, NULL, buf, + EXPECT_TRUE(oakengine_color_manager_default_view(NULL, NULL, buf, sizeof(buf)) == OAKENGINE_E_INVALID); - assert(oakengine_color_manager_default_input_color_space(NULL, buf, + EXPECT_TRUE(oakengine_color_manager_default_input_color_space(NULL, buf, sizeof(buf)) == OAKENGINE_E_INVALID); - assert(oakengine_color_manager_set_default_input_color_space(NULL, "x") == + EXPECT_TRUE(oakengine_color_manager_set_default_input_color_space(NULL, "x") == OAKENGINE_E_INVALID); - assert(oakengine_color_manager_reference_color_space(NULL, buf, + EXPECT_TRUE(oakengine_color_manager_reference_color_space(NULL, buf, sizeof(buf)) == OAKENGINE_E_INVALID); - assert(oakengine_color_manager_default_luma_coefs(NULL, rgb) == + EXPECT_TRUE(oakengine_color_manager_default_luma_coefs(NULL, rgb) == OAKENGINE_E_INVALID); - assert(oakengine_color_manager_compliant_color_space(NULL, "x", buf, + EXPECT_TRUE(oakengine_color_manager_compliant_color_space(NULL, "x", buf, sizeof(buf)) == OAKENGINE_E_INVALID); - assert(oakengine_color_manager_compliant_transform(NULL, NULL, 0, NULL, + EXPECT_TRUE(oakengine_color_manager_compliant_transform(NULL, NULL, 0, NULL, NULL, 0, NULL, 0, NULL, 0) == OAKENGINE_E_INVALID); - assert(oakengine_color_config_load_file(NULL) == NULL); - assert(oakengine_color_config_colorspace_count(NULL) == 0); - assert(oakengine_color_config_colorspace_at(NULL, 0, buf, sizeof(buf)) == + EXPECT_TRUE(oakengine_color_config_load_file(NULL) == NULL); + EXPECT_TRUE(oakengine_color_config_colorspace_count(NULL) == 0); + EXPECT_TRUE(oakengine_color_config_colorspace_at(NULL, 0, buf, sizeof(buf)) == OAKENGINE_E_INVALID); oakengine_color_config_free(NULL); // no-op - assert(oakengine_color_processor_create(NULL, "in", NULL, + EXPECT_TRUE(oakengine_color_processor_create(NULL, "in", NULL, OAKENGINE_COLOR_PROCESSOR_NORMAL) == NULL); - assert(oakengine_color_processor_is_valid(NULL) == 0); - assert(oakengine_color_processor_convert_color(NULL, rgba, rgba) == + EXPECT_TRUE(oakengine_color_processor_is_valid(NULL) == 0); + EXPECT_TRUE(oakengine_color_processor_convert_color(NULL, rgba, rgba) == OAKENGINE_E_INVALID); - assert(oakengine_color_processor_id(NULL, buf, sizeof(buf)) == + EXPECT_TRUE(oakengine_color_processor_id(NULL, buf, sizeof(buf)) == OAKENGINE_E_INVALID); oakengine_color_processor_free(NULL); // no-op } @@ -135,9 +136,9 @@ static void test_config_handle(int have_ocio) char buf[256]; // A missing file must fail cleanly with an error message. - assert(oakengine_color_config_load_file("/nonexistent/definitely.ocio") == + EXPECT_TRUE(oakengine_color_config_load_file("/nonexistent/definitely.ocio") == NULL); - assert(oakengine_color_last_error(buf, sizeof(buf)) > 0); + EXPECT_TRUE(oakengine_color_last_error(buf, sizeof(buf)) > 0); OakEngineColorConfig *config = oakengine_color_config_load_default(); if (!have_ocio) { @@ -147,19 +148,19 @@ static void test_config_handle(int have_ocio) } return; } - assert(config != NULL); + EXPECT_TRUE(config != NULL); const int count = oakengine_color_config_colorspace_count(config); - assert(count > 0); + EXPECT_TRUE(count > 0); for (int i = 0; i < count; i++) { - assert(oakengine_color_config_colorspace_at(config, i, buf, + EXPECT_TRUE(oakengine_color_config_colorspace_at(config, i, buf, sizeof(buf)) > 0); - assert(buf[0] != '\0'); + EXPECT_TRUE(buf[0] != '\0'); } - assert(oakengine_color_config_colorspace_at(config, count, buf, + EXPECT_TRUE(oakengine_color_config_colorspace_at(config, count, buf, sizeof(buf)) == OAKENGINE_E_INVALID); - assert(oakengine_color_config_colorspace_at(config, -1, buf, + EXPECT_TRUE(oakengine_color_config_colorspace_at(config, -1, buf, sizeof(buf)) == OAKENGINE_E_INVALID); @@ -176,69 +177,69 @@ static void test_manager_queries(OakEngineColorManager *mgr) // Colorspaces const int cs_count = oakengine_color_manager_colorspace_count(mgr); - assert(cs_count > 0); - assert(oakengine_color_manager_colorspace_at(mgr, 0, first_cs, + EXPECT_TRUE(cs_count > 0); + EXPECT_TRUE(oakengine_color_manager_colorspace_at(mgr, 0, first_cs, sizeof(first_cs)) > 0); - assert(first_cs[0] != '\0'); - assert(oakengine_color_manager_colorspace_at(mgr, cs_count, buf, + EXPECT_TRUE(first_cs[0] != '\0'); + EXPECT_TRUE(oakengine_color_manager_colorspace_at(mgr, cs_count, buf, sizeof(buf)) == OAKENGINE_E_INVALID); // Displays / views / looks const int disp_count = oakengine_color_manager_display_count(mgr); - assert(disp_count > 0); - assert(oakengine_color_manager_display_at(mgr, 0, buf, sizeof(buf)) > 0); + EXPECT_TRUE(disp_count > 0); + EXPECT_TRUE(oakengine_color_manager_display_at(mgr, 0, buf, sizeof(buf)) > 0); char display[256]; memcpy(display, buf, sizeof(display)); const int view_count = oakengine_color_manager_view_count(mgr, display); - assert(view_count > 0); - assert(oakengine_color_manager_view_at(mgr, display, 0, buf, sizeof(buf)) > + EXPECT_TRUE(view_count > 0); + EXPECT_TRUE(oakengine_color_manager_view_at(mgr, display, 0, buf, sizeof(buf)) > 0); - assert(oakengine_color_manager_look_count(mgr) >= 0); - assert(oakengine_color_manager_display_at(mgr, disp_count, buf, + EXPECT_TRUE(oakengine_color_manager_look_count(mgr) >= 0); + EXPECT_TRUE(oakengine_color_manager_display_at(mgr, disp_count, buf, sizeof(buf)) == OAKENGINE_E_INVALID); // Defaults char default_display[256]; - assert(oakengine_color_manager_default_display(mgr, default_display, + EXPECT_TRUE(oakengine_color_manager_default_display(mgr, default_display, sizeof(default_display)) > 0); - assert(oakengine_color_manager_default_view(mgr, default_display, buf, + EXPECT_TRUE(oakengine_color_manager_default_view(mgr, default_display, buf, sizeof(buf)) > 0); - assert(oakengine_color_manager_default_input_color_space(mgr, buf, + EXPECT_TRUE(oakengine_color_manager_default_input_color_space(mgr, buf, sizeof(buf)) > 0); - assert(oakengine_color_manager_reference_color_space(mgr, buf, + EXPECT_TRUE(oakengine_color_manager_reference_color_space(mgr, buf, sizeof(buf)) > 0); // Default input colorspace set/get roundtrip - assert(oakengine_color_manager_set_default_input_color_space(mgr, + EXPECT_TRUE(oakengine_color_manager_set_default_input_color_space(mgr, first_cs) == OAKENGINE_OK); - assert(oakengine_color_manager_default_input_color_space(mgr, buf, + EXPECT_TRUE(oakengine_color_manager_default_input_color_space(mgr, buf, sizeof(buf)) > 0); - assert(strcmp(buf, first_cs) == 0); + EXPECT_TRUE(strcmp(buf, first_cs) == 0); // Config filename set/get roundtrip (an empty filename selects the // built-in default config; setting it must not crash the queries above) - assert(oakengine_color_manager_set_config_filename(mgr, "") == + EXPECT_TRUE(oakengine_color_manager_set_config_filename(mgr, "") == OAKENGINE_OK); - assert(oakengine_color_manager_get_config_filename(mgr, buf, sizeof(buf)) >= + EXPECT_TRUE(oakengine_color_manager_get_config_filename(mgr, buf, sizeof(buf)) >= 0); // Luma coefficients: Rec.709-style weights, all positive, roughly sum to 1 - assert(oakengine_color_manager_default_luma_coefs(mgr, rgb) == + EXPECT_TRUE(oakengine_color_manager_default_luma_coefs(mgr, rgb) == OAKENGINE_OK); - assert(rgb[0] > 0 && rgb[1] > 0 && rgb[2] > 0); - assert(fabs(rgb[0] + rgb[1] + rgb[2] - 1.0) < 0.01); + EXPECT_TRUE(rgb[0] > 0 && rgb[1] > 0 && rgb[2] > 0); + EXPECT_TRUE(fabs(rgb[0] + rgb[1] + rgb[2] - 1.0) < 0.01); // Compliant colorspace: an existing space resolves to itself, an empty // name resolves to the default input space - assert(oakengine_color_manager_compliant_color_space(mgr, first_cs, buf, + EXPECT_TRUE(oakengine_color_manager_compliant_color_space(mgr, first_cs, buf, sizeof(buf)) > 0); - assert(strcmp(buf, first_cs) == 0); - assert(oakengine_color_manager_compliant_color_space(mgr, "", buf, + EXPECT_TRUE(strcmp(buf, first_cs) == 0); + EXPECT_TRUE(oakengine_color_manager_compliant_color_space(mgr, "", buf, sizeof(buf)) > 0); - assert(strcmp(buf, first_cs) == 0); + EXPECT_TRUE(strcmp(buf, first_cs) == 0); // Compliant transform: force a colorspace transform onto a display // transform and back @@ -250,19 +251,19 @@ static void test_manager_queries(OakEngineColorManager *mgr) int out_is_display = -1; char out_o[256], out_v[256], out_l[256]; out_o[0] = out_v[0] = out_l[0] = '\0'; - assert(oakengine_color_manager_compliant_transform(mgr, &in, 1, + EXPECT_TRUE(oakengine_color_manager_compliant_transform(mgr, &in, 1, &out_is_display, out_o, sizeof(out_o), out_v, sizeof(out_v), out_l, sizeof(out_l)) == OAKENGINE_OK); - assert(out_is_display == 1); - assert(out_o[0] != '\0'); - assert(oakengine_color_manager_compliant_transform( + EXPECT_TRUE(out_is_display == 1); + EXPECT_TRUE(out_o[0] != '\0'); + EXPECT_TRUE(oakengine_color_manager_compliant_transform( mgr, &in, 0, &out_is_display, out_o, sizeof(out_o), out_v, sizeof(out_v), out_l, sizeof(out_l)) == OAKENGINE_OK); - assert(out_is_display == 0); - assert(strcmp(out_o, first_cs) == 0); + EXPECT_TRUE(out_is_display == 0); + EXPECT_TRUE(strcmp(out_o, first_cs) == 0); } // ---- Color processor ---------------------------------------------------------- @@ -272,7 +273,7 @@ static void test_processor(OakEngineColorManager *mgr) char ref[256]; char buf[256]; - assert(oakengine_color_manager_reference_color_space(mgr, ref, + EXPECT_TRUE(oakengine_color_manager_reference_color_space(mgr, ref, sizeof(ref)) > 0); // Identity transform (ref -> ref): white stays white @@ -284,53 +285,53 @@ static void test_processor(OakEngineColorManager *mgr) OakEngineColorProcessor *proc = oakengine_color_processor_create( mgr, ref, &dest, OAKENGINE_COLOR_PROCESSOR_NORMAL); - assert(proc != NULL); - assert(oakengine_color_processor_is_valid(proc) == 1); + EXPECT_TRUE(proc != NULL); + EXPECT_TRUE(oakengine_color_processor_is_valid(proc) == 1); const double in[4] = { 1.0, 1.0, 1.0, 1.0 }; double out[4] = { 0, 0, 0, 0 }; - assert(oakengine_color_processor_convert_color(proc, in, out) == + EXPECT_TRUE(oakengine_color_processor_convert_color(proc, in, out) == OAKENGINE_OK); - assert(fabs(out[0] - 1.0) < 1e-3 && fabs(out[1] - 1.0) < 1e-3 && + EXPECT_TRUE(fabs(out[0] - 1.0) < 1e-3 && fabs(out[1] - 1.0) < 1e-3 && fabs(out[2] - 1.0) < 1e-3 && fabs(out[3] - 1.0) < 1e-3); // Cache id is non-empty and stable const int id_len = oakengine_color_processor_id(proc, buf, sizeof(buf)); - assert(id_len > 0); - assert(buf[0] != '\0'); - assert(oakengine_color_processor_id(proc, NULL, 0) == id_len); + EXPECT_TRUE(id_len > 0); + EXPECT_TRUE(buf[0] != '\0'); + EXPECT_TRUE(oakengine_color_processor_id(proc, NULL, 0) == id_len); // Inverse direction constructs too OakEngineColorProcessor *inv = oakengine_color_processor_create( mgr, ref, &dest, OAKENGINE_COLOR_PROCESSOR_INVERSE); - assert(inv != NULL); + EXPECT_TRUE(inv != NULL); oakengine_color_processor_free(inv); // Unknown direction is rejected - assert(oakengine_color_processor_create(mgr, ref, &dest, 7) == NULL); + EXPECT_TRUE(oakengine_color_processor_create(mgr, ref, &dest, 7) == NULL); // An unknown colorspace yields an invalid (pass-through) processor, // matching the engine's non-throwing C++ behavior dest.output = "definitely-not-a-colorspace"; OakEngineColorProcessor *bad = oakengine_color_processor_create( mgr, ref, &dest, OAKENGINE_COLOR_PROCESSOR_NORMAL); - assert(bad != NULL); + EXPECT_TRUE(bad != NULL); if (oakengine_color_processor_is_valid(bad)) { // Some configs resolve unknown names via roles; then conversion must // still not crash. - assert(oakengine_color_processor_convert_color(bad, in, out) == + EXPECT_TRUE(oakengine_color_processor_convert_color(bad, in, out) == OAKENGINE_OK); } else { out[0] = out[1] = out[2] = out[3] = 0; - assert(oakengine_color_processor_convert_color(bad, in, out) == + EXPECT_TRUE(oakengine_color_processor_convert_color(bad, in, out) == OAKENGINE_OK); - assert(out[0] == 1.0 && out[1] == 1.0 && out[2] == 1.0 && + EXPECT_TRUE(out[0] == 1.0 && out[1] == 1.0 && out[2] == 1.0 && out[3] == 1.0); } oakengine_color_processor_free(bad); // Processor is valid and usable. - assert(proc != NULL); + EXPECT_TRUE(proc != NULL); oakengine_color_processor_free(proc); } @@ -343,13 +344,13 @@ static int g_reference_events = 0; static void count_color_events(const oakengine_event *event, void *userdata) { (void)userdata; - assert(event != NULL); + EXPECT_TRUE(event != NULL); if (event->id == OAKENGINE_EVENT_COLOR_MANAGER_CONFIG_CHANGED) { g_config_events++; } else if (event->id == OAKENGINE_EVENT_COLOR_MANAGER_REFERENCE_SPACE_CHANGED) { g_reference_events++; } else { - assert(0); // unexpected event id on this subscription + EXPECT_TRUE(0); // unexpected event id on this subscription } } @@ -357,7 +358,7 @@ static void test_events(OakEngineProject *project, OakEngineColorManager *mgr) { // Family mismatch: a color manager event on a project handle must fail. - assert(oakengine_event_subscribe( + EXPECT_TRUE(oakengine_event_subscribe( project, OAKENGINE_EVENT_COLOR_MANAGER_CONFIG_CHANGED, count_color_events, NULL) == 0); @@ -367,46 +368,46 @@ static void test_events(OakEngineProject *project, int64_t sub_cfg = oakengine_event_subscribe( mgr, OAKENGINE_EVENT_COLOR_MANAGER_CONFIG_CHANGED, count_color_events, NULL); - assert(sub_ref > 0); - assert(sub_cfg > 0); + EXPECT_TRUE(sub_ref > 0); + EXPECT_TRUE(sub_cfg > 0); // Changing the reference space emits reference_space_changed. char ref[256]; - assert(oakengine_project_get_color_reference_space(project, ref, + EXPECT_TRUE(oakengine_project_get_color_reference_space(project, ref, sizeof(ref)) > 0); - assert(oakengine_project_set_color_reference_space( + EXPECT_TRUE(oakengine_project_set_color_reference_space( project, strcmp(ref, "scene_linear") == 0 ? "reference" : "scene_linear") == OAKENGINE_OK); - assert(g_reference_events == 1); - assert(g_config_events == 0); + EXPECT_TRUE(g_reference_events == 1); + EXPECT_TRUE(g_config_events == 0); - assert(oakengine_event_unsubscribe(sub_ref) == OAKENGINE_OK); - assert(oakengine_event_unsubscribe(sub_cfg) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_event_unsubscribe(sub_ref) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_event_unsubscribe(sub_cfg) == OAKENGINE_OK); } -int main(void) +TEST(OakEngineColor, Main) { make_tmpdir(); // Sandbox the config/cache/data locations (the default OCIO config is // extracted under the cache location). #if !defined(_WIN32) - assert(setenv("XDG_CONFIG_HOME", g_tmpdir, 1) == 0); - assert(setenv("XDG_CACHE_HOME", g_tmpdir, 1) == 0); - assert(setenv("XDG_DATA_HOME", g_tmpdir, 1) == 0); + EXPECT_TRUE(setenv("XDG_CONFIG_HOME", g_tmpdir, 1) == 0); + EXPECT_TRUE(setenv("XDG_CACHE_HOME", g_tmpdir, 1) == 0); + EXPECT_TRUE(setenv("XDG_DATA_HOME", g_tmpdir, 1) == 0); #endif - assert(oakengine_init(OAKENGINE_INIT_HEADLESS) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_init(OAKENGINE_INIT_HEADLESS) == OAKENGINE_OK); test_null_robustness(); OakEngineProject *project = oakengine_project_create(); - assert(project != NULL); - assert(oakengine_project_new(project) == OAKENGINE_OK); + EXPECT_TRUE(project != NULL); + EXPECT_TRUE(oakengine_project_new(project) == OAKENGINE_OK); OakEngineColorManager *mgr = oakengine_color_manager_from_project(project); - assert(mgr != NULL); + EXPECT_TRUE(mgr != NULL); // The built-in default config should always be available (it is // extracted from the engine's resources); tolerate environments where @@ -425,8 +426,6 @@ int main(void) test_events(project, mgr); oakengine_project_free(project); - assert(oakengine_shutdown() == OAKENGINE_OK); + EXPECT_TRUE(oakengine_shutdown() == OAKENGINE_OK); - printf("oakengine_color_test: all assertions passed\n"); - return 0; } diff --git a/engine/tests/oakengine_config_test.cpp b/engine/tests/oakengine_config_test.cpp index 538dec212..27eedbe6d 100644 --- a/engine/tests/oakengine_config_test.cpp +++ b/engine/tests/oakengine_config_test.cpp @@ -22,6 +22,7 @@ // (oakengine/config.h). Runs headless; no GPU required. #include +#include #include #include @@ -47,72 +48,71 @@ static void test_string_round_trip(void) char buf[256]; // Missing key returns 0 (empty string). - assert(oakengine_config_get_string("oak_test_string_key", buf, + EXPECT_TRUE(oakengine_config_get_string("oak_test_string_key", buf, sizeof(buf)) == 0); - assert(oakengine_config_set_string("oak_test_string_key", + EXPECT_TRUE(oakengine_config_set_string("oak_test_string_key", "hello world") == OAKENGINE_OK); int len = oakengine_config_get_string("oak_test_string_key", buf, sizeof(buf)); - assert(len == int(strlen("hello world"))); - assert(strcmp(buf, "hello world") == 0); + EXPECT_TRUE(len == int(strlen("hello world"))); + EXPECT_TRUE(strcmp(buf, "hello world") == 0); // Query length with NULL buffer. - assert(oakengine_config_get_string("oak_test_string_key", NULL, 0) == len); + EXPECT_TRUE(oakengine_config_get_string("oak_test_string_key", NULL, 0) == len); // NULL key is rejected. - assert(oakengine_config_get_string(NULL, buf, sizeof(buf)) == + EXPECT_TRUE(oakengine_config_get_string(NULL, buf, sizeof(buf)) == OAKENGINE_E_INVALID); - assert(oakengine_config_set_string(NULL, "x") == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_config_set_string(NULL, "x") == OAKENGINE_E_INVALID); } static void test_int_round_trip(void) { - assert(oakengine_config_get_int("oak_test_int_key", 42) == 42); + EXPECT_TRUE(oakengine_config_get_int("oak_test_int_key", 42) == 42); - assert(oakengine_config_set_int("oak_test_int_key", 12345) == + EXPECT_TRUE(oakengine_config_set_int("oak_test_int_key", 12345) == OAKENGINE_OK); - assert(oakengine_config_get_int("oak_test_int_key", 0) == 12345); + EXPECT_TRUE(oakengine_config_get_int("oak_test_int_key", 0) == 12345); - assert(oakengine_config_set_int("oak_test_int_key", -7) == + EXPECT_TRUE(oakengine_config_set_int("oak_test_int_key", -7) == OAKENGINE_OK); - assert(oakengine_config_get_int("oak_test_int_key", 0) == -7); + EXPECT_TRUE(oakengine_config_get_int("oak_test_int_key", 0) == -7); // NULL key returns default. - assert(oakengine_config_get_int(NULL, 99) == 99); - assert(oakengine_config_set_int(NULL, 1) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_config_get_int(NULL, 99) == 99); + EXPECT_TRUE(oakengine_config_set_int(NULL, 1) == OAKENGINE_E_INVALID); } static void test_error_handler(void) { g_error_calls = 0; - assert(oakengine_config_set_error_handler(error_cb, NULL) == + EXPECT_TRUE(oakengine_config_set_error_handler(error_cb, NULL) == OAKENGINE_OK); - assert(oakengine_config_report_error("Test Title", + EXPECT_TRUE(oakengine_config_report_error("Test Title", "Test Message") == OAKENGINE_OK); - assert(g_error_calls == 1); - assert(strcmp(g_last_title, "Test Title") == 0); - assert(strcmp(g_last_message, "Test Message") == 0); + EXPECT_TRUE(g_error_calls == 1); + EXPECT_TRUE(strcmp(g_last_title, "Test Title") == 0); + EXPECT_TRUE(strcmp(g_last_message, "Test Message") == 0); // Clearing the handler does not crash. - assert(oakengine_config_set_error_handler(NULL, NULL) == OAKENGINE_OK); - assert(oakengine_config_report_error("Ignored", "Ignored") == + EXPECT_TRUE(oakengine_config_set_error_handler(NULL, NULL) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_config_report_error("Ignored", "Ignored") == OAKENGINE_OK); - assert(g_error_calls == 1); + EXPECT_TRUE(g_error_calls == 1); } -int main(void) +TEST(OakEngineConfig, Main) { - assert(oakengine_init(OAKENGINE_INIT_HEADLESS) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_init(OAKENGINE_INIT_HEADLESS) == OAKENGINE_OK); test_string_round_trip(); test_int_round_trip(); test_error_handler(); - assert(oakengine_config_save() == OAKENGINE_OK); - assert(oakengine_config_load() == OAKENGINE_OK); + EXPECT_TRUE(oakengine_config_save() == OAKENGINE_OK); + EXPECT_TRUE(oakengine_config_load() == OAKENGINE_OK); - assert(oakengine_shutdown() == OAKENGINE_OK); - return 0; + EXPECT_TRUE(oakengine_shutdown() == OAKENGINE_OK); } diff --git a/engine/tests/oakengine_disk_test.cpp b/engine/tests/oakengine_disk_test.cpp index df60b3c39..e345124f5 100644 --- a/engine/tests/oakengine_disk_test.cpp +++ b/engine/tests/oakengine_disk_test.cpp @@ -24,6 +24,7 @@ // handle lookup and default path mutation. Runs headless; no GPU required. #include +#include #include #include #include @@ -53,8 +54,8 @@ static void settings_handler(const char *folder_path, void *parent_window, { (void) parent_window; (void) userdata; - assert(folder_path != NULL); - assert(strlen(folder_path) > 0); + EXPECT_TRUE(folder_path != NULL); + EXPECT_TRUE(strlen(folder_path) > 0); strncpy(g_handler_path, folder_path, sizeof(g_handler_path) - 1); g_handler_path[sizeof(g_handler_path) - 1] = '\0'; g_handler_call_count++; @@ -65,21 +66,21 @@ static void test_instance_lifecycle(void) char buf[512]; // DiskManager is created by oakengine_init(HEADLESS). - assert(oakengine_disk_get_default_cache_path(buf, sizeof(buf)) > 0); + EXPECT_TRUE(oakengine_disk_get_default_cache_path(buf, sizeof(buf)) > 0); // Destroy is allowed and idempotent. - assert(oakengine_disk_destroy_instance() == OAKENGINE_OK); - assert(oakengine_disk_get_default_cache_path(buf, sizeof(buf)) == + EXPECT_TRUE(oakengine_disk_destroy_instance() == OAKENGINE_OK); + EXPECT_TRUE(oakengine_disk_get_default_cache_path(buf, sizeof(buf)) == OAKENGINE_E_STATE); - assert(oakengine_disk_destroy_instance() == OAKENGINE_OK); + EXPECT_TRUE(oakengine_disk_destroy_instance() == OAKENGINE_OK); // Create recreates the instance. - assert(oakengine_disk_create_instance() == OAKENGINE_OK); - assert(oakengine_disk_get_default_cache_path(buf, sizeof(buf)) > 0); + EXPECT_TRUE(oakengine_disk_create_instance() == OAKENGINE_OK); + EXPECT_TRUE(oakengine_disk_get_default_cache_path(buf, sizeof(buf)) > 0); // Create is idempotent. - assert(oakengine_disk_create_instance() == OAKENGINE_OK); - assert(oakengine_disk_get_default_cache_path(buf, sizeof(buf)) > 0); + EXPECT_TRUE(oakengine_disk_create_instance() == OAKENGINE_OK); + EXPECT_TRUE(oakengine_disk_get_default_cache_path(buf, sizeof(buf)) > 0); } static void test_default_cache_path(void) @@ -88,28 +89,28 @@ static void test_default_cache_path(void) memset(buf, 0, sizeof(buf)); const int len = oakengine_disk_get_default_cache_path(buf, sizeof(buf)); - assert(len > 0); - assert((int) strlen(buf) == len); - assert(strchr(buf, '/') != NULL || strchr(buf, '\\') != NULL); + EXPECT_TRUE(len > 0); + EXPECT_TRUE((int) strlen(buf) == len); + EXPECT_TRUE(strchr(buf, '/') != NULL || strchr(buf, '\\') != NULL); // Query length with NULL buffer. - assert(oakengine_disk_get_default_cache_path(NULL, 0) == len); + EXPECT_TRUE(oakengine_disk_get_default_cache_path(NULL, 0) == len); } static void test_open_folder_handle(void) { char buf[512]; - assert(oakengine_disk_get_default_cache_path(buf, sizeof(buf)) > 0); + EXPECT_TRUE(oakengine_disk_get_default_cache_path(buf, sizeof(buf)) > 0); void *folder = oakengine_disk_get_open_folder(buf); - assert(folder != NULL); + EXPECT_TRUE(folder != NULL); // NULL/empty path returns the default folder handle. void *default_folder = oakengine_disk_get_open_folder(nullptr); - assert(default_folder == folder); + EXPECT_TRUE(default_folder == folder); void *empty_folder = oakengine_disk_get_open_folder(""); - assert(empty_folder == folder); + EXPECT_TRUE(empty_folder == folder); // A different path opens a distinct folder. char tmp[256]; @@ -123,20 +124,20 @@ static void test_open_folder_handle(void) #if defined(_WIN32) char *tmpdir = _mktemp(tmp); - assert(tmpdir != NULL); - assert(_mkdir(tmpdir) == 0); + EXPECT_TRUE(tmpdir != NULL); + EXPECT_TRUE(_mkdir(tmpdir) == 0); #else char *tmpdir = mkdtemp(tmp); - assert(tmpdir != NULL); + EXPECT_TRUE(tmpdir != NULL); #endif void *other_folder = oakengine_disk_get_open_folder(tmpdir); - assert(other_folder != NULL); - assert(other_folder != folder); + EXPECT_TRUE(other_folder != NULL); + EXPECT_TRUE(other_folder != folder); // The same path returns the same handle. void *other_folder_again = oakengine_disk_get_open_folder(tmpdir); - assert(other_folder_again == other_folder); + EXPECT_TRUE(other_folder_again == other_folder); #if defined(_WIN32) _rmdir(tmpdir); @@ -159,11 +160,11 @@ static void test_clear_cache(void) #if defined(_WIN32) char *tmpdir = _mktemp(path); - assert(tmpdir != NULL); - assert(_mkdir(tmpdir) == 0); + EXPECT_TRUE(tmpdir != NULL); + EXPECT_TRUE(_mkdir(tmpdir) == 0); #else char *tmpdir = mkdtemp(path); - assert(tmpdir != NULL); + EXPECT_TRUE(tmpdir != NULL); #endif char index_file[512]; @@ -175,17 +176,17 @@ static void test_clear_cache(void) #endif FILE *f = fopen(index_file, "w"); - assert(f != NULL); + EXPECT_TRUE(f != NULL); fclose(f); // clear_cache opens the folder and clears its contents. - assert(oakengine_disk_clear_cache(tmpdir) == 1); + EXPECT_TRUE(oakengine_disk_clear_cache(tmpdir) == 1); // Re-create a file and clear again to ensure idempotency. f = fopen(index_file, "w"); - assert(f != NULL); + EXPECT_TRUE(f != NULL); fclose(f); - assert(oakengine_disk_clear_cache(tmpdir) == 1); + EXPECT_TRUE(oakengine_disk_clear_cache(tmpdir) == 1); #if defined(_WIN32) _rmdir(tmpdir); @@ -198,49 +199,49 @@ static void test_settings_handler_round_trip(void) { reset_handler_state(); - assert(oakengine_disk_set_settings_handler(settings_handler, NULL) == + EXPECT_TRUE(oakengine_disk_set_settings_handler(settings_handler, NULL) == OAKENGINE_OK); // NULL path uses the default folder. - assert(oakengine_disk_show_settings_dialog(NULL, NULL) == OAKENGINE_OK); - assert(g_handler_call_count == 1); - assert(strlen(g_handler_path) > 0); + EXPECT_TRUE(oakengine_disk_show_settings_dialog(NULL, NULL) == OAKENGINE_OK); + EXPECT_TRUE(g_handler_call_count == 1); + EXPECT_TRUE(strlen(g_handler_path) > 0); // Calling again with a specific path invokes the handler with that path. - assert(oakengine_disk_show_settings_dialog(g_handler_path, NULL) == + EXPECT_TRUE(oakengine_disk_show_settings_dialog(g_handler_path, NULL) == OAKENGINE_OK); - assert(g_handler_call_count == 2); - assert(strcmp(g_handler_path, g_handler_path) == 0); + EXPECT_TRUE(g_handler_call_count == 2); + EXPECT_TRUE(strcmp(g_handler_path, g_handler_path) == 0); // Clearing the handler is allowed and results in a logged skip. - assert(oakengine_disk_set_settings_handler(NULL, NULL) == OAKENGINE_OK); - assert(oakengine_disk_show_settings_dialog(g_handler_path, NULL) == + EXPECT_TRUE(oakengine_disk_set_settings_handler(NULL, NULL) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_disk_show_settings_dialog(g_handler_path, NULL) == OAKENGINE_OK); - assert(g_handler_call_count == 2); + EXPECT_TRUE(g_handler_call_count == 2); } static void test_invalidate_project(void) { // No instance returns an error. - assert(oakengine_disk_destroy_instance() == OAKENGINE_OK); - assert(oakengine_disk_invalidate_project(NULL) == OAKENGINE_E_STATE); + EXPECT_TRUE(oakengine_disk_destroy_instance() == OAKENGINE_OK); + EXPECT_TRUE(oakengine_disk_invalidate_project(NULL) == OAKENGINE_E_STATE); - assert(oakengine_disk_create_instance() == OAKENGINE_OK); + EXPECT_TRUE(oakengine_disk_create_instance() == OAKENGINE_OK); // NULL project is accepted (signal emitted with null pointer). - assert(oakengine_disk_invalidate_project(NULL) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_disk_invalidate_project(NULL) == OAKENGINE_OK); // Valid project returns OK without crashing. OakEngineProject *project = oakengine_project_create(); - assert(project != NULL); - assert(oakengine_disk_invalidate_project(project) == OAKENGINE_OK); + EXPECT_TRUE(project != NULL); + EXPECT_TRUE(oakengine_disk_invalidate_project(project) == OAKENGINE_OK); oakengine_project_free(project); } static void test_set_default_cache_path(void) { char original[512]; - assert(oakengine_disk_get_default_cache_path(original, sizeof(original)) > + EXPECT_TRUE(oakengine_disk_get_default_cache_path(original, sizeof(original)) > 0); char tmp[256]; @@ -254,23 +255,23 @@ static void test_set_default_cache_path(void) #if defined(_WIN32) char *tmpdir = _mktemp(tmp); - assert(tmpdir != NULL); - assert(_mkdir(tmpdir) == 0); + EXPECT_TRUE(tmpdir != NULL); + EXPECT_TRUE(_mkdir(tmpdir) == 0); #else char *tmpdir = mkdtemp(tmp); - assert(tmpdir != NULL); + EXPECT_TRUE(tmpdir != NULL); #endif - assert(oakengine_disk_set_default_cache_path(tmpdir) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_disk_set_default_cache_path(tmpdir) == OAKENGINE_OK); char updated[512]; - assert(oakengine_disk_get_default_cache_path(updated, sizeof(updated)) > 0); - assert(strcmp(updated, tmpdir) == 0); + EXPECT_TRUE(oakengine_disk_get_default_cache_path(updated, sizeof(updated)) > 0); + EXPECT_TRUE(strcmp(updated, tmpdir) == 0); // Restore original default path. - assert(oakengine_disk_set_default_cache_path(original) == OAKENGINE_OK); - assert(oakengine_disk_get_default_cache_path(updated, sizeof(updated)) > 0); - assert(strcmp(updated, original) == 0); + EXPECT_TRUE(oakengine_disk_set_default_cache_path(original) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_disk_get_default_cache_path(updated, sizeof(updated)) > 0); + EXPECT_TRUE(strcmp(updated, original) == 0); #if defined(_WIN32) _rmdir(tmpdir); @@ -279,9 +280,9 @@ static void test_set_default_cache_path(void) #endif } -int main(void) +TEST(OakEngineDisk, Main) { - assert(oakengine_init(OAKENGINE_INIT_HEADLESS) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_init(OAKENGINE_INIT_HEADLESS) == OAKENGINE_OK); test_instance_lifecycle(); test_default_cache_path(); @@ -297,5 +298,4 @@ int main(void) oakengine_shutdown(); printf("oakengine_disk_test: OK\n"); - return 0; } diff --git a/engine/tests/oakengine_encoding_test.cpp b/engine/tests/oakengine_encoding_test.cpp index fa6fcb58d..dba26cfef 100644 --- a/engine/tests/oakengine_encoding_test.cpp +++ b/engine/tests/oakengine_encoding_test.cpp @@ -28,6 +28,7 @@ // render_with_params are touched (no sequence). #include +#include #include #include #include @@ -51,13 +52,13 @@ static void make_tmpdir(void) #if defined(_WIN32) char base[MAX_PATH]; const DWORD len = GetTempPathA(MAX_PATH, base); - assert(len > 0 && len < MAX_PATH); + EXPECT_TRUE(len > 0 && len < MAX_PATH); snprintf(g_tmpdir, sizeof(g_tmpdir), "%soakengine_encoding_test_%lu", base, (unsigned long)GetCurrentProcessId()); - assert(_mkdir(g_tmpdir) == 0); + EXPECT_TRUE(_mkdir(g_tmpdir) == 0); #else strcpy(g_tmpdir, "/tmp/oakengine_encoding_test_XXXXXX"); - assert(mkdtemp(g_tmpdir) != NULL); + EXPECT_TRUE(mkdtemp(g_tmpdir) != NULL); #endif } @@ -65,25 +66,25 @@ static void test_format_metadata(void) { char buf[256]; - assert(oakengine_encoding_format_count() > 0); + EXPECT_TRUE(oakengine_encoding_format_count() > 0); // Matroska - assert(oakengine_encoding_format_name(OAKENGINE_ENCODING_FORMAT_MATROSKA, + EXPECT_TRUE(oakengine_encoding_format_name(OAKENGINE_ENCODING_FORMAT_MATROSKA, buf, sizeof(buf)) > 0); - assert(strstr(buf, "Matroska") != NULL); - assert(oakengine_encoding_format_extension( + EXPECT_TRUE(strstr(buf, "Matroska") != NULL); + EXPECT_TRUE(oakengine_encoding_format_extension( OAKENGINE_ENCODING_FORMAT_MATROSKA, buf, sizeof(buf)) > 0); - assert(strcmp(buf, "mkv") == 0); + EXPECT_TRUE(strcmp(buf, "mkv") == 0); // Invalid format - assert(oakengine_encoding_format_name(-1, buf, sizeof(buf)) == -1); - assert(oakengine_encoding_format_extension(9999, buf, sizeof(buf)) == -1); - assert(oakengine_encoding_format_video_codec_count(-1) == -1); + EXPECT_TRUE(oakengine_encoding_format_name(-1, buf, sizeof(buf)) == -1); + EXPECT_TRUE(oakengine_encoding_format_extension(9999, buf, sizeof(buf)) == -1); + EXPECT_TRUE(oakengine_encoding_format_video_codec_count(-1) == -1); // MP4 carries H.264 video and AAC audio const int vcount = oakengine_encoding_format_video_codec_count(OAKENGINE_ENCODING_FORMAT_MPEG4_VIDEO); - assert(vcount > 0); + EXPECT_TRUE(vcount > 0); int found_h264 = 0; for (int i = 0; i < vcount; i++) { if (oakengine_encoding_format_video_codec_at( @@ -92,16 +93,16 @@ static void test_format_metadata(void) found_h264 = 1; } } - assert(found_h264); - assert(oakengine_encoding_format_video_codec_at( + EXPECT_TRUE(found_h264); + EXPECT_TRUE(oakengine_encoding_format_video_codec_at( OAKENGINE_ENCODING_FORMAT_MPEG4_VIDEO, vcount) == -1); // WAV is audio-only and carries PCM - assert(oakengine_encoding_format_video_codec_count( + EXPECT_TRUE(oakengine_encoding_format_video_codec_count( OAKENGINE_ENCODING_FORMAT_WAV) == 0); const int acount = oakengine_encoding_format_audio_codec_count( OAKENGINE_ENCODING_FORMAT_WAV); - assert(acount > 0); + EXPECT_TRUE(acount > 0); int found_pcm = 0; for (int i = 0; i < acount; i++) { if (oakengine_encoding_format_audio_codec_at( @@ -109,16 +110,16 @@ static void test_format_metadata(void) found_pcm = 1; } } - assert(found_pcm); + EXPECT_TRUE(found_pcm); // SRT is subtitles-only - assert(oakengine_encoding_format_subtitle_codec_count( + EXPECT_TRUE(oakengine_encoding_format_subtitle_codec_count( OAKENGINE_ENCODING_FORMAT_SRT) > 0); - assert(oakengine_encoding_format_subtitle_codec_at( + EXPECT_TRUE(oakengine_encoding_format_subtitle_codec_at( OAKENGINE_ENCODING_FORMAT_SRT, 0) >= 0); - assert(oakengine_encoding_format_subtitle_codec_at( + EXPECT_TRUE(oakengine_encoding_format_subtitle_codec_at( OAKENGINE_ENCODING_FORMAT_SRT, -1) < 0); - assert(oakengine_encoding_format_audio_codec_count( + EXPECT_TRUE(oakengine_encoding_format_audio_codec_count( OAKENGINE_ENCODING_FORMAT_SRT) == 0); } @@ -126,47 +127,47 @@ static void test_codec_metadata(void) { char buf[256]; - assert(oakengine_encoding_codec_name(OAKENGINE_ENCODING_CODEC_H264, buf, + EXPECT_TRUE(oakengine_encoding_codec_name(OAKENGINE_ENCODING_CODEC_H264, buf, sizeof(buf)) > 0); - assert(buf[0] != '\0'); - assert(oakengine_encoding_codec_name(-1, buf, sizeof(buf)) == -1); + EXPECT_TRUE(buf[0] != '\0'); + EXPECT_TRUE(oakengine_encoding_codec_name(-1, buf, sizeof(buf)) == -1); - assert(oakengine_encoding_codec_is_still_image(5 /* PNG */) == 1); - assert(oakengine_encoding_codec_is_still_image( + EXPECT_TRUE(oakengine_encoding_codec_is_still_image(5 /* PNG */) == 1); + EXPECT_TRUE(oakengine_encoding_codec_is_still_image( OAKENGINE_ENCODING_CODEC_H264) == 0); - assert(oakengine_encoding_codec_is_lossless(OAKENGINE_ENCODING_CODEC_PCM) == + EXPECT_TRUE(oakengine_encoding_codec_is_lossless(OAKENGINE_ENCODING_CODEC_PCM) == 1); - assert(oakengine_encoding_codec_is_lossless(OAKENGINE_ENCODING_CODEC_AAC) == + EXPECT_TRUE(oakengine_encoding_codec_is_lossless(OAKENGINE_ENCODING_CODEC_AAC) == 0); // Encoded pixel formats of H.264 in MP4: yuv420p is the preferred one const int pcount = oakengine_encoding_pix_fmt_count( OAKENGINE_ENCODING_FORMAT_MPEG4_VIDEO, OAKENGINE_ENCODING_CODEC_H264); - assert(pcount > 0); - assert(oakengine_encoding_pix_fmt_at(OAKENGINE_ENCODING_FORMAT_MPEG4_VIDEO, + EXPECT_TRUE(pcount > 0); + EXPECT_TRUE(oakengine_encoding_pix_fmt_at(OAKENGINE_ENCODING_FORMAT_MPEG4_VIDEO, OAKENGINE_ENCODING_CODEC_H264, 0, buf, sizeof(buf)) > 0); - assert(strcmp(buf, "yuv420p") == 0); - assert(oakengine_encoding_pix_fmt_at(OAKENGINE_ENCODING_FORMAT_MPEG4_VIDEO, + EXPECT_TRUE(strcmp(buf, "yuv420p") == 0); + EXPECT_TRUE(oakengine_encoding_pix_fmt_at(OAKENGINE_ENCODING_FORMAT_MPEG4_VIDEO, OAKENGINE_ENCODING_CODEC_H264, pcount, buf, sizeof(buf)) == -1); - assert(oakengine_encoding_pix_fmt_index(OAKENGINE_ENCODING_CODEC_H264, + EXPECT_TRUE(oakengine_encoding_pix_fmt_index(OAKENGINE_ENCODING_CODEC_H264, "yuv420p") == 0); - assert(oakengine_encoding_pix_fmt_index(OAKENGINE_ENCODING_CODEC_H264, + EXPECT_TRUE(oakengine_encoding_pix_fmt_index(OAKENGINE_ENCODING_CODEC_H264, "no-such-format") == 0); - assert(oakengine_encoding_pix_fmt_index(OAKENGINE_ENCODING_CODEC_H264, + EXPECT_TRUE(oakengine_encoding_pix_fmt_index(OAKENGINE_ENCODING_CODEC_H264, NULL) == 0); // Sample formats of PCM in WAV const int scount = oakengine_encoding_sample_format_count( OAKENGINE_ENCODING_FORMAT_WAV, OAKENGINE_ENCODING_CODEC_PCM); - assert(scount > 0); + EXPECT_TRUE(scount > 0); for (int i = 0; i < scount; i++) { - assert(oakengine_encoding_sample_format_at( + EXPECT_TRUE(oakengine_encoding_sample_format_at( OAKENGINE_ENCODING_FORMAT_WAV, OAKENGINE_ENCODING_CODEC_PCM, i) >= 0); } - assert(oakengine_encoding_sample_format_at( + EXPECT_TRUE(oakengine_encoding_sample_format_at( OAKENGINE_ENCODING_FORMAT_WAV, OAKENGINE_ENCODING_CODEC_PCM, scount) == -1); } @@ -175,20 +176,20 @@ static void test_filename_helpers(void) { char buf[4096]; - assert(oakengine_encoding_filename_contains_digit_placeholder( + EXPECT_TRUE(oakengine_encoding_filename_contains_digit_placeholder( "/tmp/out_[#####].png") == 1); - assert(oakengine_encoding_filename_contains_digit_placeholder( + EXPECT_TRUE(oakengine_encoding_filename_contains_digit_placeholder( "/tmp/out.png") == 0); - assert(oakengine_encoding_filename_contains_digit_placeholder(NULL) == 0); + EXPECT_TRUE(oakengine_encoding_filename_contains_digit_placeholder(NULL) == 0); - assert(oakengine_encoding_image_sequence_digit_count( + EXPECT_TRUE(oakengine_encoding_image_sequence_digit_count( "/tmp/out_[#####].png") == 5); - assert(oakengine_encoding_image_sequence_digit_count("/tmp/out.png") == 0); + EXPECT_TRUE(oakengine_encoding_image_sequence_digit_count("/tmp/out.png") == 0); - assert(oakengine_encoding_filename_remove_digit_placeholder( + EXPECT_TRUE(oakengine_encoding_filename_remove_digit_placeholder( "/tmp/out_[#####].png", buf, sizeof(buf)) > 0); - assert(strstr(buf, "[#####]") == NULL); - assert(strstr(buf, ".png") != NULL); + EXPECT_TRUE(strstr(buf, "[#####]") == NULL); + EXPECT_TRUE(strstr(buf, ".png") != NULL); } static void test_generate_matrix(void) @@ -196,37 +197,37 @@ static void test_generate_matrix(void) float m[16]; // Fit with matching dimensions is the identity - assert(oakengine_encoding_generate_matrix(OAKENGINE_ENCODING_SCALING_FIT, + EXPECT_TRUE(oakengine_encoding_generate_matrix(OAKENGINE_ENCODING_SCALING_FIT, 1920, 1080, 1920, 1080, m) == OAKENGINE_OK); const float identity[16] = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 }; for (int i = 0; i < 16; i++) { - assert(fabsf(m[i] - identity[i]) < 1e-6f); + EXPECT_TRUE(fabsf(m[i] - identity[i]) < 1e-6f); } // Stretch is the identity transform (the preview is normalized device // coordinates; stretching needs no matrix) - assert(oakengine_encoding_generate_matrix(OAKENGINE_ENCODING_SCALING_STRETCH, + EXPECT_TRUE(oakengine_encoding_generate_matrix(OAKENGINE_ENCODING_SCALING_STRETCH, 960, 540, 1920, 1080, m) == OAKENGINE_OK); for (int i = 0; i < 16; i++) { - assert(fabsf(m[i] - identity[i]) < 1e-6f); + EXPECT_TRUE(fabsf(m[i] - identity[i]) < 1e-6f); } // Fit into a wider-than-source frame pillarboxes: x scale shrinks to // source_ar/export_ar - assert(oakengine_encoding_generate_matrix(OAKENGINE_ENCODING_SCALING_FIT, + EXPECT_TRUE(oakengine_encoding_generate_matrix(OAKENGINE_ENCODING_SCALING_FIT, 1920, 1080, 1920, 540, m) == OAKENGINE_OK); const float expected_x = (1920.0f / 1080.0f) / (1920.0f / 540.0f); - assert(fabsf(m[0] - expected_x) < 1e-5f); - assert(fabsf(m[5] - 1.0f) < 1e-6f); + EXPECT_TRUE(fabsf(m[0] - expected_x) < 1e-5f); + EXPECT_TRUE(fabsf(m[5] - 1.0f) < 1e-6f); // Invalid arguments - assert(oakengine_encoding_generate_matrix(-1, 1, 1, 1, 1, + EXPECT_TRUE(oakengine_encoding_generate_matrix(-1, 1, 1, 1, 1, m) == OAKENGINE_E_INVALID); - assert(oakengine_encoding_generate_matrix(OAKENGINE_ENCODING_SCALING_FIT, 0, + EXPECT_TRUE(oakengine_encoding_generate_matrix(OAKENGINE_ENCODING_SCALING_FIT, 0, 1, 1, 1, m) == OAKENGINE_E_INVALID); } @@ -236,26 +237,26 @@ static void test_params_handle(void) char buf[1024]; OakEngineEncodingParams *p = oakengine_encoding_params_create(); - assert(p != NULL); + EXPECT_TRUE(p != NULL); // Fresh handle: nothing enabled, format unset - assert(oakengine_encoding_params_is_valid(p) == 0); - assert(oakengine_encoding_params_format(p) == -1); - assert(oakengine_encoding_params_video_enabled(p) == 0); - assert(oakengine_encoding_params_audio_enabled(p) == 0); - assert(oakengine_encoding_params_subtitles_enabled(p) == 0); - assert(oakengine_encoding_params_has_custom_range(p) == 0); + EXPECT_TRUE(oakengine_encoding_params_is_valid(p) == 0); + EXPECT_TRUE(oakengine_encoding_params_format(p) == -1); + EXPECT_TRUE(oakengine_encoding_params_video_enabled(p) == 0); + EXPECT_TRUE(oakengine_encoding_params_audio_enabled(p) == 0); + EXPECT_TRUE(oakengine_encoding_params_subtitles_enabled(p) == 0); + EXPECT_TRUE(oakengine_encoding_params_has_custom_range(p) == 0); // Filename / format roundtrip - assert(oakengine_encoding_params_set_filename(p, "/tmp/out.mp4") == + EXPECT_TRUE(oakengine_encoding_params_set_filename(p, "/tmp/out.mp4") == OAKENGINE_OK); - assert(oakengine_encoding_params_filename(p, buf, sizeof(buf)) > 0); - assert(strcmp(buf, "/tmp/out.mp4") == 0); - assert(oakengine_encoding_params_set_format( + EXPECT_TRUE(oakengine_encoding_params_filename(p, buf, sizeof(buf)) > 0); + EXPECT_TRUE(strcmp(buf, "/tmp/out.mp4") == 0); + EXPECT_TRUE(oakengine_encoding_params_set_format( p, OAKENGINE_ENCODING_FORMAT_MPEG4_VIDEO) == OAKENGINE_OK); - assert(oakengine_encoding_params_format(p) == + EXPECT_TRUE(oakengine_encoding_params_format(p) == OAKENGINE_ENCODING_FORMAT_MPEG4_VIDEO); - assert(oakengine_encoding_params_set_format(p, 9999) == + EXPECT_TRUE(oakengine_encoding_params_set_format(p, 9999) == OAKENGINE_E_INVALID); // Video roundtrip @@ -270,132 +271,132 @@ static void test_params_handle(void) v.interlacing = OAKENGINE_ENCODING_INTERLACE_BOTTOM_FIRST; v.color_range = OAKENGINE_ENCODING_COLOR_RANGE_FULL; v.divider = 1; - assert(oakengine_encoding_params_enable_video( + EXPECT_TRUE(oakengine_encoding_params_enable_video( p, &v, OAKENGINE_ENCODING_CODEC_H264) == OAKENGINE_OK); - assert(oakengine_encoding_params_is_valid(p) == 1); - assert(oakengine_encoding_params_video_enabled(p) == 1); - assert(oakengine_encoding_params_video_codec(p) == + EXPECT_TRUE(oakengine_encoding_params_is_valid(p) == 1); + EXPECT_TRUE(oakengine_encoding_params_video_enabled(p) == 1); + EXPECT_TRUE(oakengine_encoding_params_video_codec(p) == OAKENGINE_ENCODING_CODEC_H264); - assert(oakengine_encoding_params_enable_video(p, NULL, 1) == + EXPECT_TRUE(oakengine_encoding_params_enable_video(p, NULL, 1) == OAKENGINE_E_INVALID); - assert(oakengine_encoding_params_enable_video(p, &v, 9999) == + EXPECT_TRUE(oakengine_encoding_params_enable_video(p, &v, 9999) == OAKENGINE_E_INVALID); oak_video_params back = {}; - assert(oakengine_encoding_params_get_video_params(p, &back) == + EXPECT_TRUE(oakengine_encoding_params_get_video_params(p, &back) == OAKENGINE_OK); - assert(back.width == 1920 && back.height == 1080); - assert(back.time_base_num == 1001 && back.time_base_den == 30000); - assert(back.pixel_aspect_num == 1 && back.pixel_aspect_den == 1); - assert(back.interlacing == OAKENGINE_ENCODING_INTERLACE_BOTTOM_FIRST); - assert(back.color_range == OAKENGINE_ENCODING_COLOR_RANGE_FULL); + EXPECT_TRUE(back.width == 1920 && back.height == 1080); + EXPECT_TRUE(back.time_base_num == 1001 && back.time_base_den == 30000); + EXPECT_TRUE(back.pixel_aspect_num == 1 && back.pixel_aspect_den == 1); + EXPECT_TRUE(back.interlacing == OAKENGINE_ENCODING_INTERLACE_BOTTOM_FIRST); + EXPECT_TRUE(back.color_range == OAKENGINE_ENCODING_COLOR_RANGE_FULL); // Audio roundtrip - assert(oakengine_encoding_params_enable_audio(p, 48000, 0x3, 4, + EXPECT_TRUE(oakengine_encoding_params_enable_audio(p, 48000, 0x3, 4, OAKENGINE_ENCODING_CODEC_AAC) == OAKENGINE_OK); - assert(oakengine_encoding_params_audio_enabled(p) == 1); - assert(oakengine_encoding_params_audio_codec(p) == + EXPECT_TRUE(oakengine_encoding_params_audio_enabled(p) == 1); + EXPECT_TRUE(oakengine_encoding_params_audio_codec(p) == OAKENGINE_ENCODING_CODEC_AAC); int sample_rate = 0, sample_format = 0; uint64_t layout = 0; - assert(oakengine_encoding_params_get_audio_params(p, &sample_rate, &layout, + EXPECT_TRUE(oakengine_encoding_params_get_audio_params(p, &sample_rate, &layout, &sample_format) == OAKENGINE_OK); - assert(sample_rate == 48000 && layout == 0x3 && sample_format == 4); - assert(oakengine_encoding_params_enable_audio(p, 0, 0x3, 4, 0) == + EXPECT_TRUE(sample_rate == 48000 && layout == 0x3 && sample_format == 4); + EXPECT_TRUE(oakengine_encoding_params_enable_audio(p, 0, 0x3, 4, 0) == OAKENGINE_E_INVALID); // Subtitles (embedded, then sidecar) - assert(oakengine_encoding_params_enable_subtitles( + EXPECT_TRUE(oakengine_encoding_params_enable_subtitles( p, OAKENGINE_ENCODING_CODEC_SRT) == OAKENGINE_OK); - assert(oakengine_encoding_params_subtitles_enabled(p) == 1); - assert(oakengine_encoding_params_subtitles_are_sidecar(p) == 0); - assert(oakengine_encoding_params_subtitles_codec(p) == + EXPECT_TRUE(oakengine_encoding_params_subtitles_enabled(p) == 1); + EXPECT_TRUE(oakengine_encoding_params_subtitles_are_sidecar(p) == 0); + EXPECT_TRUE(oakengine_encoding_params_subtitles_codec(p) == OAKENGINE_ENCODING_CODEC_SRT); - assert(oakengine_encoding_params_enable_sidecar_subtitles( + EXPECT_TRUE(oakengine_encoding_params_enable_sidecar_subtitles( p, OAKENGINE_ENCODING_FORMAT_SRT, OAKENGINE_ENCODING_CODEC_SRT) == OAKENGINE_OK); - assert(oakengine_encoding_params_subtitles_are_sidecar(p) == 1); - assert(oakengine_encoding_params_subtitles_sidecar_format(p) == + EXPECT_TRUE(oakengine_encoding_params_subtitles_are_sidecar(p) == 1); + EXPECT_TRUE(oakengine_encoding_params_subtitles_sidecar_format(p) == OAKENGINE_ENCODING_FORMAT_SRT); // Scalar setters/getters oakengine_encoding_params_set_video_bit_rate(p, 8000000); - assert(oakengine_encoding_params_video_bit_rate(p) == 8000000); + EXPECT_TRUE(oakengine_encoding_params_video_bit_rate(p) == 8000000); oakengine_encoding_params_set_video_min_bit_rate(p, 1000); - assert(oakengine_encoding_params_video_min_bit_rate(p) == 1000); + EXPECT_TRUE(oakengine_encoding_params_video_min_bit_rate(p) == 1000); oakengine_encoding_params_set_video_max_bit_rate(p, 16000000); - assert(oakengine_encoding_params_video_max_bit_rate(p) == 16000000); + EXPECT_TRUE(oakengine_encoding_params_video_max_bit_rate(p) == 16000000); oakengine_encoding_params_set_video_buffer_size(p, 2000000); - assert(oakengine_encoding_params_video_buffer_size(p) == 2000000); + EXPECT_TRUE(oakengine_encoding_params_video_buffer_size(p) == 2000000); oakengine_encoding_params_set_video_threads(p, 4); - assert(oakengine_encoding_params_video_threads(p) == 4); + EXPECT_TRUE(oakengine_encoding_params_video_threads(p) == 4); oakengine_encoding_params_set_audio_bit_rate(p, 320000); - assert(oakengine_encoding_params_audio_bit_rate(p) == 320000); + EXPECT_TRUE(oakengine_encoding_params_audio_bit_rate(p) == 320000); - assert(oakengine_encoding_params_set_video_pix_fmt(p, "yuv420p") == + EXPECT_TRUE(oakengine_encoding_params_set_video_pix_fmt(p, "yuv420p") == OAKENGINE_OK); - assert(oakengine_encoding_params_video_pix_fmt(p, buf, sizeof(buf)) > 0); - assert(strcmp(buf, "yuv420p") == 0); + EXPECT_TRUE(oakengine_encoding_params_video_pix_fmt(p, buf, sizeof(buf)) > 0); + EXPECT_TRUE(strcmp(buf, "yuv420p") == 0); oakengine_encoding_params_set_video_is_image_sequence(p, 1); - assert(oakengine_encoding_params_video_is_image_sequence(p) == 1); + EXPECT_TRUE(oakengine_encoding_params_video_is_image_sequence(p) == 1); oakengine_encoding_params_set_video_is_image_sequence(p, 0); - assert(oakengine_encoding_params_video_is_image_sequence(p) == 0); + EXPECT_TRUE(oakengine_encoding_params_video_is_image_sequence(p) == 0); - assert(oakengine_encoding_params_set_color_transform(p, "sRGB OETF") == + EXPECT_TRUE(oakengine_encoding_params_set_color_transform(p, "sRGB OETF") == OAKENGINE_OK); - assert(oakengine_encoding_params_color_transform_output(p, buf, + EXPECT_TRUE(oakengine_encoding_params_color_transform_output(p, buf, sizeof(buf)) > 0); - assert(strcmp(buf, "sRGB OETF") == 0); + EXPECT_TRUE(strcmp(buf, "sRGB OETF") == 0); oakengine_encoding_params_set_export_length(p, 10, 1); int num = 0, den = 0; - assert(oakengine_encoding_params_get_export_length(p, &num, &den) == + EXPECT_TRUE(oakengine_encoding_params_get_export_length(p, &num, &den) == OAKENGINE_OK); - assert(num == 10 && den == 1); + EXPECT_TRUE(num == 10 && den == 1); // Custom range oakengine_encoding_params_set_custom_range(p, 1, 1, 5, 1); - assert(oakengine_encoding_params_has_custom_range(p) == 1); + EXPECT_TRUE(oakengine_encoding_params_has_custom_range(p) == 1); int64_t in_num = 0, in_den = 0, out_num = 0, out_den = 0; - assert(oakengine_encoding_params_get_custom_range(p, &in_num, &in_den, + EXPECT_TRUE(oakengine_encoding_params_get_custom_range(p, &in_num, &in_den, &out_num, &out_den) == OAKENGINE_OK); - assert(in_num == 1 && in_den == 1 && out_num == 5 && out_den == 1); + EXPECT_TRUE(in_num == 1 && in_den == 1 && out_num == 5 && out_den == 1); // Scaling method - assert(oakengine_encoding_params_set_video_scaling_method( + EXPECT_TRUE(oakengine_encoding_params_set_video_scaling_method( p, OAKENGINE_ENCODING_SCALING_CROP) == OAKENGINE_OK); - assert(oakengine_encoding_params_video_scaling_method(p) == + EXPECT_TRUE(oakengine_encoding_params_video_scaling_method(p) == OAKENGINE_ENCODING_SCALING_CROP); - assert(oakengine_encoding_params_set_video_scaling_method(p, 42) == + EXPECT_TRUE(oakengine_encoding_params_set_video_scaling_method(p, 42) == OAKENGINE_E_INVALID); // Video options - assert(oakengine_encoding_params_video_option(p, "crf", buf, + EXPECT_TRUE(oakengine_encoding_params_video_option(p, "crf", buf, sizeof(buf)) == OAKENGINE_E_NOT_FOUND); - assert(oakengine_encoding_params_set_video_option(p, "crf", "18") == + EXPECT_TRUE(oakengine_encoding_params_set_video_option(p, "crf", "18") == OAKENGINE_OK); - assert(oakengine_encoding_params_video_option(p, "crf", buf, + EXPECT_TRUE(oakengine_encoding_params_video_option(p, "crf", buf, sizeof(buf)) > 0); - assert(strcmp(buf, "18") == 0); + EXPECT_TRUE(strcmp(buf, "18") == 0); // Disables oakengine_encoding_params_disable_subtitles(p); - assert(oakengine_encoding_params_subtitles_enabled(p) == 0); + EXPECT_TRUE(oakengine_encoding_params_subtitles_enabled(p) == 0); oakengine_encoding_params_disable_video(p); - assert(oakengine_encoding_params_video_enabled(p) == 0); - assert(oakengine_encoding_params_get_video_params(p, &back) == + EXPECT_TRUE(oakengine_encoding_params_video_enabled(p) == 0); + EXPECT_TRUE(oakengine_encoding_params_get_video_params(p, &back) == OAKENGINE_E_STATE); oakengine_encoding_params_disable_audio(p); - assert(oakengine_encoding_params_audio_enabled(p) == 0); + EXPECT_TRUE(oakengine_encoding_params_audio_enabled(p) == 0); // NULL safety oakengine_encoding_params_destroy(NULL); - assert(oakengine_encoding_params_is_valid(NULL) == 0); + EXPECT_TRUE(oakengine_encoding_params_is_valid(NULL) == 0); oakengine_encoding_params_destroy(p); } @@ -405,22 +406,22 @@ static void test_preset_files(void) char buf[1024]; // Preset directory listing is readable (may be empty in the sandbox) - assert(oakengine_encoding_preset_path(buf, sizeof(buf)) > 0); + EXPECT_TRUE(oakengine_encoding_preset_path(buf, sizeof(buf)) > 0); const int count = oakengine_encoding_preset_count(); - assert(count >= 0); + EXPECT_TRUE(count >= 0); for (int i = 0; i < count; i++) { - assert(oakengine_encoding_preset_name(i, buf, sizeof(buf)) > 0); + EXPECT_TRUE(oakengine_encoding_preset_name(i, buf, sizeof(buf)) > 0); } - assert(oakengine_encoding_preset_name(count, buf, sizeof(buf)) == -1); + EXPECT_TRUE(oakengine_encoding_preset_name(count, buf, sizeof(buf)) == -1); // Save/load roundtrip through a temp file char path[4096]; snprintf(path, sizeof(path), "%s/preset.xml", g_tmpdir); OakEngineEncodingParams *p = oakengine_encoding_params_create(); - assert(oakengine_encoding_params_set_filename(p, "/tmp/out.mp4") == + EXPECT_TRUE(oakengine_encoding_params_set_filename(p, "/tmp/out.mp4") == OAKENGINE_OK); - assert(oakengine_encoding_params_set_format( + EXPECT_TRUE(oakengine_encoding_params_set_format( p, OAKENGINE_ENCODING_FORMAT_MPEG4_VIDEO) == OAKENGINE_OK); oak_video_params v = {}; v.width = 1280; @@ -433,59 +434,59 @@ static void test_preset_files(void) v.interlacing = OAKENGINE_ENCODING_INTERLACE_NONE; v.color_range = OAKENGINE_ENCODING_COLOR_RANGE_LIMITED; v.divider = 1; - assert(oakengine_encoding_params_enable_video( + EXPECT_TRUE(oakengine_encoding_params_enable_video( p, &v, OAKENGINE_ENCODING_CODEC_H264) == OAKENGINE_OK); - assert(oakengine_encoding_params_set_video_option(p, "crf", "20") == + EXPECT_TRUE(oakengine_encoding_params_set_video_option(p, "crf", "20") == OAKENGINE_OK); - assert(oakengine_encoding_params_save_file(p, path) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_encoding_params_save_file(p, path) == OAKENGINE_OK); oakengine_encoding_params_destroy(p); OakEngineEncodingParams *q = oakengine_encoding_params_create(); - assert(oakengine_encoding_params_load_file(q, path) == OAKENGINE_OK); - assert(oakengine_encoding_params_video_enabled(q) == 1); - assert(oakengine_encoding_params_video_codec(q) == + EXPECT_TRUE(oakengine_encoding_params_load_file(q, path) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_encoding_params_video_enabled(q) == 1); + EXPECT_TRUE(oakengine_encoding_params_video_codec(q) == OAKENGINE_ENCODING_CODEC_H264); oak_video_params back = {}; - assert(oakengine_encoding_params_get_video_params(q, &back) == + EXPECT_TRUE(oakengine_encoding_params_get_video_params(q, &back) == OAKENGINE_OK); - assert(back.width == 1280 && back.height == 720); - assert(back.time_base_num == 1 && back.time_base_den == 25); - assert(oakengine_encoding_params_video_option(q, "crf", buf, + EXPECT_TRUE(back.width == 1280 && back.height == 720); + EXPECT_TRUE(back.time_base_num == 1 && back.time_base_den == 25); + EXPECT_TRUE(oakengine_encoding_params_video_option(q, "crf", buf, sizeof(buf)) > 0); - assert(strcmp(buf, "20") == 0); + EXPECT_TRUE(strcmp(buf, "20") == 0); oakengine_encoding_params_destroy(q); // Loading a nonexistent file fails OakEngineEncodingParams *r = oakengine_encoding_params_create(); - assert(oakengine_encoding_params_load_file(r, "/no/such/file.xml") == + EXPECT_TRUE(oakengine_encoding_params_load_file(r, "/no/such/file.xml") == OAKENGINE_E_FAILED); oakengine_encoding_params_destroy(r); // Bad arguments - assert(oakengine_encoding_params_save_file(NULL, path) == + EXPECT_TRUE(oakengine_encoding_params_save_file(NULL, path) == OAKENGINE_E_INVALID); } static void test_last_used_and_render_errors(void) { // NULL sequence: no last-used params, no-op setter - assert(oakengine_encoding_params_get_last_used(NULL) == NULL); + EXPECT_TRUE(oakengine_encoding_params_get_last_used(NULL) == NULL); oakengine_encoding_params_set_last_used(NULL, NULL); // render_with_params without a valid sequence/params fails cleanly - assert(oakengine_export_render_with_params(NULL, NULL) == + EXPECT_TRUE(oakengine_export_render_with_params(NULL, NULL) == OAKENGINE_E_INVALID); OakEngineEncodingParams *p = oakengine_encoding_params_create(); - assert(oakengine_export_render_with_params(NULL, p) == + EXPECT_TRUE(oakengine_export_render_with_params(NULL, p) == OAKENGINE_E_INVALID); // Nothing enabled on the handle - assert(oakengine_export_render_with_params( + EXPECT_TRUE(oakengine_export_render_with_params( reinterpret_cast(p), p) == OAKENGINE_E_INVALID); oakengine_encoding_params_destroy(p); // Audio recording requires an enabled audio track on the handle - assert(oakengine_encoding_start_audio_recording(NULL, NULL, 0) == + EXPECT_TRUE(oakengine_encoding_start_audio_recording(NULL, NULL, 0) == OAKENGINE_E_INVALID); } @@ -496,61 +497,61 @@ static void test_video_params_statics(void) // Standard frame rates const int fr_count = oakengine_video_params_supported_frame_rate_count(); - assert(fr_count > 0); + EXPECT_TRUE(fr_count > 0); for (int i = 0; i < fr_count; i++) { - assert(oakengine_video_params_supported_frame_rate_at(i, &num, &den) == + EXPECT_TRUE(oakengine_video_params_supported_frame_rate_at(i, &num, &den) == OAKENGINE_OK); - assert(num > 0 && den > 0); + EXPECT_TRUE(num > 0 && den > 0); } - assert(oakengine_video_params_supported_frame_rate_at(fr_count, &num, + EXPECT_TRUE(oakengine_video_params_supported_frame_rate_at(fr_count, &num, &den) == OAKENGINE_E_INVALID); // 24000/1001 prints as 23.976... - assert(oakengine_video_params_frame_rate_to_string(24000, 1001, buf, + EXPECT_TRUE(oakengine_video_params_frame_rate_to_string(24000, 1001, buf, sizeof(buf)) > 0); - assert(strstr(buf, "23.97") != NULL); + EXPECT_TRUE(strstr(buf, "23.97") != NULL); // Standard pixel aspects: the first one is square (1:1) const int pa_count = oakengine_video_params_standard_pixel_aspect_count(); - assert(pa_count > 0); - assert(oakengine_video_params_standard_pixel_aspect_at(0, &num, &den) == + EXPECT_TRUE(pa_count > 0); + EXPECT_TRUE(oakengine_video_params_standard_pixel_aspect_at(0, &num, &den) == OAKENGINE_OK); - assert(num == 1 && den == 1); - assert(oakengine_video_params_standard_pixel_aspect_name(0, buf, + EXPECT_TRUE(num == 1 && den == 1); + EXPECT_TRUE(oakengine_video_params_standard_pixel_aspect_name(0, buf, sizeof(buf)) > 0); - assert(buf[0] != '\0'); - assert(oakengine_video_params_standard_pixel_aspect_at(pa_count, &num, + EXPECT_TRUE(buf[0] != '\0'); + EXPECT_TRUE(oakengine_video_params_standard_pixel_aspect_at(pa_count, &num, &den) == OAKENGINE_E_INVALID); // Custom PAR label template - assert(oakengine_video_params_format_pixel_aspect_ratio_string( + EXPECT_TRUE(oakengine_video_params_format_pixel_aspect_ratio_string( "Custom (%1)", 32, 27, buf, sizeof(buf)) > 0); - assert(strstr(buf, "Custom") != NULL); + EXPECT_TRUE(strstr(buf, "Custom") != NULL); // Dividers const int div_count = oakengine_video_params_supported_divider_count(); - assert(div_count > 0); + EXPECT_TRUE(div_count > 0); for (int i = 0; i < div_count; i++) { const int d = oakengine_video_params_supported_divider_at(i); - assert(d > 0); - assert(oakengine_video_params_divider_name(d, buf, sizeof(buf)) > 0); + EXPECT_TRUE(d > 0); + EXPECT_TRUE(oakengine_video_params_divider_name(d, buf, sizeof(buf)) > 0); } - assert(oakengine_video_params_supported_divider_at(div_count) == -1); + EXPECT_TRUE(oakengine_video_params_supported_divider_at(div_count) == -1); // Pixel format names: some entry must be non-empty - assert(oakengine_video_params_pixel_format_name(8, buf, sizeof(buf)) > 0); + EXPECT_TRUE(oakengine_video_params_pixel_format_name(8, buf, sizeof(buf)) > 0); // Float detection (8-bit integer formats are not float) - assert(oakengine_video_params_format_is_float(0) == 0); + EXPECT_TRUE(oakengine_video_params_format_is_float(0) == 0); // Effective (divider-scaled) size int w = 0, h = 0; - assert(oakengine_video_params_effective_size(1920, 1080, 2, &w, &h) == + EXPECT_TRUE(oakengine_video_params_effective_size(1920, 1080, 2, &w, &h) == OAKENGINE_OK); - assert(w == 960 && h == 540); - assert(oakengine_video_params_effective_size(0, 1080, 2, &w, &h) == + EXPECT_TRUE(w == 960 && h == 540); + EXPECT_TRUE(oakengine_video_params_effective_size(0, 1080, 2, &w, &h) == OAKENGINE_E_INVALID); } @@ -561,43 +562,43 @@ static void test_video_params_pod(void) oak_video_params p, q; // make fills every field - assert(oakengine_video_params_make(&p, 1920, 1080, 1001, 30000, 0, 1, 1, + EXPECT_TRUE(oakengine_video_params_make(&p, 1920, 1080, 1001, 30000, 0, 1, 1, 0, 0, 2) == OAKENGINE_OK); - assert(p.width == 1920 && p.height == 1080); - assert(p.time_base_num == 1001 && p.time_base_den == 30000); - assert(p.pixel_aspect_num == 1 && p.pixel_aspect_den == 1); - assert(p.divider == 2); - assert(oakengine_video_params_make(NULL, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1) == + EXPECT_TRUE(p.width == 1920 && p.height == 1080); + EXPECT_TRUE(p.time_base_num == 1001 && p.time_base_den == 30000); + EXPECT_TRUE(p.pixel_aspect_num == 1 && p.pixel_aspect_den == 1); + EXPECT_TRUE(p.divider == 2); + EXPECT_TRUE(oakengine_video_params_make(NULL, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1) == OAKENGINE_E_INVALID); // equal: identical PODs match, any single-field difference does not q = p; - assert(oakengine_video_params_equal(&p, &q) == 1); - assert(oakengine_video_params_equal(&p, NULL) == 0); - assert(oakengine_video_params_equal(NULL, &q) == 0); + EXPECT_TRUE(oakengine_video_params_equal(&p, &q) == 1); + EXPECT_TRUE(oakengine_video_params_equal(&p, NULL) == 0); + EXPECT_TRUE(oakengine_video_params_equal(NULL, &q) == 0); q.divider = 1; - assert(oakengine_video_params_equal(&p, &q) == 0); + EXPECT_TRUE(oakengine_video_params_equal(&p, &q) == 0); q = p; q.interlacing = 1; - assert(oakengine_video_params_equal(&p, &q) == 0); + EXPECT_TRUE(oakengine_video_params_equal(&p, &q) == 0); // is_valid: positive dimensions + in-range format passes; zero // dimensions or an out-of-range format fail - assert(oakengine_video_params_is_valid(&p) == 1); - assert(oakengine_video_params_is_valid(NULL) == 0); + EXPECT_TRUE(oakengine_video_params_is_valid(&p) == 1); + EXPECT_TRUE(oakengine_video_params_is_valid(NULL) == 0); q = p; q.width = 0; - assert(oakengine_video_params_is_valid(&q) == 0); + EXPECT_TRUE(oakengine_video_params_is_valid(&q) == 0); q = p; q.format = -1; // olive::PixelFormat::invalid - assert(oakengine_video_params_is_valid(&q) == 0); + EXPECT_TRUE(oakengine_video_params_is_valid(&q) == 0); // bytes per pixel: u8 RGBA = 4, f32 RGBA = 16 (format values follow // olive::PixelFormat::Format: 0 = u8, 4 = f32) const int channels = oakengine_video_params_internal_channel_count(); - assert(channels == 4); - assert(oakengine_video_params_bytes_per_pixel(0, channels) == 4); - assert(oakengine_video_params_bytes_per_pixel(4, channels) == 16); + EXPECT_TRUE(channels == 4); + EXPECT_TRUE(oakengine_video_params_bytes_per_pixel(0, channels) == 4); + EXPECT_TRUE(oakengine_video_params_bytes_per_pixel(4, channels) == 16); } // Engine-side VideoParams construction used by the app during R6 to avoid @@ -605,20 +606,20 @@ static void test_video_params_pod(void) static void test_video_params_create_free(void) { // NULL pod -> NULL handle - assert(oakengine_video_params_create(NULL) == NULL); + EXPECT_TRUE(oakengine_video_params_create(NULL) == NULL); // Empty POD -> default-constructed VideoParams handle oak_video_params empty = {}; void *vp_empty = oakengine_video_params_create(&empty); - assert(vp_empty != NULL); + EXPECT_TRUE(vp_empty != NULL); oakengine_video_params_free(vp_empty); // Display-path POD with explicit timebase oak_video_params pod; - assert(oakengine_video_params_make(&pod, 1920, 1080, 1001, 30000, 0, 1, 1, + EXPECT_TRUE(oakengine_video_params_make(&pod, 1920, 1080, 1001, 30000, 0, 1, 1, 0, 0, 1) == OAKENGINE_OK); void *vp = oakengine_video_params_create(&pod); - assert(vp != NULL); + EXPECT_TRUE(vp != NULL); oakengine_video_params_free(vp); // Display-path POD without timebase (uses constructor without timebase) @@ -627,20 +628,20 @@ static void test_video_params_create_free(void) pod2.height = 480; pod2.format = 0; // u8 void *vp2 = oakengine_video_params_create(&pod2); - assert(vp2 != NULL); + EXPECT_TRUE(vp2 != NULL); oakengine_video_params_free(vp2); // free(NULL) is a no-op oakengine_video_params_free(NULL); } -int main(void) +TEST(OakEngineEncoding, Main) { make_tmpdir(); // HEADLESS: no GL, but a QCoreApplication (needed by the FFmpeg encoder // probes and QStandardPaths behind the metadata queries) comes up. - assert(oakengine_init(OAKENGINE_INIT_HEADLESS) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_init(OAKENGINE_INIT_HEADLESS) == OAKENGINE_OK); test_format_metadata(); test_codec_metadata(); @@ -655,5 +656,4 @@ int main(void) oakengine_shutdown(); printf("oakengine_encoding_test: OK\n"); - return 0; } diff --git a/engine/tests/oakengine_events_test.cpp b/engine/tests/oakengine_events_test.cpp index 8bd11b7b1..1a3f89092 100644 --- a/engine/tests/oakengine_events_test.cpp +++ b/engine/tests/oakengine_events_test.cpp @@ -25,6 +25,7 @@ // asserting the callback fired with the documented payload. No GL required. #include +#include #include #include #include @@ -55,20 +56,20 @@ static void make_tmpdir(void) #if defined(_WIN32) char base[MAX_PATH]; const DWORD len = GetTempPathA(MAX_PATH, base); - assert(len > 0 && len < MAX_PATH); + EXPECT_TRUE(len > 0 && len < MAX_PATH); snprintf(g_tmpdir, sizeof(g_tmpdir), "%soakengine_events_test_%lu", base, (unsigned long)GetCurrentProcessId()); - assert(_mkdir(g_tmpdir) == 0); + EXPECT_TRUE(_mkdir(g_tmpdir) == 0); #else strcpy(g_tmpdir, "/tmp/oakengine_events_test_XXXXXX"); - assert(mkdtemp(g_tmpdir) != NULL); + EXPECT_TRUE(mkdtemp(g_tmpdir) != NULL); #endif } static void demo_path(char *dst, size_t cap) { const int n = snprintf(dst, cap, "%s/tests/demo.mp4", OAK_TEST_SOURCE_DIR); - assert(n > 0 && (size_t)n < cap); + EXPECT_TRUE(n > 0 && (size_t)n < cap); } // Callback recorder: counts deliveries per event id and keeps the last @@ -88,8 +89,8 @@ typedef struct { static void record_event(const oakengine_event *event, void *userdata) { EventLog *log = (EventLog *)userdata; - assert(event != NULL); - assert(event->id > 0 && event->id < MAX_TRACKED_EVENT); + EXPECT_TRUE(event != NULL); + EXPECT_TRUE(event->id > 0 && event->id < MAX_TRACKED_EVENT); log->count[event->id]++; log->last_a[event->id] = event->a; log->last_b[event->id] = event->b; @@ -115,32 +116,32 @@ static void test_subscribe_validation(OakEngineProject *project, memset(&log, 0, sizeof(log)); // NULL handle / NULL callback / unknown event id. - assert(oakengine_event_subscribe( + EXPECT_TRUE(oakengine_event_subscribe( NULL, OAKENGINE_EVENT_PROJECT_MODIFIED_CHANGED, record_event, &log) == 0); - assert(oakengine_event_subscribe(project, + EXPECT_TRUE(oakengine_event_subscribe(project, OAKENGINE_EVENT_PROJECT_MODIFIED_CHANGED, NULL, &log) == 0); - assert(oakengine_event_subscribe(project, 999, record_event, &log) == 0); + EXPECT_TRUE(oakengine_event_subscribe(project, 999, record_event, &log) == 0); // Handle/event family mismatches. - assert(oakengine_event_subscribe( + EXPECT_TRUE(oakengine_event_subscribe( seq, OAKENGINE_EVENT_PROJECT_MODIFIED_CHANGED, record_event, &log) == 0); - assert(oakengine_event_subscribe(project, + EXPECT_TRUE(oakengine_event_subscribe(project, OAKENGINE_EVENT_SEQUENCE_TRACK_ADDED, record_event, &log) == 0); - assert(oakengine_event_subscribe(track, + EXPECT_TRUE(oakengine_event_subscribe(track, OAKENGINE_EVENT_FOLDER_BEGIN_INSERT_ITEM, record_event, &log) == 0); - assert(oakengine_event_subscribe(project, + EXPECT_TRUE(oakengine_event_subscribe(project, OAKENGINE_EVENT_TRACK_BLOCK_ADDED, record_event, &log) == 0); // Bad unsubscribe arguments. - assert(oakengine_event_unsubscribe(0) == OAKENGINE_E_INVALID); - assert(oakengine_event_unsubscribe(-5) == OAKENGINE_E_INVALID); - assert(oakengine_event_unsubscribe(424242) == OAKENGINE_E_NOT_FOUND); + EXPECT_TRUE(oakengine_event_unsubscribe(0) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_event_unsubscribe(-5) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_event_unsubscribe(424242) == OAKENGINE_E_NOT_FOUND); } // ---- Project events --------------------------------------------------------- @@ -156,25 +157,25 @@ static void test_project_events(OakEngineProject *project) int64_t sub = oakengine_event_subscribe( project, OAKENGINE_EVENT_PROJECT_MODIFIED_CHANGED, record_event, &log); - assert(sub > 0); + EXPECT_TRUE(sub > 0); oakengine_project_set_modified(project, 1); - assert(log.count[OAKENGINE_EVENT_PROJECT_MODIFIED_CHANGED] == 1); - assert(log.last_a[OAKENGINE_EVENT_PROJECT_MODIFIED_CHANGED] == 1); - assert(log.last_source[OAKENGINE_EVENT_PROJECT_MODIFIED_CHANGED] == + EXPECT_TRUE(log.count[OAKENGINE_EVENT_PROJECT_MODIFIED_CHANGED] == 1); + EXPECT_TRUE(log.last_a[OAKENGINE_EVENT_PROJECT_MODIFIED_CHANGED] == 1); + EXPECT_TRUE(log.last_source[OAKENGINE_EVENT_PROJECT_MODIFIED_CHANGED] == (void *)project); oakengine_project_set_modified(project, 0); - assert(log.count[OAKENGINE_EVENT_PROJECT_MODIFIED_CHANGED] == 2); - assert(log.last_a[OAKENGINE_EVENT_PROJECT_MODIFIED_CHANGED] == 0); + EXPECT_TRUE(log.count[OAKENGINE_EVENT_PROJECT_MODIFIED_CHANGED] == 2); + EXPECT_TRUE(log.last_a[OAKENGINE_EVENT_PROJECT_MODIFIED_CHANGED] == 0); // After unsubscribing no further events arrive. - assert(oakengine_event_unsubscribe(sub) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_event_unsubscribe(sub) == OAKENGINE_OK); oakengine_project_set_modified(project, 1); - assert(log.count[OAKENGINE_EVENT_PROJECT_MODIFIED_CHANGED] == 2); + EXPECT_TRUE(log.count[OAKENGINE_EVENT_PROJECT_MODIFIED_CHANGED] == 2); // Unsubscribing twice is a not-found no-op. - assert(oakengine_event_unsubscribe(sub) == OAKENGINE_E_NOT_FOUND); + EXPECT_TRUE(oakengine_event_unsubscribe(sub) == OAKENGINE_E_NOT_FOUND); } // ---- Folder events ---------------------------------------------------------- @@ -187,7 +188,7 @@ static void test_folder_events(OakEngineProject *project) // A fresh project's first node is its root folder (same fixture as // oakengine_footage_test). OakEngineNode *root = oakengine_project_node_at(project, 0); - assert(root != NULL); + EXPECT_TRUE(root != NULL); int64_t sub_begin = oakengine_event_subscribe( root, OAKENGINE_EVENT_FOLDER_BEGIN_INSERT_ITEM, record_event, &log); @@ -197,30 +198,30 @@ static void test_folder_events(OakEngineProject *project) root, OAKENGINE_EVENT_FOLDER_BEGIN_REMOVE_ITEM, record_event, &log); int64_t sub_rm_end = oakengine_event_subscribe( root, OAKENGINE_EVENT_FOLDER_END_REMOVE_ITEM, record_event, &log); - assert(sub_begin > 0 && sub_end > 0 && sub_rm_begin > 0 && + EXPECT_TRUE(sub_begin > 0 && sub_end > 0 && sub_rm_begin > 0 && sub_rm_end > 0); OakEngineNode *folder = oakengine_folder_create(project, root, "Sub"); - assert(folder != NULL); + EXPECT_TRUE(folder != NULL); - assert(log.count[OAKENGINE_EVENT_FOLDER_BEGIN_INSERT_ITEM] == 1); - assert(log.last_handle[OAKENGINE_EVENT_FOLDER_BEGIN_INSERT_ITEM] == + EXPECT_TRUE(log.count[OAKENGINE_EVENT_FOLDER_BEGIN_INSERT_ITEM] == 1); + EXPECT_TRUE(log.last_handle[OAKENGINE_EVENT_FOLDER_BEGIN_INSERT_ITEM] == (void *)folder); - assert(log.last_a[OAKENGINE_EVENT_FOLDER_BEGIN_INSERT_ITEM] >= 0); - assert(log.count[OAKENGINE_EVENT_FOLDER_END_INSERT_ITEM] == 1); + EXPECT_TRUE(log.last_a[OAKENGINE_EVENT_FOLDER_BEGIN_INSERT_ITEM] >= 0); + EXPECT_TRUE(log.count[OAKENGINE_EVENT_FOLDER_END_INSERT_ITEM] == 1); // Undoing the folder creation removes it from the root again. - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(log.count[OAKENGINE_EVENT_FOLDER_BEGIN_REMOVE_ITEM] == 1); - assert(log.last_handle[OAKENGINE_EVENT_FOLDER_BEGIN_REMOVE_ITEM] == + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(log.count[OAKENGINE_EVENT_FOLDER_BEGIN_REMOVE_ITEM] == 1); + EXPECT_TRUE(log.last_handle[OAKENGINE_EVENT_FOLDER_BEGIN_REMOVE_ITEM] == (void *)folder); - assert(log.count[OAKENGINE_EVENT_FOLDER_END_REMOVE_ITEM] == 1); - assert(oakengine_project_redo(project) == OAKENGINE_OK); + EXPECT_TRUE(log.count[OAKENGINE_EVENT_FOLDER_END_REMOVE_ITEM] == 1); + EXPECT_TRUE(oakengine_project_redo(project) == OAKENGINE_OK); - assert(oakengine_event_unsubscribe(sub_begin) == OAKENGINE_OK); - assert(oakengine_event_unsubscribe(sub_end) == OAKENGINE_OK); - assert(oakengine_event_unsubscribe(sub_rm_begin) == OAKENGINE_OK); - assert(oakengine_event_unsubscribe(sub_rm_end) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_event_unsubscribe(sub_begin) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_event_unsubscribe(sub_end) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_event_unsubscribe(sub_rm_begin) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_event_unsubscribe(sub_rm_end) == OAKENGINE_OK); } // ---- Sequence / track events ------------------------------------------------- @@ -235,43 +236,43 @@ static void test_sequence_events(OakEngineProject *project, // Track added: subscribe, then append an audio track. int64_t sub_track = oakengine_event_subscribe( seq, OAKENGINE_EVENT_SEQUENCE_TRACK_ADDED, record_event, &log); - assert(sub_track > 0); - assert(oakengine_sequence_add_track(seq, OAKENGINE_TRACK_TYPE_AUDIO) == + EXPECT_TRUE(sub_track > 0); + EXPECT_TRUE(oakengine_sequence_add_track(seq, OAKENGINE_TRACK_TYPE_AUDIO) == 0); - assert(log.count[OAKENGINE_EVENT_SEQUENCE_TRACK_ADDED] == 1); - assert(log.last_a[OAKENGINE_EVENT_SEQUENCE_TRACK_ADDED] == + EXPECT_TRUE(log.count[OAKENGINE_EVENT_SEQUENCE_TRACK_ADDED] == 1); + EXPECT_TRUE(log.last_a[OAKENGINE_EVENT_SEQUENCE_TRACK_ADDED] == OAKENGINE_TRACK_TYPE_AUDIO); - assert(log.last_handle[OAKENGINE_EVENT_SEQUENCE_TRACK_ADDED] != NULL); - assert(log.last_source[OAKENGINE_EVENT_SEQUENCE_TRACK_ADDED] == + EXPECT_TRUE(log.last_handle[OAKENGINE_EVENT_SEQUENCE_TRACK_ADDED] != NULL); + EXPECT_TRUE(log.last_source[OAKENGINE_EVENT_SEQUENCE_TRACK_ADDED] == (void *)seq); - assert(oakengine_event_unsubscribe(sub_track) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_event_unsubscribe(sub_track) == OAKENGINE_OK); // Block added on the video track (track 0 was created by the caller). OakEngineTrack *track = oakengine_sequence_track_at( seq, OAKENGINE_TRACK_TYPE_VIDEO, 0); - assert(track != NULL); + EXPECT_TRUE(track != NULL); int64_t sub_block = oakengine_event_subscribe( track, OAKENGINE_EVENT_TRACK_BLOCK_ADDED, record_event, &log); - assert(sub_block > 0); + EXPECT_TRUE(sub_block > 0); OakEngineFootage *footage = oakengine_project_import_footage(project, media_path); - assert(footage != NULL); + EXPECT_TRUE(footage != NULL); OakEngineClip *clip = oakengine_sequence_add_footage_clip( seq, footage, OAKENGINE_TRACK_TYPE_VIDEO, 0, 10, 40, 5); - assert(clip != NULL); + EXPECT_TRUE(clip != NULL); // Placing at in=10 on an empty track inserts a leading gap first, so the // event fires twice (gap 0..10, then the clip 10..40); the last // delivery is the clip itself. - assert(log.count[OAKENGINE_EVENT_TRACK_BLOCK_ADDED] == 2); - assert(log.last_handle[OAKENGINE_EVENT_TRACK_BLOCK_ADDED] == + EXPECT_TRUE(log.count[OAKENGINE_EVENT_TRACK_BLOCK_ADDED] == 2); + EXPECT_TRUE(log.last_handle[OAKENGINE_EVENT_TRACK_BLOCK_ADDED] == (void *)clip); - assert(log.last_a[OAKENGINE_EVENT_TRACK_BLOCK_ADDED] == 10); - assert(log.last_b[OAKENGINE_EVENT_TRACK_BLOCK_ADDED] == 40); - assert(log.last_source[OAKENGINE_EVENT_TRACK_BLOCK_ADDED] == + EXPECT_TRUE(log.last_a[OAKENGINE_EVENT_TRACK_BLOCK_ADDED] == 10); + EXPECT_TRUE(log.last_b[OAKENGINE_EVENT_TRACK_BLOCK_ADDED] == 40); + EXPECT_TRUE(log.last_source[OAKENGINE_EVENT_TRACK_BLOCK_ADDED] == (void *)track); - assert(oakengine_event_unsubscribe(sub_block) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_event_unsubscribe(sub_block) == OAKENGINE_OK); oakengine_footage_free(footage); // Marker added / modified. @@ -279,19 +280,19 @@ static void test_sequence_events(OakEngineProject *project, seq, OAKENGINE_EVENT_SEQUENCE_MARKER_ADDED, record_event, &log); int64_t sub_marker_mod = oakengine_event_subscribe( seq, OAKENGINE_EVENT_SEQUENCE_MARKER_MODIFIED, record_event, &log); - assert(sub_marker_add > 0 && sub_marker_mod > 0); + EXPECT_TRUE(sub_marker_add > 0 && sub_marker_mod > 0); - assert(oakengine_sequence_marker_add(seq, 7, "Mark") == OAKENGINE_OK); - assert(log.count[OAKENGINE_EVENT_SEQUENCE_MARKER_ADDED] == 1); - assert(log.last_a[OAKENGINE_EVENT_SEQUENCE_MARKER_ADDED] == 7); + EXPECT_TRUE(oakengine_sequence_marker_add(seq, 7, "Mark") == OAKENGINE_OK); + EXPECT_TRUE(log.count[OAKENGINE_EVENT_SEQUENCE_MARKER_ADDED] == 1); + EXPECT_TRUE(log.last_a[OAKENGINE_EVENT_SEQUENCE_MARKER_ADDED] == 7); - assert(oakengine_sequence_marker_rename(seq, 7, "Renamed") == + EXPECT_TRUE(oakengine_sequence_marker_rename(seq, 7, "Renamed") == OAKENGINE_OK); - assert(log.count[OAKENGINE_EVENT_SEQUENCE_MARKER_MODIFIED] == 1); - assert(log.last_a[OAKENGINE_EVENT_SEQUENCE_MARKER_MODIFIED] == 7); + EXPECT_TRUE(log.count[OAKENGINE_EVENT_SEQUENCE_MARKER_MODIFIED] == 1); + EXPECT_TRUE(log.last_a[OAKENGINE_EVENT_SEQUENCE_MARKER_MODIFIED] == 7); - assert(oakengine_event_unsubscribe(sub_marker_add) == OAKENGINE_OK); - assert(oakengine_event_unsubscribe(sub_marker_mod) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_event_unsubscribe(sub_marker_add) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_event_unsubscribe(sub_marker_mod) == OAKENGINE_OK); // Workarea enabled + range changed. int64_t sub_range = oakengine_event_subscribe( @@ -300,20 +301,20 @@ static void test_sequence_events(OakEngineProject *project, int64_t sub_enabled = oakengine_event_subscribe( seq, OAKENGINE_EVENT_SEQUENCE_WORKAREA_ENABLED_CHANGED, record_event, &log); - assert(sub_range > 0 && sub_enabled > 0); + EXPECT_TRUE(sub_range > 0 && sub_enabled > 0); - assert(oakengine_sequence_set_workarea(seq, 1, 3, 21) == OAKENGINE_OK); - assert(log.count[OAKENGINE_EVENT_SEQUENCE_WORKAREA_ENABLED_CHANGED] == + EXPECT_TRUE(oakengine_sequence_set_workarea(seq, 1, 3, 21) == OAKENGINE_OK); + EXPECT_TRUE(log.count[OAKENGINE_EVENT_SEQUENCE_WORKAREA_ENABLED_CHANGED] == 1); - assert(log.last_a[OAKENGINE_EVENT_SEQUENCE_WORKAREA_ENABLED_CHANGED] == + EXPECT_TRUE(log.last_a[OAKENGINE_EVENT_SEQUENCE_WORKAREA_ENABLED_CHANGED] == 1); - assert(log.count[OAKENGINE_EVENT_SEQUENCE_WORKAREA_RANGE_CHANGED] == 1); - assert(log.last_a[OAKENGINE_EVENT_SEQUENCE_WORKAREA_RANGE_CHANGED] == 3); - assert(log.last_b[OAKENGINE_EVENT_SEQUENCE_WORKAREA_RANGE_CHANGED] == + EXPECT_TRUE(log.count[OAKENGINE_EVENT_SEQUENCE_WORKAREA_RANGE_CHANGED] == 1); + EXPECT_TRUE(log.last_a[OAKENGINE_EVENT_SEQUENCE_WORKAREA_RANGE_CHANGED] == 3); + EXPECT_TRUE(log.last_b[OAKENGINE_EVENT_SEQUENCE_WORKAREA_RANGE_CHANGED] == 21); - assert(oakengine_event_unsubscribe(sub_range) == OAKENGINE_OK); - assert(oakengine_event_unsubscribe(sub_enabled) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_event_unsubscribe(sub_range) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_event_unsubscribe(sub_enabled) == OAKENGINE_OK); } // ---- Track block traversal --------------------------------------------------- @@ -322,51 +323,51 @@ static void test_block_traversal(OakEngineSequence *seq) { OakEngineTrack *track = oakengine_sequence_track_at( seq, OAKENGINE_TRACK_TYPE_VIDEO, 0); - assert(track != NULL); + EXPECT_TRUE(track != NULL); // The caller placed one clip at 10..40; the track chain is // gap(0..10) -> clip(10..40). - assert(oakengine_track_block_count(track) == 2); + EXPECT_TRUE(oakengine_track_block_count(track) == 2); OakEngineBlock *gap = oakengine_track_nearest_block_before_or_at(track, 0); - assert(gap != NULL); - assert(oakengine_block_is_gap(gap) == 1); + EXPECT_TRUE(gap != NULL); + EXPECT_TRUE(oakengine_block_is_gap(gap) == 1); OakEngineBlock *clip = oakengine_block_next(gap); - assert(clip != NULL); - assert(oakengine_block_is_gap(clip) == 0); - assert(oakengine_block_next(clip) == NULL); - assert(oakengine_block_prev(clip) == gap); - assert(oakengine_block_prev(gap) == NULL); + EXPECT_TRUE(clip != NULL); + EXPECT_TRUE(oakengine_block_is_gap(clip) == 0); + EXPECT_TRUE(oakengine_block_next(clip) == NULL); + EXPECT_TRUE(oakengine_block_prev(clip) == gap); + EXPECT_TRUE(oakengine_block_prev(gap) == NULL); int64_t in = -1, out = -1; - assert(oakengine_block_get_range(gap, &in, &out) == OAKENGINE_OK); - assert(in == 0 && out == 10); - assert(oakengine_block_get_range(clip, &in, &out) == OAKENGINE_OK); - assert(in == 10 && out == 40); + EXPECT_TRUE(oakengine_block_get_range(gap, &in, &out) == OAKENGINE_OK); + EXPECT_TRUE(in == 0 && out == 10); + EXPECT_TRUE(oakengine_block_get_range(clip, &in, &out) == OAKENGINE_OK); + EXPECT_TRUE(in == 10 && out == 40); // Time queries. - assert(oakengine_track_block_at_time(track, 15) == clip); - assert(oakengine_track_block_at_time(track, 5) == gap); - assert(oakengine_track_block_at_time(track, 40) == NULL); - assert(oakengine_track_nearest_block_before(track, 10) == gap); - assert(oakengine_track_nearest_block_before_or_at(track, 10) == clip); - assert(oakengine_track_nearest_block_after(track, 0) == clip); - assert(oakengine_track_nearest_block_after_or_at(track, 10) == clip); - assert(oakengine_track_nearest_block_after(track, 10) == NULL); + EXPECT_TRUE(oakengine_track_block_at_time(track, 15) == clip); + EXPECT_TRUE(oakengine_track_block_at_time(track, 5) == gap); + EXPECT_TRUE(oakengine_track_block_at_time(track, 40) == NULL); + EXPECT_TRUE(oakengine_track_nearest_block_before(track, 10) == gap); + EXPECT_TRUE(oakengine_track_nearest_block_before_or_at(track, 10) == clip); + EXPECT_TRUE(oakengine_track_nearest_block_after(track, 0) == clip); + EXPECT_TRUE(oakengine_track_nearest_block_after_or_at(track, 10) == clip); + EXPECT_TRUE(oakengine_track_nearest_block_after(track, 10) == NULL); // NULL safety. - assert(oakengine_track_block_count(NULL) == OAKENGINE_E_INVALID); - assert(oakengine_track_block_at_time(NULL, 0) == NULL); - assert(oakengine_track_nearest_block_before(NULL, 0) == NULL); - assert(oakengine_track_nearest_block_before_or_at(NULL, 0) == NULL); - assert(oakengine_track_nearest_block_after(NULL, 0) == NULL); - assert(oakengine_track_nearest_block_after_or_at(NULL, 0) == NULL); - assert(oakengine_block_next(NULL) == NULL); - assert(oakengine_block_prev(NULL) == NULL); - assert(oakengine_block_is_gap(NULL) == 0); - assert(oakengine_block_get_range(NULL, &in, &out) == + EXPECT_TRUE(oakengine_track_block_count(NULL) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_track_block_at_time(NULL, 0) == NULL); + EXPECT_TRUE(oakengine_track_nearest_block_before(NULL, 0) == NULL); + EXPECT_TRUE(oakengine_track_nearest_block_before_or_at(NULL, 0) == NULL); + EXPECT_TRUE(oakengine_track_nearest_block_after(NULL, 0) == NULL); + EXPECT_TRUE(oakengine_track_nearest_block_after_or_at(NULL, 0) == NULL); + EXPECT_TRUE(oakengine_block_next(NULL) == NULL); + EXPECT_TRUE(oakengine_block_prev(NULL) == NULL); + EXPECT_TRUE(oakengine_block_is_gap(NULL) == 0); + EXPECT_TRUE(oakengine_block_get_range(NULL, &in, &out) == OAKENGINE_E_INVALID); } @@ -383,10 +384,10 @@ static void test_node_events(OakEngineProject *project) project, "org.olivevideoeditor.Olive.ociolut"); OakEngineNode *text = oakengine_project_add_node( project, "org.olivevideoeditor.Olive.text3"); - assert(solid != NULL && lut != NULL && text != NULL); + EXPECT_TRUE(solid != NULL && lut != NULL && text != NULL); // Family mismatch: node events need a node handle. - assert(oakengine_event_subscribe( + EXPECT_TRUE(oakengine_event_subscribe( project, OAKENGINE_EVENT_NODE_LABEL_CHANGED, record_event, &log) == 0); @@ -423,15 +424,15 @@ static void test_node_events(OakEngineProject *project) solid, OAKENGINE_EVENT_NODE_KEYFRAME_VALUE_CHANGED, record_event, &log); for (int i = 0; i < nsubs; i++) { - assert(subs[i] > 0); + EXPECT_TRUE(subs[i] > 0); } // Label. - assert(oakengine_node_set_label(solid, "EventSolid") == OAKENGINE_OK); - assert(log.count[OAKENGINE_EVENT_NODE_LABEL_CHANGED] == 1); - assert(strcmp(log.last_s[OAKENGINE_EVENT_NODE_LABEL_CHANGED], + EXPECT_TRUE(oakengine_node_set_label(solid, "EventSolid") == OAKENGINE_OK); + EXPECT_TRUE(log.count[OAKENGINE_EVENT_NODE_LABEL_CHANGED] == 1); + EXPECT_TRUE(strcmp(log.last_s[OAKENGINE_EVENT_NODE_LABEL_CHANGED], "EventSolid") == 0); - assert(log.last_source[OAKENGINE_EVENT_NODE_LABEL_CHANGED] == solid); + EXPECT_TRUE(log.last_source[OAKENGINE_EVENT_NODE_LABEL_CHANGED] == solid); // Value change on an input: element -1, a valid range, the input id. oak_node_value v; @@ -439,55 +440,55 @@ static void test_node_events(OakEngineProject *project) v.type = OAK_NODE_VALUE_COLOR; v.f[0] = 0.5; v.f[3] = 1.0; - assert(oakengine_node_set_input(solid, "color_in", &v) == OAKENGINE_OK); - assert(log.count[OAKENGINE_EVENT_NODE_INPUT_VALUE_CHANGED] >= 1); - assert(strcmp(log.last_s[OAKENGINE_EVENT_NODE_INPUT_VALUE_CHANGED], + EXPECT_TRUE(oakengine_node_set_input(solid, "color_in", &v) == OAKENGINE_OK); + EXPECT_TRUE(log.count[OAKENGINE_EVENT_NODE_INPUT_VALUE_CHANGED] >= 1); + EXPECT_TRUE(strcmp(log.last_s[OAKENGINE_EVENT_NODE_INPUT_VALUE_CHANGED], "color_in") == 0); - assert(log.last_a[OAKENGINE_EVENT_NODE_INPUT_VALUE_CHANGED] == -1); + EXPECT_TRUE(log.last_a[OAKENGINE_EVENT_NODE_INPUT_VALUE_CHANGED] == -1); // Edge connect/disconnect: output node in the handle field. - assert(oakengine_node_connect(solid, lut, "tex_in") == OAKENGINE_OK); - assert(log.count[OAKENGINE_EVENT_NODE_INPUT_CONNECTED] == 1); - assert(log.last_handle[OAKENGINE_EVENT_NODE_INPUT_CONNECTED] == solid); - assert(strcmp(log.last_s[OAKENGINE_EVENT_NODE_INPUT_CONNECTED], + EXPECT_TRUE(oakengine_node_connect(solid, lut, "tex_in") == OAKENGINE_OK); + EXPECT_TRUE(log.count[OAKENGINE_EVENT_NODE_INPUT_CONNECTED] == 1); + EXPECT_TRUE(log.last_handle[OAKENGINE_EVENT_NODE_INPUT_CONNECTED] == solid); + EXPECT_TRUE(strcmp(log.last_s[OAKENGINE_EVENT_NODE_INPUT_CONNECTED], "tex_in") == 0); - assert(oakengine_node_disconnect(lut, "tex_in") == OAKENGINE_OK); - assert(log.count[OAKENGINE_EVENT_NODE_INPUT_DISCONNECTED] == 1); + EXPECT_TRUE(oakengine_node_disconnect(lut, "tex_in") == OAKENGINE_OK); + EXPECT_TRUE(log.count[OAKENGINE_EVENT_NODE_INPUT_DISCONNECTED] == 1); // Property change (notified write only). - assert(oakengine_node_set_input_property_string(solid, "color_in", + EXPECT_TRUE(oakengine_node_set_input_property_string(solid, "color_in", "my_prop", "1", 1) == OAKENGINE_OK); - assert(log.count[OAKENGINE_EVENT_NODE_INPUT_PROPERTY_CHANGED] == 1); - assert(strcmp(log.last_s[OAKENGINE_EVENT_NODE_INPUT_PROPERTY_CHANGED], + EXPECT_TRUE(log.count[OAKENGINE_EVENT_NODE_INPUT_PROPERTY_CHANGED] == 1); + EXPECT_TRUE(strcmp(log.last_s[OAKENGINE_EVENT_NODE_INPUT_PROPERTY_CHANGED], "color_in") == 0); - assert(oakengine_node_set_input_property_string(solid, "color_in", + EXPECT_TRUE(oakengine_node_set_input_property_string(solid, "color_in", "my_prop", "2", 0) == OAKENGINE_OK); - assert(log.count[OAKENGINE_EVENT_NODE_INPUT_PROPERTY_CHANGED] == 1); + EXPECT_TRUE(log.count[OAKENGINE_EVENT_NODE_INPUT_PROPERTY_CHANGED] == 1); // Array size change: old and new sizes. const int arr_before = oakengine_node_input_array_size(text, "args_in"); - assert(oakengine_node_array_insert_at(text, "args_in", 0) == + EXPECT_TRUE(oakengine_node_array_insert_at(text, "args_in", 0) == OAKENGINE_OK); - assert(log.count[OAKENGINE_EVENT_NODE_INPUT_ARRAY_SIZE_CHANGED] == 1); - assert(log.last_a[OAKENGINE_EVENT_NODE_INPUT_ARRAY_SIZE_CHANGED] == + EXPECT_TRUE(log.count[OAKENGINE_EVENT_NODE_INPUT_ARRAY_SIZE_CHANGED] == 1); + EXPECT_TRUE(log.last_a[OAKENGINE_EVENT_NODE_INPUT_ARRAY_SIZE_CHANGED] == arr_before); - assert(log.last_b[OAKENGINE_EVENT_NODE_INPUT_ARRAY_SIZE_CHANGED] == + EXPECT_TRUE(log.last_b[OAKENGINE_EVENT_NODE_INPUT_ARRAY_SIZE_CHANGED] == arr_before + 1); // Keyframe enable + add/remove/time/type/value. reset_event(&log, OAKENGINE_EVENT_NODE_KEYFRAME_ADDED); - assert(oakengine_node_set_input_keyframing(solid, "color_in", -1, 1, 0, + EXPECT_TRUE(oakengine_node_set_input_keyframing(solid, "color_in", -1, 1, 0, 1, NULL) == OAKENGINE_OK); - assert(log.count[OAKENGINE_EVENT_NODE_KEYFRAME_ENABLE_CHANGED] == 1); - assert(log.last_b[OAKENGINE_EVENT_NODE_KEYFRAME_ENABLE_CHANGED] == 1); - assert(strcmp(log.last_s[OAKENGINE_EVENT_NODE_KEYFRAME_ENABLE_CHANGED], + EXPECT_TRUE(log.count[OAKENGINE_EVENT_NODE_KEYFRAME_ENABLE_CHANGED] == 1); + EXPECT_TRUE(log.last_b[OAKENGINE_EVENT_NODE_KEYFRAME_ENABLE_CHANGED] == 1); + EXPECT_TRUE(strcmp(log.last_s[OAKENGINE_EVENT_NODE_KEYFRAME_ENABLE_CHANGED], "color_in") == 0); - assert(log.count[OAKENGINE_EVENT_NODE_KEYFRAME_ADDED] >= 1); - assert(log.last_handle[OAKENGINE_EVENT_NODE_KEYFRAME_ADDED] != NULL); + EXPECT_TRUE(log.count[OAKENGINE_EVENT_NODE_KEYFRAME_ADDED] >= 1); + EXPECT_TRUE(log.last_handle[OAKENGINE_EVENT_NODE_KEYFRAME_ADDED] != NULL); // COLOR has four tracks; enabling keyframing adds one key per track. - assert(log.last_b[OAKENGINE_EVENT_NODE_KEYFRAME_ADDED] == 3); + EXPECT_TRUE(log.last_b[OAKENGINE_EVENT_NODE_KEYFRAME_ADDED] == 3); // Type change on the created key (ts 0 = time 0s). reset_event(&log, OAKENGINE_EVENT_NODE_KEYFRAME_TYPE_CHANGED); @@ -495,13 +496,13 @@ static void test_node_events(OakEngineProject *project) int tracks[1] = { 0 }; // The engine only emits the type-changed signal on multi-key tracks, // so add a second key (1s = ts 30 with the default timebase) first. - assert(oakengine_node_keyframes_toggle_at_time(solid, "color_in", -1, 1, + EXPECT_TRUE(oakengine_node_keyframes_toggle_at_time(solid, "color_in", -1, 1, 1, 1, NULL) == OAKENGINE_OK); // Default type is bezier; switch to hold (type 2) for a real change. - assert(oakengine_node_keyframes_set_type_many(solid, "color_in", -1, + EXPECT_TRUE(oakengine_node_keyframes_set_type_many(solid, "color_in", -1, times, tracks, 1, 2) == 1); - assert(log.count[OAKENGINE_EVENT_NODE_KEYFRAME_TYPE_CHANGED] == 1); + EXPECT_TRUE(log.count[OAKENGINE_EVENT_NODE_KEYFRAME_TYPE_CHANGED] == 1); // Value change. reset_event(&log, OAKENGINE_EVENT_NODE_KEYFRAME_VALUE_CHANGED); @@ -509,32 +510,32 @@ static void test_node_events(OakEngineProject *project) memset(&nv, 0, sizeof(nv)); nv.type = OAK_NODE_VALUE_COLOR; nv.f[0] = 0.75; - assert(oakengine_node_keyframes_set_value_many(solid, "color_in", -1, + EXPECT_TRUE(oakengine_node_keyframes_set_value_many(solid, "color_in", -1, times, tracks, 1, &nv, NULL) == 1); - assert(log.count[OAKENGINE_EVENT_NODE_KEYFRAME_VALUE_CHANGED] == 1); + EXPECT_TRUE(log.count[OAKENGINE_EVENT_NODE_KEYFRAME_VALUE_CHANGED] == 1); // Time change. reset_event(&log, OAKENGINE_EVENT_NODE_KEYFRAME_TIME_CHANGED); - assert(oakengine_node_keyframes_set_time_many(solid, "color_in", -1, + EXPECT_TRUE(oakengine_node_keyframes_set_time_many(solid, "color_in", -1, times, tracks, 1, 30) == 1); - assert(log.count[OAKENGINE_EVENT_NODE_KEYFRAME_TIME_CHANGED] == 1); + EXPECT_TRUE(log.count[OAKENGINE_EVENT_NODE_KEYFRAME_TIME_CHANGED] == 1); // Removal. reset_event(&log, OAKENGINE_EVENT_NODE_KEYFRAME_REMOVED); - assert(oakengine_node_set_input_keyframing(solid, "color_in", -1, 0, 0, + EXPECT_TRUE(oakengine_node_set_input_keyframing(solid, "color_in", -1, 0, 0, 1, NULL) == OAKENGINE_OK); - assert(log.count[OAKENGINE_EVENT_NODE_KEYFRAME_REMOVED] >= 1); - assert(log.count[OAKENGINE_EVENT_NODE_KEYFRAME_ENABLE_CHANGED] == 2); + EXPECT_TRUE(log.count[OAKENGINE_EVENT_NODE_KEYFRAME_REMOVED] >= 1); + EXPECT_TRUE(log.count[OAKENGINE_EVENT_NODE_KEYFRAME_ENABLE_CHANGED] == 2); for (int i = 0; i < nsubs; i++) { - assert(oakengine_event_unsubscribe(subs[i]) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_event_unsubscribe(subs[i]) == OAKENGINE_OK); } - assert(oakengine_project_remove_node(project, solid) == OAKENGINE_OK); - assert(oakengine_project_remove_node(project, lut) == OAKENGINE_OK); - assert(oakengine_project_remove_node(project, text) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_remove_node(project, solid) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_remove_node(project, lut) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_remove_node(project, text) == OAKENGINE_OK); } // ---- Group + context position events ----------------------------------------- @@ -548,7 +549,7 @@ static void test_group_events(OakEngineProject *project) project, "org.olivevideoeditor.Olive.group"); OakEngineNode *solid = oakengine_project_add_node( project, "org.olivevideoeditor.Olive.solidgenerator"); - assert(group != NULL && solid != NULL); + EXPECT_TRUE(group != NULL && solid != NULL); int64_t subs[4]; int nsubs = 0; @@ -565,75 +566,75 @@ static void test_group_events(OakEngineProject *project) group, OAKENGINE_EVENT_NODE_CONTEXT_POSITION_CHANGED, record_event, &log); for (int i = 0; i < nsubs; i++) { - assert(subs[i] > 0); + EXPECT_TRUE(subs[i] > 0); } // The group must contain the inner node before a passthrough can be // added (insertion itself fires the position-changed event). - assert(oakengine_node_set_context_position(group, solid, 0.0, 0.0) == + EXPECT_TRUE(oakengine_node_set_context_position(group, solid, 0.0, 0.0) == OAKENGINE_OK); reset_event(&log, OAKENGINE_EVENT_NODE_CONTEXT_POSITION_CHANGED); // Add passthrough: handle = inner node, s = input id, a = element. - assert(oakengine_group_add_input_passthrough(group, solid, "color_in", + EXPECT_TRUE(oakengine_group_add_input_passthrough(group, solid, "color_in", -1, NULL, NULL, 0) > 0); - assert(log.count[OAKENGINE_EVENT_GROUP_INPUT_PASSTHROUGH_ADDED] == 1); - assert(log.last_source[OAKENGINE_EVENT_GROUP_INPUT_PASSTHROUGH_ADDED] == + EXPECT_TRUE(log.count[OAKENGINE_EVENT_GROUP_INPUT_PASSTHROUGH_ADDED] == 1); + EXPECT_TRUE(log.last_source[OAKENGINE_EVENT_GROUP_INPUT_PASSTHROUGH_ADDED] == group); - assert(log.last_handle[OAKENGINE_EVENT_GROUP_INPUT_PASSTHROUGH_ADDED] == + EXPECT_TRUE(log.last_handle[OAKENGINE_EVENT_GROUP_INPUT_PASSTHROUGH_ADDED] == solid); - assert(strcmp(log.last_s[OAKENGINE_EVENT_GROUP_INPUT_PASSTHROUGH_ADDED], + EXPECT_TRUE(strcmp(log.last_s[OAKENGINE_EVENT_GROUP_INPUT_PASSTHROUGH_ADDED], "color_in") == 0); - assert(log.last_a[OAKENGINE_EVENT_GROUP_INPUT_PASSTHROUGH_ADDED] == -1); + EXPECT_TRUE(log.last_a[OAKENGINE_EVENT_GROUP_INPUT_PASSTHROUGH_ADDED] == -1); // Output passthrough: handle = the new output node. - assert(oakengine_group_set_output_passthrough(group, solid) == + EXPECT_TRUE(oakengine_group_set_output_passthrough(group, solid) == OAKENGINE_OK); - assert(log.count[OAKENGINE_EVENT_GROUP_OUTPUT_PASSTHROUGH_CHANGED] == 1); - assert(log.last_handle[OAKENGINE_EVENT_GROUP_OUTPUT_PASSTHROUGH_CHANGED] == + EXPECT_TRUE(log.count[OAKENGINE_EVENT_GROUP_OUTPUT_PASSTHROUGH_CHANGED] == 1); + EXPECT_TRUE(log.last_handle[OAKENGINE_EVENT_GROUP_OUTPUT_PASSTHROUGH_CHANGED] == solid); // Remove passthrough. - assert(oakengine_group_remove_input_passthrough(group, solid, "color_in", + EXPECT_TRUE(oakengine_group_remove_input_passthrough(group, solid, "color_in", -1) == OAKENGINE_OK); - assert(log.count[OAKENGINE_EVENT_GROUP_INPUT_PASSTHROUGH_REMOVED] == 1); - assert(log.last_handle[OAKENGINE_EVENT_GROUP_INPUT_PASSTHROUGH_REMOVED] == + EXPECT_TRUE(log.count[OAKENGINE_EVENT_GROUP_INPUT_PASSTHROUGH_REMOVED] == 1); + EXPECT_TRUE(log.last_handle[OAKENGINE_EVENT_GROUP_INPUT_PASSTHROUGH_REMOVED] == solid); - assert(strcmp(log.last_s[OAKENGINE_EVENT_GROUP_INPUT_PASSTHROUGH_REMOVED], + EXPECT_TRUE(strcmp(log.last_s[OAKENGINE_EVENT_GROUP_INPUT_PASSTHROUGH_REMOVED], "color_in") == 0); - assert(log.last_a[OAKENGINE_EVENT_GROUP_INPUT_PASSTHROUGH_REMOVED] == -1); + EXPECT_TRUE(log.last_a[OAKENGINE_EVENT_GROUP_INPUT_PASSTHROUGH_REMOVED] == -1); // Context position: handle = child node, a/b = x/y double bit patterns. - assert(oakengine_node_set_context_position(group, solid, 3.5, -2.25) == + EXPECT_TRUE(oakengine_node_set_context_position(group, solid, 3.5, -2.25) == OAKENGINE_OK); - assert(log.count[OAKENGINE_EVENT_NODE_CONTEXT_POSITION_CHANGED] == 1); - assert(log.last_source[OAKENGINE_EVENT_NODE_CONTEXT_POSITION_CHANGED] == + EXPECT_TRUE(log.count[OAKENGINE_EVENT_NODE_CONTEXT_POSITION_CHANGED] == 1); + EXPECT_TRUE(log.last_source[OAKENGINE_EVENT_NODE_CONTEXT_POSITION_CHANGED] == group); - assert(log.last_handle[OAKENGINE_EVENT_NODE_CONTEXT_POSITION_CHANGED] == + EXPECT_TRUE(log.last_handle[OAKENGINE_EVENT_NODE_CONTEXT_POSITION_CHANGED] == solid); double px, py; memcpy(&px, &log.last_a[OAKENGINE_EVENT_NODE_CONTEXT_POSITION_CHANGED], sizeof(px)); memcpy(&py, &log.last_b[OAKENGINE_EVENT_NODE_CONTEXT_POSITION_CHANGED], sizeof(py)); - assert(px == 3.5 && py == -2.25); + EXPECT_TRUE(px == 3.5 && py == -2.25); // Moving again re-emits with the new coordinates. - assert(oakengine_node_set_context_position(group, solid, 0.0, 1.0) == + EXPECT_TRUE(oakengine_node_set_context_position(group, solid, 0.0, 1.0) == OAKENGINE_OK); - assert(log.count[OAKENGINE_EVENT_NODE_CONTEXT_POSITION_CHANGED] == 2); + EXPECT_TRUE(log.count[OAKENGINE_EVENT_NODE_CONTEXT_POSITION_CHANGED] == 2); memcpy(&px, &log.last_a[OAKENGINE_EVENT_NODE_CONTEXT_POSITION_CHANGED], sizeof(px)); memcpy(&py, &log.last_b[OAKENGINE_EVENT_NODE_CONTEXT_POSITION_CHANGED], sizeof(py)); - assert(px == 0.0 && py == 1.0); + EXPECT_TRUE(px == 0.0 && py == 1.0); for (int i = 0; i < nsubs; i++) { - assert(oakengine_event_unsubscribe(subs[i]) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_event_unsubscribe(subs[i]) == OAKENGINE_OK); } - assert(oakengine_project_remove_node(project, group) == OAKENGINE_OK); - assert(oakengine_project_remove_node(project, solid) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_remove_node(project, group) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_remove_node(project, solid) == OAKENGINE_OK); } // ---- Track / block state events (B4c) --------------------------------------- @@ -647,25 +648,25 @@ static void test_track_extra_events(OakEngineSequence *seq, memset(&log, 0, sizeof(log)); // Family mismatches: a track is not a sequence and vice versa. - assert(oakengine_event_subscribe( + EXPECT_TRUE(oakengine_event_subscribe( track, OAKENGINE_EVENT_SEQUENCE_TRACK_LIST_CHANGED, record_event, &log) == 0); - assert(oakengine_event_subscribe(seq, OAKENGINE_EVENT_TRACK_MUTED_CHANGED, + EXPECT_TRUE(oakengine_event_subscribe(seq, OAKENGINE_EVENT_TRACK_MUTED_CHANGED, record_event, &log) == 0); // Muted changed. int64_t sub_mute = oakengine_event_subscribe( track, OAKENGINE_EVENT_TRACK_MUTED_CHANGED, record_event, &log); - assert(sub_mute > 0); - assert(oakengine_track_set_muted(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 1) == + EXPECT_TRUE(sub_mute > 0); + EXPECT_TRUE(oakengine_track_set_muted(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 1) == OAKENGINE_OK); - assert(log.count[OAKENGINE_EVENT_TRACK_MUTED_CHANGED] == 1); - assert(log.last_a[OAKENGINE_EVENT_TRACK_MUTED_CHANGED] == 1); - assert(oakengine_track_set_muted(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 0) == + EXPECT_TRUE(log.count[OAKENGINE_EVENT_TRACK_MUTED_CHANGED] == 1); + EXPECT_TRUE(log.last_a[OAKENGINE_EVENT_TRACK_MUTED_CHANGED] == 1); + EXPECT_TRUE(oakengine_track_set_muted(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 0) == OAKENGINE_OK); - assert(log.count[OAKENGINE_EVENT_TRACK_MUTED_CHANGED] == 2); - assert(log.last_a[OAKENGINE_EVENT_TRACK_MUTED_CHANGED] == 0); - assert(oakengine_event_unsubscribe(sub_mute) == OAKENGINE_OK); + EXPECT_TRUE(log.count[OAKENGINE_EVENT_TRACK_MUTED_CHANGED] == 2); + EXPECT_TRUE(log.last_a[OAKENGINE_EVENT_TRACK_MUTED_CHANGED] == 0); + EXPECT_TRUE(oakengine_event_unsubscribe(sub_mute) == OAKENGINE_OK); // Track height changed (track-level, double bit pattern) and the // sequence-level pixel variant. @@ -674,69 +675,69 @@ static void test_track_extra_events(OakEngineSequence *seq, int64_t sub_sh = oakengine_event_subscribe( seq, OAKENGINE_EVENT_SEQUENCE_TRACK_HEIGHT_CHANGED, record_event, &log); - assert(sub_h > 0 && sub_sh > 0); - assert(oakengine_track_set_height(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, + EXPECT_TRUE(sub_h > 0 && sub_sh > 0); + EXPECT_TRUE(oakengine_track_set_height(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 2.5) == OAKENGINE_OK); - assert(log.count[OAKENGINE_EVENT_TRACK_HEIGHT_CHANGED] == 1); + EXPECT_TRUE(log.count[OAKENGINE_EVENT_TRACK_HEIGHT_CHANGED] == 1); double h; memcpy(&h, &log.last_a[OAKENGINE_EVENT_TRACK_HEIGHT_CHANGED], sizeof(h)); - assert(h == 2.5); - assert(log.count[OAKENGINE_EVENT_SEQUENCE_TRACK_HEIGHT_CHANGED] == 1); - assert(log.last_a[OAKENGINE_EVENT_SEQUENCE_TRACK_HEIGHT_CHANGED] == + EXPECT_TRUE(h == 2.5); + EXPECT_TRUE(log.count[OAKENGINE_EVENT_SEQUENCE_TRACK_HEIGHT_CHANGED] == 1); + EXPECT_TRUE(log.last_a[OAKENGINE_EVENT_SEQUENCE_TRACK_HEIGHT_CHANGED] == OAKENGINE_TRACK_TYPE_VIDEO); - assert(log.last_b[OAKENGINE_EVENT_SEQUENCE_TRACK_HEIGHT_CHANGED] == + EXPECT_TRUE(log.last_b[OAKENGINE_EVENT_SEQUENCE_TRACK_HEIGHT_CHANGED] == oakengine_track_height_internal_to_pixels(2.5)); - assert(log.last_handle[OAKENGINE_EVENT_SEQUENCE_TRACK_HEIGHT_CHANGED] == + EXPECT_TRUE(log.last_handle[OAKENGINE_EVENT_SEQUENCE_TRACK_HEIGHT_CHANGED] == (void *)track); - assert(oakengine_event_unsubscribe(sub_h) == OAKENGINE_OK); - assert(oakengine_event_unsubscribe(sub_sh) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_event_unsubscribe(sub_h) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_event_unsubscribe(sub_sh) == OAKENGINE_OK); // Track list changed + index changed: append a second video track, // then move track 0 to position 1. int64_t sub_list = oakengine_event_subscribe( seq, OAKENGINE_EVENT_SEQUENCE_TRACK_LIST_CHANGED, record_event, &log); - assert(sub_list > 0); - assert(oakengine_sequence_add_track(seq, OAKENGINE_TRACK_TYPE_VIDEO) == + EXPECT_TRUE(sub_list > 0); + EXPECT_TRUE(oakengine_sequence_add_track(seq, OAKENGINE_TRACK_TYPE_VIDEO) == 1); - assert(log.count[OAKENGINE_EVENT_SEQUENCE_TRACK_LIST_CHANGED] >= 1); - assert(log.last_a[OAKENGINE_EVENT_SEQUENCE_TRACK_LIST_CHANGED] == + EXPECT_TRUE(log.count[OAKENGINE_EVENT_SEQUENCE_TRACK_LIST_CHANGED] >= 1); + EXPECT_TRUE(log.last_a[OAKENGINE_EVENT_SEQUENCE_TRACK_LIST_CHANGED] == OAKENGINE_TRACK_TYPE_VIDEO); int64_t sub_index = oakengine_event_subscribe( track, OAKENGINE_EVENT_TRACK_INDEX_CHANGED, record_event, &log); - assert(sub_index > 0); - assert(oakengine_sequence_move_track(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, + EXPECT_TRUE(sub_index > 0); + EXPECT_TRUE(oakengine_sequence_move_track(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 1) == OAKENGINE_OK); - assert(log.count[OAKENGINE_EVENT_TRACK_INDEX_CHANGED] >= 1); - assert(log.last_b[OAKENGINE_EVENT_TRACK_INDEX_CHANGED] == 1); - assert(oakengine_sequence_move_track(seq, OAKENGINE_TRACK_TYPE_VIDEO, 1, + EXPECT_TRUE(log.count[OAKENGINE_EVENT_TRACK_INDEX_CHANGED] >= 1); + EXPECT_TRUE(log.last_b[OAKENGINE_EVENT_TRACK_INDEX_CHANGED] == 1); + EXPECT_TRUE(oakengine_sequence_move_track(seq, OAKENGINE_TRACK_TYPE_VIDEO, 1, 0) == OAKENGINE_OK); - assert(oakengine_event_unsubscribe(sub_index) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_event_unsubscribe(sub_index) == OAKENGINE_OK); // Clean up the extra track. - assert(oakengine_sequence_remove_track(seq, OAKENGINE_TRACK_TYPE_VIDEO, + EXPECT_TRUE(oakengine_sequence_remove_track(seq, OAKENGINE_TRACK_TYPE_VIDEO, 1) == OAKENGINE_OK); - assert(oakengine_event_unsubscribe(sub_list) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_event_unsubscribe(sub_list) == OAKENGINE_OK); // Blocks refreshed: emitted when the track re-lays out its block chain // (e.g. moving a clip onto it). int64_t sub_refresh = oakengine_event_subscribe( track, OAKENGINE_EVENT_TRACK_BLOCKS_REFRESHED, record_event, &log); - assert(sub_refresh > 0); - assert(oakengine_sequence_move_clip(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 0, + EXPECT_TRUE(sub_refresh > 0); + EXPECT_TRUE(oakengine_sequence_move_clip(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 0, 50) == OAKENGINE_OK); - assert(log.count[OAKENGINE_EVENT_TRACK_BLOCKS_REFRESHED] >= 1); + EXPECT_TRUE(log.count[OAKENGINE_EVENT_TRACK_BLOCKS_REFRESHED] >= 1); // Move it back to 10 to restore the original layout. - assert(oakengine_sequence_move_clip(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 0, + EXPECT_TRUE(oakengine_sequence_move_clip(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 0, 10) == OAKENGINE_OK); - assert(oakengine_event_unsubscribe(sub_refresh) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_event_unsubscribe(sub_refresh) == OAKENGINE_OK); // Subtitles changed: subscription validates (no headless trigger -- // the signal only fires on subtitle-track cache invalidation). int64_t sub_subs = oakengine_event_subscribe( seq, OAKENGINE_EVENT_SEQUENCE_SUBTITLES_CHANGED, record_event, &log); - assert(sub_subs > 0); - assert(oakengine_event_unsubscribe(sub_subs) == OAKENGINE_OK); + EXPECT_TRUE(sub_subs > 0); + EXPECT_TRUE(oakengine_event_unsubscribe(sub_subs) == OAKENGINE_OK); } static void test_block_state_events(OakEngineSequence *seq, @@ -749,46 +750,46 @@ static void test_block_state_events(OakEngineSequence *seq, // counted by the clip family). OakEngineClip *clip = oakengine_sequence_clip_at( seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 0); - assert(clip != NULL); + EXPECT_TRUE(clip != NULL); OakEngineBlock *block = (OakEngineBlock *)clip; // Family mismatch: a block is not a track. - assert(oakengine_event_subscribe( + EXPECT_TRUE(oakengine_event_subscribe( block, OAKENGINE_EVENT_TRACK_MUTED_CHANGED, record_event, &log) == 0); int64_t sub_en = oakengine_event_subscribe( block, OAKENGINE_EVENT_BLOCK_ENABLED_CHANGED, record_event, &log); - assert(sub_en > 0); + EXPECT_TRUE(sub_en > 0); // The engine emits enabled_changed twice per flip (Block::set_enabled // and Block::InputValueChangedEvent), so each toggle delivers two. OakEngineClip *clips[1] = { clip }; - assert(oakengine_clip_toggle_enabled(clips, 1) == 1); - assert(log.count[OAKENGINE_EVENT_BLOCK_ENABLED_CHANGED] == 2); - assert(oakengine_block_is_enabled(block) == 0); - assert(oakengine_clip_toggle_enabled(clips, 1) == 1); - assert(log.count[OAKENGINE_EVENT_BLOCK_ENABLED_CHANGED] == 4); - assert(oakengine_block_is_enabled(block) == 1); - assert(oakengine_event_unsubscribe(sub_en) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_clip_toggle_enabled(clips, 1) == 1); + EXPECT_TRUE(log.count[OAKENGINE_EVENT_BLOCK_ENABLED_CHANGED] == 2); + EXPECT_TRUE(oakengine_block_is_enabled(block) == 0); + EXPECT_TRUE(oakengine_clip_toggle_enabled(clips, 1) == 1); + EXPECT_TRUE(log.count[OAKENGINE_EVENT_BLOCK_ENABLED_CHANGED] == 4); + EXPECT_TRUE(oakengine_block_is_enabled(block) == 1); + EXPECT_TRUE(oakengine_event_unsubscribe(sub_en) == OAKENGINE_OK); // Preview changed: writing the loop-mode input fires it. int64_t sub_prev = oakengine_event_subscribe( block, OAKENGINE_EVENT_BLOCK_PREVIEW_CHANGED, record_event, &log); - assert(sub_prev > 0); + EXPECT_TRUE(sub_prev > 0); oak_node_value v; memset(&v, 0, sizeof(v)); v.type = OAK_NODE_VALUE_COMBO; v.num = 1; - assert(oakengine_node_set_input((OakEngineNode *)clip, + EXPECT_TRUE(oakengine_node_set_input((OakEngineNode *)clip, oakengine_clip_loop_mode_input_id(), &v) == OAKENGINE_OK); - assert(log.count[OAKENGINE_EVENT_BLOCK_PREVIEW_CHANGED] == 1); + EXPECT_TRUE(log.count[OAKENGINE_EVENT_BLOCK_PREVIEW_CHANGED] == 1); v.num = 0; - assert(oakengine_node_set_input((OakEngineNode *)clip, + EXPECT_TRUE(oakengine_node_set_input((OakEngineNode *)clip, oakengine_clip_loop_mode_input_id(), &v) == OAKENGINE_OK); - assert(log.count[OAKENGINE_EVENT_BLOCK_PREVIEW_CHANGED] == 2); - assert(oakengine_event_unsubscribe(sub_prev) == OAKENGINE_OK); + EXPECT_TRUE(log.count[OAKENGINE_EVENT_BLOCK_PREVIEW_CHANGED] == 2); + EXPECT_TRUE(oakengine_event_unsubscribe(sub_prev) == OAKENGINE_OK); // Node links/color changed (Node signals on the block handle). int64_t sub_links = oakengine_event_subscribe( @@ -797,25 +798,25 @@ static void test_block_state_events(OakEngineSequence *seq, int64_t sub_color = oakengine_event_subscribe( (OakEngineNode *)clip, OAKENGINE_EVENT_NODE_COLOR_CHANGED, record_event, &log); - assert(sub_links > 0 && sub_color > 0); + EXPECT_TRUE(sub_links > 0 && sub_color > 0); OakEngineNode *one[1] = { (OakEngineNode *)clip }; - assert(oakengine_node_set_color_label(one, 1, 4) == OAKENGINE_OK); - assert(log.count[OAKENGINE_EVENT_NODE_COLOR_CHANGED] == 1); + EXPECT_TRUE(oakengine_node_set_color_label(one, 1, 4) == OAKENGINE_OK); + EXPECT_TRUE(log.count[OAKENGINE_EVENT_NODE_COLOR_CHANGED] == 1); OakEngineFootage *footage = oakengine_project_import_footage(oakengine_node_get_project( (OakEngineNode *)seq), media_path); - assert(footage != NULL); + EXPECT_TRUE(footage != NULL); OakEngineClip *clip2 = oakengine_sequence_add_footage_clip( seq, footage, OAKENGINE_TRACK_TYPE_VIDEO, 0, 50, 80, 0); - assert(clip2 != NULL); + EXPECT_TRUE(clip2 != NULL); OakEngineClip *pair[2] = { clip, clip2 }; - assert(oakengine_clip_set_linked(pair, 2, 1) == OAKENGINE_OK); - assert(log.count[OAKENGINE_EVENT_NODE_LINKS_CHANGED] >= 1); - assert(oakengine_clip_set_linked(pair, 2, 0) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_clip_set_linked(pair, 2, 1) == OAKENGINE_OK); + EXPECT_TRUE(log.count[OAKENGINE_EVENT_NODE_LINKS_CHANGED] >= 1); + EXPECT_TRUE(oakengine_clip_set_linked(pair, 2, 0) == OAKENGINE_OK); oakengine_footage_free(footage); - assert(oakengine_event_unsubscribe(sub_links) == OAKENGINE_OK); - assert(oakengine_event_unsubscribe(sub_color) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_event_unsubscribe(sub_links) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_event_unsubscribe(sub_color) == OAKENGINE_OK); } static void test_marker_list_events(OakEngineSequence *seq) @@ -825,10 +826,10 @@ static void test_marker_list_events(OakEngineSequence *seq) OakEngineMarkerList *list = oakengine_viewer_get_marker_list((OakEngineNode *)seq); - assert(list != NULL); + EXPECT_TRUE(list != NULL); // Family mismatch: a marker list is not a workarea. - assert(oakengine_event_subscribe( + EXPECT_TRUE(oakengine_event_subscribe( list, OAKENGINE_EVENT_WORKAREA_RANGE_CHANGED, record_event, &log) == 0); @@ -840,32 +841,32 @@ static void test_marker_list_events(OakEngineSequence *seq) int64_t sub_rm = oakengine_event_subscribe( list, OAKENGINE_EVENT_MARKER_LIST_MARKER_REMOVED, record_event, &log); - assert(sub_add > 0 && sub_mod > 0 && sub_rm > 0); + EXPECT_TRUE(sub_add > 0 && sub_mod > 0 && sub_rm > 0); // Add a marker at 2 seconds (rational seconds, not timestamps). - assert(oakengine_marker_list_add(list, 2, 1, 2, 1, "ListMark", 3) == + EXPECT_TRUE(oakengine_marker_list_add(list, 2, 1, 2, 1, "ListMark", 3) == OAKENGINE_OK); - assert(log.count[OAKENGINE_EVENT_MARKER_LIST_MARKER_ADDED] == 1); + EXPECT_TRUE(log.count[OAKENGINE_EVENT_MARKER_LIST_MARKER_ADDED] == 1); OakEngineMarker *marker = (OakEngineMarker *)log.last_handle [OAKENGINE_EVENT_MARKER_LIST_MARKER_ADDED]; - assert(marker != NULL); - assert(oakengine_marker_list_at(list, 0) != NULL); + EXPECT_TRUE(marker != NULL); + EXPECT_TRUE(oakengine_marker_list_at(list, 0) != NULL); // Modify: recolor through the properties batch. OakEngineMarker *one[1] = { marker }; - assert(oakengine_marker_set_properties(one, 1, 5, NULL, 0, 0, 0, 0, 0, + EXPECT_TRUE(oakengine_marker_set_properties(one, 1, 5, NULL, 0, 0, 0, 0, 0, NULL) == OAKENGINE_OK); - assert(log.count[OAKENGINE_EVENT_MARKER_LIST_MARKER_MODIFIED] == 1); - assert(log.last_handle[OAKENGINE_EVENT_MARKER_LIST_MARKER_MODIFIED] == + EXPECT_TRUE(log.count[OAKENGINE_EVENT_MARKER_LIST_MARKER_MODIFIED] == 1); + EXPECT_TRUE(log.last_handle[OAKENGINE_EVENT_MARKER_LIST_MARKER_MODIFIED] == (void *)marker); // Remove. - assert(oakengine_marker_remove(marker) == OAKENGINE_OK); - assert(log.count[OAKENGINE_EVENT_MARKER_LIST_MARKER_REMOVED] == 1); + EXPECT_TRUE(oakengine_marker_remove(marker) == OAKENGINE_OK); + EXPECT_TRUE(log.count[OAKENGINE_EVENT_MARKER_LIST_MARKER_REMOVED] == 1); - assert(oakengine_event_unsubscribe(sub_add) == OAKENGINE_OK); - assert(oakengine_event_unsubscribe(sub_mod) == OAKENGINE_OK); - assert(oakengine_event_unsubscribe(sub_rm) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_event_unsubscribe(sub_add) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_event_unsubscribe(sub_mod) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_event_unsubscribe(sub_rm) == OAKENGINE_OK); } static void test_workarea_events(OakEngineSequence *seq) @@ -876,61 +877,61 @@ static void test_workarea_events(OakEngineSequence *seq) // Viewer-owned (borrowed) workarea. OakEngineWorkarea *wa = oakengine_viewer_get_workarea_handle((OakEngineNode *)seq); - assert(wa != NULL); + EXPECT_TRUE(wa != NULL); int64_t sub_range = oakengine_event_subscribe( wa, OAKENGINE_EVENT_WORKAREA_RANGE_CHANGED, record_event, &log); int64_t sub_en = oakengine_event_subscribe( wa, OAKENGINE_EVENT_WORKAREA_ENABLED_CHANGED, record_event, &log); - assert(sub_range > 0 && sub_en > 0); + EXPECT_TRUE(sub_range > 0 && sub_en > 0); - assert(oakengine_workarea_set_range(wa, 1, 1, 4, 1) == OAKENGINE_OK); - assert(log.count[OAKENGINE_EVENT_WORKAREA_RANGE_CHANGED] == 1); + EXPECT_TRUE(oakengine_workarea_set_range(wa, 1, 1, 4, 1) == OAKENGINE_OK); + EXPECT_TRUE(log.count[OAKENGINE_EVENT_WORKAREA_RANGE_CHANGED] == 1); int64_t in_num = 0, in_den = 0, out_num = 0, out_den = 0; - assert(oakengine_workarea_get(wa, &in_num, &in_den, &out_num, &out_den, + EXPECT_TRUE(oakengine_workarea_get(wa, &in_num, &in_den, &out_num, &out_den, NULL) == OAKENGINE_OK); - assert(in_num == 1 && in_den == 1 && out_num == 4 && out_den == 1); + EXPECT_TRUE(in_num == 1 && in_den == 1 && out_num == 4 && out_den == 1); - assert(oakengine_workarea_set_enabled(wa, 1) == OAKENGINE_OK); - assert(log.count[OAKENGINE_EVENT_WORKAREA_ENABLED_CHANGED] == 1); - assert(log.last_a[OAKENGINE_EVENT_WORKAREA_ENABLED_CHANGED] == 1); - assert(oakengine_workarea_set_enabled(wa, 0) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_workarea_set_enabled(wa, 1) == OAKENGINE_OK); + EXPECT_TRUE(log.count[OAKENGINE_EVENT_WORKAREA_ENABLED_CHANGED] == 1); + EXPECT_TRUE(log.last_a[OAKENGINE_EVENT_WORKAREA_ENABLED_CHANGED] == 1); + EXPECT_TRUE(oakengine_workarea_set_enabled(wa, 0) == OAKENGINE_OK); - assert(oakengine_event_unsubscribe(sub_range) == OAKENGINE_OK); - assert(oakengine_event_unsubscribe(sub_en) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_event_unsubscribe(sub_range) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_event_unsubscribe(sub_en) == OAKENGINE_OK); // Standalone owned workarea (the footage viewer override pattern). OakEngineWorkarea *over = oakengine_workarea_create(); - assert(over != NULL); + EXPECT_TRUE(over != NULL); int64_t sub_over = oakengine_event_subscribe( over, OAKENGINE_EVENT_WORKAREA_RANGE_CHANGED, record_event, &log); - assert(sub_over > 0); - assert(oakengine_workarea_set_range(over, 0, 1, 7, 2) == OAKENGINE_OK); - assert(log.count[OAKENGINE_EVENT_WORKAREA_RANGE_CHANGED] == 2); - assert(oakengine_event_unsubscribe(sub_over) == OAKENGINE_OK); + EXPECT_TRUE(sub_over > 0); + EXPECT_TRUE(oakengine_workarea_set_range(over, 0, 1, 7, 2) == OAKENGINE_OK); + EXPECT_TRUE(log.count[OAKENGINE_EVENT_WORKAREA_RANGE_CHANGED] == 2); + EXPECT_TRUE(oakengine_event_unsubscribe(sub_over) == OAKENGINE_OK); oakengine_workarea_free(over); oakengine_workarea_free(NULL); } -int main(void) +TEST(OakEngineEvents, Main) { make_tmpdir(); // Sandbox the config/cache/data locations (see oakengine_init_test). #if !defined(_WIN32) - assert(setenv("XDG_CONFIG_HOME", g_tmpdir, 1) == 0); - assert(setenv("XDG_CACHE_HOME", g_tmpdir, 1) == 0); - assert(setenv("XDG_DATA_HOME", g_tmpdir, 1) == 0); + EXPECT_TRUE(setenv("XDG_CONFIG_HOME", g_tmpdir, 1) == 0); + EXPECT_TRUE(setenv("XDG_CACHE_HOME", g_tmpdir, 1) == 0); + EXPECT_TRUE(setenv("XDG_DATA_HOME", g_tmpdir, 1) == 0); #endif - assert(oakengine_init(OAKENGINE_INIT_HEADLESS) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_init(OAKENGINE_INIT_HEADLESS) == OAKENGINE_OK); OakEngineProject *project = oakengine_project_create(); - assert(project != NULL); - assert(oakengine_project_new(project) == OAKENGINE_OK); + EXPECT_TRUE(project != NULL); + EXPECT_TRUE(oakengine_project_new(project) == OAKENGINE_OK); OakEngineSequence *seq = oakengine_sequence_new(project, "Events"); - assert(seq != NULL); - assert(oakengine_sequence_add_track(seq, OAKENGINE_TRACK_TYPE_VIDEO) == + EXPECT_TRUE(seq != NULL); + EXPECT_TRUE(oakengine_sequence_add_track(seq, OAKENGINE_TRACK_TYPE_VIDEO) == 0); char path[4096]; @@ -938,7 +939,7 @@ int main(void) OakEngineTrack *track = oakengine_sequence_track_at( seq, OAKENGINE_TRACK_TYPE_VIDEO, 0); - assert(track != NULL); + EXPECT_TRUE(track != NULL); test_subscribe_validation(project, seq, track); test_project_events(project); @@ -953,8 +954,6 @@ int main(void) test_group_events(project); oakengine_project_free(project); - assert(oakengine_shutdown() == OAKENGINE_OK); + EXPECT_TRUE(oakengine_shutdown() == OAKENGINE_OK); - printf("oakengine_events_test: all assertions passed\n"); - return 0; } diff --git a/engine/tests/oakengine_export_test.cpp b/engine/tests/oakengine_export_test.cpp index 0ab48071c..17ed5187c 100644 --- a/engine/tests/oakengine_export_test.cpp +++ b/engine/tests/oakengine_export_test.cpp @@ -27,6 +27,7 @@ // progress callback. #include +#include #include #include #include @@ -76,13 +77,13 @@ static void make_tmpdir(void) #if defined(_WIN32) char base[MAX_PATH]; const DWORD len = GetTempPathA(MAX_PATH, base); - assert(len > 0 && len < MAX_PATH); + EXPECT_TRUE(len > 0 && len < MAX_PATH); snprintf(g_tmpdir, sizeof(g_tmpdir), "%soakengine_export_test_%lu", base, (unsigned long)GetCurrentProcessId()); - assert(_mkdir(g_tmpdir) == 0); + EXPECT_TRUE(_mkdir(g_tmpdir) == 0); #else strcpy(g_tmpdir, "/tmp/oakengine_export_test_XXXXXX"); - assert(mkdtemp(g_tmpdir) != NULL); + EXPECT_TRUE(mkdtemp(g_tmpdir) != NULL); #endif } @@ -142,39 +143,39 @@ static void progress_cb(double fraction, void *userdata) static void test_codecs_and_validation(OakEngineSequence *seq) { // Codec probing needs no RENDER bit and no GL. - assert(oakengine_export_has_video_codec(OAKENGINE_EXPORT_VIDEO_H264) == + EXPECT_TRUE(oakengine_export_has_video_codec(OAKENGINE_EXPORT_VIDEO_H264) == 1); - assert(oakengine_export_has_video_codec(OAKENGINE_EXPORT_VIDEO_H265) == + EXPECT_TRUE(oakengine_export_has_video_codec(OAKENGINE_EXPORT_VIDEO_H265) == 1); - assert(oakengine_export_has_video_codec( + EXPECT_TRUE(oakengine_export_has_video_codec( OAKENGINE_EXPORT_VIDEO_PNG_SEQUENCE) == 1); - assert(oakengine_export_has_video_codec(-2) == 0); - assert(oakengine_export_has_video_codec(99) == 0); - assert(oakengine_export_has_audio_codec(OAKENGINE_EXPORT_AUDIO_AAC) == 1); - assert(oakengine_export_has_audio_codec(OAKENGINE_EXPORT_AUDIO_PCM) == 1); - assert(oakengine_export_has_audio_codec( + EXPECT_TRUE(oakengine_export_has_video_codec(-2) == 0); + EXPECT_TRUE(oakengine_export_has_video_codec(99) == 0); + EXPECT_TRUE(oakengine_export_has_audio_codec(OAKENGINE_EXPORT_AUDIO_AAC) == 1); + EXPECT_TRUE(oakengine_export_has_audio_codec(OAKENGINE_EXPORT_AUDIO_PCM) == 1); + EXPECT_TRUE(oakengine_export_has_audio_codec( OAKENGINE_EXPORT_AUDIO_NONE) == 0); - assert(oakengine_export_has_audio_codec(99) == 0); + EXPECT_TRUE(oakengine_export_has_audio_codec(99) == 0); // Argument validation (engine has no RENDER bit yet either). char path[4096]; snprintf(path, sizeof(path), "%s/out.mp4", g_tmpdir); - assert(oakengine_export_render(NULL, path, 0, 30, 320, 180, NULL) == + EXPECT_TRUE(oakengine_export_render(NULL, path, 0, 30, 320, 180, NULL) == OAKENGINE_E_INVALID); - assert(oakengine_export_render(seq, NULL, 0, 30, 320, 180, NULL) == + EXPECT_TRUE(oakengine_export_render(seq, NULL, 0, 30, 320, 180, NULL) == OAKENGINE_E_INVALID); - assert(oakengine_export_render(seq, path, -1, 30, 320, 180, NULL) == + EXPECT_TRUE(oakengine_export_render(seq, path, -1, 30, 320, 180, NULL) == OAKENGINE_E_INVALID); - assert(oakengine_export_render(seq, path, 30, 30, 320, 180, NULL) == + EXPECT_TRUE(oakengine_export_render(seq, path, 30, 30, 320, 180, NULL) == OAKENGINE_E_INVALID); - assert(oakengine_export_render(seq, path, 40, 30, 320, 180, NULL) == + EXPECT_TRUE(oakengine_export_render(seq, path, 40, 30, 320, 180, NULL) == OAKENGINE_E_INVALID); // Without OAKENGINE_INIT_RENDER the export is refused with E_STATE. - assert(oakengine_export_render(seq, path, 0, 30, 320, 180, NULL) == + EXPECT_TRUE(oakengine_export_render(seq, path, 0, 30, 320, 180, NULL) == OAKENGINE_E_STATE); char err[256]; - assert(oakengine_export_last_error(err, sizeof(err)) > 0); + EXPECT_TRUE(oakengine_export_last_error(err, sizeof(err)) > 0); } // Generate a loud test tone (440 Hz stereo sine, 2 s) with the ffmpeg @@ -187,9 +188,9 @@ static void make_tone(const char *path) "ffmpeg -v error -y -f lavfi -i " "\"sine=frequency=440:duration=2\" -ar 48000 -ac 2 \"%s\"", path); - assert(system(cmd) == 0); + EXPECT_TRUE(system(cmd) == 0); FILE *f = fopen(path, "rb"); - assert(f != NULL); + EXPECT_TRUE(f != NULL); fclose(f); } @@ -198,32 +199,32 @@ static void make_tone(const char *path) static void assert_probe_matches(const char *cmd, const char *needle) { FILE *probe = popen(cmd, "r"); - assert(probe != NULL); + EXPECT_TRUE(probe != NULL); char out[2048] = { 0 }; const size_t len = fread(out, 1, sizeof(out) - 1, probe); (void)len; - assert(pclose(probe) == 0); - assert(strstr(out, needle) != NULL); + EXPECT_TRUE(pclose(probe) == 0); + EXPECT_TRUE(strstr(out, needle) != NULL); } -int main(void) +TEST(OakEngineExport, Main) { make_tmpdir(); // Sandbox the config/cache/data locations (see oakengine_init_test). #if !defined(_WIN32) - assert(setenv("XDG_CONFIG_HOME", g_tmpdir, 1) == 0); - assert(setenv("XDG_CACHE_HOME", g_tmpdir, 1) == 0); - assert(setenv("XDG_DATA_HOME", g_tmpdir, 1) == 0); + EXPECT_TRUE(setenv("XDG_CONFIG_HOME", g_tmpdir, 1) == 0); + EXPECT_TRUE(setenv("XDG_CACHE_HOME", g_tmpdir, 1) == 0); + EXPECT_TRUE(setenv("XDG_DATA_HOME", g_tmpdir, 1) == 0); #endif - assert(oakengine_init(OAKENGINE_INIT_HEADLESS) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_init(OAKENGINE_INIT_HEADLESS) == OAKENGINE_OK); OakEngineProject *project = oakengine_project_create(); - assert(project != NULL); - assert(oakengine_project_new(project) == OAKENGINE_OK); + EXPECT_TRUE(project != NULL); + EXPECT_TRUE(oakengine_project_new(project) == OAKENGINE_OK); OakEngineSequence *seq = oakengine_sequence_new(project, "Export"); - assert(seq != NULL); + EXPECT_TRUE(seq != NULL); test_codecs_and_validation(seq); @@ -233,19 +234,19 @@ int main(void) "available, export assertions skipped\n"); oakengine_project_free(project); oakengine_shutdown(); - return 0; + return; } if (!worker_binary_exists()) { printf("oakengine_export_test: SKIP: oak-render-worker binary not " "found, export assertions skipped\n"); oakengine_project_free(project); oakengine_shutdown(); - return 0; + return; } olive::Config::current()[QStringLiteral("GraphicsBackend")] = QStringLiteral("opengl"); - assert(oakengine_init(OAKENGINE_INIT_HEADLESS | OAKENGINE_INIT_RENDER) == + EXPECT_TRUE(oakengine_init(OAKENGINE_INIT_HEADLESS | OAKENGINE_INIT_RENDER) == OAKENGINE_OK); // Solid red generator -> texture input (engine C++ API, internal test). @@ -273,34 +274,34 @@ int main(void) err : "(no error)"); } - assert(rc == OAKENGINE_OK); + EXPECT_TRUE(rc == OAKENGINE_OK); oakengine_export_set_progress_callback(NULL, NULL); // Progress was reported, monotonically, and completed. - assert(g_progress_calls > 0); - assert(g_progress_monotonic == 1); - assert(fabs(g_progress_last - 1.0) < 1e-6); + EXPECT_TRUE(g_progress_calls > 0); + EXPECT_TRUE(g_progress_monotonic == 1); + EXPECT_TRUE(fabs(g_progress_last - 1.0) < 1e-6); // Validate the MP4 with ffprobe: h264 video, 320x180, ~1 second. - assert(access(out, F_OK) == 0); + EXPECT_TRUE(access(out, F_OK) == 0); char cmd[4608]; snprintf(cmd, sizeof(cmd), "ffprobe -v error -select_streams v:0 -show_entries " "stream=codec_name,width,height,duration -of csv=p=0 \"%s\"", out); FILE *probe = popen(cmd, "r"); - assert(probe != NULL); + EXPECT_TRUE(probe != NULL); char probe_out[512] = { 0 }; const size_t probe_len = fread(probe_out, 1, sizeof(probe_out) - 1, probe); (void)probe_len; - assert(pclose(probe) == 0); - assert(strstr(probe_out, "h264") != NULL); - assert(strstr(probe_out, "320,180") != NULL); + EXPECT_TRUE(pclose(probe) == 0); + EXPECT_TRUE(strstr(probe_out, "h264") != NULL); + EXPECT_TRUE(strstr(probe_out, "320,180") != NULL); // Duration is the last csv field; 30 frames at 30000/1001 ~= 1.001 s. const char *comma = strrchr(probe_out, ','); - assert(comma != NULL); + EXPECT_TRUE(comma != NULL); const double duration = atof(comma + 1); - assert(fabs(duration - 1.001) < 0.15); + EXPECT_TRUE(fabs(duration - 1.001) < 0.15); // ---- First-conform audio export --------------------------------------- // The sandboxed cache guarantees no conform exists yet: this is the @@ -316,10 +317,10 @@ int main(void) // primitives. OakEngineFootage *tone = oakengine_project_import_footage(project, tone_path); - assert(tone != NULL); - assert(oakengine_sequence_add_track(seq, OAKENGINE_TRACK_TYPE_AUDIO) == + EXPECT_TRUE(tone != NULL); + EXPECT_TRUE(oakengine_sequence_add_track(seq, OAKENGINE_TRACK_TYPE_AUDIO) == 0); - assert(oakengine_sequence_add_footage_clip( + EXPECT_TRUE(oakengine_sequence_add_footage_clip( seq, tone, OAKENGINE_TRACK_TYPE_AUDIO, 0, 0, 30, 0) != NULL); @@ -338,8 +339,8 @@ int main(void) err : "(no error)"); } - assert(rc == OAKENGINE_OK); - assert(access(out2, F_OK) == 0); + EXPECT_TRUE(rc == OAKENGINE_OK); + EXPECT_TRUE(access(out2, F_OK) == 0); // The MP4 carries an AAC audio stream... snprintf(cmd, sizeof(cmd), @@ -355,15 +356,15 @@ int main(void) "null - 2>&1 | grep mean_volume", out2); FILE *vol = popen(cmd, "r"); - assert(vol != NULL); + EXPECT_TRUE(vol != NULL); char vol_out[512] = { 0 }; const size_t vol_len = fread(vol_out, 1, sizeof(vol_out) - 1, vol); (void)vol_len; - assert(pclose(vol) == 0); + EXPECT_TRUE(pclose(vol) == 0); const char *db = strstr(vol_out, "mean_volume:"); - assert(db != NULL); + EXPECT_TRUE(db != NULL); const double mean_db = atof(db + strlen("mean_volume:")); - assert(mean_db > -60.0); + EXPECT_TRUE(mean_db > -60.0); oakengine_footage_free(tone); } @@ -380,44 +381,44 @@ int main(void) snprintf(out_bad, sizeof(out_bad), "%s/bad.mp4", g_tmpdir); bad.format = -1; - assert(oakengine_export_render_ex(seq, out_bad, &bad) == + EXPECT_TRUE(oakengine_export_render_ex(seq, out_bad, &bad) == OAKENGINE_E_INVALID); bad.format = 99; - assert(oakengine_export_render_ex(seq, out_bad, &bad) == + EXPECT_TRUE(oakengine_export_render_ex(seq, out_bad, &bad) == OAKENGINE_E_INVALID); bad.format = 2; bad.video_codec = 99; - assert(oakengine_export_render_ex(seq, out_bad, &bad) == + EXPECT_TRUE(oakengine_export_render_ex(seq, out_bad, &bad) == OAKENGINE_E_INVALID); bad.video_codec = 1; bad.range_mode = OAKENGINE_EXPORT_RANGE_CUSTOM; bad.range_in_ts = 30; bad.range_out_ts = 30; - assert(oakengine_export_render_ex(seq, out_bad, &bad) == + EXPECT_TRUE(oakengine_export_render_ex(seq, out_bad, &bad) == OAKENGINE_E_INVALID); bad.range_mode = OAKENGINE_EXPORT_RANGE_STILL; bad.still_time_ts = -1; - assert(oakengine_export_render_ex(seq, out_bad, &bad) == + EXPECT_TRUE(oakengine_export_render_ex(seq, out_bad, &bad) == OAKENGINE_E_INVALID); bad.range_mode = OAKENGINE_EXPORT_RANGE_ENTIRE; bad.color_transform = OAKENGINE_EXPORT_COLOR_CUSTOM; bad.color_transform_name[0] = '\0'; - assert(oakengine_export_render_ex(seq, out_bad, &bad) == + EXPECT_TRUE(oakengine_export_render_ex(seq, out_bad, &bad) == OAKENGINE_E_INVALID); bad.color_transform = OAKENGINE_EXPORT_COLOR_SRGB_OETF; bad.video_pix_fmt = 99; - assert(oakengine_export_render_ex(seq, out_bad, &bad) == + EXPECT_TRUE(oakengine_export_render_ex(seq, out_bad, &bad) == OAKENGINE_E_INVALID); - assert(oakengine_export_render_ex(NULL, out_bad, &bad) == + EXPECT_TRUE(oakengine_export_render_ex(NULL, out_bad, &bad) == OAKENGINE_E_INVALID); - assert(oakengine_export_render_ex(seq, NULL, &bad) == + EXPECT_TRUE(oakengine_export_render_ex(seq, NULL, &bad) == OAKENGINE_E_INVALID); - assert(oakengine_export_render_ex(seq, out_bad, NULL) == + EXPECT_TRUE(oakengine_export_render_ex(seq, out_bad, NULL) == OAKENGINE_E_INVALID); } @@ -451,22 +452,22 @@ int main(void) err : "(no error)"); } - assert(rc == OAKENGINE_OK); + EXPECT_TRUE(rc == OAKENGINE_OK); oakengine_export_set_video_option(NULL, NULL); snprintf(cmd, sizeof(cmd), "ffprobe -v error -show_entries stream=codec_type,duration " "-of csv=p=0 \"%s\"", out3); FILE *p3 = popen(cmd, "r"); - assert(p3 != NULL); + EXPECT_TRUE(p3 != NULL); char p3_out[512] = { 0 }; const size_t p3_len = fread(p3_out, 1, sizeof(p3_out) - 1, p3); (void)p3_len; - assert(pclose(p3) == 0); - assert(strstr(p3_out, "video") != NULL); - assert(strstr(p3_out, "audio") != NULL); + EXPECT_TRUE(pclose(p3) == 0); + EXPECT_TRUE(strstr(p3_out, "video") != NULL); + EXPECT_TRUE(strstr(p3_out, "audio") != NULL); // 20 frames at 30000/1001 ~= 0.667 s. - assert(strstr(p3_out, "0.6") != NULL); + EXPECT_TRUE(strstr(p3_out, "0.6") != NULL); // PNG sequence over 5 frames (image-sequence flag auto-fills the // frame placeholder). @@ -486,10 +487,10 @@ int main(void) err : "(no error)"); } - assert(rc == OAKENGINE_OK); + EXPECT_TRUE(rc == OAKENGINE_OK); char png0[4096]; snprintf(png0, sizeof(png0), "%s/seqout_00000.png", g_tmpdir); - assert(access(png0, F_OK) == 0); + EXPECT_TRUE(access(png0, F_OK) == 0); snprintf(cmd, sizeof(cmd), "file \"%s\"", png0); assert_probe_matches(cmd, "PNG image data"); @@ -504,15 +505,13 @@ int main(void) }); const int cancel_rc = oakengine_export_render_ex(seq, out3, &o5); canceller.join(); - assert(cancel_rc == OAKENGINE_OK || + EXPECT_TRUE(cancel_rc == OAKENGINE_OK || cancel_rc == OAKENGINE_E_CANCELLED); snprintf(out3, sizeof(out3), "%s/ex_after.mp4", g_tmpdir); - assert(oakengine_export_render_ex(seq, out3, &o5) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_export_render_ex(seq, out3, &o5) == OAKENGINE_OK); } oakengine_project_free(project); - assert(oakengine_shutdown() == OAKENGINE_OK); + EXPECT_TRUE(oakengine_shutdown() == OAKENGINE_OK); - printf("oakengine_export_test: all assertions passed\n"); - return 0; } diff --git a/engine/tests/oakengine_footage_test.cpp b/engine/tests/oakengine_footage_test.cpp index 432f16708..5c90728e2 100644 --- a/engine/tests/oakengine_footage_test.cpp +++ b/engine/tests/oakengine_footage_test.cpp @@ -24,6 +24,7 @@ // and covers the failure paths. No GL required. #include +#include #include #include #include @@ -53,20 +54,20 @@ static void make_tmpdir(void) #if defined(_WIN32) char base[MAX_PATH]; const DWORD len = GetTempPathA(MAX_PATH, base); - assert(len > 0 && len < MAX_PATH); + EXPECT_TRUE(len > 0 && len < MAX_PATH); snprintf(g_tmpdir, sizeof(g_tmpdir), "%soakengine_footage_test_%lu", base, (unsigned long)GetCurrentProcessId()); - assert(_mkdir(g_tmpdir) == 0); + EXPECT_TRUE(_mkdir(g_tmpdir) == 0); #else strcpy(g_tmpdir, "/tmp/oakengine_footage_test_XXXXXX"); - assert(mkdtemp(g_tmpdir) != NULL); + EXPECT_TRUE(mkdtemp(g_tmpdir) != NULL); #endif } static void demo_path(char *dst, size_t cap) { const int n = snprintf(dst, cap, "%s/tests/demo.mp4", OAK_TEST_SOURCE_DIR); - assert(n > 0 && (size_t)n < cap); + EXPECT_TRUE(n > 0 && (size_t)n < cap); } // tests/demo.mp4: 1920x1080 25 fps video (~17 s) + 48 kHz stereo audio, @@ -77,60 +78,60 @@ static void test_probe(void) demo_path(path, sizeof(path)); OakEngineFootage *f = oakengine_footage_probe(path); - assert(f != NULL); + EXPECT_TRUE(f != NULL); char name[64]; - assert(oakengine_footage_get_decoder_name(f, name, sizeof(name)) > 0); - assert(strcmp(name, "ffmpeg") == 0); + EXPECT_TRUE(oakengine_footage_get_decoder_name(f, name, sizeof(name)) > 0); + EXPECT_TRUE(strcmp(name, "ffmpeg") == 0); double duration = 0.0; - assert(oakengine_footage_get_duration(f, &duration) == OAKENGINE_OK); - assert(fabs(duration - 17.0) < 0.5); + EXPECT_TRUE(oakengine_footage_get_duration(f, &duration) == OAKENGINE_OK); + EXPECT_TRUE(fabs(duration - 17.0) < 0.5); - assert(oakengine_footage_get_video_stream_count(f) == 1); - assert(oakengine_footage_get_audio_stream_count(f) == 1); - assert(oakengine_footage_get_subtitle_stream_count(f) == 0); + EXPECT_TRUE(oakengine_footage_get_video_stream_count(f) == 1); + EXPECT_TRUE(oakengine_footage_get_audio_stream_count(f) == 1); + EXPECT_TRUE(oakengine_footage_get_subtitle_stream_count(f) == 0); oak_footage_video_info vi; memset(&vi, 0, sizeof(vi)); - assert(oakengine_footage_get_video_stream_info(f, 0, &vi) == + EXPECT_TRUE(oakengine_footage_get_video_stream_info(f, 0, &vi) == OAKENGINE_OK); - assert(vi.stream_index == 0); - assert(vi.width == 1920 && vi.height == 1080); - assert(vi.frame_rate_num == 25 && vi.frame_rate_den == 1); + EXPECT_TRUE(vi.stream_index == 0); + EXPECT_TRUE(vi.width == 1920 && vi.height == 1080); + EXPECT_TRUE(vi.frame_rate_num == 25 && vi.frame_rate_den == 1); // Duration units make sense against the time base (17 s +/- 0.5). - assert(vi.time_base_den > 0); + EXPECT_TRUE(vi.time_base_den > 0); const double vsecs = double(vi.duration_ts) * vi.time_base_num / vi.time_base_den; - assert(fabs(vsecs - 17.0) < 0.5); - assert(vi.color_primaries == 1); // BT.709 - assert(vi.color_trc == 1); - assert(vi.interlaced == 0); + EXPECT_TRUE(fabs(vsecs - 17.0) < 0.5); + EXPECT_TRUE(vi.color_primaries == 1); // BT.709 + EXPECT_TRUE(vi.color_trc == 1); + EXPECT_TRUE(vi.interlaced == 0); oak_footage_audio_info ai; memset(&ai, 0, sizeof(ai)); - assert(oakengine_footage_get_audio_stream_info(f, 0, &ai) == + EXPECT_TRUE(oakengine_footage_get_audio_stream_info(f, 0, &ai) == OAKENGINE_OK); - assert(ai.stream_index == 1); - assert(ai.sample_rate == 48000); - assert(ai.channel_count == 2); - assert(ai.time_base_den > 0); + EXPECT_TRUE(ai.stream_index == 1); + EXPECT_TRUE(ai.sample_rate == 48000); + EXPECT_TRUE(ai.channel_count == 2); + EXPECT_TRUE(ai.time_base_den > 0); const double asecs = double(ai.duration_ts) * ai.time_base_num / ai.time_base_den; - assert(fabs(asecs - 17.0) < 0.5); + EXPECT_TRUE(fabs(asecs - 17.0) < 0.5); - assert(oakengine_footage_is_online(f) == 1); + EXPECT_TRUE(oakengine_footage_is_online(f) == 1); // demo.mp4 carries a timecode track reading 01:00:00:00 at 25 fps, // i.e. a source start time of 3600 seconds. int num = -1, den = -1; - assert(oakengine_footage_get_source_start_time(f, &num, &den) == 1); - assert(num == 3600 && den == 1); + EXPECT_TRUE(oakengine_footage_get_source_start_time(f, &num, &den) == 1); + EXPECT_TRUE(num == 3600 && den == 1); // Out-of-range stream indexes report OAKENGINE_E_NOT_FOUND. - assert(oakengine_footage_get_video_stream_info(f, 1, &vi) == + EXPECT_TRUE(oakengine_footage_get_video_stream_info(f, 1, &vi) == OAKENGINE_E_NOT_FOUND); - assert(oakengine_footage_get_audio_stream_info(f, 1, &ai) == + EXPECT_TRUE(oakengine_footage_get_audio_stream_info(f, 1, &ai) == OAKENGINE_E_NOT_FOUND); oakengine_footage_free(f); @@ -138,52 +139,52 @@ static void test_probe(void) static void test_import(void) { - assert(oakengine_init(OAKENGINE_INIT_HEADLESS) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_init(OAKENGINE_INIT_HEADLESS) == OAKENGINE_OK); OakEngineProject *project = oakengine_project_create(); - assert(project != NULL); - assert(oakengine_project_new(project) == OAKENGINE_OK); - assert(oakengine_project_footage_count(project) == 0); + EXPECT_TRUE(project != NULL); + EXPECT_TRUE(oakengine_project_new(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_footage_count(project) == 0); char path[4096]; demo_path(path, sizeof(path)); OakEngineFootage *f = oakengine_project_import_footage(project, path); - assert(f != NULL); + EXPECT_TRUE(f != NULL); // The import went into the project as an undoable command. - assert(oakengine_project_footage_count(project) == 1); - assert(oakengine_project_can_undo(project) == 1); - assert(oakengine_project_is_modified(project) == 1); + EXPECT_TRUE(oakengine_project_footage_count(project) == 1); + EXPECT_TRUE(oakengine_project_can_undo(project) == 1); + EXPECT_TRUE(oakengine_project_is_modified(project) == 1); // The project's view of the footage matches the imported file. char filename[4096]; - assert(oakengine_project_footage_filename(project, 0, filename, + EXPECT_TRUE(oakengine_project_footage_filename(project, 0, filename, sizeof(filename)) > 0); - assert(strcmp(filename, path) == 0); - assert(oakengine_project_footage_is_online(project, 0) == 1); + EXPECT_TRUE(strcmp(filename, path) == 0); + EXPECT_TRUE(oakengine_project_footage_is_online(project, 0) == 1); // The borrowed handle exposes the same probe information. - assert(oakengine_footage_get_video_stream_count(f) == 1); - assert(oakengine_footage_get_audio_stream_count(f) == 1); + EXPECT_TRUE(oakengine_footage_get_video_stream_count(f) == 1); + EXPECT_TRUE(oakengine_footage_get_audio_stream_count(f) == 1); oak_footage_video_info vi; - assert(oakengine_footage_get_video_stream_info(f, 0, &vi) == + EXPECT_TRUE(oakengine_footage_get_video_stream_info(f, 0, &vi) == OAKENGINE_OK); - assert(vi.width == 1920 && vi.height == 1080); + EXPECT_TRUE(vi.width == 1920 && vi.height == 1080); char name[64]; - assert(oakengine_footage_get_decoder_name(f, name, sizeof(name)) > 0); - assert(strcmp(name, "ffmpeg") == 0); - assert(oakengine_footage_is_online(f) == 1); + EXPECT_TRUE(oakengine_footage_get_decoder_name(f, name, sizeof(name)) > 0); + EXPECT_TRUE(strcmp(name, "ffmpeg") == 0); + EXPECT_TRUE(oakengine_footage_is_online(f) == 1); // Undo removes the footage from the project, redo brings it back. - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_project_footage_count(project) == 0); - assert(oakengine_project_can_redo(project) == 1); - assert(oakengine_project_redo(project) == OAKENGINE_OK); - assert(oakengine_project_footage_count(project) == 1); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_footage_count(project) == 0); + EXPECT_TRUE(oakengine_project_can_redo(project) == 1); + EXPECT_TRUE(oakengine_project_redo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_footage_count(project) == 1); // Releasing the borrowed handle frees only the wrapper. oakengine_footage_free(f); - assert(oakengine_project_footage_count(project) == 1); + EXPECT_TRUE(oakengine_project_footage_count(project) == 1); oakengine_project_free(project); } @@ -195,52 +196,52 @@ static void test_failures(void) OAK_TEST_SOURCE_DIR); char err[512]; - assert(oakengine_footage_probe(path) == NULL); - assert(oakengine_footage_last_error(err, sizeof(err)) > 0); + EXPECT_TRUE(oakengine_footage_probe(path) == NULL); + EXPECT_TRUE(oakengine_footage_last_error(err, sizeof(err)) > 0); // A non-media file is rejected by the probe. snprintf(path, sizeof(path), "%s/not-media.txt", g_tmpdir); FILE *txt = fopen(path, "w"); - assert(txt != NULL); + EXPECT_TRUE(txt != NULL); fputs("this is not a media file\n", txt); fclose(txt); - assert(oakengine_footage_probe(path) == NULL); - assert(oakengine_footage_last_error(err, sizeof(err)) > 0); + EXPECT_TRUE(oakengine_footage_probe(path) == NULL); + EXPECT_TRUE(oakengine_footage_last_error(err, sizeof(err)) > 0); // Importing a missing file fails with a reason. OakEngineProject *project = oakengine_project_create(); - assert(project != NULL); - assert(oakengine_project_new(project) == OAKENGINE_OK); + EXPECT_TRUE(project != NULL); + EXPECT_TRUE(oakengine_project_new(project) == OAKENGINE_OK); snprintf(path, sizeof(path), "%s/tests/definitely-not-there.mp4", OAK_TEST_SOURCE_DIR); - assert(oakengine_project_import_footage(project, path) == NULL); - assert(oakengine_footage_last_error(err, sizeof(err)) > 0); - assert(oakengine_project_footage_count(project) == 0); - assert(oakengine_project_import_footage(NULL, path) == NULL); + EXPECT_TRUE(oakengine_project_import_footage(project, path) == NULL); + EXPECT_TRUE(oakengine_footage_last_error(err, sizeof(err)) > 0); + EXPECT_TRUE(oakengine_project_footage_count(project) == 0); + EXPECT_TRUE(oakengine_project_import_footage(NULL, path) == NULL); oakengine_project_free(project); // Borrowing nothing yields no handle. - assert(oakengine_footage_borrow(NULL) == NULL); - assert(oakengine_footage_last_error(err, sizeof(err)) > 0); + EXPECT_TRUE(oakengine_footage_borrow(NULL) == NULL); + EXPECT_TRUE(oakengine_footage_last_error(err, sizeof(err)) > 0); // NULL safety. oakengine_footage_free(NULL); - assert(oakengine_footage_get_decoder_name(NULL, err, sizeof(err)) == + EXPECT_TRUE(oakengine_footage_get_decoder_name(NULL, err, sizeof(err)) == OAKENGINE_E_INVALID); - assert(oakengine_footage_get_video_stream_count(NULL) == 0); - assert(oakengine_footage_get_audio_stream_count(NULL) == 0); - assert(oakengine_footage_get_subtitle_stream_count(NULL) == 0); + EXPECT_TRUE(oakengine_footage_get_video_stream_count(NULL) == 0); + EXPECT_TRUE(oakengine_footage_get_audio_stream_count(NULL) == 0); + EXPECT_TRUE(oakengine_footage_get_subtitle_stream_count(NULL) == 0); oak_footage_video_info vi; - assert(oakengine_footage_get_video_stream_info(NULL, 0, &vi) == + EXPECT_TRUE(oakengine_footage_get_video_stream_info(NULL, 0, &vi) == OAKENGINE_E_INVALID); oak_footage_audio_info ai; - assert(oakengine_footage_get_audio_stream_info(NULL, 0, &ai) == + EXPECT_TRUE(oakengine_footage_get_audio_stream_info(NULL, 0, &ai) == OAKENGINE_E_INVALID); double duration = 0.0; - assert(oakengine_footage_get_duration(NULL, &duration) == + EXPECT_TRUE(oakengine_footage_get_duration(NULL, &duration) == OAKENGINE_E_INVALID); - assert(oakengine_footage_is_online(NULL) == OAKENGINE_E_INVALID); - assert(oakengine_footage_get_source_start_time(NULL, NULL, NULL) == + EXPECT_TRUE(oakengine_footage_is_online(NULL) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_footage_get_source_start_time(NULL, NULL, NULL) == OAKENGINE_E_INVALID); } @@ -248,13 +249,13 @@ static void test_failures(void) static void copy_file(const char *src, const char *dst) { FILE *in = fopen(src, "rb"); - assert(in != NULL); + EXPECT_TRUE(in != NULL); FILE *out = fopen(dst, "wb"); - assert(out != NULL); + EXPECT_TRUE(out != NULL); char chunk[65536]; size_t n; while ((n = fread(chunk, 1, sizeof(chunk), in)) > 0) { - assert(fwrite(chunk, 1, n, out) == n); + EXPECT_TRUE(fwrite(chunk, 1, n, out) == n); } fclose(out); fclose(in); @@ -262,11 +263,11 @@ static void copy_file(const char *src, const char *dst) static void test_relink(void) { - assert(oakengine_init(OAKENGINE_INIT_HEADLESS) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_init(OAKENGINE_INIT_HEADLESS) == OAKENGINE_OK); OakEngineProject *project = oakengine_project_create(); - assert(project != NULL); - assert(oakengine_project_new(project) == OAKENGINE_OK); + EXPECT_TRUE(project != NULL); + EXPECT_TRUE(oakengine_project_new(project) == OAKENGINE_OK); char path[4096], img[4096], missing[4096], txt[4096]; demo_path(path, sizeof(path)); @@ -276,46 +277,46 @@ static void test_relink(void) snprintf(txt, sizeof(txt), "%s/not-media.txt", g_tmpdir); { FILE *f = fopen(txt, "w"); - assert(f != NULL); + EXPECT_TRUE(f != NULL); fputs("not media\n", f); fclose(f); } OakEngineFootage *f = oakengine_project_import_footage(project, path); - assert(f != NULL); + EXPECT_TRUE(f != NULL); // Missing target, non-media target, probe handles, NULL. - assert(oakengine_footage_relink(f, missing) == OAKENGINE_E_NOT_FOUND); - assert(oakengine_footage_relink(f, txt) == OAKENGINE_E_FAILED); - assert(oakengine_footage_relink(NULL, path) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_footage_relink(f, missing) == OAKENGINE_E_NOT_FOUND); + EXPECT_TRUE(oakengine_footage_relink(f, txt) == OAKENGINE_E_FAILED); + EXPECT_TRUE(oakengine_footage_relink(NULL, path) == OAKENGINE_E_INVALID); OakEngineFootage *probed = oakengine_footage_probe(path); - assert(probed != NULL); - assert(oakengine_footage_relink(probed, img) == OAKENGINE_E_INVALID); + EXPECT_TRUE(probed != NULL); + EXPECT_TRUE(oakengine_footage_relink(probed, img) == OAKENGINE_E_INVALID); oakengine_footage_free(probed); // Relink to the same file: still valid, still online. - assert(oakengine_footage_relink(f, path) == OAKENGINE_OK); - assert(oakengine_footage_is_online(f) == 1); - assert(oakengine_footage_get_video_stream_count(f) == 1); + EXPECT_TRUE(oakengine_footage_relink(f, path) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_footage_is_online(f) == 1); + EXPECT_TRUE(oakengine_footage_get_video_stream_count(f) == 1); // Relink to a still image: decoder/filename update. - assert(oakengine_footage_relink(f, img) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_footage_relink(f, img) == OAKENGINE_OK); char filename[4096]; - assert(oakengine_project_footage_filename(project, 0, filename, + EXPECT_TRUE(oakengine_project_footage_filename(project, 0, filename, sizeof(filename)) > 0); - assert(strcmp(filename, img) == 0); + EXPECT_TRUE(strcmp(filename, img) == 0); char decoder[64]; - assert(oakengine_footage_get_decoder_name(f, decoder, + EXPECT_TRUE(oakengine_footage_get_decoder_name(f, decoder, sizeof(decoder)) > 0); - assert(strlen(decoder) > 0); - assert(oakengine_footage_get_video_stream_count(f) >= 1); - assert(oakengine_footage_is_online(f) == 1); + EXPECT_TRUE(strlen(decoder) > 0); + EXPECT_TRUE(oakengine_footage_get_video_stream_count(f) >= 1); + EXPECT_TRUE(oakengine_footage_is_online(f) == 1); // And back to the demo file. - assert(oakengine_footage_relink(f, path) == OAKENGINE_OK); - assert(oakengine_project_footage_filename(project, 0, filename, + EXPECT_TRUE(oakengine_footage_relink(f, path) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_footage_filename(project, 0, filename, sizeof(filename)) > 0); - assert(strcmp(filename, path) == 0); + EXPECT_TRUE(strcmp(filename, path) == 0); oakengine_footage_free(f); oakengine_project_free(project); @@ -324,8 +325,8 @@ static void test_relink(void) static void test_find_offline(void) { OakEngineProject *project = oakengine_project_create(); - assert(project != NULL); - assert(oakengine_project_new(project) == OAKENGINE_OK); + EXPECT_TRUE(project != NULL); + EXPECT_TRUE(oakengine_project_new(project) == OAKENGINE_OK); // Import a staged copy, then delete it so the footage goes offline. char staged[4096], tests_dir[4096]; @@ -336,25 +337,25 @@ static void test_find_offline(void) copy_file(path, staged); OakEngineFootage *f = oakengine_project_import_footage(project, staged); - assert(f != NULL); - assert(oakengine_project_footage_is_online(project, 0) == 1); - assert(remove(staged) == 0); - assert(oakengine_project_footage_is_online(project, 0) == 0); + EXPECT_TRUE(f != NULL); + EXPECT_TRUE(oakengine_project_footage_is_online(project, 0) == 1); + EXPECT_TRUE(remove(staged) == 0); + EXPECT_TRUE(oakengine_project_footage_is_online(project, 0) == 0); // The search directory has a file with the same name: relinked. - assert(oakengine_project_find_offline_footage(project, tests_dir) == 1); - assert(oakengine_project_footage_is_online(project, 0) == 1); + EXPECT_TRUE(oakengine_project_find_offline_footage(project, tests_dir) == 1); + EXPECT_TRUE(oakengine_project_footage_is_online(project, 0) == 1); char filename[4096]; - assert(oakengine_project_footage_filename(project, 0, filename, + EXPECT_TRUE(oakengine_project_footage_filename(project, 0, filename, sizeof(filename)) > 0); - assert(strcmp(filename, path) == 0); + EXPECT_TRUE(strcmp(filename, path) == 0); // Nothing left to do; a missing search directory is an error. - assert(oakengine_project_find_offline_footage(project, tests_dir) == 0); - assert(oakengine_project_find_offline_footage(project, + EXPECT_TRUE(oakengine_project_find_offline_footage(project, tests_dir) == 0); + EXPECT_TRUE(oakengine_project_find_offline_footage(project, "/definitely/not/here") == OAKENGINE_E_INVALID); - assert(oakengine_project_find_offline_footage(NULL, tests_dir) == + EXPECT_TRUE(oakengine_project_find_offline_footage(NULL, tests_dir) == OAKENGINE_E_INVALID); oakengine_footage_free(f); @@ -364,51 +365,51 @@ static void test_find_offline(void) static void test_proxy(void) { OakEngineProject *project = oakengine_project_create(); - assert(project != NULL); - assert(oakengine_project_new(project) == OAKENGINE_OK); + EXPECT_TRUE(project != NULL); + EXPECT_TRUE(oakengine_project_new(project) == OAKENGINE_OK); char path[4096]; demo_path(path, sizeof(path)); OakEngineFootage *f = oakengine_project_import_footage(project, path); - assert(f != NULL); + EXPECT_TRUE(f != NULL); - assert(oakengine_footage_proxy_get_state(f) == 0); // missing - assert(oakengine_footage_proxy_get_state(NULL) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_footage_proxy_get_state(f) == 0); // missing + EXPECT_TRUE(oakengine_footage_proxy_get_state(NULL) == OAKENGINE_E_INVALID); // Generate synchronously (CPU transcode of the 17 s demo file). - assert(oakengine_footage_proxy_generate(f) == OAKENGINE_OK); - assert(oakengine_footage_proxy_get_state(f) == 2); // ready + EXPECT_TRUE(oakengine_footage_proxy_generate(f) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_footage_proxy_get_state(f) == 2); // ready char proxy_path[4096]; - assert(oakengine_footage_proxy_get_path(f, proxy_path, + EXPECT_TRUE(oakengine_footage_proxy_get_path(f, proxy_path, sizeof(proxy_path)) > 0); FILE *pf = fopen(proxy_path, "rb"); - assert(pf != NULL); + EXPECT_TRUE(pf != NULL); fclose(pf); - assert(oakengine_footage_proxy_is_enabled(f) == 1); + EXPECT_TRUE(oakengine_footage_proxy_is_enabled(f) == 1); // Enable/disable round-trip. - assert(oakengine_footage_proxy_set_enabled(f, 0) == OAKENGINE_OK); - assert(oakengine_footage_proxy_is_enabled(f) == 0); - assert(oakengine_footage_proxy_set_enabled(f, 1) == OAKENGINE_OK); - assert(oakengine_footage_proxy_is_enabled(f) == 1); + EXPECT_TRUE(oakengine_footage_proxy_set_enabled(f, 0) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_footage_proxy_is_enabled(f) == 0); + EXPECT_TRUE(oakengine_footage_proxy_set_enabled(f, 1) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_footage_proxy_is_enabled(f) == 1); // Delete: state and file are gone. - assert(oakengine_footage_proxy_delete(f) == OAKENGINE_OK); - assert(oakengine_footage_proxy_get_state(f) == 0); - assert(fopen(proxy_path, "rb") == NULL); + EXPECT_TRUE(oakengine_footage_proxy_delete(f) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_footage_proxy_get_state(f) == 0); + EXPECT_TRUE(fopen(proxy_path, "rb") == NULL); // Error paths. - assert(oakengine_footage_proxy_generate(NULL) == OAKENGINE_E_INVALID); - assert(oakengine_footage_proxy_delete(NULL) == OAKENGINE_E_INVALID); - assert(oakengine_footage_proxy_set_enabled(NULL, 1) == + EXPECT_TRUE(oakengine_footage_proxy_generate(NULL) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_footage_proxy_delete(NULL) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_footage_proxy_set_enabled(NULL, 1) == OAKENGINE_E_INVALID); - assert(oakengine_footage_proxy_get_path(NULL, proxy_path, + EXPECT_TRUE(oakengine_footage_proxy_get_path(NULL, proxy_path, sizeof(proxy_path)) == OAKENGINE_E_INVALID); - assert(oakengine_footage_proxy_is_enabled(NULL) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_footage_proxy_is_enabled(NULL) == OAKENGINE_E_INVALID); OakEngineFootage *probed = oakengine_footage_probe(path); - assert(probed != NULL); - assert(oakengine_footage_proxy_generate(probed) == OAKENGINE_E_INVALID); + EXPECT_TRUE(probed != NULL); + EXPECT_TRUE(oakengine_footage_proxy_generate(probed) == OAKENGINE_E_INVALID); oakengine_footage_free(probed); oakengine_footage_free(f); @@ -418,137 +419,137 @@ static void test_proxy(void) static void test_stream_overrides(void) { OakEngineProject *project = oakengine_project_create(); - assert(project != NULL); - assert(oakengine_project_new(project) == OAKENGINE_OK); + EXPECT_TRUE(project != NULL); + EXPECT_TRUE(oakengine_project_new(project) == OAKENGINE_OK); char path[4096]; demo_path(path, sizeof(path)); OakEngineFootage *f = oakengine_project_import_footage(project, path); - assert(f != NULL); + EXPECT_TRUE(f != NULL); char cs[128]; int range = -1, interlace = -1, premult = -1; // Defaults from the probe. - assert(oakengine_footage_get_video_stream_overrides( + EXPECT_TRUE(oakengine_footage_get_video_stream_overrides( f, 0, cs, sizeof(cs), &range, &interlace, &premult) == OAKENGINE_OK); - assert(range == 0); // limited - assert(interlace == 0); // progressive - assert(premult == 0); + EXPECT_TRUE(range == 0); // limited + EXPECT_TRUE(interlace == 0); // progressive + EXPECT_TRUE(premult == 0); // Full override write + read-back + undo/redo. - assert(oakengine_footage_set_video_stream_overrides( + EXPECT_TRUE(oakengine_footage_set_video_stream_overrides( f, 0, "Rec.709 OETF", 1, 1, 1) == OAKENGINE_OK); - assert(oakengine_footage_get_video_stream_overrides( + EXPECT_TRUE(oakengine_footage_get_video_stream_overrides( f, 0, cs, sizeof(cs), &range, &interlace, &premult) == OAKENGINE_OK); - assert(strcmp(cs, "Rec.709 OETF") == 0); - assert(range == 1 && interlace == 1 && premult == 1); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_footage_get_video_stream_overrides( + EXPECT_TRUE(strcmp(cs, "Rec.709 OETF") == 0); + EXPECT_TRUE(range == 1 && interlace == 1 && premult == 1); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_footage_get_video_stream_overrides( f, 0, cs, sizeof(cs), &range, &interlace, &premult) == OAKENGINE_OK); - assert(range == 0 && interlace == 0 && premult == 0); - assert(oakengine_project_redo(project) == OAKENGINE_OK); - assert(oakengine_footage_get_video_stream_overrides( + EXPECT_TRUE(range == 0 && interlace == 0 && premult == 0); + EXPECT_TRUE(oakengine_project_redo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_footage_get_video_stream_overrides( f, 0, cs, sizeof(cs), &range, &interlace, &premult) == OAKENGINE_OK); - assert(range == 1 && interlace == 1 && premult == 1); + EXPECT_TRUE(range == 1 && interlace == 1 && premult == 1); // Partial write: NULL/-1 leaves fields alone. - assert(oakengine_footage_set_video_stream_overrides(f, 0, NULL, 0, -1, + EXPECT_TRUE(oakengine_footage_set_video_stream_overrides(f, 0, NULL, 0, -1, -1) == OAKENGINE_OK); - assert(oakengine_footage_get_video_stream_overrides( + EXPECT_TRUE(oakengine_footage_get_video_stream_overrides( f, 0, cs, sizeof(cs), &range, &interlace, &premult) == OAKENGINE_OK); - assert(range == 0 && interlace == 1 && premult == 1); + EXPECT_TRUE(range == 0 && interlace == 1 && premult == 1); // Pixel aspect ratio. int num = 0, den = 0; - assert(oakengine_footage_get_pixel_aspect(f, 0, &num, &den) == + EXPECT_TRUE(oakengine_footage_get_pixel_aspect(f, 0, &num, &den) == OAKENGINE_OK); - assert(num == 1 && den == 1); - assert(oakengine_footage_set_pixel_aspect(f, 0, 4, 3) == OAKENGINE_OK); - assert(oakengine_footage_get_pixel_aspect(f, 0, &num, &den) == + EXPECT_TRUE(num == 1 && den == 1); + EXPECT_TRUE(oakengine_footage_set_pixel_aspect(f, 0, 4, 3) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_footage_get_pixel_aspect(f, 0, &num, &den) == OAKENGINE_OK); - assert(num == 4 && den == 3); - assert(oakengine_footage_set_pixel_aspect(f, 0, 0, 3) == + EXPECT_TRUE(num == 4 && den == 3); + EXPECT_TRUE(oakengine_footage_set_pixel_aspect(f, 0, 0, 3) == OAKENGINE_E_INVALID); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_footage_get_pixel_aspect(f, 0, &num, &den) == + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_footage_get_pixel_aspect(f, 0, &num, &den) == OAKENGINE_OK); - assert(num == 1 && den == 1); + EXPECT_TRUE(num == 1 && den == 1); // Image-sequence parameters round-trip (stored even for non-sequence // footage; the dialog shows them only for image sequences). int64_t start = -1, dur = -1; - assert(oakengine_footage_get_image_sequence_params(f, 0, &start, &dur, + EXPECT_TRUE(oakengine_footage_get_image_sequence_params(f, 0, &start, &dur, &num, &den) == OAKENGINE_OK); - assert(oakengine_footage_set_image_sequence_params(f, 0, 10, 100, 25, + EXPECT_TRUE(oakengine_footage_set_image_sequence_params(f, 0, 10, 100, 25, 1) == OAKENGINE_OK); - assert(oakengine_footage_get_image_sequence_params(f, 0, &start, &dur, + EXPECT_TRUE(oakengine_footage_get_image_sequence_params(f, 0, &start, &dur, &num, &den) == OAKENGINE_OK); - assert(start == 10 && dur == 100 && num == 25 && den == 1); - assert(oakengine_footage_set_image_sequence_params(f, 0, 0, 0, 25, 1) == + EXPECT_TRUE(start == 10 && dur == 100 && num == 25 && den == 1); + EXPECT_TRUE(oakengine_footage_set_image_sequence_params(f, 0, 0, 0, 25, 1) == OAKENGINE_E_INVALID); - assert(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); // Stream enable toggles. - assert(oakengine_footage_get_stream_enabled(f, 0, 0) == 1); - assert(oakengine_footage_set_stream_enabled(f, 0, 0, 0) == OAKENGINE_OK); - assert(oakengine_footage_get_stream_enabled(f, 0, 0) == 0); - assert(oakengine_footage_set_stream_enabled(f, 0, 0, 1) == OAKENGINE_OK); - assert(oakengine_footage_get_stream_enabled(f, 0, 0) == 1); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_footage_get_stream_enabled(f, 0, 0) == 0); - assert(oakengine_footage_get_stream_enabled(f, 1, 0) == 1); - assert(oakengine_footage_get_stream_enabled(f, 0, 99) == + EXPECT_TRUE(oakengine_footage_get_stream_enabled(f, 0, 0) == 1); + EXPECT_TRUE(oakengine_footage_set_stream_enabled(f, 0, 0, 0) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_footage_get_stream_enabled(f, 0, 0) == 0); + EXPECT_TRUE(oakengine_footage_set_stream_enabled(f, 0, 0, 1) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_footage_get_stream_enabled(f, 0, 0) == 1); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_footage_get_stream_enabled(f, 0, 0) == 0); + EXPECT_TRUE(oakengine_footage_get_stream_enabled(f, 1, 0) == 1); + EXPECT_TRUE(oakengine_footage_get_stream_enabled(f, 0, 99) == OAKENGINE_E_NOT_FOUND); - assert(oakengine_footage_set_stream_enabled(f, 9, 0, 1) == + EXPECT_TRUE(oakengine_footage_set_stream_enabled(f, 9, 0, 1) == OAKENGINE_E_INVALID); // Source start time set/clear with source label. int snum = 0, sden = 0; - assert(oakengine_footage_get_source_start_time(f, &snum, &sden) == 1); + EXPECT_TRUE(oakengine_footage_get_source_start_time(f, &snum, &sden) == 1); char source[64]; - assert(oakengine_footage_set_source_start_time(f, 1, 42, 1) == + EXPECT_TRUE(oakengine_footage_set_source_start_time(f, 1, 42, 1) == OAKENGINE_OK); - assert(oakengine_footage_get_source_start_time(f, &snum, &sden) == 1); - assert(snum == 42 && sden == 1); - assert(oakengine_footage_get_source_start_time_source(f, source, + EXPECT_TRUE(oakengine_footage_get_source_start_time(f, &snum, &sden) == 1); + EXPECT_TRUE(snum == 42 && sden == 1); + EXPECT_TRUE(oakengine_footage_get_source_start_time_source(f, source, sizeof(source)) > 0); - assert(strcmp(source, "manual") == 0); - assert(oakengine_footage_set_source_start_time(f, 0, 0, 1) == + EXPECT_TRUE(strcmp(source, "manual") == 0); + EXPECT_TRUE(oakengine_footage_set_source_start_time(f, 0, 0, 1) == OAKENGINE_OK); - assert(oakengine_footage_get_source_start_time(f, &snum, &sden) == 0); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_footage_get_source_start_time(f, &snum, &sden) == 1); - assert(snum == 42); + EXPECT_TRUE(oakengine_footage_get_source_start_time(f, &snum, &sden) == 0); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_footage_get_source_start_time(f, &snum, &sden) == 1); + EXPECT_TRUE(snum == 42); // Out-of-range and NULL. - assert(oakengine_footage_get_video_stream_overrides( + EXPECT_TRUE(oakengine_footage_get_video_stream_overrides( f, 9, cs, sizeof(cs), &range, &interlace, &premult) == OAKENGINE_E_NOT_FOUND); - assert(oakengine_footage_set_video_stream_overrides(f, 9, "x", 0, 0, + EXPECT_TRUE(oakengine_footage_set_video_stream_overrides(f, 9, "x", 0, 0, 0) == OAKENGINE_E_NOT_FOUND); - assert(oakengine_footage_get_pixel_aspect(f, 9, &num, &den) == + EXPECT_TRUE(oakengine_footage_get_pixel_aspect(f, 9, &num, &den) == OAKENGINE_E_NOT_FOUND); - assert(oakengine_footage_get_image_sequence_params(f, 9, &start, &dur, + EXPECT_TRUE(oakengine_footage_get_image_sequence_params(f, 9, &start, &dur, &num, &den) == OAKENGINE_E_NOT_FOUND); - assert(oakengine_footage_get_video_stream_overrides( + EXPECT_TRUE(oakengine_footage_get_video_stream_overrides( NULL, 0, cs, sizeof(cs), &range, &interlace, &premult) == OAKENGINE_E_INVALID); OakEngineFootage *probed = oakengine_footage_probe(path); - assert(probed != NULL); - assert(oakengine_footage_set_video_stream_overrides(probed, 0, "x", 0, + EXPECT_TRUE(probed != NULL); + EXPECT_TRUE(oakengine_footage_set_video_stream_overrides(probed, 0, "x", 0, 0, 0) == OAKENGINE_E_INVALID); - assert(oakengine_footage_colorspace_count(probed) == 0); + EXPECT_TRUE(oakengine_footage_colorspace_count(probed) == 0); oakengine_footage_free(probed); oakengine_footage_free(f); @@ -558,33 +559,33 @@ static void test_stream_overrides(void) static void test_colorspace_candidates(void) { OakEngineProject *project = oakengine_project_create(); - assert(project != NULL); - assert(oakengine_project_new(project) == OAKENGINE_OK); + EXPECT_TRUE(project != NULL); + EXPECT_TRUE(oakengine_project_new(project) == OAKENGINE_OK); char path[4096]; demo_path(path, sizeof(path)); OakEngineFootage *f = oakengine_project_import_footage(project, path); - assert(f != NULL); + EXPECT_TRUE(f != NULL); const int count = oakengine_footage_colorspace_count(f); - assert(count > 0); + EXPECT_TRUE(count > 0); char name[128]; int found_rec709 = 0; for (int i = 0; i < count; i++) { - assert(oakengine_footage_colorspace_at(f, i, name, sizeof(name)) > 0); - assert(strlen(name) > 0); + EXPECT_TRUE(oakengine_footage_colorspace_at(f, i, name, sizeof(name)) > 0); + EXPECT_TRUE(strlen(name) > 0); if (strcmp(name, "Rec.709 OETF") == 0) { found_rec709 = 1; } } - assert(found_rec709 == 1); - assert(oakengine_footage_colorspace_at(f, count, name, sizeof(name)) == + EXPECT_TRUE(found_rec709 == 1); + EXPECT_TRUE(oakengine_footage_colorspace_at(f, count, name, sizeof(name)) == OAKENGINE_E_NOT_FOUND); - assert(oakengine_footage_colorspace_at(f, -1, name, sizeof(name)) == + EXPECT_TRUE(oakengine_footage_colorspace_at(f, -1, name, sizeof(name)) == OAKENGINE_E_NOT_FOUND); - assert(oakengine_footage_colorspace_at(NULL, 0, name, sizeof(name)) == + EXPECT_TRUE(oakengine_footage_colorspace_at(NULL, 0, name, sizeof(name)) == OAKENGINE_E_INVALID); - assert(oakengine_footage_colorspace_count(NULL) == 0); + EXPECT_TRUE(oakengine_footage_colorspace_count(NULL) == 0); oakengine_footage_free(f); oakengine_project_free(project); @@ -594,75 +595,75 @@ static void test_colorspace_candidates(void) static void test_project_extras(void) { OakEngineProject *project = oakengine_project_create(); - assert(project != NULL); - assert(oakengine_project_new(project) == OAKENGINE_OK); + EXPECT_TRUE(project != NULL); + EXPECT_TRUE(oakengine_project_new(project) == OAKENGINE_OK); char buf[4096]; // Untitled project: pretty filename is the "(untitled)" placeholder. - assert(oakengine_project_pretty_filename(project, buf, sizeof(buf)) > 0); - assert(strlen(buf) > 0); + EXPECT_TRUE(oakengine_project_pretty_filename(project, buf, sizeof(buf)) > 0); + EXPECT_TRUE(strlen(buf) > 0); // set_filename round-trips through the plain filename getter. char target[4096]; snprintf(target, sizeof(target), "%s/roundtrip.ove", g_tmpdir); - assert(oakengine_project_set_filename(project, target) == OAKENGINE_OK); - assert(oakengine_project_filename(project, buf, sizeof(buf)) > 0); - assert(strcmp(buf, target) == 0); - assert(oakengine_project_set_filename(project, NULL) == + EXPECT_TRUE(oakengine_project_set_filename(project, target) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_filename(project, buf, sizeof(buf)) > 0); + EXPECT_TRUE(strcmp(buf, target) == 0); + EXPECT_TRUE(oakengine_project_set_filename(project, NULL) == OAKENGINE_E_INVALID); - assert(oakengine_project_set_filename(NULL, target) == + EXPECT_TRUE(oakengine_project_set_filename(NULL, target) == OAKENGINE_E_INVALID); // With a filename set, the cache paths are derivable and non-empty. - assert(oakengine_project_cache_path(project, buf, sizeof(buf)) > 0); - assert(strlen(buf) > 0); - assert(oakengine_project_cache_alongside_path(project, buf, sizeof(buf)) > + EXPECT_TRUE(oakengine_project_cache_path(project, buf, sizeof(buf)) > 0); + EXPECT_TRUE(strlen(buf) > 0); + EXPECT_TRUE(oakengine_project_cache_alongside_path(project, buf, sizeof(buf)) > 0); - assert(strlen(buf) > 0); + EXPECT_TRUE(strlen(buf) > 0); // Custom cache path setting round-trip (NULL clears). - assert(oakengine_project_set_custom_cache_path(project, "/tmp/oakcache") == + EXPECT_TRUE(oakengine_project_set_custom_cache_path(project, "/tmp/oakcache") == OAKENGINE_OK); - assert(oakengine_project_get_custom_cache_path(project, buf, + EXPECT_TRUE(oakengine_project_get_custom_cache_path(project, buf, sizeof(buf)) > 0); - assert(strcmp(buf, "/tmp/oakcache") == 0); - assert(oakengine_project_set_custom_cache_path(project, NULL) == + EXPECT_TRUE(strcmp(buf, "/tmp/oakcache") == 0); + EXPECT_TRUE(oakengine_project_set_custom_cache_path(project, NULL) == OAKENGINE_OK); - assert(oakengine_project_get_custom_cache_path(project, buf, + EXPECT_TRUE(oakengine_project_get_custom_cache_path(project, buf, sizeof(buf)) == 0); // Color reference space setting round-trip. - assert(oakengine_project_set_color_reference_space( + EXPECT_TRUE(oakengine_project_set_color_reference_space( project, "Rec.709 OETF") == OAKENGINE_OK); - assert(oakengine_project_get_color_reference_space(project, buf, + EXPECT_TRUE(oakengine_project_get_color_reference_space(project, buf, sizeof(buf)) > 0); - assert(strcmp(buf, "Rec.709 OETF") == 0); - assert(oakengine_project_set_color_reference_space(NULL, "x") == + EXPECT_TRUE(strcmp(buf, "Rec.709 OETF") == 0); + EXPECT_TRUE(oakengine_project_set_color_reference_space(NULL, "x") == OAKENGINE_E_INVALID); // Cache location setting defaults to a valid enum value; NULL is invalid. - assert(oakengine_project_get_cache_location_setting(project) >= 0); - assert(oakengine_project_get_cache_location_setting(NULL) < 0); + EXPECT_TRUE(oakengine_project_get_cache_location_setting(project) >= 0); + EXPECT_TRUE(oakengine_project_get_cache_location_setting(NULL) < 0); // The project item MIME type is a non-empty static string. const char *mime = oakengine_project_item_mime_type(); - assert(mime != NULL && strlen(mime) > 0); + EXPECT_TRUE(mime != NULL && strlen(mime) > 0); // from_object: the root node resolves back to its owning project. OakEngineNode *root = oakengine_project_node_at(project, 0); - assert(root != NULL); - assert(oakengine_project_from_object(root) == project); - assert(oakengine_project_from_object(NULL) == NULL); + EXPECT_TRUE(root != NULL); + EXPECT_TRUE(oakengine_project_from_object(root) == project); + EXPECT_TRUE(oakengine_project_from_object(NULL) == NULL); // NULL safety. - assert(oakengine_project_pretty_filename(NULL, buf, sizeof(buf)) == + EXPECT_TRUE(oakengine_project_pretty_filename(NULL, buf, sizeof(buf)) == OAKENGINE_E_INVALID); - assert(oakengine_project_cache_path(NULL, buf, sizeof(buf)) == + EXPECT_TRUE(oakengine_project_cache_path(NULL, buf, sizeof(buf)) == OAKENGINE_E_INVALID); - assert(oakengine_project_get_custom_cache_path(NULL, buf, sizeof(buf)) == + EXPECT_TRUE(oakengine_project_get_custom_cache_path(NULL, buf, sizeof(buf)) == OAKENGINE_E_INVALID); - assert(oakengine_project_get_color_reference_space(NULL, buf, + EXPECT_TRUE(oakengine_project_get_color_reference_space(NULL, buf, sizeof(buf)) == OAKENGINE_E_INVALID); @@ -673,74 +674,74 @@ static void test_project_extras(void) static void test_folder(void) { OakEngineProject *project = oakengine_project_create(); - assert(project != NULL); - assert(oakengine_project_new(project) == OAKENGINE_OK); + EXPECT_TRUE(project != NULL); + EXPECT_TRUE(oakengine_project_new(project) == OAKENGINE_OK); // A fresh project's first node is its root folder. OakEngineNode *root = oakengine_project_node_at(project, 0); - assert(root != NULL); + EXPECT_TRUE(root != NULL); OakEngineNode *folder = oakengine_folder_create(project, root, "My Folder"); - assert(folder != NULL); - assert(oakengine_folder_has_child_recursive(root, folder) == 1); - assert(oakengine_folder_index_of_child(root, folder) >= 0); + EXPECT_TRUE(folder != NULL); + EXPECT_TRUE(oakengine_folder_has_child_recursive(root, folder) == 1); + EXPECT_TRUE(oakengine_folder_index_of_child(root, folder) >= 0); // A subfolder is found recursively from the root. OakEngineNode *sub = oakengine_folder_create(project, folder, "Sub"); - assert(sub != NULL); - assert(oakengine_folder_has_child_recursive(root, sub) == 1); - assert(oakengine_folder_has_child_recursive(folder, sub) == 1); - assert(oakengine_folder_has_child_recursive(sub, folder) == 0); + EXPECT_TRUE(sub != NULL); + EXPECT_TRUE(oakengine_folder_has_child_recursive(root, sub) == 1); + EXPECT_TRUE(oakengine_folder_has_child_recursive(folder, sub) == 1); + EXPECT_TRUE(oakengine_folder_has_child_recursive(sub, folder) == 0); // A folder from another project is not a child here. OakEngineProject *other = oakengine_project_create(); - assert(other != NULL); - assert(oakengine_project_new(other) == OAKENGINE_OK); + EXPECT_TRUE(other != NULL); + EXPECT_TRUE(oakengine_project_new(other) == OAKENGINE_OK); OakEngineNode *other_root = oakengine_project_node_at(other, 0); - assert(other_root != NULL); + EXPECT_TRUE(other_root != NULL); OakEngineNode *alien = oakengine_folder_create(other, other_root, "Alien"); - assert(alien != NULL); - assert(oakengine_folder_has_child_recursive(root, alien) == 0); - assert(oakengine_folder_index_of_child(root, alien) == + EXPECT_TRUE(alien != NULL); + EXPECT_TRUE(oakengine_folder_has_child_recursive(root, alien) == 0); + EXPECT_TRUE(oakengine_folder_index_of_child(root, alien) == OAKENGINE_E_NOT_FOUND); oakengine_project_free(other); // The child input key is a non-empty static string. const char *key = oakengine_folder_child_input_key(); - assert(key != NULL && strlen(key) > 0); + EXPECT_TRUE(key != NULL && strlen(key) > 0); // Error paths: non-folder parents, non-folder queries, NULL. - assert(oakengine_folder_create(project, folder, NULL) != NULL); + EXPECT_TRUE(oakengine_folder_create(project, folder, NULL) != NULL); OakEngineNode *footage_node = NULL; { char path[4096]; demo_path(path, sizeof(path)); OakEngineFootage *f = oakengine_project_import_footage(project, path); - assert(f != NULL); + EXPECT_TRUE(f != NULL); oakengine_footage_free(f); // The imported footage is a non-folder project node. for (int i = 0; i < oakengine_project_node_count(project); i++) { OakEngineNode *n = oakengine_project_node_at(project, i); char id[128]; - assert(oakengine_node_get_type_id(n, id, sizeof(id)) > 0); + EXPECT_TRUE(oakengine_node_get_type_id(n, id, sizeof(id)) > 0); if (strcmp(id, "org.olivevideoeditor.Olive.folder") != 0) { footage_node = n; break; } } - assert(footage_node != NULL); + EXPECT_TRUE(footage_node != NULL); } - assert(oakengine_folder_create(project, footage_node, "Nope") == NULL); - assert(oakengine_folder_has_child_recursive(footage_node, folder) == 0); - assert(oakengine_folder_index_of_child(footage_node, folder) == + EXPECT_TRUE(oakengine_folder_create(project, footage_node, "Nope") == NULL); + EXPECT_TRUE(oakengine_folder_has_child_recursive(footage_node, folder) == 0); + EXPECT_TRUE(oakengine_folder_index_of_child(footage_node, folder) == OAKENGINE_E_INVALID); - assert(oakengine_folder_has_child_recursive(NULL, folder) == 0); - assert(oakengine_folder_has_child_recursive(root, NULL) == 0); - assert(oakengine_folder_index_of_child(NULL, folder) == + EXPECT_TRUE(oakengine_folder_has_child_recursive(NULL, folder) == 0); + EXPECT_TRUE(oakengine_folder_has_child_recursive(root, NULL) == 0); + EXPECT_TRUE(oakengine_folder_index_of_child(NULL, folder) == OAKENGINE_E_INVALID); - assert(oakengine_folder_index_of_child(root, NULL) == OAKENGINE_E_INVALID); - assert(oakengine_folder_create(NULL, root, "Nope") == NULL); + EXPECT_TRUE(oakengine_folder_index_of_child(root, NULL) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_folder_create(NULL, root, "Nope") == NULL); oakengine_project_free(project); } @@ -750,67 +751,67 @@ static void test_folder(void) static void test_footage_extras(void) { OakEngineProject *project = oakengine_project_create(); - assert(project != NULL); - assert(oakengine_project_new(project) == OAKENGINE_OK); + EXPECT_TRUE(project != NULL); + EXPECT_TRUE(oakengine_project_new(project) == OAKENGINE_OK); char path[4096]; demo_path(path, sizeof(path)); OakEngineFootage *f = oakengine_project_import_footage(project, path); - assert(f != NULL); + EXPECT_TRUE(f != NULL); char buf[4096]; // Filename of the imported footage. - assert(oakengine_footage_get_filename(f, buf, sizeof(buf)) > 0); - assert(strcmp(buf, path) == 0); - assert(oakengine_footage_get_filename(NULL, buf, sizeof(buf)) == + EXPECT_TRUE(oakengine_footage_get_filename(f, buf, sizeof(buf)) > 0); + EXPECT_TRUE(strcmp(buf, path) == 0); + EXPECT_TRUE(oakengine_footage_get_filename(NULL, buf, sizeof(buf)) == OAKENGINE_E_INVALID); // Real stream index 0 is the video stream, 1 the audio stream. int track_type = -1, stream_index = -1; - assert(oakengine_footage_get_stream_reference(f, 0, &track_type, + EXPECT_TRUE(oakengine_footage_get_stream_reference(f, 0, &track_type, &stream_index) == OAKENGINE_OK); - assert(track_type == OAKENGINE_TRACK_TYPE_VIDEO && stream_index == 0); - assert(oakengine_footage_get_stream_reference(f, 1, &track_type, + EXPECT_TRUE(track_type == OAKENGINE_TRACK_TYPE_VIDEO && stream_index == 0); + EXPECT_TRUE(oakengine_footage_get_stream_reference(f, 1, &track_type, &stream_index) == OAKENGINE_OK); - assert(track_type == OAKENGINE_TRACK_TYPE_AUDIO && stream_index == 0); - assert(oakengine_footage_get_stream_reference(f, 99, &track_type, + EXPECT_TRUE(track_type == OAKENGINE_TRACK_TYPE_AUDIO && stream_index == 0); + EXPECT_TRUE(oakengine_footage_get_stream_reference(f, 99, &track_type, &stream_index) == OAKENGINE_E_NOT_FOUND); - assert(oakengine_footage_get_stream_reference(NULL, 0, &track_type, + EXPECT_TRUE(oakengine_footage_get_stream_reference(NULL, 0, &track_type, &stream_index) == OAKENGINE_E_INVALID); // Stream descriptions. - assert(oakengine_footage_describe_video_stream(f, 0, buf, sizeof(buf)) > + EXPECT_TRUE(oakengine_footage_describe_video_stream(f, 0, buf, sizeof(buf)) > 0); - assert(strlen(buf) > 0); - assert(oakengine_footage_describe_audio_stream(f, 0, buf, sizeof(buf)) > + EXPECT_TRUE(strlen(buf) > 0); + EXPECT_TRUE(oakengine_footage_describe_audio_stream(f, 0, buf, sizeof(buf)) > 0); - assert(strlen(buf) > 0); - assert(oakengine_footage_describe_video_stream(f, 9, buf, sizeof(buf)) == + EXPECT_TRUE(strlen(buf) > 0); + EXPECT_TRUE(oakengine_footage_describe_video_stream(f, 9, buf, sizeof(buf)) == OAKENGINE_E_NOT_FOUND); - assert(oakengine_footage_describe_audio_stream(f, 9, buf, sizeof(buf)) == + EXPECT_TRUE(oakengine_footage_describe_audio_stream(f, 9, buf, sizeof(buf)) == OAKENGINE_E_NOT_FOUND); - assert(oakengine_footage_describe_video_stream(NULL, 0, buf, + EXPECT_TRUE(oakengine_footage_describe_video_stream(NULL, 0, buf, sizeof(buf)) == OAKENGINE_E_INVALID); // Static stream type names (no handle needed). - assert(oakengine_footage_stream_type_name(OAKENGINE_TRACK_TYPE_VIDEO, buf, + EXPECT_TRUE(oakengine_footage_stream_type_name(OAKENGINE_TRACK_TYPE_VIDEO, buf, sizeof(buf)) > 0); - assert(strlen(buf) > 0); - assert(oakengine_footage_stream_type_name(OAKENGINE_TRACK_TYPE_AUDIO, buf, + EXPECT_TRUE(strlen(buf) > 0); + EXPECT_TRUE(oakengine_footage_stream_type_name(OAKENGINE_TRACK_TYPE_AUDIO, buf, sizeof(buf)) > 0); - assert(strlen(buf) > 0); + EXPECT_TRUE(strlen(buf) > 0); // Proxy params: effective defaults first, then a custom round-trip. - assert(oakengine_footage_has_custom_proxy_params(f) == 0); + EXPECT_TRUE(oakengine_footage_has_custom_proxy_params(f) == 0); oak_proxy_params params; memset(¶ms, 0, sizeof(params)); - assert(oakengine_footage_get_effective_proxy_params(f, ¶ms) == + EXPECT_TRUE(oakengine_footage_get_effective_proxy_params(f, ¶ms) == OAKENGINE_OK); - assert(params.width > 0 && params.height > 0); + EXPECT_TRUE(params.width > 0 && params.height > 0); params.width = 640; params.height = 360; params.divider = 1; @@ -819,77 +820,77 @@ static void test_footage_extras(void) params.include_audio = 0; strcpy(params.extension, "mkv"); strcpy(params.preset, "slow"); - assert(oakengine_footage_set_custom_proxy_params(f, ¶ms) == + EXPECT_TRUE(oakengine_footage_set_custom_proxy_params(f, ¶ms) == OAKENGINE_OK); - assert(oakengine_footage_has_custom_proxy_params(f) == 1); + EXPECT_TRUE(oakengine_footage_has_custom_proxy_params(f) == 1); oak_proxy_params back; memset(&back, 0, sizeof(back)); - assert(oakengine_footage_get_effective_proxy_params(f, &back) == + EXPECT_TRUE(oakengine_footage_get_effective_proxy_params(f, &back) == OAKENGINE_OK); - assert(back.width == 640 && back.height == 360 && back.crf == 30); - assert(back.include_audio == 0); - assert(strcmp(back.extension, "mkv") == 0); - assert(strcmp(back.preset, "slow") == 0); - assert(oakengine_footage_clear_custom_proxy_params(f) == OAKENGINE_OK); - assert(oakengine_footage_has_custom_proxy_params(f) == 0); - assert(oakengine_footage_set_custom_proxy_params(f, NULL) == + EXPECT_TRUE(back.width == 640 && back.height == 360 && back.crf == 30); + EXPECT_TRUE(back.include_audio == 0); + EXPECT_TRUE(strcmp(back.extension, "mkv") == 0); + EXPECT_TRUE(strcmp(back.preset, "slow") == 0); + EXPECT_TRUE(oakengine_footage_clear_custom_proxy_params(f) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_footage_has_custom_proxy_params(f) == 0); + EXPECT_TRUE(oakengine_footage_set_custom_proxy_params(f, NULL) == OAKENGINE_E_INVALID); - assert(oakengine_footage_get_effective_proxy_params(f, NULL) == + EXPECT_TRUE(oakengine_footage_get_effective_proxy_params(f, NULL) == OAKENGINE_E_INVALID); - assert(oakengine_footage_has_custom_proxy_params(NULL) == + EXPECT_TRUE(oakengine_footage_has_custom_proxy_params(NULL) == OAKENGINE_E_INVALID); // Manual proxy state: set then clear (no file is created here). - assert(oakengine_footage_set_proxy(f, "/tmp/fake_proxy.mp4", 2, 0, 1, + EXPECT_TRUE(oakengine_footage_set_proxy(f, "/tmp/fake_proxy.mp4", 2, 0, 1, 1) == OAKENGINE_OK); - assert(oakengine_footage_proxy_get_state(f) == 2); - assert(oakengine_footage_proxy_get_path(f, buf, sizeof(buf)) > 0); - assert(strcmp(buf, "/tmp/fake_proxy.mp4") == 0); - assert(oakengine_footage_proxy_is_enabled(f) == 1); - assert(oakengine_footage_clear_proxy(f) == OAKENGINE_OK); - assert(oakengine_footage_proxy_get_state(f) == 0); - assert(oakengine_footage_proxy_get_path(f, buf, sizeof(buf)) == 0); - assert(oakengine_footage_set_proxy(NULL, "x", 2, 0, 1, 1) == + EXPECT_TRUE(oakengine_footage_proxy_get_state(f) == 2); + EXPECT_TRUE(oakengine_footage_proxy_get_path(f, buf, sizeof(buf)) > 0); + EXPECT_TRUE(strcmp(buf, "/tmp/fake_proxy.mp4") == 0); + EXPECT_TRUE(oakengine_footage_proxy_is_enabled(f) == 1); + EXPECT_TRUE(oakengine_footage_clear_proxy(f) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_footage_proxy_get_state(f) == 0); + EXPECT_TRUE(oakengine_footage_proxy_get_path(f, buf, sizeof(buf)) == 0); + EXPECT_TRUE(oakengine_footage_set_proxy(NULL, "x", 2, 0, 1, 1) == OAKENGINE_E_INVALID); - assert(oakengine_footage_clear_proxy(NULL) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_footage_clear_proxy(NULL) == OAKENGINE_E_INVALID); // Cache invalidation after proxy/relink changes. - assert(oakengine_footage_invalidate(f) == OAKENGINE_OK); - assert(oakengine_footage_invalidate(NULL) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_footage_invalidate(f) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_footage_invalidate(NULL) == OAKENGINE_E_INVALID); // Probe handles carry no project node: the whole section rejects them. OakEngineFootage *probed = oakengine_footage_probe(path); - assert(probed != NULL); - assert(oakengine_footage_get_filename(probed, buf, sizeof(buf)) == + EXPECT_TRUE(probed != NULL); + EXPECT_TRUE(oakengine_footage_get_filename(probed, buf, sizeof(buf)) == OAKENGINE_E_INVALID); - assert(oakengine_footage_get_stream_reference(probed, 0, &track_type, + EXPECT_TRUE(oakengine_footage_get_stream_reference(probed, 0, &track_type, &stream_index) == OAKENGINE_E_INVALID); - assert(oakengine_footage_describe_video_stream(probed, 0, buf, + EXPECT_TRUE(oakengine_footage_describe_video_stream(probed, 0, buf, sizeof(buf)) == OAKENGINE_E_INVALID); - assert(oakengine_footage_get_effective_proxy_params(probed, ¶ms) == + EXPECT_TRUE(oakengine_footage_get_effective_proxy_params(probed, ¶ms) == OAKENGINE_E_INVALID); - assert(oakengine_footage_invalidate(probed) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_footage_invalidate(probed) == OAKENGINE_E_INVALID); oakengine_footage_free(probed); oakengine_footage_free(f); oakengine_project_free(project); } -int main(void) +TEST(OakEngineFootage, Main) { make_tmpdir(); // Sandbox the config/cache/data locations (see oakengine_init_test); // the probe metadata cache then lives in the temp dir. #if !defined(_WIN32) - assert(setenv("XDG_CONFIG_HOME", g_tmpdir, 1) == 0); - assert(setenv("XDG_CACHE_HOME", g_tmpdir, 1) == 0); - assert(setenv("XDG_DATA_HOME", g_tmpdir, 1) == 0); + EXPECT_TRUE(setenv("XDG_CONFIG_HOME", g_tmpdir, 1) == 0); + EXPECT_TRUE(setenv("XDG_CACHE_HOME", g_tmpdir, 1) == 0); + EXPECT_TRUE(setenv("XDG_DATA_HOME", g_tmpdir, 1) == 0); #endif - assert(oakengine_init(OAKENGINE_INIT_HEADLESS) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_init(OAKENGINE_INIT_HEADLESS) == OAKENGINE_OK); test_probe(); test_import(); @@ -903,8 +904,6 @@ int main(void) test_folder(); test_footage_extras(); - assert(oakengine_shutdown() == OAKENGINE_OK); + EXPECT_TRUE(oakengine_shutdown() == OAKENGINE_OK); - printf("oakengine_footage_test: all assertions passed\n"); - return 0; } diff --git a/engine/tests/oakengine_init_test.cpp b/engine/tests/oakengine_init_test.cpp index bebcc2b55..10fe1abe5 100644 --- a/engine/tests/oakengine_init_test.cpp +++ b/engine/tests/oakengine_init_test.cpp @@ -26,6 +26,7 @@ // QCoreApplication itself when needed. #include +#include #include #include #include @@ -53,20 +54,20 @@ static void make_tmpdir(void) #if defined(_WIN32) char base[MAX_PATH]; const DWORD len = GetTempPathA(MAX_PATH, base); - assert(len > 0 && len < MAX_PATH); + EXPECT_TRUE(len > 0 && len < MAX_PATH); snprintf(g_tmpdir, sizeof(g_tmpdir), "%soakengine_init_test_%lu", base, (unsigned long)GetCurrentProcessId()); - assert(_mkdir(g_tmpdir) == 0); + EXPECT_TRUE(_mkdir(g_tmpdir) == 0); #else strcpy(g_tmpdir, "/tmp/oakengine_init_test_XXXXXX"); - assert(mkdtemp(g_tmpdir) != NULL); + EXPECT_TRUE(mkdtemp(g_tmpdir) != NULL); #endif } static void make_path(char *dst, size_t cap, const char *filename) { const int n = snprintf(dst, cap, "%s/%s", g_tmpdir, filename); - assert(n > 0 && (size_t)n < cap); + EXPECT_TRUE(n > 0 && (size_t)n < cap); } static int file_exists(const char *path) @@ -81,58 +82,58 @@ static int file_exists(const char *path) static void test_init(void) { - assert(oakengine_init(0) == OAKENGINE_E_INVALID); - assert(oakengine_init(4) == OAKENGINE_E_INVALID); // unknown bit + EXPECT_TRUE(oakengine_init(0) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_init(4) == OAKENGINE_E_INVALID); // unknown bit - assert(oakengine_init(OAKENGINE_INIT_HEADLESS) == OAKENGINE_OK); - assert(oakengine_init_flags() == OAKENGINE_INIT_HEADLESS); + EXPECT_TRUE(oakengine_init(OAKENGINE_INIT_HEADLESS) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_init_flags() == OAKENGINE_INIT_HEADLESS); // Repeated init is idempotent. - assert(oakengine_init(OAKENGINE_INIT_HEADLESS) == OAKENGINE_OK); - assert(oakengine_init_flags() == OAKENGINE_INIT_HEADLESS); + EXPECT_TRUE(oakengine_init(OAKENGINE_INIT_HEADLESS) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_init_flags() == OAKENGINE_INIT_HEADLESS); } static void test_project_basics(void) { OakEngineProject *p = oakengine_project_create(); - assert(p != NULL); + EXPECT_TRUE(p != NULL); // Fresh shell: untitled, unmodified, empty. - assert(oakengine_project_is_modified(p) == 0); - assert(oakengine_project_footage_count(p) == 0); - assert(oakengine_project_sequence_count(p) == 0); - assert(oakengine_project_can_undo(p) == 0); - assert(oakengine_project_can_redo(p) == 0); + EXPECT_TRUE(oakengine_project_is_modified(p) == 0); + EXPECT_TRUE(oakengine_project_footage_count(p) == 0); + EXPECT_TRUE(oakengine_project_sequence_count(p) == 0); + EXPECT_TRUE(oakengine_project_can_undo(p) == 0); + EXPECT_TRUE(oakengine_project_can_redo(p) == 0); - assert(oakengine_project_new(p) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_new(p) == OAKENGINE_OK); // Content setup may only happen once. - assert(oakengine_project_new(p) == OAKENGINE_E_STATE); + EXPECT_TRUE(oakengine_project_new(p) == OAKENGINE_E_STATE); // An untitled project reports the engine's "(untitled)" name and an // empty filename. char name[64]; const int name_len = oakengine_project_name(p, NULL, 0); - assert(name_len > 0); - assert(oakengine_project_name(p, name, sizeof(name)) == name_len); - assert((int)strlen(name) == name_len); - assert(strcmp(name, "(untitled)") == 0); + EXPECT_TRUE(name_len > 0); + EXPECT_TRUE(oakengine_project_name(p, name, sizeof(name)) == name_len); + EXPECT_TRUE((int)strlen(name) == name_len); + EXPECT_TRUE(strcmp(name, "(untitled)") == 0); // buf/size truncation: reports the full size, writes what fits. char tiny[4]; - assert(oakengine_project_name(p, tiny, sizeof(tiny)) == name_len); - assert(strlen(tiny) == sizeof(tiny) - 1); + EXPECT_TRUE(oakengine_project_name(p, tiny, sizeof(tiny)) == name_len); + EXPECT_TRUE(strlen(tiny) == sizeof(tiny) - 1); char filename[16]; - assert(oakengine_project_filename(p, filename, sizeof(filename)) == 0); - assert(filename[0] == '\0'); + EXPECT_TRUE(oakengine_project_filename(p, filename, sizeof(filename)) == 0); + EXPECT_TRUE(filename[0] == '\0'); // Modified flag round-trips. - assert(oakengine_project_set_modified(p, 1) == OAKENGINE_OK); - assert(oakengine_project_is_modified(p) == 1); - assert(oakengine_project_set_modified(p, 0) == OAKENGINE_OK); - assert(oakengine_project_is_modified(p) == 0); + EXPECT_TRUE(oakengine_project_set_modified(p, 1) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_is_modified(p) == 1); + EXPECT_TRUE(oakengine_project_set_modified(p, 0) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_is_modified(p) == 0); // Saving an untitled project without a path fails. - assert(oakengine_project_save(p, NULL) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_project_save(p, NULL) == OAKENGINE_E_INVALID); oakengine_project_free(p); } @@ -143,158 +144,158 @@ static void test_sequence_and_save_load(void) make_path(path, sizeof(path), "roundtrip.ove"); OakEngineProject *p = oakengine_project_create(); - assert(p != NULL); - assert(oakengine_project_new(p) == OAKENGINE_OK); + EXPECT_TRUE(p != NULL); + EXPECT_TRUE(oakengine_project_new(p) == OAKENGINE_OK); // Create a sequence through the facade; it is owned by the project. OakEngineSequence *seq = oakengine_sequence_new(p, "Main"); - assert(seq != NULL); - assert(oakengine_project_sequence_count(p) == 1); - assert(oakengine_project_sequence_at(p, 0) == seq); - assert(oakengine_project_sequence_at(p, 1) == NULL); - assert(oakengine_project_sequence_at(p, -1) == NULL); + EXPECT_TRUE(seq != NULL); + EXPECT_TRUE(oakengine_project_sequence_count(p) == 1); + EXPECT_TRUE(oakengine_project_sequence_at(p, 0) == seq); + EXPECT_TRUE(oakengine_project_sequence_at(p, 1) == NULL); + EXPECT_TRUE(oakengine_project_sequence_at(p, -1) == NULL); // The creation went onto the global undo stack and marked the project. - assert(oakengine_project_can_undo(p) == 1); - assert(oakengine_project_is_modified(p) == 1); + EXPECT_TRUE(oakengine_project_can_undo(p) == 1); + EXPECT_TRUE(oakengine_project_is_modified(p) == 1); // Sequence name round-trips. char name[64]; const int name_len = oakengine_sequence_name(seq, NULL, 0); - assert(name_len == 4); - assert(oakengine_sequence_name(seq, name, sizeof(name)) == 4); - assert(strcmp(name, "Main") == 0); + EXPECT_TRUE(name_len == 4); + EXPECT_TRUE(oakengine_sequence_name(seq, name, sizeof(name)) == 4); + EXPECT_TRUE(strcmp(name, "Main") == 0); // Empty sequence: zero length. double seconds = -1.0; - assert(oakengine_sequence_get_length(seq, &seconds) == OAKENGINE_OK); - assert(seconds == 0.0); + EXPECT_TRUE(oakengine_sequence_get_length(seq, &seconds) == OAKENGINE_OK); + EXPECT_TRUE(seconds == 0.0); int num = -1, den = -1; - assert(oakengine_sequence_get_length_rational(seq, &num, &den) == + EXPECT_TRUE(oakengine_sequence_get_length_rational(seq, &num, &den) == OAKENGINE_OK); - assert(num == 0); + EXPECT_TRUE(num == 0); // Default frame rate from Config's DefaultSequenceFrameRate entry // (time base 1001/30000 -> frame rate 30000/1001). num = den = -1; - assert(oakengine_sequence_get_frame_rate(seq, &num, &den) == OAKENGINE_OK); - assert(num == 30000 && den == 1001); + EXPECT_TRUE(oakengine_sequence_get_frame_rate(seq, &num, &den) == OAKENGINE_OK); + EXPECT_TRUE(num == 30000 && den == 1001); // Default video dimensions (Config's DefaultSequenceWidth/Height) and // square pixels int width = -1, height = -1, par_num = -1, par_den = -1; - assert(oakengine_sequence_get_video_params(seq, &width, &height, &par_num, + EXPECT_TRUE(oakengine_sequence_get_video_params(seq, &width, &height, &par_num, &par_den) == OAKENGINE_OK); - assert(width == 1920 && height == 1080); - assert(par_num == 1 && par_den == 1); - assert(oakengine_sequence_get_video_params(NULL, NULL, NULL, NULL, NULL) == + EXPECT_TRUE(width == 1920 && height == 1080); + EXPECT_TRUE(par_num == 1 && par_den == 1); + EXPECT_TRUE(oakengine_sequence_get_video_params(NULL, NULL, NULL, NULL, NULL) == OAKENGINE_E_INVALID); // Fresh sequences have no tracks. int video = -1, audio = -1, subtitle = -1; - assert(oakengine_sequence_track_count(seq, &video, &audio, &subtitle) == + EXPECT_TRUE(oakengine_sequence_track_count(seq, &video, &audio, &subtitle) == OAKENGINE_OK); - assert(video == 0 && audio == 0 && subtitle == 0); + EXPECT_TRUE(video == 0 && audio == 0 && subtitle == 0); // Playhead starts at zero and accepts frame timestamps. int64_t ts = -1; - assert(oakengine_sequence_get_playhead(seq, &ts) == OAKENGINE_OK); - assert(ts == 0); - assert(oakengine_sequence_set_playhead(seq, 30) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_sequence_get_playhead(seq, &ts) == OAKENGINE_OK); + EXPECT_TRUE(ts == 0); + EXPECT_TRUE(oakengine_sequence_set_playhead(seq, 30) == OAKENGINE_OK); ts = -1; - assert(oakengine_sequence_get_playhead(seq, &ts) == OAKENGINE_OK); - assert(ts == 30); + EXPECT_TRUE(oakengine_sequence_get_playhead(seq, &ts) == OAKENGINE_OK); + EXPECT_TRUE(ts == 30); // 30 frames at 1001/30000 per frame = 1.001 seconds. seconds = -1.0; - assert(oakengine_sequence_get_playhead_seconds(seq, &seconds) == + EXPECT_TRUE(oakengine_sequence_get_playhead_seconds(seq, &seconds) == OAKENGINE_OK); - assert(fabs(seconds - 1.001) < 1e-9); + EXPECT_TRUE(fabs(seconds - 1.001) < 1e-9); // Workarea: disabled by default, then set + read back. - assert(oakengine_sequence_workarea_is_enabled(seq) == 0); - assert(oakengine_sequence_set_workarea(seq, 1, 10, 40) == OAKENGINE_OK); - assert(oakengine_sequence_workarea_is_enabled(seq) == 1); + EXPECT_TRUE(oakengine_sequence_workarea_is_enabled(seq) == 0); + EXPECT_TRUE(oakengine_sequence_set_workarea(seq, 1, 10, 40) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_sequence_workarea_is_enabled(seq) == 1); int64_t in = -1, out = -1; - assert(oakengine_sequence_get_workarea(seq, &in, &out) == OAKENGINE_OK); - assert(in == 10 && out == 40); + EXPECT_TRUE(oakengine_sequence_get_workarea(seq, &in, &out) == OAKENGINE_OK); + EXPECT_TRUE(in == 10 && out == 40); // No markers on a fresh sequence. - assert(oakengine_sequence_marker_count(seq) == 0); - assert(oakengine_sequence_marker_at(seq, 0, NULL, NULL, 0, NULL) == + EXPECT_TRUE(oakengine_sequence_marker_count(seq) == 0); + EXPECT_TRUE(oakengine_sequence_marker_at(seq, 0, NULL, NULL, 0, NULL) == OAKENGINE_E_NOT_FOUND); // Save; the modified flag clears and the filename is adopted. - assert(oakengine_project_save(p, path) == OAKENGINE_OK); - assert(oakengine_project_is_modified(p) == 0); - assert(file_exists(path)); + EXPECT_TRUE(oakengine_project_save(p, path) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_is_modified(p) == 0); + EXPECT_TRUE(file_exists(path)); char filename[4096]; - assert(oakengine_project_filename(p, filename, sizeof(filename)) == + EXPECT_TRUE(oakengine_project_filename(p, filename, sizeof(filename)) == (int)strlen(path)); - assert(strcmp(filename, path) == 0); + EXPECT_TRUE(strcmp(filename, path) == 0); // Undo removes the sequence, redo brings the same object back. - assert(oakengine_project_undo(p) == OAKENGINE_OK); - assert(oakengine_project_sequence_count(p) == 0); - assert(oakengine_project_can_redo(p) == 1); - assert(oakengine_project_redo(p) == OAKENGINE_OK); - assert(oakengine_project_sequence_count(p) == 1); - assert(oakengine_project_sequence_at(p, 0) == seq); + EXPECT_TRUE(oakengine_project_undo(p) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_sequence_count(p) == 0); + EXPECT_TRUE(oakengine_project_can_redo(p) == 1); + EXPECT_TRUE(oakengine_project_redo(p) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_sequence_count(p) == 1); + EXPECT_TRUE(oakengine_project_sequence_at(p, 0) == seq); oakengine_project_free(p); // Load the saved file into a fresh project. OakEngineProject *q = oakengine_project_create(); - assert(q != NULL); + EXPECT_TRUE(q != NULL); char err[512]; - assert(oakengine_project_load(q, path, err, sizeof(err)) == OAKENGINE_OK); - assert(oakengine_project_is_modified(q) == 0); - assert(oakengine_project_can_undo(q) == 0); // load clears the undo stack - assert(oakengine_project_can_redo(q) == 0); + EXPECT_TRUE(oakengine_project_load(q, path, err, sizeof(err)) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_is_modified(q) == 0); + EXPECT_TRUE(oakengine_project_can_undo(q) == 0); // load clears the undo stack + EXPECT_TRUE(oakengine_project_can_redo(q) == 0); // Project name derives from the file's base name. const int qname_len = oakengine_project_name(q, NULL, 0); - assert(qname_len == (int)strlen("roundtrip")); - assert(oakengine_project_name(q, name, sizeof(name)) == qname_len); - assert(strcmp(name, "roundtrip") == 0); - assert(oakengine_project_filename(q, filename, sizeof(filename)) == + EXPECT_TRUE(qname_len == (int)strlen("roundtrip")); + EXPECT_TRUE(oakengine_project_name(q, name, sizeof(name)) == qname_len); + EXPECT_TRUE(strcmp(name, "roundtrip") == 0); + EXPECT_TRUE(oakengine_project_filename(q, filename, sizeof(filename)) == (int)strlen(path)); - assert(strcmp(filename, path) == 0); + EXPECT_TRUE(strcmp(filename, path) == 0); // The sequence survived the round trip, workarea included (the workarea // is serialized by ViewerOutput::save_custom()). - assert(oakengine_project_sequence_count(q) == 1); + EXPECT_TRUE(oakengine_project_sequence_count(q) == 1); OakEngineSequence *loaded = oakengine_project_sequence_at(q, 0); - assert(loaded != NULL); - assert(oakengine_sequence_name(loaded, name, sizeof(name)) == 4); - assert(strcmp(name, "Main") == 0); + EXPECT_TRUE(loaded != NULL); + EXPECT_TRUE(oakengine_sequence_name(loaded, name, sizeof(name)) == 4); + EXPECT_TRUE(strcmp(name, "Main") == 0); num = den = -1; - assert(oakengine_sequence_get_frame_rate(loaded, &num, &den) == + EXPECT_TRUE(oakengine_sequence_get_frame_rate(loaded, &num, &den) == OAKENGINE_OK); - assert(num == 30000 && den == 1001); - assert(oakengine_sequence_track_count(loaded, &video, &audio, + EXPECT_TRUE(num == 30000 && den == 1001); + EXPECT_TRUE(oakengine_sequence_track_count(loaded, &video, &audio, &subtitle) == OAKENGINE_OK); - assert(video == 0 && audio == 0 && subtitle == 0); - assert(oakengine_sequence_workarea_is_enabled(loaded) == 1); + EXPECT_TRUE(video == 0 && audio == 0 && subtitle == 0); + EXPECT_TRUE(oakengine_sequence_workarea_is_enabled(loaded) == 1); in = out = -1; - assert(oakengine_sequence_get_workarea(loaded, &in, &out) == OAKENGINE_OK); - assert(in == 10 && out == 40); - assert(oakengine_project_footage_count(q) == 0); + EXPECT_TRUE(oakengine_sequence_get_workarea(loaded, &in, &out) == OAKENGINE_OK); + EXPECT_TRUE(in == 10 && out == 40); + EXPECT_TRUE(oakengine_project_footage_count(q) == 0); // Saving with a NULL path reuses the project's current filename. - assert(oakengine_project_save(q, NULL) == OAKENGINE_OK); - assert(file_exists(path)); + EXPECT_TRUE(oakengine_project_save(q, NULL) == OAKENGINE_OK); + EXPECT_TRUE(file_exists(path)); oakengine_project_free(q); // Loading a missing file fails and reports a human-readable reason. OakEngineProject *r = oakengine_project_create(); - assert(r != NULL); + EXPECT_TRUE(r != NULL); char missing[4096]; make_path(missing, sizeof(missing), "does-not-exist.ove"); - assert(oakengine_project_load(r, missing, err, sizeof(err)) == + EXPECT_TRUE(oakengine_project_load(r, missing, err, sizeof(err)) == OAKENGINE_E_FAILED); - assert(strlen(err) > 0); + EXPECT_TRUE(strlen(err) > 0); // Loading into a project that already has content is rejected. - assert(oakengine_project_new(r) == OAKENGINE_OK); - assert(oakengine_project_load(r, missing, err, sizeof(err)) == + EXPECT_TRUE(oakengine_project_new(r) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_load(r, missing, err, sizeof(err)) == OAKENGINE_E_STATE); oakengine_project_free(r); } @@ -308,36 +309,36 @@ static void test_footage_fixture(void) const int n = snprintf(fixture, sizeof(fixture), "%s/tests/project_with_footage.ove", OAK_TEST_SOURCE_DIR); - assert(n > 0 && (size_t)n < sizeof(fixture)); - assert(file_exists(fixture)); + EXPECT_TRUE(n > 0 && (size_t)n < sizeof(fixture)); + EXPECT_TRUE(file_exists(fixture)); OakEngineProject *p = oakengine_project_create(); - assert(p != NULL); + EXPECT_TRUE(p != NULL); char err[512]; - assert(oakengine_project_load(p, fixture, err, sizeof(err)) == + EXPECT_TRUE(oakengine_project_load(p, fixture, err, sizeof(err)) == OAKENGINE_OK); - assert(oakengine_project_footage_count(p) == 1); + EXPECT_TRUE(oakengine_project_footage_count(p) == 1); char filename[256]; - assert(oakengine_project_footage_filename(p, 0, filename, + EXPECT_TRUE(oakengine_project_footage_filename(p, 0, filename, sizeof(filename)) > 0); - assert(strcmp(filename, "demo.mp4") == 0); + EXPECT_TRUE(strcmp(filename, "demo.mp4") == 0); // The stored relative path resolves against the project file's // directory (tests/), where demo.mp4 exists. - assert(oakengine_project_footage_is_online(p, 0) == 1); + EXPECT_TRUE(oakengine_project_footage_is_online(p, 0) == 1); // Out-of-range footage indexes report OAKENGINE_E_NOT_FOUND. - assert(oakengine_project_footage_filename(p, 1, filename, + EXPECT_TRUE(oakengine_project_footage_filename(p, 1, filename, sizeof(filename)) == OAKENGINE_E_NOT_FOUND); - assert(oakengine_project_footage_is_online(p, -1) == + EXPECT_TRUE(oakengine_project_footage_is_online(p, -1) == OAKENGINE_E_NOT_FOUND); - assert(oakengine_project_sequence_count(p) == 1); + EXPECT_TRUE(oakengine_project_sequence_count(p) == 1); OakEngineSequence *seq = oakengine_project_sequence_at(p, 0); - assert(seq != NULL); + EXPECT_TRUE(seq != NULL); char name[64]; - assert(oakengine_sequence_name(seq, name, sizeof(name)) > 0); - assert(strcmp(name, "Fixture Sequence") == 0); + EXPECT_TRUE(oakengine_sequence_name(seq, name, sizeof(name)) > 0); + EXPECT_TRUE(strcmp(name, "Fixture Sequence") == 0); oakengine_project_free(p); } @@ -345,65 +346,65 @@ static void test_footage_fixture(void) static void test_null_safety(void) { oakengine_project_free(NULL); - assert(oakengine_project_new(NULL) == OAKENGINE_E_INVALID); - assert(oakengine_project_load(NULL, "/tmp/x.ove", NULL, 0) == + EXPECT_TRUE(oakengine_project_new(NULL) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_project_load(NULL, "/tmp/x.ove", NULL, 0) == OAKENGINE_E_INVALID); - assert(oakengine_project_save(NULL, "/tmp/x.ove") == OAKENGINE_E_INVALID); - assert(oakengine_project_is_modified(NULL) == 0); - assert(oakengine_project_set_modified(NULL, 1) == OAKENGINE_E_INVALID); - assert(oakengine_project_name(NULL, NULL, 0) == OAKENGINE_E_INVALID); - assert(oakengine_project_filename(NULL, NULL, 0) == OAKENGINE_E_INVALID); - assert(oakengine_project_footage_count(NULL) == 0); - assert(oakengine_project_footage_filename(NULL, 0, NULL, 0) == + EXPECT_TRUE(oakengine_project_save(NULL, "/tmp/x.ove") == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_project_is_modified(NULL) == 0); + EXPECT_TRUE(oakengine_project_set_modified(NULL, 1) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_project_name(NULL, NULL, 0) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_project_filename(NULL, NULL, 0) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_project_footage_count(NULL) == 0); + EXPECT_TRUE(oakengine_project_footage_filename(NULL, 0, NULL, 0) == OAKENGINE_E_INVALID); - assert(oakengine_project_footage_is_online(NULL, 0) == + EXPECT_TRUE(oakengine_project_footage_is_online(NULL, 0) == OAKENGINE_E_INVALID); - assert(oakengine_project_can_undo(NULL) == 0); - assert(oakengine_project_can_redo(NULL) == 0); - assert(oakengine_project_undo(NULL) == OAKENGINE_E_INVALID); - assert(oakengine_project_redo(NULL) == OAKENGINE_E_INVALID); - assert(oakengine_project_sequence_count(NULL) == 0); - assert(oakengine_project_sequence_at(NULL, 0) == NULL); + EXPECT_TRUE(oakengine_project_can_undo(NULL) == 0); + EXPECT_TRUE(oakengine_project_can_redo(NULL) == 0); + EXPECT_TRUE(oakengine_project_undo(NULL) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_project_redo(NULL) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_project_sequence_count(NULL) == 0); + EXPECT_TRUE(oakengine_project_sequence_at(NULL, 0) == NULL); - assert(oakengine_sequence_new(NULL, "x") == NULL); - assert(oakengine_sequence_name(NULL, NULL, 0) == OAKENGINE_E_INVALID); - assert(oakengine_sequence_get_length(NULL, NULL) == OAKENGINE_E_INVALID); - assert(oakengine_sequence_get_length_rational(NULL, NULL, NULL) == + EXPECT_TRUE(oakengine_sequence_new(NULL, "x") == NULL); + EXPECT_TRUE(oakengine_sequence_name(NULL, NULL, 0) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_sequence_get_length(NULL, NULL) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_sequence_get_length_rational(NULL, NULL, NULL) == OAKENGINE_E_INVALID); - assert(oakengine_sequence_get_frame_rate(NULL, NULL, NULL) == + EXPECT_TRUE(oakengine_sequence_get_frame_rate(NULL, NULL, NULL) == OAKENGINE_E_INVALID); - assert(oakengine_sequence_track_count(NULL, NULL, NULL, NULL) == + EXPECT_TRUE(oakengine_sequence_track_count(NULL, NULL, NULL, NULL) == OAKENGINE_E_INVALID); - assert(oakengine_sequence_get_playhead(NULL, NULL) == OAKENGINE_E_INVALID); - assert(oakengine_sequence_set_playhead(NULL, 0) == OAKENGINE_E_INVALID); - assert(oakengine_sequence_get_playhead_seconds(NULL, NULL) == + EXPECT_TRUE(oakengine_sequence_get_playhead(NULL, NULL) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_sequence_set_playhead(NULL, 0) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_sequence_get_playhead_seconds(NULL, NULL) == OAKENGINE_E_INVALID); - assert(oakengine_sequence_workarea_is_enabled(NULL) == 0); - assert(oakengine_sequence_get_workarea(NULL, NULL, NULL) == + EXPECT_TRUE(oakengine_sequence_workarea_is_enabled(NULL) == 0); + EXPECT_TRUE(oakengine_sequence_get_workarea(NULL, NULL, NULL) == OAKENGINE_E_INVALID); - assert(oakengine_sequence_set_workarea(NULL, 0, 0, 0) == + EXPECT_TRUE(oakengine_sequence_set_workarea(NULL, 0, 0, 0) == OAKENGINE_E_INVALID); - assert(oakengine_sequence_marker_count(NULL) == 0); - assert(oakengine_sequence_marker_at(NULL, 0, NULL, NULL, 0, NULL) == + EXPECT_TRUE(oakengine_sequence_marker_count(NULL) == 0); + EXPECT_TRUE(oakengine_sequence_marker_at(NULL, 0, NULL, NULL, 0, NULL) == OAKENGINE_E_INVALID); } static void test_shutdown_pairing(void) { - assert(oakengine_shutdown() == OAKENGINE_OK); - assert(oakengine_init_flags() == 0); + EXPECT_TRUE(oakengine_shutdown() == OAKENGINE_OK); + EXPECT_TRUE(oakengine_init_flags() == 0); // Shutdown is idempotent. - assert(oakengine_shutdown() == OAKENGINE_OK); + EXPECT_TRUE(oakengine_shutdown() == OAKENGINE_OK); // init may run again after a paired shutdown. - assert(oakengine_init(OAKENGINE_INIT_HEADLESS) == OAKENGINE_OK); - assert(oakengine_init_flags() == OAKENGINE_INIT_HEADLESS); - assert(oakengine_shutdown() == OAKENGINE_OK); - assert(oakengine_init_flags() == 0); + EXPECT_TRUE(oakengine_init(OAKENGINE_INIT_HEADLESS) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_init_flags() == OAKENGINE_INIT_HEADLESS); + EXPECT_TRUE(oakengine_shutdown() == OAKENGINE_OK); + EXPECT_TRUE(oakengine_init_flags() == 0); } -int main(void) +TEST(OakEngineInit, Main) { make_tmpdir(); @@ -413,9 +414,9 @@ int main(void) // (FileFunctions::get_configuration_location()), which follows // XDG_DATA_HOME on Linux; the other two are sandboxed for good measure. #if !defined(_WIN32) - assert(setenv("XDG_CONFIG_HOME", g_tmpdir, 1) == 0); - assert(setenv("XDG_CACHE_HOME", g_tmpdir, 1) == 0); - assert(setenv("XDG_DATA_HOME", g_tmpdir, 1) == 0); + EXPECT_TRUE(setenv("XDG_CONFIG_HOME", g_tmpdir, 1) == 0); + EXPECT_TRUE(setenv("XDG_CACHE_HOME", g_tmpdir, 1) == 0); + EXPECT_TRUE(setenv("XDG_DATA_HOME", g_tmpdir, 1) == 0); #endif test_init(); @@ -425,6 +426,4 @@ int main(void) test_null_safety(); test_shutdown_pairing(); - printf("oakengine_init_test: all assertions passed\n"); - return 0; } diff --git a/engine/tests/oakengine_ipc_test.cpp b/engine/tests/oakengine_ipc_test.cpp index 1d04c0d41..c14810481 100644 --- a/engine/tests/oakengine_ipc_test.cpp +++ b/engine/tests/oakengine_ipc_test.cpp @@ -23,6 +23,7 @@ // layout) and every control-plane message build/parse pair. No Qt, no GL. #include +#include #include #include #include @@ -58,7 +59,7 @@ static void assert_json_eq(const char *produced, const char *expected) if (strcmp(produced, expected) != 0) { fprintf(stderr, "JSON mismatch:\n produced: %s\n expected: %s\n", produced, expected); - assert(0); + EXPECT_TRUE(0); } } @@ -70,79 +71,79 @@ static void test_shm(void) int needed = oakengine_ipc_shm_make_key(pid, 0, NULL, 0); char expected[64]; snprintf(expected, sizeof(expected), "olive-rw-%lld-0", (long long)pid); - assert(needed == (int)strlen(expected)); - assert(oakengine_ipc_shm_make_key(pid, 0, key, sizeof(key)) == needed); - assert(strcmp(key, expected) == 0); - assert(oakengine_ipc_shm_make_key(pid, 0, key, 6) == needed); // truncated - assert(strcmp(key, "olive") == 0); + EXPECT_TRUE(needed == (int)strlen(expected)); + EXPECT_TRUE(oakengine_ipc_shm_make_key(pid, 0, key, sizeof(key)) == needed); + EXPECT_TRUE(strcmp(key, expected) == 0); + EXPECT_TRUE(oakengine_ipc_shm_make_key(pid, 0, key, 6) == needed); // truncated + EXPECT_TRUE(strcmp(key, "olive") == 0); // A different worker index produces a different key. char key1[OAK_IPC_SHM_KEY_CAP]; - assert(oakengine_ipc_shm_make_key(pid, 1, key1, sizeof(key1)) == needed); - assert(strcmp(key1, expected) != 0); + EXPECT_TRUE(oakengine_ipc_shm_make_key(pid, 1, key1, sizeof(key1)) == needed); + EXPECT_TRUE(strcmp(key1, expected) != 0); const int key_len = oakengine_ipc_shm_make_key(pid, 0, key, sizeof(key)); (void)key_len; // Attaching to a missing segment fails and reports an error. OakSharedMemoryRegion *missing = oakengine_ipc_shm_create(); - assert(oakengine_ipc_shm_open(missing, key, 4096, + EXPECT_TRUE(oakengine_ipc_shm_open(missing, key, 4096, OAK_IPC_SHM_MODE_ATTACH) == 0); - assert(oakengine_ipc_shm_is_valid(missing) == 0); + EXPECT_TRUE(oakengine_ipc_shm_is_valid(missing) == 0); char err[256]; - assert(oakengine_ipc_shm_error(missing, err, sizeof(err)) > 0); - assert(strlen(err) > 0); + EXPECT_TRUE(oakengine_ipc_shm_error(missing, err, sizeof(err)) > 0); + EXPECT_TRUE(strlen(err) > 0); oakengine_ipc_shm_free(missing); // Create the owner: valid, sized, zero-initialized. OakSharedMemoryRegion *owner = oakengine_ipc_shm_create(); - assert(oakengine_ipc_shm_open(owner, key, 8192, OAK_IPC_SHM_MODE_CREATE) == + EXPECT_TRUE(oakengine_ipc_shm_open(owner, key, 8192, OAK_IPC_SHM_MODE_CREATE) == 1); - assert(oakengine_ipc_shm_is_valid(owner) == 1); - assert(oakengine_ipc_shm_size(owner) == 8192); + EXPECT_TRUE(oakengine_ipc_shm_is_valid(owner) == 1); + EXPECT_TRUE(oakengine_ipc_shm_size(owner) == 8192); unsigned char *data = (unsigned char *)oakengine_ipc_shm_data(owner); - assert(data != NULL); + EXPECT_TRUE(data != NULL); for (int i = 0; i < 8192; i++) { - assert(data[i] == 0); + EXPECT_TRUE(data[i] == 0); } // key() round-trips the opened key. char opened_key[OAK_IPC_SHM_KEY_CAP]; - assert(oakengine_ipc_shm_key(owner, opened_key, sizeof(opened_key)) == + EXPECT_TRUE(oakengine_ipc_shm_key(owner, opened_key, sizeof(opened_key)) == key_len); - assert(strcmp(opened_key, key) == 0); + EXPECT_TRUE(strcmp(opened_key, key) == 0); // A peer attaches by the same key and sees the owner's bytes. data[0] = 0xAB; data[8191] = 0xCD; OakSharedMemoryRegion *peer = oakengine_ipc_shm_create(); - assert(oakengine_ipc_shm_open(peer, key, 8192, OAK_IPC_SHM_MODE_ATTACH) == + EXPECT_TRUE(oakengine_ipc_shm_open(peer, key, 8192, OAK_IPC_SHM_MODE_ATTACH) == 1); - assert(oakengine_ipc_shm_size(peer) == 8192); + EXPECT_TRUE(oakengine_ipc_shm_size(peer) == 8192); const unsigned char *peer_data = (const unsigned char *)oakengine_ipc_shm_data(peer); - assert(peer_data[0] == 0xAB && peer_data[8191] == 0xCD); + EXPECT_TRUE(peer_data[0] == 0xAB && peer_data[8191] == 0xCD); peer_data = NULL; // The peer closes without unlinking; the owner stays valid. oakengine_ipc_shm_close(peer); - assert(oakengine_ipc_shm_is_valid(peer) == 0); - assert(oakengine_ipc_shm_is_valid(owner) == 1); + EXPECT_TRUE(oakengine_ipc_shm_is_valid(peer) == 0); + EXPECT_TRUE(oakengine_ipc_shm_is_valid(owner) == 1); oakengine_ipc_shm_free(peer); // The owner unlinks on close: a late attach must fail. oakengine_ipc_shm_close(owner); - assert(oakengine_ipc_shm_is_valid(owner) == 0); + EXPECT_TRUE(oakengine_ipc_shm_is_valid(owner) == 0); OakSharedMemoryRegion *late = oakengine_ipc_shm_create(); - assert(oakengine_ipc_shm_open(late, key, 8192, OAK_IPC_SHM_MODE_ATTACH) == + EXPECT_TRUE(oakengine_ipc_shm_open(late, key, 8192, OAK_IPC_SHM_MODE_ATTACH) == 0); oakengine_ipc_shm_free(late); oakengine_ipc_shm_free(owner); // NULL safety. oakengine_ipc_shm_close(NULL); - assert(oakengine_ipc_shm_is_valid(NULL) == 0); - assert(oakengine_ipc_shm_data(NULL) == NULL); - assert(oakengine_ipc_shm_size(NULL) == 0); + EXPECT_TRUE(oakengine_ipc_shm_is_valid(NULL) == 0); + EXPECT_TRUE(oakengine_ipc_shm_data(NULL) == NULL); + EXPECT_TRUE(oakengine_ipc_shm_size(NULL) == 0); oakengine_ipc_shm_free(NULL); } @@ -152,51 +153,51 @@ static void test_framepool(void) const size_t k_slot_bytes = 256; // bytes_needed stays 64-aligned and grows with geometry. - assert(oakengine_ipc_framepool_bytes_needed(k_slots, k_slot_bytes) % 64 == + EXPECT_TRUE(oakengine_ipc_framepool_bytes_needed(k_slots, k_slot_bytes) % 64 == 0); - assert(oakengine_ipc_framepool_bytes_needed(2, 65) == + EXPECT_TRUE(oakengine_ipc_framepool_bytes_needed(2, 65) == oakengine_ipc_framepool_bytes_needed(2, 128)); - assert(oakengine_ipc_framepool_bytes_needed(1, 64) < + EXPECT_TRUE(oakengine_ipc_framepool_bytes_needed(1, 64) < oakengine_ipc_framepool_bytes_needed(2, 64)); const size_t bytes = oakengine_ipc_framepool_bytes_needed(k_slots, k_slot_bytes); void *mem = malloc(bytes); - assert(mem != NULL); + EXPECT_TRUE(mem != NULL); OakFrameSlotPool *filler = oakengine_ipc_framepool_create(mem, k_slots, k_slot_bytes); - assert(filler != NULL); - assert(oakengine_ipc_framepool_is_valid(filler) == 1); - assert(oakengine_ipc_framepool_slot_count(filler) == k_slots); - assert(oakengine_ipc_framepool_slot_data_bytes(filler) == k_slot_bytes); + EXPECT_TRUE(filler != NULL); + EXPECT_TRUE(oakengine_ipc_framepool_is_valid(filler) == 1); + EXPECT_TRUE(oakengine_ipc_framepool_slot_count(filler) == k_slots); + EXPECT_TRUE(oakengine_ipc_framepool_slot_data_bytes(filler) == k_slot_bytes); // Peer maps the same memory; a copy of the handle views it too. OakFrameSlotPool *drainer = oakengine_ipc_framepool_attach(mem); - assert(oakengine_ipc_framepool_is_valid(drainer) == 1); + EXPECT_TRUE(oakengine_ipc_framepool_is_valid(drainer) == 1); OakFrameSlotPool *drainer_copy = oakengine_ipc_framepool_copy(drainer); - assert(drainer_copy != NULL && drainer_copy != drainer); - assert(oakengine_ipc_framepool_slot_count(drainer_copy) == k_slots); + EXPECT_TRUE(drainer_copy != NULL && drainer_copy != drainer); + EXPECT_TRUE(oakengine_ipc_framepool_slot_count(drainer_copy) == k_slots); // Free slots are issued FIFO; the pool then reports exhausted. uint32_t held[3]; for (uint32_t i = 0; i < k_slots; i++) { - assert(oakengine_ipc_framepool_acquire(filler, &held[i]) == 1); - assert(held[i] == i); + EXPECT_TRUE(oakengine_ipc_framepool_acquire(filler, &held[i]) == 1); + EXPECT_TRUE(held[i] == i); } uint32_t overflow = 99; - assert(oakengine_ipc_framepool_acquire(filler, &overflow) == 0); - assert(overflow == 99); + EXPECT_TRUE(oakengine_ipc_framepool_acquire(filler, &overflow) == 0); + EXPECT_TRUE(overflow == 99); // Fill slot 0 with a pattern + full metadata and publish it. unsigned char *data = (unsigned char *)oakengine_ipc_framepool_slot_data(filler, held[0]); - assert(data != NULL); + EXPECT_TRUE(data != NULL); for (size_t i = 0; i < k_slot_bytes; i++) { data[i] = (unsigned char)(i & 0xFF); } oak_frame_slot_meta *meta = oakengine_ipc_framepool_meta(filler, held[0]); - assert(meta != NULL); + EXPECT_TRUE(meta != NULL); meta->id = -4242; meta->time_num = 1001; meta->time_den = 30000; @@ -208,48 +209,48 @@ static void test_framepool(void) meta->data_size = (int32_t)k_slot_bytes; strncpy(meta->colorspace, "acescg", sizeof(meta->colorspace) - 1); meta->colorspace[sizeof(meta->colorspace) - 1] = '\0'; - assert(oakengine_ipc_framepool_publish(filler, held[0]) == 1); + EXPECT_TRUE(oakengine_ipc_framepool_publish(filler, held[0]) == 1); // Publish slot 2 then slot 1: consume order follows publish order. - assert(oakengine_ipc_framepool_publish(filler, held[2]) == 1); - assert(oakengine_ipc_framepool_publish(filler, held[1]) == 1); + EXPECT_TRUE(oakengine_ipc_framepool_publish(filler, held[2]) == 1); + EXPECT_TRUE(oakengine_ipc_framepool_publish(filler, held[1]) == 1); uint32_t got = 99; - assert(oakengine_ipc_framepool_consume(drainer, &got) == 1); - assert(got == held[0]); + EXPECT_TRUE(oakengine_ipc_framepool_consume(drainer, &got) == 1); + EXPECT_TRUE(got == held[0]); // Metadata and pixels arrive intact on the drainer side. const oak_frame_slot_meta *out = oakengine_ipc_framepool_meta_const(drainer, got); - assert(out != NULL); - assert(out->id == -4242); - assert(out->time_num == 1001 && out->time_den == 30000); - assert(out->width == 3840 && out->height == 2160); - assert(out->format == 17 && out->channel_count == 4); - assert(out->linesize == 3840 * 4 * 4); - assert(out->data_size == (int32_t)k_slot_bytes); - assert(strcmp(out->colorspace, "acescg") == 0); + EXPECT_TRUE(out != NULL); + EXPECT_TRUE(out->id == -4242); + EXPECT_TRUE(out->time_num == 1001 && out->time_den == 30000); + EXPECT_TRUE(out->width == 3840 && out->height == 2160); + EXPECT_TRUE(out->format == 17 && out->channel_count == 4); + EXPECT_TRUE(out->linesize == 3840 * 4 * 4); + EXPECT_TRUE(out->data_size == (int32_t)k_slot_bytes); + EXPECT_TRUE(strcmp(out->colorspace, "acescg") == 0); const unsigned char *out_data = (const unsigned char *)oakengine_ipc_framepool_slot_data_const(drainer, got); - assert(out_data != NULL); + EXPECT_TRUE(out_data != NULL); for (size_t i = 0; i < k_slot_bytes; i++) { - assert(out_data[i] == (unsigned char)(i & 0xFF)); + EXPECT_TRUE(out_data[i] == (unsigned char)(i & 0xFF)); } - assert(oakengine_ipc_framepool_release(drainer, got) == 1); + EXPECT_TRUE(oakengine_ipc_framepool_release(drainer, got) == 1); // The copied handle consumes the remaining slots in publish order. - assert(oakengine_ipc_framepool_consume(drainer_copy, &got) == 1); - assert(got == held[2]); - assert(oakengine_ipc_framepool_release(drainer_copy, got) == 1); - assert(oakengine_ipc_framepool_consume(drainer_copy, &got) == 1); - assert(got == held[1]); - assert(oakengine_ipc_framepool_release(drainer_copy, got) == 1); - assert(oakengine_ipc_framepool_consume(drainer, &got) == 0); // drained + EXPECT_TRUE(oakengine_ipc_framepool_consume(drainer_copy, &got) == 1); + EXPECT_TRUE(got == held[2]); + EXPECT_TRUE(oakengine_ipc_framepool_release(drainer_copy, got) == 1); + EXPECT_TRUE(oakengine_ipc_framepool_consume(drainer_copy, &got) == 1); + EXPECT_TRUE(got == held[1]); + EXPECT_TRUE(oakengine_ipc_framepool_release(drainer_copy, got) == 1); + EXPECT_TRUE(oakengine_ipc_framepool_consume(drainer, &got) == 0); // drained // Released slots cycle back to the filler. uint32_t again = 0; - assert(oakengine_ipc_framepool_acquire(filler, &again) == 1); + EXPECT_TRUE(oakengine_ipc_framepool_acquire(filler, &again) == 1); oakengine_ipc_framepool_free(drainer_copy); oakengine_ipc_framepool_free(drainer); @@ -258,21 +259,21 @@ static void test_framepool(void) // A region without the pool magic attaches as invalid. void *raw = calloc(1, oakengine_ipc_framepool_bytes_needed(2, 64)); - assert(raw != NULL); + EXPECT_TRUE(raw != NULL); OakFrameSlotPool *bad = oakengine_ipc_framepool_attach(raw); - assert(bad != NULL); - assert(oakengine_ipc_framepool_is_valid(bad) == 0); - assert(oakengine_ipc_framepool_slot_count(bad) == 0); - assert(oakengine_ipc_framepool_slot_data_bytes(bad) == 0); + EXPECT_TRUE(bad != NULL); + EXPECT_TRUE(oakengine_ipc_framepool_is_valid(bad) == 0); + EXPECT_TRUE(oakengine_ipc_framepool_slot_count(bad) == 0); + EXPECT_TRUE(oakengine_ipc_framepool_slot_data_bytes(bad) == 0); oakengine_ipc_framepool_free(bad); free(raw); // NULL safety. - assert(oakengine_ipc_framepool_is_valid(NULL) == 0); - assert(oakengine_ipc_framepool_slot_count(NULL) == 0); - assert(oakengine_ipc_framepool_slot_data(NULL, 0) == NULL); - assert(oakengine_ipc_framepool_meta(NULL, 0) == NULL); - assert(oakengine_ipc_framepool_acquire(NULL, &again) == 0); + EXPECT_TRUE(oakengine_ipc_framepool_is_valid(NULL) == 0); + EXPECT_TRUE(oakengine_ipc_framepool_slot_count(NULL) == 0); + EXPECT_TRUE(oakengine_ipc_framepool_slot_data(NULL, 0) == NULL); + EXPECT_TRUE(oakengine_ipc_framepool_meta(NULL, 0) == NULL); + EXPECT_TRUE(oakengine_ipc_framepool_acquire(NULL, &again) == 0); oakengine_ipc_framepool_free(NULL); } @@ -280,7 +281,7 @@ static void test_framepool(void) static void test_framepool_over_shm(void) { char key[OAK_IPC_SHM_KEY_CAP]; - assert(oakengine_ipc_shm_make_key(getpid(), 7, key, sizeof(key)) > 0); + EXPECT_TRUE(oakengine_ipc_shm_make_key(getpid(), 7, key, sizeof(key)) > 0); const uint32_t k_slots = 2; const size_t k_slot_bytes = 64; @@ -288,35 +289,35 @@ static void test_framepool_over_shm(void) oakengine_ipc_framepool_bytes_needed(k_slots, k_slot_bytes); OakSharedMemoryRegion *owner = oakengine_ipc_shm_create(); - assert(oakengine_ipc_shm_open(owner, key, bytes, OAK_IPC_SHM_MODE_CREATE) == + EXPECT_TRUE(oakengine_ipc_shm_open(owner, key, bytes, OAK_IPC_SHM_MODE_CREATE) == 1); OakSharedMemoryRegion *peer = oakengine_ipc_shm_create(); - assert(oakengine_ipc_shm_open(peer, key, bytes, OAK_IPC_SHM_MODE_ATTACH) == + EXPECT_TRUE(oakengine_ipc_shm_open(peer, key, bytes, OAK_IPC_SHM_MODE_ATTACH) == 1); OakFrameSlotPool *filler = oakengine_ipc_framepool_create( oakengine_ipc_shm_data(owner), k_slots, k_slot_bytes); OakFrameSlotPool *drainer = oakengine_ipc_framepool_attach( oakengine_ipc_shm_data(peer)); - assert(oakengine_ipc_framepool_is_valid(filler) == 1); - assert(oakengine_ipc_framepool_is_valid(drainer) == 1); + EXPECT_TRUE(oakengine_ipc_framepool_is_valid(filler) == 1); + EXPECT_TRUE(oakengine_ipc_framepool_is_valid(drainer) == 1); uint32_t idx = 0; - assert(oakengine_ipc_framepool_acquire(filler, &idx) == 1); + EXPECT_TRUE(oakengine_ipc_framepool_acquire(filler, &idx) == 1); oak_frame_slot_meta *meta = oakengine_ipc_framepool_meta(filler, idx); meta->id = 77; meta->data_size = (int32_t)k_slot_bytes; memset(oakengine_ipc_framepool_slot_data(filler, idx), 0x5A, k_slot_bytes); - assert(oakengine_ipc_framepool_publish(filler, idx) == 1); + EXPECT_TRUE(oakengine_ipc_framepool_publish(filler, idx) == 1); uint32_t got = 0; - assert(oakengine_ipc_framepool_consume(drainer, &got) == 1); - assert(got == idx); - assert(oakengine_ipc_framepool_meta_const(drainer, got)->id == 77); + EXPECT_TRUE(oakengine_ipc_framepool_consume(drainer, &got) == 1); + EXPECT_TRUE(got == idx); + EXPECT_TRUE(oakengine_ipc_framepool_meta_const(drainer, got)->id == 77); const unsigned char *d = (const unsigned char *) oakengine_ipc_framepool_slot_data_const(drainer, got); - assert(d[0] == 0x5A && d[k_slot_bytes - 1] == 0x5A); - assert(oakengine_ipc_framepool_release(drainer, got) == 1); + EXPECT_TRUE(d[0] == 0x5A && d[k_slot_bytes - 1] == 0x5A); + EXPECT_TRUE(oakengine_ipc_framepool_release(drainer, got) == 1); oakengine_ipc_framepool_free(drainer); oakengine_ipc_framepool_free(filler); @@ -337,28 +338,28 @@ static void test_handshake(void) hs.input_slot_data_bytes = 128ll * 1024 * 1024; const int needed = oakengine_ipc_handshake_to_json(&hs, NULL, 0); - assert(needed > 0); + EXPECT_TRUE(needed > 0); char *json = (char *)malloc(size_t(needed) + 1); - assert(json != NULL); - assert(oakengine_ipc_handshake_to_json(&hs, json, needed + 1) == needed); - assert((int)strlen(json) == needed); + EXPECT_TRUE(json != NULL); + EXPECT_TRUE(oakengine_ipc_handshake_to_json(&hs, json, needed + 1) == needed); + EXPECT_TRUE((int)strlen(json) == needed); // buf/size convention: a short buffer truncates but reports the full size. char tiny[8]; - assert(oakengine_ipc_handshake_to_json(&hs, tiny, sizeof(tiny)) == needed); - assert(strlen(tiny) == sizeof(tiny) - 1); + EXPECT_TRUE(oakengine_ipc_handshake_to_json(&hs, tiny, sizeof(tiny)) == needed); + EXPECT_TRUE(strlen(tiny) == sizeof(tiny) - 1); - assert(oakengine_ipc_message_type(json) == OAK_IPC_MSGTYPE_HANDSHAKE); + EXPECT_TRUE(oakengine_ipc_message_type(json) == OAK_IPC_MSGTYPE_HANDSHAKE); oak_ipc_handshake back; - assert(oakengine_ipc_handshake_parse(json, &back) == 1); - assert(back.protocol_version == hs.protocol_version); - assert(strcmp(back.shm_key, hs.shm_key) == 0); - assert(strcmp(back.input_shm_key, hs.input_shm_key) == 0); - assert(back.input_slots == hs.input_slots); - assert(back.output_slots == hs.output_slots); - assert(back.slot_data_bytes == hs.slot_data_bytes); - assert(back.input_slot_data_bytes == hs.input_slot_data_bytes); + EXPECT_TRUE(oakengine_ipc_handshake_parse(json, &back) == 1); + EXPECT_TRUE(back.protocol_version == hs.protocol_version); + EXPECT_TRUE(strcmp(back.shm_key, hs.shm_key) == 0); + EXPECT_TRUE(strcmp(back.input_shm_key, hs.input_shm_key) == 0); + EXPECT_TRUE(back.input_slots == hs.input_slots); + EXPECT_TRUE(back.output_slots == hs.output_slots); + EXPECT_TRUE(back.slot_data_bytes == hs.slot_data_bytes); + EXPECT_TRUE(back.input_slot_data_bytes == hs.input_slot_data_bytes); free(json); // Exact wire text: same field names and compact shape the Qt builder emits. @@ -373,8 +374,8 @@ static void test_handshake(void) small.input_slot_data_bytes = 128; const int n2 = oakengine_ipc_handshake_to_json(&small, NULL, 0); char *json2 = (char *)malloc(size_t(n2) + 1); - assert(json2 != NULL); - assert(oakengine_ipc_handshake_to_json(&small, json2, n2 + 1) == n2); + EXPECT_TRUE(json2 != NULL); + EXPECT_TRUE(oakengine_ipc_handshake_to_json(&small, json2, n2 + 1) == n2); assert_json_eq(json2, "{\"input_shm_key\":\"in\",\"input_slot_data_bytes\":128," "\"input_slots\":4,\"output_slots\":6,\"protocol_version\":1," @@ -382,9 +383,9 @@ static void test_handshake(void) "\"type\":\"handshake\"}"); free(json2); - assert(oakengine_ipc_handshake_to_json(NULL, NULL, 0) == -1); - assert(oakengine_ipc_handshake_parse("not json", &back) == 0); - assert(oakengine_ipc_handshake_parse(NULL, &back) == 0); + EXPECT_TRUE(oakengine_ipc_handshake_to_json(NULL, NULL, 0) == -1); + EXPECT_TRUE(oakengine_ipc_handshake_parse("not json", &back) == 0); + EXPECT_TRUE(oakengine_ipc_handshake_parse(NULL, &back) == 0); } static void test_render_frame(void) @@ -412,26 +413,26 @@ static void test_render_frame(void) const int needed = oakengine_ipc_render_frame_to_json(&rf, NULL, 0); char *json = (char *)malloc(size_t(needed) + 1); - assert(json != NULL); - assert(oakengine_ipc_render_frame_to_json(&rf, json, needed + 1) == needed); - assert(oakengine_ipc_message_type(json) == OAK_IPC_MSGTYPE_RENDER_FRAME); + EXPECT_TRUE(json != NULL); + EXPECT_TRUE(oakengine_ipc_render_frame_to_json(&rf, json, needed + 1) == needed); + EXPECT_TRUE(oakengine_ipc_message_type(json) == OAK_IPC_MSGTYPE_RENDER_FRAME); oak_ipc_render_frame back; - assert(oakengine_ipc_render_frame_parse(json, &back) == 1); - assert(back.ticket_id == rf.ticket_id); - assert(strcmp(back.node_uuid, rf.node_uuid) == 0); - assert(back.time_num == rf.time_num); - assert(back.time_den == rf.time_den); - assert(back.width == rf.width && back.height == rf.height); - assert(back.format == rf.format && back.channel_count == rf.channel_count); - assert(back.mode == rf.mode); - assert(back.input_slot == rf.input_slot); - assert(back.input_slot_count == 2); - assert(back.input_slots[0] == 2 && back.input_slots[1] == 3); - assert(back.has_color_transform == 1 && back.color_is_display == 1); - assert(strcmp(back.color_output, rf.color_output) == 0); - assert(strcmp(back.color_view, rf.color_view) == 0); - assert(strcmp(back.color_look, rf.color_look) == 0); + EXPECT_TRUE(oakengine_ipc_render_frame_parse(json, &back) == 1); + EXPECT_TRUE(back.ticket_id == rf.ticket_id); + EXPECT_TRUE(strcmp(back.node_uuid, rf.node_uuid) == 0); + EXPECT_TRUE(back.time_num == rf.time_num); + EXPECT_TRUE(back.time_den == rf.time_den); + EXPECT_TRUE(back.width == rf.width && back.height == rf.height); + EXPECT_TRUE(back.format == rf.format && back.channel_count == rf.channel_count); + EXPECT_TRUE(back.mode == rf.mode); + EXPECT_TRUE(back.input_slot == rf.input_slot); + EXPECT_TRUE(back.input_slot_count == 2); + EXPECT_TRUE(back.input_slots[0] == 2 && back.input_slots[1] == 3); + EXPECT_TRUE(back.has_color_transform == 1 && back.color_is_display == 1); + EXPECT_TRUE(strcmp(back.color_output, rf.color_output) == 0); + EXPECT_TRUE(strcmp(back.color_view, rf.color_view) == 0); + EXPECT_TRUE(strcmp(back.color_look, rf.color_look) == 0); free(json); // Without a color transform the color keys are omitted from the wire text. @@ -452,9 +453,9 @@ static void test_render_frame(void) plain.input_slot_count = 2; const int n2 = oakengine_ipc_render_frame_to_json(&plain, NULL, 0); char *json2 = (char *)malloc(size_t(n2) + 1); - assert(json2 != NULL); - assert(oakengine_ipc_render_frame_to_json(&plain, json2, n2 + 1) == n2); - assert(strstr(json2, "has_color_transform") == NULL); + EXPECT_TRUE(json2 != NULL); + EXPECT_TRUE(oakengine_ipc_render_frame_to_json(&plain, json2, n2 + 1) == n2); + EXPECT_TRUE(strstr(json2, "has_color_transform") == NULL); assert_json_eq(json2, "{\"channels\":4,\"format\":3,\"height\":1080," "\"input_slot\":2,\"input_slots\":[2,3],\"mode\":1," @@ -464,32 +465,32 @@ static void test_render_frame(void) // Defaults for a sparse message, mirroring the Qt from_json defaults. oak_ipc_render_frame sparse; - assert(oakengine_ipc_render_frame_parse("{\"type\":\"render_frame\"}", + EXPECT_TRUE(oakengine_ipc_render_frame_parse("{\"type\":\"render_frame\"}", &sparse) == 1); - assert(sparse.ticket_id == 0); - assert(sparse.time_num == 0 && sparse.time_den == 1); - assert(sparse.width == 0 && sparse.height == 0); - assert(sparse.format == -1 && sparse.channel_count == 0 && sparse.mode == 0); - assert(sparse.input_slot == -1 && sparse.input_slot_count == 0); - assert(sparse.has_color_transform == 0); + EXPECT_TRUE(sparse.ticket_id == 0); + EXPECT_TRUE(sparse.time_num == 0 && sparse.time_den == 1); + EXPECT_TRUE(sparse.width == 0 && sparse.height == 0); + EXPECT_TRUE(sparse.format == -1 && sparse.channel_count == 0 && sparse.mode == 0); + EXPECT_TRUE(sparse.input_slot == -1 && sparse.input_slot_count == 0); + EXPECT_TRUE(sparse.has_color_transform == 0); // Legacy scalar input_slot folds into the array when it is absent. oak_ipc_render_frame legacy; - assert(oakengine_ipc_render_frame_parse( + EXPECT_TRUE(oakengine_ipc_render_frame_parse( "{\"type\":\"render_frame\",\"ticket\":5,\"input_slot\":3}", &legacy) == 1); - assert(legacy.input_slot == 3); - assert(legacy.input_slot_count == 1 && legacy.input_slots[0] == 3); + EXPECT_TRUE(legacy.input_slot == 3); + EXPECT_TRUE(legacy.input_slot_count == 1 && legacy.input_slots[0] == 3); // Type mismatches are rejected. oak_ipc_handshake hs; memset(&hs, 0, sizeof(hs)); const int hn = oakengine_ipc_handshake_to_json(&hs, NULL, 0); char *hjson = (char *)malloc(size_t(hn) + 1); - assert(hjson != NULL); - assert(oakengine_ipc_handshake_to_json(&hs, hjson, hn + 1) == hn); - assert(oakengine_ipc_render_frame_parse(hjson, &back) == 0); - assert(oakengine_ipc_handshake_parse(hjson, &hs) == 1); + EXPECT_TRUE(hjson != NULL); + EXPECT_TRUE(oakengine_ipc_handshake_to_json(&hs, hjson, hn + 1) == hn); + EXPECT_TRUE(oakengine_ipc_render_frame_parse(hjson, &back) == 0); + EXPECT_TRUE(oakengine_ipc_handshake_parse(hjson, &hs) == 1); free(hjson); } @@ -501,13 +502,13 @@ static void test_small_messages(void) fr.output_slot = 2; const int fn = oakengine_ipc_frame_ready_to_json(&fr, NULL, 0); char *fjson = (char *)malloc(size_t(fn) + 1); - assert(fjson != NULL); - assert(oakengine_ipc_frame_ready_to_json(&fr, fjson, fn + 1) == fn); + EXPECT_TRUE(fjson != NULL); + EXPECT_TRUE(oakengine_ipc_frame_ready_to_json(&fr, fjson, fn + 1) == fn); assert_json_eq(fjson, "{\"slot\":2,\"ticket\":99,\"type\":\"frame_ready\"}"); - assert(oakengine_ipc_message_type(fjson) == OAK_IPC_MSGTYPE_FRAME_READY); + EXPECT_TRUE(oakengine_ipc_message_type(fjson) == OAK_IPC_MSGTYPE_FRAME_READY); oak_ipc_frame_ready fr_back; - assert(oakengine_ipc_frame_ready_parse(fjson, &fr_back) == 1); - assert(fr_back.ticket_id == 99 && fr_back.output_slot == 2); + EXPECT_TRUE(oakengine_ipc_frame_ready_parse(fjson, &fr_back) == 1); + EXPECT_TRUE(fr_back.ticket_id == 99 && fr_back.output_slot == 2); free(fjson); // cancel @@ -515,15 +516,15 @@ static void test_small_messages(void) cancel.ticket_id = 7; const int cn = oakengine_ipc_cancel_to_json(&cancel, NULL, 0); char *cjson = (char *)malloc(size_t(cn) + 1); - assert(cjson != NULL); - assert(oakengine_ipc_cancel_to_json(&cancel, cjson, cn + 1) == cn); + EXPECT_TRUE(cjson != NULL); + EXPECT_TRUE(oakengine_ipc_cancel_to_json(&cancel, cjson, cn + 1) == cn); assert_json_eq(cjson, "{\"ticket\":7,\"type\":\"cancel\"}"); - assert(oakengine_ipc_message_type(cjson) == OAK_IPC_MSGTYPE_CANCEL); + EXPECT_TRUE(oakengine_ipc_message_type(cjson) == OAK_IPC_MSGTYPE_CANCEL); oak_ipc_cancel cancel_back; - assert(oakengine_ipc_cancel_parse(cjson, &cancel_back) == 1); - assert(cancel_back.ticket_id == 7); + EXPECT_TRUE(oakengine_ipc_cancel_parse(cjson, &cancel_back) == 1); + EXPECT_TRUE(cancel_back.ticket_id == 7); // cancel rejects a frame_ready payload. - assert(oakengine_ipc_cancel_parse("{\"slot\":2,\"ticket\":7,\"type\":" + EXPECT_TRUE(oakengine_ipc_cancel_parse("{\"slot\":2,\"ticket\":7,\"type\":" "\"frame_ready\"}", &cancel_back) == 0); free(cjson); @@ -533,51 +534,51 @@ static void test_small_messages(void) strcpy(load.path, "/tmp/oak-render-graph-abc123.ove"); const int ln = oakengine_ipc_load_graph_to_json(&load, NULL, 0); char *ljson = (char *)malloc(size_t(ln) + 1); - assert(ljson != NULL); - assert(oakengine_ipc_load_graph_to_json(&load, ljson, ln + 1) == ln); + EXPECT_TRUE(ljson != NULL); + EXPECT_TRUE(oakengine_ipc_load_graph_to_json(&load, ljson, ln + 1) == ln); assert_json_eq(ljson, "{\"path\":\"/tmp/oak-render-graph-abc123.ove\",\"type\":" "\"load_graph\"}"); - assert(oakengine_ipc_message_type(ljson) == OAK_IPC_MSGTYPE_LOAD_GRAPH); + EXPECT_TRUE(oakengine_ipc_message_type(ljson) == OAK_IPC_MSGTYPE_LOAD_GRAPH); oak_ipc_load_graph load_back; - assert(oakengine_ipc_load_graph_parse(ljson, &load_back) == 1); - assert(strcmp(load_back.path, load.path) == 0); + EXPECT_TRUE(oakengine_ipc_load_graph_parse(ljson, &load_back) == 1); + EXPECT_TRUE(strcmp(load_back.path, load.path) == 0); free(ljson); // shutdown const int sn = oakengine_ipc_shutdown_to_json(NULL, 0); char *sjson = (char *)malloc(size_t(sn) + 1); - assert(sjson != NULL); - assert(oakengine_ipc_shutdown_to_json(sjson, sn + 1) == sn); + EXPECT_TRUE(sjson != NULL); + EXPECT_TRUE(oakengine_ipc_shutdown_to_json(sjson, sn + 1) == sn); assert_json_eq(sjson, "{\"type\":\"shutdown\"}"); - assert(oakengine_ipc_shutdown_parse(sjson) == 1); - assert(oakengine_ipc_shutdown_parse("{\"type\":\"cancel\"}") == 0); - assert(oakengine_ipc_message_type(sjson) == OAK_IPC_MSGTYPE_SHUTDOWN); + EXPECT_TRUE(oakengine_ipc_shutdown_parse(sjson) == 1); + EXPECT_TRUE(oakengine_ipc_shutdown_parse("{\"type\":\"cancel\"}") == 0); + EXPECT_TRUE(oakengine_ipc_message_type(sjson) == OAK_IPC_MSGTYPE_SHUTDOWN); free(sjson); // error const int en = oakengine_ipc_error_to_json("boom", NULL, 0); char *ejson = (char *)malloc(size_t(en) + 1); - assert(ejson != NULL); - assert(oakengine_ipc_error_to_json("boom", ejson, en + 1) == en); + EXPECT_TRUE(ejson != NULL); + EXPECT_TRUE(oakengine_ipc_error_to_json("boom", ejson, en + 1) == en); assert_json_eq(ejson, "{\"message\":\"boom\",\"type\":\"error\"}"); - assert(oakengine_ipc_message_type(ejson) == OAK_IPC_MSGTYPE_ERROR); + EXPECT_TRUE(oakengine_ipc_message_type(ejson) == OAK_IPC_MSGTYPE_ERROR); char msg[OAK_IPC_ERROR_MESSAGE_CAP]; - assert(oakengine_ipc_error_parse(ejson, msg, sizeof(msg)) == 1); - assert(strcmp(msg, "boom") == 0); - assert(oakengine_ipc_error_parse("{\"type\":\"shutdown\"}", msg, + EXPECT_TRUE(oakengine_ipc_error_parse(ejson, msg, sizeof(msg)) == 1); + EXPECT_TRUE(strcmp(msg, "boom") == 0); + EXPECT_TRUE(oakengine_ipc_error_parse("{\"type\":\"shutdown\"}", msg, sizeof(msg)) == 0); free(ejson); // Unknown and malformed input. - assert(oakengine_ipc_message_type("{\"type\":\"nope\"}") == + EXPECT_TRUE(oakengine_ipc_message_type("{\"type\":\"nope\"}") == OAK_IPC_MSGTYPE_UNKNOWN); - assert(oakengine_ipc_message_type("garbage") == OAK_IPC_MSGTYPE_UNKNOWN); - assert(oakengine_ipc_message_type(NULL) == OAK_IPC_MSGTYPE_UNKNOWN); - assert(OAK_IPC_MSGTYPE_GRAPH_UPDATE != OAK_IPC_MSGTYPE_UNKNOWN); + EXPECT_TRUE(oakengine_ipc_message_type("garbage") == OAK_IPC_MSGTYPE_UNKNOWN); + EXPECT_TRUE(oakengine_ipc_message_type(NULL) == OAK_IPC_MSGTYPE_UNKNOWN); + EXPECT_TRUE(OAK_IPC_MSGTYPE_GRAPH_UPDATE != OAK_IPC_MSGTYPE_UNKNOWN); } -int main() +TEST(OakEngineIpc, Main) { test_shm(); test_framepool(); @@ -586,6 +587,4 @@ int main() test_render_frame(); test_small_messages(); - printf("oakengine_ipc_test: all assertions passed\n"); - return 0; } diff --git a/engine/tests/oakengine_keyframe_test.cpp b/engine/tests/oakengine_keyframe_test.cpp index e6a58cbd8..a6482f87c 100644 --- a/engine/tests/oakengine_keyframe_test.cpp +++ b/engine/tests/oakengine_keyframe_test.cpp @@ -24,6 +24,7 @@ // undo/redo chain. No GL required. #include +#include #include #include #include @@ -52,13 +53,13 @@ static void make_tmpdir(void) #if defined(_WIN32) char base[MAX_PATH]; const DWORD len = GetTempPathA(MAX_PATH, base); - assert(len > 0 && len < MAX_PATH); + EXPECT_TRUE(len > 0 && len < MAX_PATH); snprintf(g_tmpdir, sizeof(g_tmpdir), "%soakengine_keyframe_test_%lu", base, (unsigned long)GetCurrentProcessId()); - assert(_mkdir(g_tmpdir) == 0); + EXPECT_TRUE(_mkdir(g_tmpdir) == 0); #else strcpy(g_tmpdir, "/tmp/oakengine_keyframe_test_XXXXXX"); - assert(mkdtemp(g_tmpdir) != NULL); + EXPECT_TRUE(mkdtemp(g_tmpdir) != NULL); #endif } @@ -76,143 +77,143 @@ static void test_float_lifecycle(OakEngineProject *project, { char err[256]; - assert(oakengine_node_input_is_keyframed(opacity, "opacity_in") == 0); - assert(oakengine_node_keyframe_count(opacity, "opacity_in") == 0); + EXPECT_TRUE(oakengine_node_input_is_keyframed(opacity, "opacity_in") == 0); + EXPECT_TRUE(oakengine_node_keyframe_count(opacity, "opacity_in") == 0); // Missing input ids and missing keyframes report errors. oak_node_value v = float_value(0.5); - assert(oakengine_node_keyframe_add(opacity, "no_such_input", 0, &v, 0, 0, + EXPECT_TRUE(oakengine_node_keyframe_add(opacity, "no_such_input", 0, &v, 0, 0, 0, 0, 0) == OAKENGINE_E_NOT_FOUND); - assert(oakengine_node_last_error(err, sizeof(err)) > 0); - assert(oakengine_node_keyframe_add(NULL, "opacity_in", 0, &v, 0, 0, 0, + EXPECT_TRUE(oakengine_node_last_error(err, sizeof(err)) > 0); + EXPECT_TRUE(oakengine_node_keyframe_add(NULL, "opacity_in", 0, &v, 0, 0, 0, 0, 0) == OAKENGINE_E_INVALID); - assert(oakengine_node_keyframe_add(opacity, "opacity_in", 0, NULL, 0, 0, + EXPECT_TRUE(oakengine_node_keyframe_add(opacity, "opacity_in", 0, NULL, 0, 0, 0, 0, 0) == OAKENGINE_E_INVALID); - assert(oakengine_node_keyframe_add(opacity, "opacity_in", 0, &v, 9, 0, 0, + EXPECT_TRUE(oakengine_node_keyframe_add(opacity, "opacity_in", 0, &v, 9, 0, 0, 0, 0) == OAKENGINE_E_INVALID); // Three linear keys at 0, 15, 30. v = float_value(0.0); - assert(oakengine_node_keyframe_add(opacity, "opacity_in", 0, &v, 0, 0, 0, + EXPECT_TRUE(oakengine_node_keyframe_add(opacity, "opacity_in", 0, &v, 0, 0, 0, 0, 0) == OAKENGINE_OK); - assert(oakengine_node_input_is_keyframed(opacity, "opacity_in") == 1); + EXPECT_TRUE(oakengine_node_input_is_keyframed(opacity, "opacity_in") == 1); v = float_value(0.5); - assert(oakengine_node_keyframe_add(opacity, "opacity_in", 15, &v, 0, 0, + EXPECT_TRUE(oakengine_node_keyframe_add(opacity, "opacity_in", 15, &v, 0, 0, 0, 0, 0) == OAKENGINE_OK); v = float_value(1.0); - assert(oakengine_node_keyframe_add(opacity, "opacity_in", 30, &v, 0, 0, + EXPECT_TRUE(oakengine_node_keyframe_add(opacity, "opacity_in", 30, &v, 0, 0, 0, 0, 0) == OAKENGINE_OK); - assert(oakengine_node_keyframe_count(opacity, "opacity_in") == 3); + EXPECT_TRUE(oakengine_node_keyframe_count(opacity, "opacity_in") == 3); // A key at an occupied time is refused. v = float_value(0.25); - assert(oakengine_node_keyframe_add(opacity, "opacity_in", 15, &v, 0, 0, + EXPECT_TRUE(oakengine_node_keyframe_add(opacity, "opacity_in", 15, &v, 0, 0, 0, 0, 0) == OAKENGINE_E_STATE); // Read them back: ordered, correct times and values, linear easing. int64_t ts = -1; oak_node_value out; for (int i = 0; i < 3; i++) { - assert(oakengine_node_keyframe_at(opacity, "opacity_in", i, &ts, + EXPECT_TRUE(oakengine_node_keyframe_at(opacity, "opacity_in", i, &ts, &out) == OAKENGINE_OK); - assert(ts == i * 15); - assert(out.type == OAK_NODE_VALUE_FLOAT); - assert(fabs(out.f[0] - i * 0.5) < 1e-9); + EXPECT_TRUE(ts == i * 15); + EXPECT_TRUE(out.type == OAK_NODE_VALUE_FLOAT); + EXPECT_TRUE(fabs(out.f[0] - i * 0.5) < 1e-9); int type = -1; float x1 = -1, y1 = -1, x2 = -1, y2 = -1; - assert(oakengine_node_keyframe_get_easing(opacity, "opacity_in", i, + EXPECT_TRUE(oakengine_node_keyframe_get_easing(opacity, "opacity_in", i, &x1, &y1, &x2, &y2, &type) == OAKENGINE_OK); - assert(type == 0); // linear - assert(x1 == 0 && y1 == 0 && x2 == 0 && y2 == 0); + EXPECT_TRUE(type == 0); // linear + EXPECT_TRUE(x1 == 0 && y1 == 0 && x2 == 0 && y2 == 0); } - assert(oakengine_node_keyframe_at(opacity, "opacity_in", 3, &ts, &out) == + EXPECT_TRUE(oakengine_node_keyframe_at(opacity, "opacity_in", 3, &ts, &out) == OAKENGINE_E_NOT_FOUND); - assert(oakengine_node_keyframe_get_easing(opacity, "opacity_in", 99, + EXPECT_TRUE(oakengine_node_keyframe_get_easing(opacity, "opacity_in", 99, NULL, NULL, NULL, NULL, NULL) == OAKENGINE_E_NOT_FOUND); // Undo the adds one by one, then redo them all. - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_node_keyframe_count(opacity, "opacity_in") == 2); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_node_keyframe_count(opacity, "opacity_in") == 1); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_node_keyframe_count(opacity, "opacity_in") == 0); - assert(oakengine_node_input_is_keyframed(opacity, "opacity_in") == 0); - assert(oakengine_project_redo(project) == OAKENGINE_OK); - assert(oakengine_project_redo(project) == OAKENGINE_OK); - assert(oakengine_project_redo(project) == OAKENGINE_OK); - assert(oakengine_node_keyframe_count(opacity, "opacity_in") == 3); - assert(oakengine_node_input_is_keyframed(opacity, "opacity_in") == 1); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_keyframe_count(opacity, "opacity_in") == 2); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_keyframe_count(opacity, "opacity_in") == 1); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_keyframe_count(opacity, "opacity_in") == 0); + EXPECT_TRUE(oakengine_node_input_is_keyframed(opacity, "opacity_in") == 0); + EXPECT_TRUE(oakengine_project_redo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_redo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_redo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_keyframe_count(opacity, "opacity_in") == 3); + EXPECT_TRUE(oakengine_node_input_is_keyframed(opacity, "opacity_in") == 1); } static void test_easing_and_remove(OakEngineProject *project, OakEngineNode *opacity) { // Bezier easing on the middle key, control points round-trip. - assert(oakengine_node_keyframe_set_easing(opacity, "opacity_in", 15, 1, + EXPECT_TRUE(oakengine_node_keyframe_set_easing(opacity, "opacity_in", 15, 1, 0.1f, 0.2f, 0.3f, 0.4f) == OAKENGINE_OK); int type = -1; float x1 = 0, y1 = 0, x2 = 0, y2 = 0; - assert(oakengine_node_keyframe_get_easing(opacity, "opacity_in", 1, &x1, + EXPECT_TRUE(oakengine_node_keyframe_get_easing(opacity, "opacity_in", 1, &x1, &y1, &x2, &y2, &type) == OAKENGINE_OK); - assert(type == 1); // bezier - assert(fabsf(x1 - 0.1f) < 1e-6f && fabsf(y1 - 0.2f) < 1e-6f); - assert(fabsf(x2 - 0.3f) < 1e-6f && fabsf(y2 - 0.4f) < 1e-6f); + EXPECT_TRUE(type == 1); // bezier + EXPECT_TRUE(fabsf(x1 - 0.1f) < 1e-6f && fabsf(y1 - 0.2f) < 1e-6f); + EXPECT_TRUE(fabsf(x2 - 0.3f) < 1e-6f && fabsf(y2 - 0.4f) < 1e-6f); // Undo restores linear, redo restores bezier. - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_node_keyframe_get_easing(opacity, "opacity_in", 1, &x1, + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_keyframe_get_easing(opacity, "opacity_in", 1, &x1, &y1, &x2, &y2, &type) == OAKENGINE_OK); - assert(type == 0); - assert(oakengine_project_redo(project) == OAKENGINE_OK); - assert(oakengine_node_keyframe_get_easing(opacity, "opacity_in", 1, &x1, + EXPECT_TRUE(type == 0); + EXPECT_TRUE(oakengine_project_redo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_keyframe_get_easing(opacity, "opacity_in", 1, &x1, &y1, &x2, &y2, &type) == OAKENGINE_OK); - assert(type == 1); + EXPECT_TRUE(type == 1); // Hold easing on the first key. - assert(oakengine_node_keyframe_set_easing(opacity, "opacity_in", 0, 2, 0, + EXPECT_TRUE(oakengine_node_keyframe_set_easing(opacity, "opacity_in", 0, 2, 0, 0, 0, 0) == OAKENGINE_OK); - assert(oakengine_node_keyframe_get_easing(opacity, "opacity_in", 0, NULL, + EXPECT_TRUE(oakengine_node_keyframe_get_easing(opacity, "opacity_in", 0, NULL, NULL, NULL, NULL, &type) == OAKENGINE_OK); - assert(type == 2); // hold - assert(oakengine_node_keyframe_set_easing(opacity, "opacity_in", 15, 9, 0, + EXPECT_TRUE(type == 2); // hold + EXPECT_TRUE(oakengine_node_keyframe_set_easing(opacity, "opacity_in", 15, 9, 0, 0, 0, 0) == OAKENGINE_E_INVALID); - assert(oakengine_node_keyframe_set_easing(opacity, "opacity_in", 77, 1, 0, + EXPECT_TRUE(oakengine_node_keyframe_set_easing(opacity, "opacity_in", 77, 1, 0, 0, 0, 0) == OAKENGINE_E_NOT_FOUND); // Remove the middle key; order compacts. - assert(oakengine_node_keyframe_remove(opacity, "opacity_in", 15) == + EXPECT_TRUE(oakengine_node_keyframe_remove(opacity, "opacity_in", 15) == OAKENGINE_OK); - assert(oakengine_node_keyframe_count(opacity, "opacity_in") == 2); + EXPECT_TRUE(oakengine_node_keyframe_count(opacity, "opacity_in") == 2); int64_t ts = -1; oak_node_value out; - assert(oakengine_node_keyframe_at(opacity, "opacity_in", 1, &ts, &out) == + EXPECT_TRUE(oakengine_node_keyframe_at(opacity, "opacity_in", 1, &ts, &out) == OAKENGINE_OK); - assert(ts == 30 && fabs(out.f[0] - 1.0) < 1e-9); - assert(oakengine_node_keyframe_remove(opacity, "opacity_in", 15) == + EXPECT_TRUE(ts == 30 && fabs(out.f[0] - 1.0) < 1e-9); + EXPECT_TRUE(oakengine_node_keyframe_remove(opacity, "opacity_in", 15) == OAKENGINE_E_NOT_FOUND); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_node_keyframe_count(opacity, "opacity_in") == 3); - assert(oakengine_node_keyframe_at(opacity, "opacity_in", 1, &ts, &out) == + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_keyframe_count(opacity, "opacity_in") == 3); + EXPECT_TRUE(oakengine_node_keyframe_at(opacity, "opacity_in", 1, &ts, &out) == OAKENGINE_OK); - assert(ts == 15); + EXPECT_TRUE(ts == 15); // Clear all, then undo. - assert(oakengine_node_keyframes_clear(opacity, "opacity_in") == + EXPECT_TRUE(oakengine_node_keyframes_clear(opacity, "opacity_in") == OAKENGINE_OK); - assert(oakengine_node_keyframe_count(opacity, "opacity_in") == 0); - assert(oakengine_node_keyframes_clear(opacity, "opacity_in") == + EXPECT_TRUE(oakengine_node_keyframe_count(opacity, "opacity_in") == 0); + EXPECT_TRUE(oakengine_node_keyframes_clear(opacity, "opacity_in") == OAKENGINE_OK); // no-op on empty - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_node_keyframe_count(opacity, "opacity_in") == 3); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_keyframe_count(opacity, "opacity_in") == 3); } static void test_rational_and_color(OakEngineProject *project, @@ -225,21 +226,21 @@ static void test_rational_and_color(OakEngineProject *project, v.type = OAK_NODE_VALUE_RATIONAL; v.num = 30; v.den = 1; - assert(oakengine_node_keyframe_add(timeremap, "time_in", 0, &v, 0, 0, 0, + EXPECT_TRUE(oakengine_node_keyframe_add(timeremap, "time_in", 0, &v, 0, 0, 0, 0, 0) == OAKENGINE_OK); - assert(oakengine_node_keyframe_count(timeremap, "time_in") == 1); + EXPECT_TRUE(oakengine_node_keyframe_count(timeremap, "time_in") == 1); int64_t ts = -1; oak_node_value out; - assert(oakengine_node_keyframe_at(timeremap, "time_in", 0, &ts, &out) == + EXPECT_TRUE(oakengine_node_keyframe_at(timeremap, "time_in", 0, &ts, &out) == OAKENGINE_OK); - assert(ts == 0); - assert(out.type == OAK_NODE_VALUE_RATIONAL); - assert(out.num == 30 && out.den == 1); + EXPECT_TRUE(ts == 0); + EXPECT_TRUE(out.type == OAK_NODE_VALUE_RATIONAL); + EXPECT_TRUE(out.num == 30 && out.den == 1); // A type mismatch is rejected. v.type = OAK_NODE_VALUE_FLOAT; v.f[0] = 1.5; - assert(oakengine_node_keyframe_add(timeremap, "time_in", 5, &v, 0, 0, 0, + EXPECT_TRUE(oakengine_node_keyframe_add(timeremap, "time_in", 5, &v, 0, 0, 0, 0, 0) == OAKENGINE_E_INVALID); // COLOR on the Solid generator: track 0 is the red component. @@ -249,17 +250,17 @@ static void test_rational_and_color(OakEngineProject *project, v.f[1] = 0.5; v.f[2] = 0.75; v.f[3] = 1.0; - assert(oakengine_node_keyframe_add(solid, "color_in", 10, &v, 0, 0, 0, 0, + EXPECT_TRUE(oakengine_node_keyframe_add(solid, "color_in", 10, &v, 0, 0, 0, 0, 0) == OAKENGINE_OK); - assert(oakengine_node_keyframe_at(solid, "color_in", 0, &ts, &out) == + EXPECT_TRUE(oakengine_node_keyframe_at(solid, "color_in", 0, &ts, &out) == OAKENGINE_OK); - assert(ts == 10); - assert(out.type == OAK_NODE_VALUE_COLOR); - assert(fabs(out.f[0] - 0.25) < 1e-6); // first component only + EXPECT_TRUE(ts == 10); + EXPECT_TRUE(out.type == OAK_NODE_VALUE_COLOR); + EXPECT_TRUE(fabs(out.f[0] - 0.25) < 1e-6); // first component only - assert(oakengine_node_keyframes_clear(timeremap, "time_in") == + EXPECT_TRUE(oakengine_node_keyframes_clear(timeremap, "time_in") == OAKENGINE_OK); - assert(oakengine_node_keyframes_clear(solid, "color_in") == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_keyframes_clear(solid, "color_in") == OAKENGINE_OK); } static void test_panel_paths(OakEngineProject *project, @@ -269,67 +270,67 @@ static void test_panel_paths(OakEngineProject *project, // Frame time base (1001/30000 with the default sequence). int tbn = 0, tbd = 0; - assert(oakengine_node_frame_time_base(opacity, &tbn, &tbd) == + EXPECT_TRUE(oakengine_node_frame_time_base(opacity, &tbn, &tbd) == OAKENGINE_OK); - assert(tbn > 0 && tbd > 0); - assert(oakengine_node_frame_time_base(NULL, &tbn, &tbd) == + EXPECT_TRUE(tbn > 0 && tbd > 0); + EXPECT_TRUE(oakengine_node_frame_time_base(NULL, &tbn, &tbd) == OAKENGINE_E_INVALID); // set_input_at_time on a NON-keyframed input (fresh node) sets the // standard value; undo restores it. OakEngineNode *op2 = oakengine_project_add_node( project, "org.olivevideoeditor.Olive.opacity"); - assert(op2 != NULL); + EXPECT_TRUE(op2 != NULL); oak_node_value v = float_value(0.75); - assert(oakengine_node_set_input_at_time(op2, "opacity_in", -1, 10, 0, &v, + EXPECT_TRUE(oakengine_node_set_input_at_time(op2, "opacity_in", -1, 10, 0, &v, 1) == OAKENGINE_OK); - assert(oakengine_node_get_input(op2, "opacity_in", &out) == OAKENGINE_OK); - assert(fabs(out.f[0] - 0.75) < 1e-9); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_node_get_input(op2, "opacity_in", &out) == OAKENGINE_OK); - assert(fabs(out.f[0] - 0.75) > 1e-9); + EXPECT_TRUE(oakengine_node_get_input(op2, "opacity_in", &out) == OAKENGINE_OK); + EXPECT_TRUE(fabs(out.f[0] - 0.75) < 1e-9); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_get_input(op2, "opacity_in", &out) == OAKENGINE_OK); + EXPECT_TRUE(fabs(out.f[0] - 0.75) > 1e-9); // Component type must match the declared type; bad track/id rejected. oak_node_value wrong; memset(&wrong, 0, sizeof(wrong)); wrong.type = OAK_NODE_VALUE_INT; - assert(oakengine_node_set_input_at_time(op2, "opacity_in", -1, 0, 0, + EXPECT_TRUE(oakengine_node_set_input_at_time(op2, "opacity_in", -1, 0, 0, &wrong, 1) == OAKENGINE_E_INVALID); - assert(oakengine_node_set_input_at_time(op2, "opacity_in", -1, 0, 1, &v, + EXPECT_TRUE(oakengine_node_set_input_at_time(op2, "opacity_in", -1, 0, 1, &v, 1) == OAKENGINE_E_INVALID); - assert(oakengine_node_set_input_at_time(op2, "nope", -1, 0, 0, &v, + EXPECT_TRUE(oakengine_node_set_input_at_time(op2, "nope", -1, 0, 0, &v, 1) == OAKENGINE_E_NOT_FOUND); - assert(oakengine_node_set_input_at_time(NULL, "opacity_in", -1, 0, 0, &v, + EXPECT_TRUE(oakengine_node_set_input_at_time(NULL, "opacity_in", -1, 0, 0, &v, 1) == OAKENGINE_E_INVALID); // `opacity` is keyframed at this point (keys at 0/15/30 left by the // earlier tests): the call writes a KEYFRAME at the time // (set_value_at_time semantics) -- insert first, then update in place. v = float_value(0.9); - assert(oakengine_node_set_input_at_time(opacity, "opacity_in", -1, 20, 0, + EXPECT_TRUE(oakengine_node_set_input_at_time(opacity, "opacity_in", -1, 20, 0, &v, 1) == OAKENGINE_OK); - assert(oakengine_node_keyframe_count(opacity, "opacity_in") == 4); + EXPECT_TRUE(oakengine_node_keyframe_count(opacity, "opacity_in") == 4); int64_t ts = -1; - assert(oakengine_node_keyframe_at(opacity, "opacity_in", 2, &ts, &out) == + EXPECT_TRUE(oakengine_node_keyframe_at(opacity, "opacity_in", 2, &ts, &out) == OAKENGINE_OK); - assert(ts == 20 && fabs(out.f[0] - 0.9) < 1e-9); + EXPECT_TRUE(ts == 20 && fabs(out.f[0] - 0.9) < 1e-9); v = float_value(0.8); - assert(oakengine_node_set_input_at_time(opacity, "opacity_in", -1, 20, 0, + EXPECT_TRUE(oakengine_node_set_input_at_time(opacity, "opacity_in", -1, 20, 0, &v, 1) == OAKENGINE_OK); - assert(oakengine_node_keyframe_count(opacity, "opacity_in") == 4); - assert(oakengine_node_keyframe_at(opacity, "opacity_in", 2, &ts, &out) == + EXPECT_TRUE(oakengine_node_keyframe_count(opacity, "opacity_in") == 4); + EXPECT_TRUE(oakengine_node_keyframe_at(opacity, "opacity_in", 2, &ts, &out) == OAKENGINE_OK); - assert(fabs(out.f[0] - 0.8) < 1e-9); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_node_keyframe_count(opacity, "opacity_in") == 3); + EXPECT_TRUE(fabs(out.f[0] - 0.8) < 1e-9); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_keyframe_count(opacity, "opacity_in") == 3); // track -1 writes all color components in one command (fresh node, so // the standard value itself is written and readable back). OakEngineNode *solid2 = oakengine_project_add_node( project, "org.olivevideoeditor.Olive.solidgenerator"); - assert(solid2 != NULL); + EXPECT_TRUE(solid2 != NULL); oak_node_value c; memset(&c, 0, sizeof(c)); c.type = OAK_NODE_VALUE_COLOR; @@ -337,85 +338,85 @@ static void test_panel_paths(OakEngineProject *project, c.f[1] = 0.2; c.f[2] = 0.3; c.f[3] = 0.4; - assert(oakengine_node_set_input_at_time(solid2, "color_in", -1, 5, -1, &c, + EXPECT_TRUE(oakengine_node_set_input_at_time(solid2, "color_in", -1, 5, -1, &c, 0) == OAKENGINE_OK); - assert(oakengine_node_get_input(solid2, "color_in", &out) == + EXPECT_TRUE(oakengine_node_get_input(solid2, "color_in", &out) == OAKENGINE_OK); - assert(fabs(out.f[0] - 0.1) < 1e-6 && fabs(out.f[1] - 0.2) < 1e-6 && + EXPECT_TRUE(fabs(out.f[0] - 0.1) < 1e-6 && fabs(out.f[1] - 0.2) < 1e-6 && fabs(out.f[2] - 0.3) < 1e-6 && fabs(out.f[3] - 0.4) < 1e-6); - assert(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); // String-at-time on the text node; the POD path rejects strings and // vice versa. OakEngineNode *text = oakengine_project_add_node( project, "org.olivevideoeditor.Olive.text3"); - assert(text != NULL); - assert(oakengine_node_set_input_string_at_time(text, "text_in", -1, 0, + EXPECT_TRUE(text != NULL); + EXPECT_TRUE(oakengine_node_set_input_string_at_time(text, "text_in", -1, 0, "hello") == OAKENGINE_OK); - assert(oakengine_node_set_input_string_at_time(text, "nope", -1, 0, + EXPECT_TRUE(oakengine_node_set_input_string_at_time(text, "nope", -1, 0, "x") == OAKENGINE_E_NOT_FOUND); - assert(oakengine_node_set_input_string_at_time(op2, "opacity_in", -1, 0, + EXPECT_TRUE(oakengine_node_set_input_string_at_time(op2, "opacity_in", -1, 0, "x") == OAKENGINE_E_INVALID); - assert(oakengine_node_set_input_at_time(text, "text_in", -1, 0, 0, &v, + EXPECT_TRUE(oakengine_node_set_input_at_time(text, "text_in", -1, 0, 0, &v, 1) == OAKENGINE_E_INVALID); // Array insert/remove on the text node's args_in array. - assert(oakengine_node_array_insert_at(text, "args_in", 0) == + EXPECT_TRUE(oakengine_node_array_insert_at(text, "args_in", 0) == OAKENGINE_OK); - assert(oakengine_node_array_insert_at(text, "args_in", 1) == + EXPECT_TRUE(oakengine_node_array_insert_at(text, "args_in", 1) == OAKENGINE_OK); - assert(oakengine_node_array_remove_at(text, "args_in", 1) == + EXPECT_TRUE(oakengine_node_array_remove_at(text, "args_in", 1) == OAKENGINE_OK); - assert(oakengine_node_array_remove_at(text, "args_in", 5) == + EXPECT_TRUE(oakengine_node_array_remove_at(text, "args_in", 5) == OAKENGINE_E_NOT_FOUND); - assert(oakengine_node_array_remove_at(text, "args_in", 0) == + EXPECT_TRUE(oakengine_node_array_remove_at(text, "args_in", 0) == OAKENGINE_OK); - assert(oakengine_node_array_insert_at(text, "args_in", -1) == + EXPECT_TRUE(oakengine_node_array_insert_at(text, "args_in", -1) == OAKENGINE_E_INVALID); - assert(oakengine_node_array_remove_at(NULL, "args_in", 0) == + EXPECT_TRUE(oakengine_node_array_remove_at(NULL, "args_in", 0) == OAKENGINE_E_INVALID); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); // keyframes_set_type_many: keys at 0 and 15 to hold in one command. const int64_t times[2] = { 0, 15 }; const int tracks[2] = { 0, 0 }; - assert(oakengine_node_keyframes_set_type_many(opacity, "opacity_in", -1, + EXPECT_TRUE(oakengine_node_keyframes_set_type_many(opacity, "opacity_in", -1, times, tracks, 2, 2) == 2); int type = -1; - assert(oakengine_node_keyframe_get_easing(opacity, "opacity_in", 0, NULL, + EXPECT_TRUE(oakengine_node_keyframe_get_easing(opacity, "opacity_in", 0, NULL, NULL, NULL, NULL, &type) == OAKENGINE_OK); - assert(type == 2); - assert(oakengine_node_keyframe_get_easing(opacity, "opacity_in", 1, NULL, + EXPECT_TRUE(type == 2); + EXPECT_TRUE(oakengine_node_keyframe_get_easing(opacity, "opacity_in", 1, NULL, NULL, NULL, NULL, &type) == OAKENGINE_OK); - assert(type == 2); + EXPECT_TRUE(type == 2); // One undo restores each key's own previous easing (hold at 0, bezier // at 15 -- left over from the earlier tests). - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_node_keyframe_get_easing(opacity, "opacity_in", 0, NULL, + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_keyframe_get_easing(opacity, "opacity_in", 0, NULL, NULL, NULL, NULL, &type) == OAKENGINE_OK); - assert(type == 2); - assert(oakengine_node_keyframe_get_easing(opacity, "opacity_in", 1, NULL, + EXPECT_TRUE(type == 2); + EXPECT_TRUE(oakengine_node_keyframe_get_easing(opacity, "opacity_in", 1, NULL, NULL, NULL, NULL, &type) == OAKENGINE_OK); - assert(type == 1); + EXPECT_TRUE(type == 1); // A bad address fails without side effects; zero count is a no-op. const int64_t bad[1] = { 99 }; - assert(oakengine_node_keyframes_set_type_many(opacity, "opacity_in", -1, + EXPECT_TRUE(oakengine_node_keyframes_set_type_many(opacity, "opacity_in", -1, bad, tracks, 1, 1) == OAKENGINE_E_NOT_FOUND); - assert(oakengine_node_keyframes_set_type_many(opacity, "opacity_in", -1, + EXPECT_TRUE(oakengine_node_keyframes_set_type_many(opacity, "opacity_in", -1, times, tracks, 0, 1) == 0); - assert(oakengine_node_keyframes_set_type_many(NULL, "opacity_in", -1, + EXPECT_TRUE(oakengine_node_keyframes_set_type_many(NULL, "opacity_in", -1, times, tracks, 1, 1) == OAKENGINE_E_INVALID); - assert(oakengine_node_keyframe_count(opacity, "opacity_in") == 3); + EXPECT_TRUE(oakengine_node_keyframe_count(opacity, "opacity_in") == 3); } static void test_keyframe_properties(OakEngineProject *project, @@ -429,34 +430,34 @@ static void test_keyframe_properties(OakEngineProject *project, // set_time_many: move 15 -> 20 and undo. const int64_t olds[1] = { 15 }; - assert(oakengine_node_keyframes_set_time_many(opacity, "opacity_in", -1, + EXPECT_TRUE(oakengine_node_keyframes_set_time_many(opacity, "opacity_in", -1, olds, tr1, 1, 20) == 1); - assert(oakengine_node_keyframe_at(opacity, "opacity_in", 1, &ts, NULL) == + EXPECT_TRUE(oakengine_node_keyframe_at(opacity, "opacity_in", 1, &ts, NULL) == OAKENGINE_OK); - assert(ts == 20); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_node_keyframe_at(opacity, "opacity_in", 1, &ts, NULL) == + EXPECT_TRUE(ts == 20); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_keyframe_at(opacity, "opacity_in", 1, &ts, NULL) == OAKENGINE_OK); - assert(ts == 15); + EXPECT_TRUE(ts == 15); // Moving onto an occupied time is a conflict; onto the key's own time // is allowed; a missing key is NOT_FOUND. Failures push nothing. - assert(oakengine_node_keyframes_set_time_many(opacity, "opacity_in", -1, + EXPECT_TRUE(oakengine_node_keyframes_set_time_many(opacity, "opacity_in", -1, olds, tr1, 1, 30) == OAKENGINE_E_STATE); - assert(oakengine_node_keyframes_set_time_many(opacity, "opacity_in", -1, + EXPECT_TRUE(oakengine_node_keyframes_set_time_many(opacity, "opacity_in", -1, olds, tr1, 1, 15) == 1); - assert(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); const int64_t miss[1] = { 99 }; - assert(oakengine_node_keyframes_set_time_many(opacity, "opacity_in", -1, + EXPECT_TRUE(oakengine_node_keyframes_set_time_many(opacity, "opacity_in", -1, miss, tr1, 1, 40) == OAKENGINE_E_NOT_FOUND); - assert(oakengine_node_keyframes_set_time_many(NULL, "opacity_in", -1, + EXPECT_TRUE(oakengine_node_keyframes_set_time_many(NULL, "opacity_in", -1, olds, tr1, 1, 40) == OAKENGINE_E_INVALID); - assert(oakengine_node_keyframes_set_time_many(opacity, "opacity_in", -1, + EXPECT_TRUE(oakengine_node_keyframes_set_time_many(opacity, "opacity_in", -1, olds, tr1, 0, 40) == 0); - assert(oakengine_node_keyframe_count(opacity, "opacity_in") == 3); + EXPECT_TRUE(oakengine_node_keyframe_count(opacity, "opacity_in") == 3); // set_value_many: captured old values are restored by undo. const int64_t times2[2] = { 0, 15 }; @@ -464,100 +465,100 @@ static void test_keyframe_properties(OakEngineProject *project, oak_node_value nv[2]; nv[0] = float_value(0.7); nv[1] = float_value(0.6); - assert(oakengine_node_keyframes_set_value_many(opacity, "opacity_in", -1, + EXPECT_TRUE(oakengine_node_keyframes_set_value_many(opacity, "opacity_in", -1, times2, tr2, 2, nv, NULL) == 2); - assert(oakengine_node_keyframe_at(opacity, "opacity_in", 0, &ts, &out) == + EXPECT_TRUE(oakengine_node_keyframe_at(opacity, "opacity_in", 0, &ts, &out) == OAKENGINE_OK); - assert(fabs(out.f[0] - 0.7) < 1e-9); - assert(oakengine_node_keyframe_at(opacity, "opacity_in", 1, &ts, &out) == + EXPECT_TRUE(fabs(out.f[0] - 0.7) < 1e-9); + EXPECT_TRUE(oakengine_node_keyframe_at(opacity, "opacity_in", 1, &ts, &out) == OAKENGINE_OK); - assert(fabs(out.f[0] - 0.6) < 1e-9); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_node_keyframe_at(opacity, "opacity_in", 0, &ts, &out) == + EXPECT_TRUE(fabs(out.f[0] - 0.6) < 1e-9); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_keyframe_at(opacity, "opacity_in", 0, &ts, &out) == OAKENGINE_OK); - assert(fabs(out.f[0] - 0.0) < 1e-9); - assert(oakengine_node_keyframe_at(opacity, "opacity_in", 1, &ts, &out) == + EXPECT_TRUE(fabs(out.f[0] - 0.0) < 1e-9); + EXPECT_TRUE(oakengine_node_keyframe_at(opacity, "opacity_in", 1, &ts, &out) == OAKENGINE_OK); - assert(fabs(out.f[0] - 0.5) < 1e-9); + EXPECT_TRUE(fabs(out.f[0] - 0.5) < 1e-9); // Explicit old values (the live-set drag pattern): undo restores the // recorded old, redo the new. oak_node_value ov[2]; ov[0] = float_value(9.9); ov[1] = float_value(9.8); - assert(oakengine_node_keyframes_set_value_many(opacity, "opacity_in", -1, + EXPECT_TRUE(oakengine_node_keyframes_set_value_many(opacity, "opacity_in", -1, times2, tr2, 2, nv, ov) == 2); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_node_keyframe_at(opacity, "opacity_in", 0, &ts, &out) == + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_keyframe_at(opacity, "opacity_in", 0, &ts, &out) == OAKENGINE_OK); - assert(fabs(out.f[0] - 9.9) < 1e-9); - assert(oakengine_project_redo(project) == OAKENGINE_OK); + EXPECT_TRUE(fabs(out.f[0] - 9.9) < 1e-9); + EXPECT_TRUE(oakengine_project_redo(project) == OAKENGINE_OK); oak_node_value orig[2]; orig[0] = float_value(0.0); orig[1] = float_value(0.5); - assert(oakengine_node_keyframes_set_value_many(opacity, "opacity_in", -1, + EXPECT_TRUE(oakengine_node_keyframes_set_value_many(opacity, "opacity_in", -1, times2, tr2, 2, orig, NULL) == 2); // bezier_many: both control points on both keys, undo restores each // key's own previous points (key 15 had 0.1/0.2/0.3/0.4). - assert(oakengine_node_keyframes_set_bezier_many( + EXPECT_TRUE(oakengine_node_keyframes_set_bezier_many( opacity, "opacity_in", -1, times2, tr2, 2, 0.11f, 0.22f, 0.33f, 0.44f) == 2); float x1 = 0, y1 = 0, x2 = 0, y2 = 0; int type = -1; - assert(oakengine_node_keyframe_get_easing(opacity, "opacity_in", 1, &x1, + EXPECT_TRUE(oakengine_node_keyframe_get_easing(opacity, "opacity_in", 1, &x1, &y1, &x2, &y2, &type) == OAKENGINE_OK); - assert(fabsf(x1 - 0.11f) < 1e-6f && fabsf(y1 - 0.22f) < 1e-6f && + EXPECT_TRUE(fabsf(x1 - 0.11f) < 1e-6f && fabsf(y1 - 0.22f) < 1e-6f && fabsf(x2 - 0.33f) < 1e-6f && fabsf(y2 - 0.44f) < 1e-6f); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_node_keyframe_get_easing(opacity, "opacity_in", 1, &x1, + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_keyframe_get_easing(opacity, "opacity_in", 1, &x1, &y1, &x2, &y2, &type) == OAKENGINE_OK); - assert(fabsf(x1 - 0.1f) < 1e-6f && fabsf(y1 - 0.2f) < 1e-6f); - assert(oakengine_node_keyframes_set_bezier_many( + EXPECT_TRUE(fabsf(x1 - 0.1f) < 1e-6f && fabsf(y1 - 0.2f) < 1e-6f); + EXPECT_TRUE(oakengine_node_keyframes_set_bezier_many( opacity, "opacity_in", -1, miss, tr1, 1, 0.f, 0.f, 0.f, 0.f) == OAKENGINE_E_NOT_FOUND); // set_bezier_point: NaN old captures the current point. - assert(oakengine_node_keyframe_set_bezier_point( + EXPECT_TRUE(oakengine_node_keyframe_set_bezier_point( opacity, "opacity_in", -1, 15, 0, 0, 0.5f, 0.6f, NAN, NAN) == OAKENGINE_OK); - assert(oakengine_node_keyframe_get_easing(opacity, "opacity_in", 1, &x1, + EXPECT_TRUE(oakengine_node_keyframe_get_easing(opacity, "opacity_in", 1, &x1, &y1, &x2, &y2, &type) == OAKENGINE_OK); - assert(fabsf(x1 - 0.5f) < 1e-6f && fabsf(y1 - 0.6f) < 1e-6f); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_node_keyframe_get_easing(opacity, "opacity_in", 1, &x1, + EXPECT_TRUE(fabsf(x1 - 0.5f) < 1e-6f && fabsf(y1 - 0.6f) < 1e-6f); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_keyframe_get_easing(opacity, "opacity_in", 1, &x1, &y1, &x2, &y2, &type) == OAKENGINE_OK); - assert(fabsf(x1 - 0.1f) < 1e-6f && fabsf(y1 - 0.2f) < 1e-6f); + EXPECT_TRUE(fabsf(x1 - 0.1f) < 1e-6f && fabsf(y1 - 0.2f) < 1e-6f); // Explicit old restores the recorded point on undo. - assert(oakengine_node_keyframe_set_bezier_point( + EXPECT_TRUE(oakengine_node_keyframe_set_bezier_point( opacity, "opacity_in", -1, 15, 0, 0, 0.7f, 0.8f, 9.0f, 9.0f) == OAKENGINE_OK); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_node_keyframe_get_easing(opacity, "opacity_in", 1, &x1, + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_keyframe_get_easing(opacity, "opacity_in", 1, &x1, &y1, &x2, &y2, &type) == OAKENGINE_OK); - assert(fabsf(x1 - 9.0f) < 1e-6f); + EXPECT_TRUE(fabsf(x1 - 9.0f) < 1e-6f); // Put the point back so later state matches the earlier tests. - assert(oakengine_node_keyframe_set_bezier_point( + EXPECT_TRUE(oakengine_node_keyframe_set_bezier_point( opacity, "opacity_in", -1, 15, 0, 0, 0.1f, 0.2f, NAN, NAN) == OAKENGINE_OK); // Errors: bad point index, missing key, NULL node. - assert(oakengine_node_keyframe_set_bezier_point( + EXPECT_TRUE(oakengine_node_keyframe_set_bezier_point( opacity, "opacity_in", -1, 15, 0, 2, 0.f, 0.f, 0.f, 0.f) == OAKENGINE_E_INVALID); - assert(oakengine_node_keyframe_set_bezier_point( + EXPECT_TRUE(oakengine_node_keyframe_set_bezier_point( opacity, "opacity_in", -1, 99, 0, 0, 0.f, 0.f, 0.f, 0.f) == OAKENGINE_E_NOT_FOUND); - assert(oakengine_node_keyframe_set_bezier_point( + EXPECT_TRUE(oakengine_node_keyframe_set_bezier_point( NULL, "opacity_in", -1, 15, 0, 0, 0.f, 0.f, 0.f, 0.f) == OAKENGINE_E_INVALID); } @@ -572,51 +573,51 @@ static void test_handle_family(OakEngineProject *project, oak_node_value v; // Start from a clean, keyframing-enabled, empty input. - assert(oakengine_node_keyframes_clear(opacity, "opacity_in") == + EXPECT_TRUE(oakengine_node_keyframes_clear(opacity, "opacity_in") == OAKENGINE_OK); - assert(oakengine_node_keyframe_count_on_track(opacity, "opacity_in", -1, + EXPECT_TRUE(oakengine_node_keyframe_count_on_track(opacity, "opacity_in", -1, 0) == 0); // Toggle ON at 1s: one keyframe with the current value and best type. - assert(oakengine_node_keyframes_toggle_at_time( + EXPECT_TRUE(oakengine_node_keyframes_toggle_at_time( opacity, "opacity_in", -1, 1, 1, 1, NULL) == OAKENGINE_OK); - assert(oakengine_node_keyframe_track_count(opacity, "opacity_in", -1) == + EXPECT_TRUE(oakengine_node_keyframe_track_count(opacity, "opacity_in", -1) == 1); - assert(oakengine_node_keyframe_count_on_track(opacity, "opacity_in", -1, + EXPECT_TRUE(oakengine_node_keyframe_count_on_track(opacity, "opacity_in", -1, 0) == 1); - assert(oakengine_node_has_keyframe_at_time(opacity, "opacity_in", -1, 1, + EXPECT_TRUE(oakengine_node_has_keyframe_at_time(opacity, "opacity_in", -1, 1, 1) == 1); // Toggling on again at the same time is a no-op. - assert(oakengine_node_keyframes_toggle_at_time( + EXPECT_TRUE(oakengine_node_keyframes_toggle_at_time( opacity, "opacity_in", -1, 1, 1, 1, NULL) == OAKENGINE_OK); - assert(oakengine_node_keyframe_count_on_track(opacity, "opacity_in", -1, + EXPECT_TRUE(oakengine_node_keyframe_count_on_track(opacity, "opacity_in", -1, 0) == 1); // More keys via toggles for navigation tests. - assert(oakengine_node_keyframes_toggle_at_time( + EXPECT_TRUE(oakengine_node_keyframes_toggle_at_time( opacity, "opacity_in", -1, 0, 1, 1, NULL) == OAKENGINE_OK); - assert(oakengine_node_keyframes_toggle_at_time( + EXPECT_TRUE(oakengine_node_keyframes_toggle_at_time( opacity, "opacity_in", -1, 3, 1, 1, NULL) == OAKENGINE_OK); - assert(oakengine_node_keyframe_count_on_track(opacity, "opacity_in", -1, + EXPECT_TRUE(oakengine_node_keyframe_count_on_track(opacity, "opacity_in", -1, 0) == 3); // Navigation. int64_t num = -1, den = -1; - assert(oakengine_node_keyframe_earliest_time(opacity, "opacity_in", -1, + EXPECT_TRUE(oakengine_node_keyframe_earliest_time(opacity, "opacity_in", -1, &num, &den) == 1); - assert(num == 0 && den == 1); - assert(oakengine_node_keyframe_latest_time(opacity, "opacity_in", -1, + EXPECT_TRUE(num == 0 && den == 1); + EXPECT_TRUE(oakengine_node_keyframe_latest_time(opacity, "opacity_in", -1, &num, &den) == 1); - assert(num == 3 && den == 1); - assert(oakengine_node_keyframe_closest_time_before( + EXPECT_TRUE(num == 3 && den == 1); + EXPECT_TRUE(oakengine_node_keyframe_closest_time_before( opacity, "opacity_in", -1, 2, 1, &num, &den) == 1); - assert(num == 1 && den == 1); - assert(oakengine_node_keyframe_closest_time_after( + EXPECT_TRUE(num == 1 && den == 1); + EXPECT_TRUE(oakengine_node_keyframe_closest_time_after( opacity, "opacity_in", -1, 2, 1, &num, &den) == 1); - assert(num == 3 && den == 1); - assert(oakengine_node_keyframe_closest_time_before( + EXPECT_TRUE(num == 3 && den == 1); + EXPECT_TRUE(oakengine_node_keyframe_closest_time_before( opacity, "opacity_in", -1, 0, 1, &num, &den) == 0); - assert(oakengine_node_keyframe_closest_time_after( + EXPECT_TRUE(oakengine_node_keyframe_closest_time_after( opacity, "opacity_in", -1, 3, 1, &num, &den) == 0); // Handle lookup: on-track enumeration, at-time lookup, and the batch @@ -625,92 +626,92 @@ static void test_handle_family(OakEngineProject *project, oakengine_node_keyframe_handle_on_track(opacity, "opacity_in", -1, 0, 0); OakEngineKeyframe *k1 = oakengine_node_keyframe_handle_on_track(opacity, "opacity_in", -1, 0, 1); - assert(k0 != NULL && k1 != NULL && k0 != k1); - assert(oakengine_node_keyframe_handle_on_track(opacity, "opacity_in", -1, + EXPECT_TRUE(k0 != NULL && k1 != NULL && k0 != k1); + EXPECT_TRUE(oakengine_node_keyframe_handle_on_track(opacity, "opacity_in", -1, 0, 3) == NULL); - assert(oakengine_node_keyframe_handle_on_track(opacity, "opacity_in", -1, + EXPECT_TRUE(oakengine_node_keyframe_handle_on_track(opacity, "opacity_in", -1, 1, 0) == NULL); - assert(oakengine_node_keyframe_handle_at_time(opacity, "opacity_in", -1, + EXPECT_TRUE(oakengine_node_keyframe_handle_at_time(opacity, "opacity_in", -1, 0, 0, 1) == k0); - assert(oakengine_node_keyframe_handle_at_time(opacity, "opacity_in", -1, + EXPECT_TRUE(oakengine_node_keyframe_handle_at_time(opacity, "opacity_in", -1, 0, 1, 1) == k1); - assert(oakengine_node_keyframe_handle_at_time(opacity, "opacity_in", -1, + EXPECT_TRUE(oakengine_node_keyframe_handle_at_time(opacity, "opacity_in", -1, 0, 2, 1) == NULL); OakEngineKeyframe *at[4] = { NULL, NULL, NULL, NULL }; - assert(oakengine_node_keyframes_at_time(opacity, "opacity_in", -1, 1, 1, + EXPECT_TRUE(oakengine_node_keyframes_at_time(opacity, "opacity_in", -1, 1, 1, at, 4) == 1); - assert(at[0] == k1); + EXPECT_TRUE(at[0] == k1); // Handle accessors. - assert(oakengine_keyframe_get_time(k1, &num, &den) == OAKENGINE_OK); - assert(num == 1 && den == 1); - assert(oakengine_keyframe_get_input_id(k1, buf, sizeof(buf)) > 0); - assert(strcmp(buf, "opacity_in") == 0); - assert(oakengine_keyframe_get_track(k1) == 0); - assert(oakengine_keyframe_get_element(k1) == -1); - assert(oakengine_keyframe_get_node(k1) == opacity); - assert(oakengine_keyframe_get_type(k1) >= 0); - assert(oakengine_keyframe_default_type() >= 0); - assert(oakengine_keyframe_get_value(k1, &v) == OAKENGINE_OK); - assert(v.type == OAK_NODE_VALUE_FLOAT); + EXPECT_TRUE(oakengine_keyframe_get_time(k1, &num, &den) == OAKENGINE_OK); + EXPECT_TRUE(num == 1 && den == 1); + EXPECT_TRUE(oakengine_keyframe_get_input_id(k1, buf, sizeof(buf)) > 0); + EXPECT_TRUE(strcmp(buf, "opacity_in") == 0); + EXPECT_TRUE(oakengine_keyframe_get_track(k1) == 0); + EXPECT_TRUE(oakengine_keyframe_get_element(k1) == -1); + EXPECT_TRUE(oakengine_keyframe_get_node(k1) == opacity); + EXPECT_TRUE(oakengine_keyframe_get_type(k1) >= 0); + EXPECT_TRUE(oakengine_keyframe_default_type() >= 0); + EXPECT_TRUE(oakengine_keyframe_get_value(k1, &v) == OAKENGINE_OK); + EXPECT_TRUE(v.type == OAK_NODE_VALUE_FLOAT); // Sibling check: a key at 0s sees the key at 1s and vice versa. - assert(oakengine_keyframe_has_sibling_at_time(k0, 1, 1) == 1); - assert(oakengine_keyframe_has_sibling_at_time(k0, 0, 1) == 0); + EXPECT_TRUE(oakengine_keyframe_has_sibling_at_time(k0, 1, 1) == 1); + EXPECT_TRUE(oakengine_keyframe_has_sibling_at_time(k0, 0, 1) == 0); // NULL safety. - assert(oakengine_keyframe_get_time(NULL, &num, &den) == + EXPECT_TRUE(oakengine_keyframe_get_time(NULL, &num, &den) == OAKENGINE_E_INVALID); - assert(oakengine_keyframe_get_type(NULL) == -1); - assert(oakengine_keyframe_get_node(NULL) == NULL); - assert(oakengine_keyframe_get_track(NULL) == -1); - assert(oakengine_keyframe_has_sibling_at_time(NULL, 1, 1) == 0); + EXPECT_TRUE(oakengine_keyframe_get_type(NULL) == -1); + EXPECT_TRUE(oakengine_keyframe_get_node(NULL) == NULL); + EXPECT_TRUE(oakengine_keyframe_get_track(NULL) == -1); + EXPECT_TRUE(oakengine_keyframe_has_sibling_at_time(NULL, 1, 1) == 0); // Bezier points: set easing through the existing API, then live-move a // handle (no undo entry) and read it back raw and valid. - assert(oakengine_node_keyframe_add(opacity, "opacity_in", 45, &v, 1, + EXPECT_TRUE(oakengine_node_keyframe_add(opacity, "opacity_in", 45, &v, 1, 0.1f, 0.2f, 0.3f, 0.4f) == OAKENGINE_OK); - assert(oakengine_keyframe_set_bezier_point_live(k1, 0, 0.11, 0.22) == + EXPECT_TRUE(oakengine_keyframe_set_bezier_point_live(k1, 0, 0.11, 0.22) == OAKENGINE_OK); double x = 0, y = 0; - assert(oakengine_keyframe_get_bezier_point(k1, 0, &x, &y) == + EXPECT_TRUE(oakengine_keyframe_get_bezier_point(k1, 0, &x, &y) == OAKENGINE_OK); - assert(fabs(x - 0.11) < 1e-9 && fabs(y - 0.22) < 1e-9); - assert(oakengine_keyframe_get_valid_bezier_point(k1, 0, &x, &y) == + EXPECT_TRUE(fabs(x - 0.11) < 1e-9 && fabs(y - 0.22) < 1e-9); + EXPECT_TRUE(oakengine_keyframe_get_valid_bezier_point(k1, 0, &x, &y) == OAKENGINE_OK); - assert(oakengine_keyframe_get_bezier_point(k1, 2, &x, &y) == + EXPECT_TRUE(oakengine_keyframe_get_bezier_point(k1, 2, &x, &y) == OAKENGINE_E_INVALID); // The live move pushed no undo entry of its own: undoing pops the add. - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_node_keyframe_count_on_track(opacity, "opacity_in", -1, + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_keyframe_count_on_track(opacity, "opacity_in", -1, 0) == 3); // Live value/time mutation. - assert(oakengine_keyframe_set_value_live(k1, &v) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_keyframe_set_value_live(k1, &v) == OAKENGINE_OK); oak_node_value readback; - assert(oakengine_keyframe_get_value(k1, &readback) == OAKENGINE_OK); - assert(fabs(readback.f[0] - v.f[0]) < 1e-9); - assert(oakengine_keyframe_set_time_live(k1, 2, 1) == OAKENGINE_OK); - assert(oakengine_node_has_keyframe_at_time(opacity, "opacity_in", -1, 2, + EXPECT_TRUE(oakengine_keyframe_get_value(k1, &readback) == OAKENGINE_OK); + EXPECT_TRUE(fabs(readback.f[0] - v.f[0]) < 1e-9); + EXPECT_TRUE(oakengine_keyframe_set_time_live(k1, 2, 1) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_has_keyframe_at_time(opacity, "opacity_in", -1, 2, 1) == 1); - assert(oakengine_keyframe_set_time_live(k1, 1, 1) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_keyframe_set_time_live(k1, 1, 1) == OAKENGINE_OK); // remove_many: delete the keys at 0s and 3s as ONE undoable command. OakEngineKeyframe *victims[2] = { k0, oakengine_node_keyframe_handle_at_time( opacity, "opacity_in", -1, 0, 3, 1) }; - assert(victims[1] != NULL); - assert(oakengine_keyframes_remove_many(victims, 2, NULL) == OAKENGINE_OK); - assert(oakengine_node_keyframe_count_on_track(opacity, "opacity_in", -1, + EXPECT_TRUE(victims[1] != NULL); + EXPECT_TRUE(oakengine_keyframes_remove_many(victims, 2, NULL) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_keyframe_count_on_track(opacity, "opacity_in", -1, 0) == 1); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_node_keyframe_count_on_track(opacity, "opacity_in", -1, + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_keyframe_count_on_track(opacity, "opacity_in", -1, 0) == 3); - assert(oakengine_project_redo(project) == OAKENGINE_OK); - assert(oakengine_node_keyframe_count_on_track(opacity, "opacity_in", -1, + EXPECT_TRUE(oakengine_project_redo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_keyframe_count_on_track(opacity, "opacity_in", -1, 0) == 1); // NULL entries are refused and nothing is pushed. OakEngineKeyframe *with_null[2] = { k1, NULL }; - assert(oakengine_keyframes_remove_many(with_null, 2, NULL) == + EXPECT_TRUE(oakengine_keyframes_remove_many(with_null, 2, NULL) == OAKENGINE_E_INVALID); // Detached create + paste as ONE undoable command, then dispose. @@ -723,133 +724,133 @@ static void test_handle_family(OakEngineProject *project, opacity, "opacity_in", -1, 0, 6, 1, &v, 0); OakEngineKeyframe *detached3 = oakengine_keyframe_create( opacity, "opacity_in", -1, 0, 7, 1, &v, 0); - assert(detached1 != NULL && detached2 != NULL && detached3 != NULL); - assert(oakengine_keyframe_create(opacity, "no_such", -1, 0, 5, 1, &v, + EXPECT_TRUE(detached1 != NULL && detached2 != NULL && detached3 != NULL); + EXPECT_TRUE(oakengine_keyframe_create(opacity, "no_such", -1, 0, 5, 1, &v, 0) == NULL); v.f[0] = 1.5; OakEngineKeyframe *both[2] = { detached1, detached2 }; - assert(oakengine_node_keyframes_paste(opacity, both, 2, NULL) == + EXPECT_TRUE(oakengine_node_keyframes_paste(opacity, both, 2, NULL) == OAKENGINE_OK); - assert(oakengine_node_keyframe_count_on_track(opacity, "opacity_in", -1, + EXPECT_TRUE(oakengine_node_keyframe_count_on_track(opacity, "opacity_in", -1, 0) == 3); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_node_keyframe_count_on_track(opacity, "opacity_in", -1, + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_keyframe_count_on_track(opacity, "opacity_in", -1, 0) == 1); - assert(oakengine_project_redo(project) == OAKENGINE_OK); - assert(oakengine_node_keyframe_count_on_track(opacity, "opacity_in", -1, + EXPECT_TRUE(oakengine_project_redo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_keyframe_count_on_track(opacity, "opacity_in", -1, 0) == 3); oakengine_keyframe_dispose(detached3); oakengine_keyframe_dispose(NULL); // no-op // Toggle OFF the key at 1s: removed, single-track standard value fix-up. - assert(oakengine_node_keyframes_toggle_at_time( + EXPECT_TRUE(oakengine_node_keyframes_toggle_at_time( opacity, "opacity_in", -1, 1, 1, 0, NULL) == OAKENGINE_OK); - assert(oakengine_node_has_keyframe_at_time(opacity, "opacity_in", -1, 1, + EXPECT_TRUE(oakengine_node_has_keyframe_at_time(opacity, "opacity_in", -1, 1, 1) == 0); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_node_has_keyframe_at_time(opacity, "opacity_in", -1, 1, + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_has_keyframe_at_time(opacity, "opacity_in", -1, 1, 1) == 1); - assert(oakengine_project_redo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_redo(project) == OAKENGINE_OK); // Disable keyframing entirely: all keys gone, keyframing flag off. - assert(oakengine_node_set_input_keyframing(opacity, "opacity_in", -1, 0, + EXPECT_TRUE(oakengine_node_set_input_keyframing(opacity, "opacity_in", -1, 0, 1, 1, NULL) == OAKENGINE_OK); - assert(oakengine_node_input_is_keyframed(opacity, "opacity_in") == 0); - assert(oakengine_node_keyframe_count_on_track(opacity, "opacity_in", -1, + EXPECT_TRUE(oakengine_node_input_is_keyframed(opacity, "opacity_in") == 0); + EXPECT_TRUE(oakengine_node_keyframe_count_on_track(opacity, "opacity_in", -1, 0) == 0); // Re-enable through the facade: one default-type key per track. - assert(oakengine_node_set_input_keyframing(opacity, "opacity_in", -1, 1, + EXPECT_TRUE(oakengine_node_set_input_keyframing(opacity, "opacity_in", -1, 1, 1, 1, NULL) == OAKENGINE_OK); - assert(oakengine_node_input_is_keyframed_ex(opacity, "opacity_in", -1) == + EXPECT_TRUE(oakengine_node_input_is_keyframed_ex(opacity, "opacity_in", -1) == 1); - assert(oakengine_node_keyframe_count_on_track(opacity, "opacity_in", -1, + EXPECT_TRUE(oakengine_node_keyframe_count_on_track(opacity, "opacity_in", -1, 0) == 1); OakEngineKeyframe *sole = oakengine_node_keyframe_handle_on_track( opacity, "opacity_in", -1, 0, 0); - assert(oakengine_keyframe_get_type(sole) == + EXPECT_TRUE(oakengine_keyframe_get_type(sole) == oakengine_keyframe_default_type()); // Redundant enable is a no-op success. - assert(oakengine_node_set_input_keyframing(opacity, "opacity_in", -1, 1, + EXPECT_TRUE(oakengine_node_set_input_keyframing(opacity, "opacity_in", -1, 1, 1, 1, NULL) == OAKENGINE_OK); - assert(oakengine_node_keyframe_count_on_track(opacity, "opacity_in", -1, + EXPECT_TRUE(oakengine_node_keyframe_count_on_track(opacity, "opacity_in", -1, 0) == 1); // Undo both steps back to keyframing disabled, then redo to enabled. - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_node_input_is_keyframed(opacity, "opacity_in") == 0); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_project_redo(project) == OAKENGINE_OK); - assert(oakengine_project_redo(project) == OAKENGINE_OK); - assert(oakengine_node_input_is_keyframed(opacity, "opacity_in") == 1); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_input_is_keyframed(opacity, "opacity_in") == 0); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_redo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_redo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_input_is_keyframed(opacity, "opacity_in") == 1); // Input dragger: start creates a key at the drag time, drag live-sets, // end pushes ONE undoable command. OakEngineNodeDragger *dragger = oakengine_dragger_create(opacity, "opacity_in", -1, 0); - assert(dragger != NULL); - assert(oakengine_dragger_create(opacity, "no_such", -1, 0) == NULL); - assert(oakengine_dragger_is_started(dragger) == 0); - assert(oakengine_dragger_end(dragger, NULL) == OAKENGINE_E_STATE); + EXPECT_TRUE(dragger != NULL); + EXPECT_TRUE(oakengine_dragger_create(opacity, "no_such", -1, 0) == NULL); + EXPECT_TRUE(oakengine_dragger_is_started(dragger) == 0); + EXPECT_TRUE(oakengine_dragger_end(dragger, NULL) == OAKENGINE_E_STATE); const int keys_before = oakengine_node_keyframe_count_on_track(opacity, "opacity_in", -1, 0); - assert(oakengine_dragger_start(dragger, 4, 1, 1) == OAKENGINE_OK); - assert(oakengine_dragger_is_started(dragger) == 1); - assert(oakengine_dragger_start(dragger, 4, 1, 1) == OAKENGINE_E_STATE); + EXPECT_TRUE(oakengine_dragger_start(dragger, 4, 1, 1) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_dragger_is_started(dragger) == 1); + EXPECT_TRUE(oakengine_dragger_start(dragger, 4, 1, 1) == OAKENGINE_E_STATE); oak_node_value drag_value; memset(&drag_value, 0, sizeof(drag_value)); drag_value.type = OAK_NODE_VALUE_FLOAT; drag_value.f[0] = 0.9; - assert(oakengine_dragger_drag(dragger, &drag_value) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_dragger_drag(dragger, &drag_value) == OAKENGINE_OK); oak_node_value at_time; - assert(oakengine_node_get_input_at_time(opacity, "opacity_in", -1, 0, 4, + EXPECT_TRUE(oakengine_node_get_input_at_time(opacity, "opacity_in", -1, 0, 4, 1, &at_time) == OAKENGINE_OK); - assert(fabs(at_time.f[0] - 0.9) < 1e-9); - assert(oakengine_dragger_end(dragger, "Drag Opacity") == OAKENGINE_OK); - assert(oakengine_dragger_is_started(dragger) == 0); - assert(oakengine_node_keyframe_count_on_track(opacity, "opacity_in", -1, + EXPECT_TRUE(fabs(at_time.f[0] - 0.9) < 1e-9); + EXPECT_TRUE(oakengine_dragger_end(dragger, "Drag Opacity") == OAKENGINE_OK); + EXPECT_TRUE(oakengine_dragger_is_started(dragger) == 0); + EXPECT_TRUE(oakengine_node_keyframe_count_on_track(opacity, "opacity_in", -1, 0) == keys_before + 1); // The whole drag (created key + value) unwinds with one undo. - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_node_keyframe_count_on_track(opacity, "opacity_in", -1, + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_keyframe_count_on_track(opacity, "opacity_in", -1, 0) == keys_before); - assert(oakengine_project_redo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_redo(project) == OAKENGINE_OK); oakengine_dragger_free(dragger); oakengine_dragger_free(NULL); // Clean up for later tests. - assert(oakengine_node_keyframes_clear(opacity, "opacity_in") == + EXPECT_TRUE(oakengine_node_keyframes_clear(opacity, "opacity_in") == OAKENGINE_OK); } -int main(void) +TEST(OakEngineKeyframe, Main) { make_tmpdir(); // Sandbox the config/cache/data locations (see oakengine_init_test). #if !defined(_WIN32) - assert(setenv("XDG_CONFIG_HOME", g_tmpdir, 1) == 0); - assert(setenv("XDG_CACHE_HOME", g_tmpdir, 1) == 0); - assert(setenv("XDG_DATA_HOME", g_tmpdir, 1) == 0); + EXPECT_TRUE(setenv("XDG_CONFIG_HOME", g_tmpdir, 1) == 0); + EXPECT_TRUE(setenv("XDG_CACHE_HOME", g_tmpdir, 1) == 0); + EXPECT_TRUE(setenv("XDG_DATA_HOME", g_tmpdir, 1) == 0); #endif - assert(oakengine_init(OAKENGINE_INIT_HEADLESS) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_init(OAKENGINE_INIT_HEADLESS) == OAKENGINE_OK); OakEngineProject *project = oakengine_project_create(); - assert(project != NULL); - assert(oakengine_project_new(project) == OAKENGINE_OK); + EXPECT_TRUE(project != NULL); + EXPECT_TRUE(oakengine_project_new(project) == OAKENGINE_OK); // A sequence provides the frame-rate timebase for keyframe timestamps. OakEngineSequence *seq = oakengine_sequence_new(project, "Seq"); - assert(seq != NULL); + EXPECT_TRUE(seq != NULL); OakEngineNode *opacity = oakengine_project_add_node( project, "org.olivevideoeditor.Olive.opacity"); - assert(opacity != NULL); + EXPECT_TRUE(opacity != NULL); OakEngineNode *timeremap = oakengine_project_add_node( project, "org.olivevideoeditor.Olive.timeremap"); - assert(timeremap != NULL); + EXPECT_TRUE(timeremap != NULL); OakEngineNode *solid = oakengine_project_add_node( project, "org.olivevideoeditor.Olive.solidgenerator"); - assert(solid != NULL); + EXPECT_TRUE(solid != NULL); test_float_lifecycle(project, opacity); test_easing_and_remove(project, opacity); @@ -859,8 +860,6 @@ int main(void) test_handle_family(project, opacity); oakengine_project_free(project); - assert(oakengine_shutdown() == OAKENGINE_OK); + EXPECT_TRUE(oakengine_shutdown() == OAKENGINE_OK); - printf("oakengine_keyframe_test: all assertions passed\n"); - return 0; } diff --git a/engine/tests/oakengine_lut_test.cpp b/engine/tests/oakengine_lut_test.cpp index 3bb54adec..69c2d1c85 100644 --- a/engine/tests/oakengine_lut_test.cpp +++ b/engine/tests/oakengine_lut_test.cpp @@ -22,6 +22,7 @@ // Runs headless; no GPU required. #include +#include #include #include @@ -30,40 +31,39 @@ static void test_counts_after_init(void) { - assert(oakengine_lut_directory_count() >= 0); - assert(oakengine_lut_file_count() >= 0); + EXPECT_TRUE(oakengine_lut_directory_count() >= 0); + EXPECT_TRUE(oakengine_lut_file_count() >= 0); // Out-of-range index returns an error. char buf[256]; - assert(oakengine_lut_directory_at(-1, buf, sizeof(buf)) < 0); - assert(oakengine_lut_file_at(-1, buf, sizeof(buf)) < 0); + EXPECT_TRUE(oakengine_lut_directory_at(-1, buf, sizeof(buf)) < 0); + EXPECT_TRUE(oakengine_lut_file_at(-1, buf, sizeof(buf)) < 0); } static void test_set_directories_round_trip(void) { const char *dirs[] = { "/tmp/oak_lut_a", "/tmp/oak_lut_b" }; - assert(oakengine_lut_set_directories(dirs, 2) == OAKENGINE_OK); - assert(oakengine_lut_directory_count() == 2); + EXPECT_TRUE(oakengine_lut_set_directories(dirs, 2) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_lut_directory_count() == 2); char buf[256]; - assert(oakengine_lut_directory_at(0, buf, sizeof(buf)) > 0); - assert(strcmp(buf, "/tmp/oak_lut_a") == 0); - assert(oakengine_lut_directory_at(1, buf, sizeof(buf)) > 0); - assert(strcmp(buf, "/tmp/oak_lut_b") == 0); + EXPECT_TRUE(oakengine_lut_directory_at(0, buf, sizeof(buf)) > 0); + EXPECT_TRUE(strcmp(buf, "/tmp/oak_lut_a") == 0); + EXPECT_TRUE(oakengine_lut_directory_at(1, buf, sizeof(buf)) > 0); + EXPECT_TRUE(strcmp(buf, "/tmp/oak_lut_b") == 0); // Clearing the library. - assert(oakengine_lut_set_directories(NULL, 0) == OAKENGINE_OK); - assert(oakengine_lut_directory_count() == 0); + EXPECT_TRUE(oakengine_lut_set_directories(NULL, 0) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_lut_directory_count() == 0); } -int main(void) +TEST(OakEngineLut, Main) { - assert(oakengine_init(OAKENGINE_INIT_HEADLESS) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_init(OAKENGINE_INIT_HEADLESS) == OAKENGINE_OK); test_counts_after_init(); test_set_directories_round_trip(); - assert(oakengine_shutdown() == OAKENGINE_OK); - return 0; + EXPECT_TRUE(oakengine_shutdown() == OAKENGINE_OK); } diff --git a/engine/tests/oakengine_node_test.cpp b/engine/tests/oakengine_node_test.cpp index 18b7d7ec6..f214f23f1 100644 --- a/engine/tests/oakengine_node_test.cpp +++ b/engine/tests/oakengine_node_test.cpp @@ -25,6 +25,7 @@ // fixtures. No GL required. #include +#include #include #include #include @@ -54,13 +55,13 @@ static void make_tmpdir(void) #if defined(_WIN32) char base[MAX_PATH]; const DWORD len = GetTempPathA(MAX_PATH, base); - assert(len > 0 && len < MAX_PATH); + EXPECT_TRUE(len > 0 && len < MAX_PATH); snprintf(g_tmpdir, sizeof(g_tmpdir), "%soakengine_node_test_%lu", base, (unsigned long)GetCurrentProcessId()); - assert(_mkdir(g_tmpdir) == 0); + EXPECT_TRUE(_mkdir(g_tmpdir) == 0); #else strcpy(g_tmpdir, "/tmp/oakengine_node_test_XXXXXX"); - assert(mkdtemp(g_tmpdir) != NULL); + EXPECT_TRUE(mkdtemp(g_tmpdir) != NULL); #endif } @@ -68,35 +69,35 @@ static void test_enumeration(OakEngineProject *project) { // A fresh project holds at least its root folder node. const int count = oakengine_project_node_count(project); - assert(count >= 1); - assert(oakengine_project_node_at(project, 0) != NULL); - assert(oakengine_project_node_at(project, count - 1) != NULL); - assert(oakengine_project_node_at(project, count) == NULL); - assert(oakengine_project_node_at(project, -1) == NULL); + EXPECT_TRUE(count >= 1); + EXPECT_TRUE(oakengine_project_node_at(project, 0) != NULL); + EXPECT_TRUE(oakengine_project_node_at(project, count - 1) != NULL); + EXPECT_TRUE(oakengine_project_node_at(project, count) == NULL); + EXPECT_TRUE(oakengine_project_node_at(project, -1) == NULL); // NULL safety. - assert(oakengine_project_node_count(NULL) == 0); - assert(oakengine_project_node_at(NULL, 0) == NULL); - assert(oakengine_node_get_type_id(NULL, NULL, 0) == OAKENGINE_E_INVALID); - assert(oakengine_node_get_name(NULL, NULL, 0) == OAKENGINE_E_INVALID); - assert(oakengine_node_get_label(NULL, NULL, 0) == OAKENGINE_E_INVALID); - assert(oakengine_node_set_label(NULL, "x") == OAKENGINE_E_INVALID); - assert(oakengine_node_input_count(NULL) == 0); - assert(oakengine_node_input_id(NULL, 0, NULL, 0) == OAKENGINE_E_INVALID); - assert(oakengine_node_input_get_type(NULL, "x") == OAK_NODE_VALUE_NONE); - assert(oakengine_node_input_is_connected(NULL, "x") == 0); + EXPECT_TRUE(oakengine_project_node_count(NULL) == 0); + EXPECT_TRUE(oakengine_project_node_at(NULL, 0) == NULL); + EXPECT_TRUE(oakengine_node_get_type_id(NULL, NULL, 0) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_node_get_name(NULL, NULL, 0) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_node_get_label(NULL, NULL, 0) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_node_set_label(NULL, "x") == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_node_input_count(NULL) == 0); + EXPECT_TRUE(oakengine_node_input_id(NULL, 0, NULL, 0) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_node_input_get_type(NULL, "x") == OAK_NODE_VALUE_NONE); + EXPECT_TRUE(oakengine_node_input_is_connected(NULL, "x") == 0); oak_node_value v; memset(&v, 0, sizeof(v)); - assert(oakengine_node_get_input(NULL, "x", &v) == OAKENGINE_E_INVALID); - assert(oakengine_node_set_input(NULL, "x", &v) == OAKENGINE_E_INVALID); - assert(oakengine_node_get_input_string(NULL, "x", NULL, 0) == + EXPECT_TRUE(oakengine_node_get_input(NULL, "x", &v) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_node_set_input(NULL, "x", &v) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_node_get_input_string(NULL, "x", NULL, 0) == OAKENGINE_E_INVALID); - assert(oakengine_node_set_input_string(NULL, "x", "y") == + EXPECT_TRUE(oakengine_node_set_input_string(NULL, "x", "y") == OAKENGINE_E_INVALID); - assert(oakengine_project_add_node(NULL, "x") == NULL); - assert(oakengine_project_remove_node(NULL, NULL) == OAKENGINE_E_INVALID); - assert(oakengine_node_connect(NULL, NULL, "x") == OAKENGINE_E_INVALID); - assert(oakengine_node_disconnect(NULL, "x") == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_project_add_node(NULL, "x") == NULL); + EXPECT_TRUE(oakengine_project_remove_node(NULL, NULL) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_node_connect(NULL, NULL, "x") == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_node_disconnect(NULL, "x") == OAKENGINE_E_INVALID); } static void test_add_and_metadata(OakEngineProject *project, @@ -108,35 +109,35 @@ static void test_add_and_metadata(OakEngineProject *project, OakEngineNode *solid = oakengine_project_add_node( project, "org.olivevideoeditor.Olive.solidgenerator"); - assert(solid != NULL); - assert(oakengine_project_node_count(project) == before + 1); + EXPECT_TRUE(solid != NULL); + EXPECT_TRUE(oakengine_project_node_count(project) == before + 1); - assert(oakengine_node_get_type_id(solid, buf, sizeof(buf)) > 0); - assert(strcmp(buf, "org.olivevideoeditor.Olive.solidgenerator") == 0); - assert(oakengine_node_get_name(solid, buf, sizeof(buf)) > 0); - assert(strcmp(buf, "Solid") == 0); + EXPECT_TRUE(oakengine_node_get_type_id(solid, buf, sizeof(buf)) > 0); + EXPECT_TRUE(strcmp(buf, "org.olivevideoeditor.Olive.solidgenerator") == 0); + EXPECT_TRUE(oakengine_node_get_name(solid, buf, sizeof(buf)) > 0); + EXPECT_TRUE(strcmp(buf, "Solid") == 0); // Unknown type id fails with a reason. - assert(oakengine_project_add_node(project, "org.example.nonexistent") == + EXPECT_TRUE(oakengine_project_add_node(project, "org.example.nonexistent") == NULL); char err[256]; - assert(oakengine_node_last_error(err, sizeof(err)) > 0); + EXPECT_TRUE(oakengine_node_last_error(err, sizeof(err)) > 0); // Label round-trip with undo/redo. - assert(oakengine_node_get_label(solid, buf, sizeof(buf)) >= 0); - assert(oakengine_node_set_label(solid, "MySolid") == OAKENGINE_OK); - assert(oakengine_node_get_label(solid, buf, sizeof(buf)) > 0); - assert(strcmp(buf, "MySolid") == 0); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_node_get_label(solid, buf, sizeof(buf)) >= 0); - assert(strcmp(buf, "MySolid") != 0); - assert(oakengine_project_redo(project) == OAKENGINE_OK); - assert(oakengine_node_get_label(solid, buf, sizeof(buf)) > 0); - assert(strcmp(buf, "MySolid") == 0); + EXPECT_TRUE(oakengine_node_get_label(solid, buf, sizeof(buf)) >= 0); + EXPECT_TRUE(oakengine_node_set_label(solid, "MySolid") == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_get_label(solid, buf, sizeof(buf)) > 0); + EXPECT_TRUE(strcmp(buf, "MySolid") == 0); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_get_label(solid, buf, sizeof(buf)) >= 0); + EXPECT_TRUE(strcmp(buf, "MySolid") != 0); + EXPECT_TRUE(oakengine_project_redo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_get_label(solid, buf, sizeof(buf)) > 0); + EXPECT_TRUE(strcmp(buf, "MySolid") == 0); OakEngineNode *lut = oakengine_project_add_node( project, "org.olivevideoeditor.Olive.ociolut"); - assert(lut != NULL); + EXPECT_TRUE(lut != NULL); *solid_out = solid; *lut_out = lut; @@ -150,123 +151,123 @@ static void test_inputs_and_params(OakEngineProject *project, // Introspection on the Solid generator: the Node base class provides // "enabled_in" (BOOL), the generator itself adds "color_in" (COLOR). const int inputs = oakengine_node_input_count(solid); - assert(inputs >= 2); - assert(oakengine_node_input_id(solid, 0, buf, sizeof(buf)) > 0); - assert(strcmp(buf, "enabled_in") == 0); - assert(oakengine_node_input_id(solid, 1, buf, sizeof(buf)) > 0); - assert(strcmp(buf, "color_in") == 0); - assert(oakengine_node_input_id(solid, inputs, buf, sizeof(buf)) == + EXPECT_TRUE(inputs >= 2); + EXPECT_TRUE(oakengine_node_input_id(solid, 0, buf, sizeof(buf)) > 0); + EXPECT_TRUE(strcmp(buf, "enabled_in") == 0); + EXPECT_TRUE(oakengine_node_input_id(solid, 1, buf, sizeof(buf)) > 0); + EXPECT_TRUE(strcmp(buf, "color_in") == 0); + EXPECT_TRUE(oakengine_node_input_id(solid, inputs, buf, sizeof(buf)) == OAKENGINE_E_NOT_FOUND); - assert(oakengine_node_input_get_type(solid, "enabled_in") == + EXPECT_TRUE(oakengine_node_input_get_type(solid, "enabled_in") == OAK_NODE_VALUE_BOOL); - assert(oakengine_node_input_get_type(solid, "color_in") == + EXPECT_TRUE(oakengine_node_input_get_type(solid, "color_in") == OAK_NODE_VALUE_COLOR); - assert(oakengine_node_input_get_type(solid, "no_such_input") == + EXPECT_TRUE(oakengine_node_input_get_type(solid, "no_such_input") == OAK_NODE_VALUE_NONE); - assert(oakengine_node_input_is_connected(solid, "color_in") == 0); + EXPECT_TRUE(oakengine_node_input_is_connected(solid, "color_in") == 0); // BOOL get/set on the base-class input (defaults to true). oak_node_value v; memset(&v, 0, sizeof(v)); - assert(oakengine_node_get_input(solid, "enabled_in", &v) == + EXPECT_TRUE(oakengine_node_get_input(solid, "enabled_in", &v) == OAKENGINE_OK); - assert(v.type == OAK_NODE_VALUE_BOOL && v.num == 1); + EXPECT_TRUE(v.type == OAK_NODE_VALUE_BOOL && v.num == 1); v.num = 0; - assert(oakengine_node_set_input(solid, "enabled_in", &v) == + EXPECT_TRUE(oakengine_node_set_input(solid, "enabled_in", &v) == OAKENGINE_OK); memset(&v, 0, sizeof(v)); - assert(oakengine_node_get_input(solid, "enabled_in", &v) == + EXPECT_TRUE(oakengine_node_get_input(solid, "enabled_in", &v) == OAKENGINE_OK); - assert(v.num == 0); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_node_get_input(solid, "enabled_in", &v) == + EXPECT_TRUE(v.num == 0); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_get_input(solid, "enabled_in", &v) == OAKENGINE_OK); - assert(v.num == 1); - assert(oakengine_project_redo(project) == OAKENGINE_OK); + EXPECT_TRUE(v.num == 1); + EXPECT_TRUE(oakengine_project_redo(project) == OAKENGINE_OK); // COLOR get/set round-trip (Solid defaults to opaque red). memset(&v, 0, sizeof(v)); - assert(oakengine_node_get_input(solid, "color_in", &v) == OAKENGINE_OK); - assert(v.type == OAK_NODE_VALUE_COLOR); - assert(fabs(v.f[0] - 1.0) < 1e-6 && fabs(v.f[3] - 1.0) < 1e-6); + EXPECT_TRUE(oakengine_node_get_input(solid, "color_in", &v) == OAKENGINE_OK); + EXPECT_TRUE(v.type == OAK_NODE_VALUE_COLOR); + EXPECT_TRUE(fabs(v.f[0] - 1.0) < 1e-6 && fabs(v.f[3] - 1.0) < 1e-6); v.f[0] = 0.2; v.f[1] = 0.4; v.f[2] = 0.6; v.f[3] = 1.0; - assert(oakengine_node_set_input(solid, "color_in", &v) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_set_input(solid, "color_in", &v) == OAKENGINE_OK); memset(&v, 0, sizeof(v)); - assert(oakengine_node_get_input(solid, "color_in", &v) == OAKENGINE_OK); - assert(fabs(v.f[0] - 0.2) < 1e-6 && fabs(v.f[1] - 0.4) < 1e-6 && + EXPECT_TRUE(oakengine_node_get_input(solid, "color_in", &v) == OAKENGINE_OK); + EXPECT_TRUE(fabs(v.f[0] - 0.2) < 1e-6 && fabs(v.f[1] - 0.4) < 1e-6 && fabs(v.f[2] - 0.6) < 1e-6); // Undo restores the default, redo applies it again. - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_node_get_input(solid, "color_in", &v) == OAKENGINE_OK); - assert(fabs(v.f[0] - 1.0) < 1e-6); - assert(oakengine_project_redo(project) == OAKENGINE_OK); - assert(oakengine_node_get_input(solid, "color_in", &v) == OAKENGINE_OK); - assert(fabs(v.f[0] - 0.2) < 1e-6); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_get_input(solid, "color_in", &v) == OAKENGINE_OK); + EXPECT_TRUE(fabs(v.f[0] - 1.0) < 1e-6); + EXPECT_TRUE(oakengine_project_redo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_get_input(solid, "color_in", &v) == OAKENGINE_OK); + EXPECT_TRUE(fabs(v.f[0] - 0.2) < 1e-6); // Type errors: INT into a COLOR input, POD into a string input, POD and // string APIs on an unknown id. memset(&v, 0, sizeof(v)); v.type = OAK_NODE_VALUE_INT; v.num = 3; - assert(oakengine_node_set_input(solid, "color_in", &v) == + EXPECT_TRUE(oakengine_node_set_input(solid, "color_in", &v) == OAKENGINE_E_INVALID); v.type = OAK_NODE_VALUE_COLOR; - assert(oakengine_node_set_input(solid, "no_such_input", &v) == + EXPECT_TRUE(oakengine_node_set_input(solid, "no_such_input", &v) == OAKENGINE_E_NOT_FOUND); - assert(oakengine_node_get_input(solid, "no_such_input", &v) == + EXPECT_TRUE(oakengine_node_get_input(solid, "no_such_input", &v) == OAKENGINE_E_NOT_FOUND); - assert(oakengine_node_set_input_string(solid, "color_in", "x") == + EXPECT_TRUE(oakengine_node_set_input_string(solid, "color_in", "x") == OAKENGINE_E_INVALID); - assert(oakengine_node_get_input_string(solid, "color_in", buf, + EXPECT_TRUE(oakengine_node_get_input_string(solid, "color_in", buf, sizeof(buf)) == OAKENGINE_E_INVALID); // STRING (k_file) on the LUT node: empty by default, round-trip + undo. - assert(oakengine_node_input_get_type(lut, "lut_file_in") == + EXPECT_TRUE(oakengine_node_input_get_type(lut, "lut_file_in") == OAK_NODE_VALUE_STRING); - assert(oakengine_node_get_input_string(lut, "lut_file_in", buf, + EXPECT_TRUE(oakengine_node_get_input_string(lut, "lut_file_in", buf, sizeof(buf)) == 0); - assert(oakengine_node_set_input_string(lut, "lut_file_in", + EXPECT_TRUE(oakengine_node_set_input_string(lut, "lut_file_in", "/tmp/x.cube") == OAKENGINE_OK); - assert(oakengine_node_get_input_string(lut, "lut_file_in", buf, + EXPECT_TRUE(oakengine_node_get_input_string(lut, "lut_file_in", buf, sizeof(buf)) > 0); - assert(strcmp(buf, "/tmp/x.cube") == 0); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_node_get_input_string(lut, "lut_file_in", buf, + EXPECT_TRUE(strcmp(buf, "/tmp/x.cube") == 0); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_get_input_string(lut, "lut_file_in", buf, sizeof(buf)) == 0); - assert(oakengine_project_redo(project) == OAKENGINE_OK); - assert(oakengine_node_get_input_string(lut, "lut_file_in", buf, + EXPECT_TRUE(oakengine_project_redo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_get_input_string(lut, "lut_file_in", buf, sizeof(buf)) > 0); - assert(strcmp(buf, "/tmp/x.cube") == 0); + EXPECT_TRUE(strcmp(buf, "/tmp/x.cube") == 0); // String typed inputs are rejected by the POD pair. memset(&v, 0, sizeof(v)); - assert(oakengine_node_get_input(lut, "lut_file_in", &v) == + EXPECT_TRUE(oakengine_node_get_input(lut, "lut_file_in", &v) == OAKENGINE_E_INVALID); v.type = OAK_NODE_VALUE_STRING; - assert(oakengine_node_set_input(lut, "lut_file_in", &v) == + EXPECT_TRUE(oakengine_node_set_input(lut, "lut_file_in", &v) == OAKENGINE_E_INVALID); // COMBO on the LUT direction input: 0 by default, set 1, undo. - assert(oakengine_node_input_get_type(lut, "lut_dir_in") == + EXPECT_TRUE(oakengine_node_input_get_type(lut, "lut_dir_in") == OAK_NODE_VALUE_COMBO); memset(&v, 0, sizeof(v)); - assert(oakengine_node_get_input(lut, "lut_dir_in", &v) == OAKENGINE_OK); - assert(v.type == OAK_NODE_VALUE_COMBO && v.num == 0); + EXPECT_TRUE(oakengine_node_get_input(lut, "lut_dir_in", &v) == OAKENGINE_OK); + EXPECT_TRUE(v.type == OAK_NODE_VALUE_COMBO && v.num == 0); v.num = 1; - assert(oakengine_node_set_input(lut, "lut_dir_in", &v) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_set_input(lut, "lut_dir_in", &v) == OAKENGINE_OK); memset(&v, 0, sizeof(v)); - assert(oakengine_node_get_input(lut, "lut_dir_in", &v) == OAKENGINE_OK); - assert(v.num == 1); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_node_get_input(lut, "lut_dir_in", &v) == OAKENGINE_OK); - assert(v.num == 0); - assert(oakengine_project_redo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_get_input(lut, "lut_dir_in", &v) == OAKENGINE_OK); + EXPECT_TRUE(v.num == 1); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_get_input(lut, "lut_dir_in", &v) == OAKENGINE_OK); + EXPECT_TRUE(v.num == 0); + EXPECT_TRUE(oakengine_project_redo(project) == OAKENGINE_OK); } static void test_edges(OakEngineProject *project, OakEngineNode *solid, @@ -275,55 +276,55 @@ static void test_edges(OakEngineProject *project, OakEngineNode *solid, char err[256]; // Solid's texture output -> LUT's "tex_in". - assert(oakengine_node_input_is_connected(lut, "tex_in") == 0); - assert(oakengine_node_connect(solid, lut, "tex_in") == OAKENGINE_OK); - assert(oakengine_node_input_is_connected(lut, "tex_in") == 1); + EXPECT_TRUE(oakengine_node_input_is_connected(lut, "tex_in") == 0); + EXPECT_TRUE(oakengine_node_connect(solid, lut, "tex_in") == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_input_is_connected(lut, "tex_in") == 1); // Already-connected input is refused; unknown ids and unconnectable // inputs fail. - assert(oakengine_node_connect(solid, lut, "tex_in") == + EXPECT_TRUE(oakengine_node_connect(solid, lut, "tex_in") == OAKENGINE_E_STATE); - assert(oakengine_node_connect(solid, lut, "no_such_input") == + EXPECT_TRUE(oakengine_node_connect(solid, lut, "no_such_input") == OAKENGINE_E_NOT_FOUND); - assert(oakengine_node_connect(solid, lut, "lut_file_in") == + EXPECT_TRUE(oakengine_node_connect(solid, lut, "lut_file_in") == OAKENGINE_E_INVALID); - assert(oakengine_node_last_error(err, sizeof(err)) > 0); + EXPECT_TRUE(oakengine_node_last_error(err, sizeof(err)) > 0); // Disconnect restores the unconnected state; a second disconnect fails. - assert(oakengine_node_disconnect(lut, "tex_in") == OAKENGINE_OK); - assert(oakengine_node_input_is_connected(lut, "tex_in") == 0); - assert(oakengine_node_disconnect(lut, "tex_in") == + EXPECT_TRUE(oakengine_node_disconnect(lut, "tex_in") == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_input_is_connected(lut, "tex_in") == 0); + EXPECT_TRUE(oakengine_node_disconnect(lut, "tex_in") == OAKENGINE_E_NOT_FOUND); // disconnect_ex with element -1 mirrors disconnect(); on an unconnected // input it reports E_NOT_FOUND. NULL/unknown-input rejection matches // disconnect() too. - assert(oakengine_node_disconnect_ex(NULL, "tex_in", -1) == + EXPECT_TRUE(oakengine_node_disconnect_ex(NULL, "tex_in", -1) == OAKENGINE_E_INVALID); - assert(oakengine_node_disconnect_ex(lut, "no_such_input", -1) == + EXPECT_TRUE(oakengine_node_disconnect_ex(lut, "no_such_input", -1) == OAKENGINE_E_NOT_FOUND); - assert(oakengine_node_disconnect_ex(lut, "tex_in", -1) == + EXPECT_TRUE(oakengine_node_disconnect_ex(lut, "tex_in", -1) == OAKENGINE_E_NOT_FOUND); - assert(oakengine_node_connect(solid, lut, "tex_in") == OAKENGINE_OK); - assert(oakengine_node_disconnect_ex(lut, "tex_in", -1) == OAKENGINE_OK); - assert(oakengine_node_input_is_connected(lut, "tex_in") == 0); + EXPECT_TRUE(oakengine_node_connect(solid, lut, "tex_in") == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_disconnect_ex(lut, "tex_in", -1) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_input_is_connected(lut, "tex_in") == 0); // Undo the disconnect_ex so the undo/redo sequence below starts from // the same "connected" state as before this block. - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_node_input_is_connected(lut, "tex_in") == 1); - assert(oakengine_node_disconnect(lut, "tex_in") == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_input_is_connected(lut, "tex_in") == 1); + EXPECT_TRUE(oakengine_node_disconnect(lut, "tex_in") == OAKENGINE_OK); // Undo/redo the disconnect and the connect: undo brings the connection // back, undo again removes it; redoing both replays connect then // disconnect, so the end state is disconnected. - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_node_input_is_connected(lut, "tex_in") == 1); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_node_input_is_connected(lut, "tex_in") == 0); - assert(oakengine_project_redo(project) == OAKENGINE_OK); - assert(oakengine_node_input_is_connected(lut, "tex_in") == 1); - assert(oakengine_project_redo(project) == OAKENGINE_OK); - assert(oakengine_node_input_is_connected(lut, "tex_in") == 0); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_input_is_connected(lut, "tex_in") == 1); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_input_is_connected(lut, "tex_in") == 0); + EXPECT_TRUE(oakengine_project_redo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_input_is_connected(lut, "tex_in") == 1); + EXPECT_TRUE(oakengine_project_redo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_input_is_connected(lut, "tex_in") == 0); } static void test_remove(OakEngineProject *project, OakEngineNode *solid, @@ -333,20 +334,20 @@ static void test_remove(OakEngineProject *project, OakEngineNode *solid, // A node from another project is refused. OakEngineProject *other = oakengine_project_create(); - assert(other != NULL); - assert(oakengine_project_new(other) == OAKENGINE_OK); - assert(oakengine_project_remove_node(other, solid) == + EXPECT_TRUE(other != NULL); + EXPECT_TRUE(oakengine_project_new(other) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_remove_node(other, solid) == OAKENGINE_E_INVALID); oakengine_project_free(other); - assert(oakengine_project_remove_node(project, lut) == OAKENGINE_OK); - assert(oakengine_project_node_count(project) == before - 1); + EXPECT_TRUE(oakengine_project_remove_node(project, lut) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_node_count(project) == before - 1); // Undo brings the node back, redo removes it again. - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_project_node_count(project) == before); - assert(oakengine_project_redo(project) == OAKENGINE_OK); - assert(oakengine_project_node_count(project) == before - 1); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_node_count(project) == before); + EXPECT_TRUE(oakengine_project_redo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_node_count(project) == before - 1); (void)solid; } @@ -357,34 +358,34 @@ static void test_label_and_color_many(OakEngineProject *project) project, "org.olivevideoeditor.Olive.solidgenerator"); OakEngineNode *b = oakengine_project_add_node( project, "org.olivevideoeditor.Olive.text3"); - assert(a != NULL && b != NULL); + EXPECT_TRUE(a != NULL && b != NULL); OakEngineNode *two[2] = { a, b }; char buf[128]; // One command renames both; undo restores each node's own label. - assert(oakengine_node_set_label_many(two, 2, "Shared") == OAKENGINE_OK); - assert(oakengine_node_get_label(a, buf, sizeof(buf)) > 0); - assert(strcmp(buf, "Shared") == 0); - assert(oakengine_node_get_label(b, buf, sizeof(buf)) > 0); - assert(strcmp(buf, "Shared") == 0); - assert(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_set_label_many(two, 2, "Shared") == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_get_label(a, buf, sizeof(buf)) > 0); + EXPECT_TRUE(strcmp(buf, "Shared") == 0); + EXPECT_TRUE(oakengine_node_get_label(b, buf, sizeof(buf)) > 0); + EXPECT_TRUE(strcmp(buf, "Shared") == 0); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); // The original labels were empty. - assert(oakengine_node_get_label(a, buf, sizeof(buf)) == 0); - assert(oakengine_node_get_label(b, buf, sizeof(buf)) == 0); - assert(oakengine_node_set_label_many(NULL, 1, "x") == + EXPECT_TRUE(oakengine_node_get_label(a, buf, sizeof(buf)) == 0); + EXPECT_TRUE(oakengine_node_get_label(b, buf, sizeof(buf)) == 0); + EXPECT_TRUE(oakengine_node_set_label_many(NULL, 1, "x") == OAKENGINE_E_INVALID); - assert(oakengine_node_set_label_many(two, 0, "x") == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_set_label_many(two, 0, "x") == OAKENGINE_OK); // Color labels batch in one command too. - assert(oakengine_node_get_color_label(a) == -1); - assert(oakengine_node_set_color_label(two, 2, 5) == OAKENGINE_OK); - assert(oakengine_node_get_color_label(a) == 5); - assert(oakengine_node_get_color_label(b) == 5); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_node_get_color_label(a) == -1); - assert(oakengine_node_get_color_label(b) == -1); - assert(oakengine_node_get_color_label(NULL) == -1); - assert(oakengine_node_set_color_label(NULL, 1, 1) == + EXPECT_TRUE(oakengine_node_get_color_label(a) == -1); + EXPECT_TRUE(oakengine_node_set_color_label(two, 2, 5) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_get_color_label(a) == 5); + EXPECT_TRUE(oakengine_node_get_color_label(b) == 5); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_get_color_label(a) == -1); + EXPECT_TRUE(oakengine_node_get_color_label(b) == -1); + EXPECT_TRUE(oakengine_node_get_color_label(NULL) == -1); + EXPECT_TRUE(oakengine_node_set_color_label(NULL, 1, 1) == OAKENGINE_E_INVALID); } @@ -401,104 +402,104 @@ static void test_extended_metadata(OakEngineProject *project) project, "org.olivevideoeditor.Olive.ociolut"); OakEngineNode *text = oakengine_project_add_node( project, "org.olivevideoeditor.Olive.text3"); - assert(solid != NULL && lut != NULL && text != NULL); + EXPECT_TRUE(solid != NULL && lut != NULL && text != NULL); // Introspection. - assert(oakengine_node_input_is_array(text, "args_in") == 1); - assert(oakengine_node_input_is_array(solid, "color_in") == 0); - assert(oakengine_node_input_array_size(text, "args_in") >= 0); - assert(oakengine_node_input_array_size(solid, "color_in") == 0); - assert(oakengine_node_input_get_flags(solid, "color_in") >= 0); - assert(oakengine_node_input_get_flags(NULL, "color_in") == 0); - assert(oakengine_node_input_is_connectable(lut, "tex_in") == 1); - assert(oakengine_node_input_is_connectable(lut, "lut_file_in") == 0); - assert(oakengine_node_input_is_keyframable(solid, "color_in") == 1); - assert(oakengine_node_input_is_keyframable(lut, "tex_in") == 0); - assert(oakengine_node_input_is_keyframed_ex(solid, "color_in", -1) == 0); + EXPECT_TRUE(oakengine_node_input_is_array(text, "args_in") == 1); + EXPECT_TRUE(oakengine_node_input_is_array(solid, "color_in") == 0); + EXPECT_TRUE(oakengine_node_input_array_size(text, "args_in") >= 0); + EXPECT_TRUE(oakengine_node_input_array_size(solid, "color_in") == 0); + EXPECT_TRUE(oakengine_node_input_get_flags(solid, "color_in") >= 0); + EXPECT_TRUE(oakengine_node_input_get_flags(NULL, "color_in") == 0); + EXPECT_TRUE(oakengine_node_input_is_connectable(lut, "tex_in") == 1); + EXPECT_TRUE(oakengine_node_input_is_connectable(lut, "lut_file_in") == 0); + EXPECT_TRUE(oakengine_node_input_is_keyframable(solid, "color_in") == 1); + EXPECT_TRUE(oakengine_node_input_is_keyframable(lut, "tex_in") == 0); + EXPECT_TRUE(oakengine_node_input_is_keyframed_ex(solid, "color_in", -1) == 0); // Properties: set (with and without notification), read back through // every typed getter, enumerate. - assert(oakengine_node_input_has_property(solid, "color_in", + EXPECT_TRUE(oakengine_node_input_has_property(solid, "color_in", "my_prop") == 0); - assert(oakengine_node_set_input_property_string( + EXPECT_TRUE(oakengine_node_set_input_property_string( solid, "color_in", "my_prop", "2.5", 1) == OAKENGINE_OK); - assert(oakengine_node_input_has_property(solid, "color_in", + EXPECT_TRUE(oakengine_node_input_has_property(solid, "color_in", "my_prop") == 1); - assert(oakengine_node_input_get_property_string( + EXPECT_TRUE(oakengine_node_input_get_property_string( solid, "color_in", "my_prop", buf, sizeof(buf)) > 0); - assert(strcmp(buf, "2.5") == 0); + EXPECT_TRUE(strcmp(buf, "2.5") == 0); double d = 0; - assert(oakengine_node_input_get_property_number(solid, "color_in", + EXPECT_TRUE(oakengine_node_input_get_property_number(solid, "color_in", "my_prop", -1, &d) == OAKENGINE_OK); - assert(fabs(d - 2.5) < 1e-9); + EXPECT_TRUE(fabs(d - 2.5) < 1e-9); // The per-track variant resolves (component value is type-dependent). - assert(oakengine_node_input_get_property_number(solid, "color_in", + EXPECT_TRUE(oakengine_node_input_get_property_number(solid, "color_in", "my_prop", 2, &d) == OAKENGINE_OK); - assert(oakengine_node_set_input_property_string( + EXPECT_TRUE(oakengine_node_set_input_property_string( solid, "color_in", "int_prop", "7", 1) == OAKENGINE_OK); int64_t i64 = 0; - assert(oakengine_node_input_get_property_int(solid, "color_in", + EXPECT_TRUE(oakengine_node_input_get_property_int(solid, "color_in", "int_prop", &i64) == OAKENGINE_OK); - assert(i64 == 7); - assert(oakengine_node_input_get_property_rational( + EXPECT_TRUE(i64 == 7); + EXPECT_TRUE(oakengine_node_input_get_property_rational( solid, "color_in", "my_prop", NULL, NULL) == OAKENGINE_OK); - assert(oakengine_node_input_get_property_count(solid, "color_in") >= 1); - assert(oakengine_node_input_get_property_string( + EXPECT_TRUE(oakengine_node_input_get_property_count(solid, "color_in") >= 1); + EXPECT_TRUE(oakengine_node_input_get_property_string( solid, "color_in", "no_such", buf, sizeof(buf)) == OAKENGINE_E_NOT_FOUND); - assert(oakengine_node_input_get_property_number(solid, "color_in", + EXPECT_TRUE(oakengine_node_input_get_property_number(solid, "color_in", "no_such", -1, &d) == OAKENGINE_E_NOT_FOUND); // A scalar string reads back as a one-element list. - assert(oakengine_node_input_get_property_string_list_count( + EXPECT_TRUE(oakengine_node_input_get_property_string_list_count( solid, "color_in", "my_prop") == 1); - assert(oakengine_node_input_get_property_string_list( + EXPECT_TRUE(oakengine_node_input_get_property_string_list( solid, "color_in", "my_prop", 0, buf, sizeof(buf)) > 0); - assert(strcmp(buf, "2.5") == 0); - assert(oakengine_node_input_get_property_string_list( + EXPECT_TRUE(strcmp(buf, "2.5") == 0); + EXPECT_TRUE(oakengine_node_input_get_property_string_list( solid, "color_in", "my_prop", 1, buf, sizeof(buf)) == OAKENGINE_E_NOT_FOUND); // Suppressed write keeps the value too. - assert(oakengine_node_set_input_property_string( + EXPECT_TRUE(oakengine_node_set_input_property_string( solid, "color_in", "my_prop", "3.5", 0) == OAKENGINE_OK); - assert(oakengine_node_input_get_property_string( + EXPECT_TRUE(oakengine_node_input_get_property_string( solid, "color_in", "my_prop", buf, sizeof(buf)) > 0); - assert(strcmp(buf, "3.5") == 0); + EXPECT_TRUE(strcmp(buf, "3.5") == 0); // Names. - assert(oakengine_node_get_label_and_name(solid, buf, sizeof(buf)) > 0); - assert(strcmp(buf, "Solid") == 0); - assert(oakengine_node_set_label(solid, "MySolid") == OAKENGINE_OK); - assert(oakengine_node_get_label_and_name(solid, buf, sizeof(buf)) > 0); - assert(strstr(buf, "MySolid") != NULL && strstr(buf, "Solid") != NULL); - assert(oakengine_node_get_input_name(solid, "color_in", buf, + EXPECT_TRUE(oakengine_node_get_label_and_name(solid, buf, sizeof(buf)) > 0); + EXPECT_TRUE(strcmp(buf, "Solid") == 0); + EXPECT_TRUE(oakengine_node_set_label(solid, "MySolid") == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_get_label_and_name(solid, buf, sizeof(buf)) > 0); + EXPECT_TRUE(strstr(buf, "MySolid") != NULL && strstr(buf, "Solid") != NULL); + EXPECT_TRUE(oakengine_node_get_input_name(solid, "color_in", buf, sizeof(buf)) >= 0); // Default value: Solid's color defaults to opaque red. oak_node_value def; - assert(oakengine_node_input_get_default_value(solid, "color_in", 0, + EXPECT_TRUE(oakengine_node_input_get_default_value(solid, "color_in", 0, &def) == OAKENGINE_OK); - assert(def.type == OAK_NODE_VALUE_COLOR && fabs(def.f[0] - 1.0) < 1e-6); - assert(oakengine_node_input_get_default_value(solid, "color_in", 99, + EXPECT_TRUE(def.type == OAK_NODE_VALUE_COLOR && fabs(def.f[0] - 1.0) < 1e-6); + EXPECT_TRUE(oakengine_node_input_get_default_value(solid, "color_in", 99, &def) == OAKENGINE_E_NOT_FOUND); // Project and edge lookup. - assert(oakengine_node_get_project(solid) == project); - assert(oakengine_node_get_project(NULL) == NULL); - assert(oakengine_node_input_get_connected_node(lut, "tex_in", -1) == + EXPECT_TRUE(oakengine_node_get_project(solid) == project); + EXPECT_TRUE(oakengine_node_get_project(NULL) == NULL); + EXPECT_TRUE(oakengine_node_input_get_connected_node(lut, "tex_in", -1) == NULL); - assert(oakengine_node_connect(solid, lut, "tex_in") == OAKENGINE_OK); - assert(oakengine_node_input_get_connected_node(lut, "tex_in", -1) == + EXPECT_TRUE(oakengine_node_connect(solid, lut, "tex_in") == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_input_get_connected_node(lut, "tex_in", -1) == solid); - assert(oakengine_node_disconnect(lut, "tex_in") == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_disconnect(lut, "tex_in") == OAKENGINE_OK); // copy_inputs: values (not connections) transfer as one undoable step. OakEngineNode *solid2 = oakengine_project_add_node( project, "org.olivevideoeditor.Olive.solidgenerator"); - assert(solid2 != NULL); + EXPECT_TRUE(solid2 != NULL); oak_node_value c; memset(&c, 0, sizeof(c)); c.type = OAK_NODE_VALUE_COLOR; @@ -506,46 +507,46 @@ static void test_extended_metadata(OakEngineProject *project) c.f[1] = 0.2; c.f[2] = 0.3; c.f[3] = 1.0; - assert(oakengine_node_set_input(solid, "color_in", &c) == OAKENGINE_OK); - assert(oakengine_node_copy_inputs(solid2, solid) == OAKENGINE_OK); - assert(oakengine_node_get_input(solid2, "color_in", &def) == OAKENGINE_OK); - assert(fabs(def.f[0] - 0.1) < 1e-6 && fabs(def.f[2] - 0.3) < 1e-6); - assert(oakengine_node_copy_inputs(NULL, solid) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_node_set_input(solid, "color_in", &c) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_copy_inputs(solid2, solid) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_get_input(solid2, "color_in", &def) == OAKENGINE_OK); + EXPECT_TRUE(fabs(def.f[0] - 0.1) < 1e-6 && fabs(def.f[2] - 0.3) < 1e-6); + EXPECT_TRUE(oakengine_node_copy_inputs(NULL, solid) == OAKENGINE_E_INVALID); // At-time readers: whole value and per-track component. oak_node_value at; - assert(oakengine_node_get_input_at_time(solid, "color_in", -1, -1, 0, 1, + EXPECT_TRUE(oakengine_node_get_input_at_time(solid, "color_in", -1, -1, 0, 1, &at) == OAKENGINE_OK); - assert(at.type == OAK_NODE_VALUE_COLOR && fabs(at.f[0] - 0.1) < 1e-6); - assert(oakengine_node_get_input_at_time(solid, "color_in", -1, 2, 0, 1, + EXPECT_TRUE(at.type == OAK_NODE_VALUE_COLOR && fabs(at.f[0] - 0.1) < 1e-6); + EXPECT_TRUE(oakengine_node_get_input_at_time(solid, "color_in", -1, 2, 0, 1, &at) == OAKENGINE_OK); - assert(at.type == OAK_NODE_VALUE_COLOR && fabs(at.f[0] - 0.3) < 1e-6); - assert(oakengine_node_get_input_at_time(solid, "enabled_in", -1, 0, 0, + EXPECT_TRUE(at.type == OAK_NODE_VALUE_COLOR && fabs(at.f[0] - 0.3) < 1e-6); + EXPECT_TRUE(oakengine_node_get_input_at_time(solid, "enabled_in", -1, 0, 0, 1, &at) == OAKENGINE_OK); - assert(at.type == OAK_NODE_VALUE_BOOL && at.num == 1); + EXPECT_TRUE(at.type == OAK_NODE_VALUE_BOOL && at.num == 1); // String-family inputs need the string getter. - assert(oakengine_node_get_input_at_time(text, "text_in", -1, 0, 0, 1, + EXPECT_TRUE(oakengine_node_get_input_at_time(text, "text_in", -1, 0, 0, 1, &at) == OAKENGINE_E_INVALID); - assert(oakengine_node_set_input_string_at_time(text, "text_in", -1, 0, + EXPECT_TRUE(oakengine_node_set_input_string_at_time(text, "text_in", -1, 0, "hello") == OAKENGINE_OK); - assert(oakengine_node_get_input_string_at_time(text, "text_in", -1, 0, + EXPECT_TRUE(oakengine_node_get_input_string_at_time(text, "text_in", -1, 0, 1, buf, sizeof(buf)) > 0); - assert(strcmp(buf, "hello") == 0); + EXPECT_TRUE(strcmp(buf, "hello") == 0); // Bezier/binary getters reject mismatched inputs. double b6[6]; - assert(oakengine_node_get_input_bezier_at_time(solid, "color_in", -1, 0, + EXPECT_TRUE(oakengine_node_get_input_bezier_at_time(solid, "color_in", -1, 0, 1, b6) == OAKENGINE_E_INVALID); - assert(oakengine_node_get_input_binary_at_time(solid, "color_in", -1, 0, + EXPECT_TRUE(oakengine_node_get_input_binary_at_time(solid, "color_in", -1, 0, 1, NULL, 0) == OAKENGINE_E_INVALID); // Clean up the played-with nodes so later tests see a fresh graph. - assert(oakengine_project_remove_node(project, solid) == OAKENGINE_OK); - assert(oakengine_project_remove_node(project, solid2) == OAKENGINE_OK); - assert(oakengine_project_remove_node(project, lut) == OAKENGINE_OK); - assert(oakengine_project_remove_node(project, text) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_remove_node(project, solid) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_remove_node(project, solid2) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_remove_node(project, lut) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_remove_node(project, text) == OAKENGINE_OK); } // ---- Context positions ----------------------------------------------------- @@ -558,71 +559,71 @@ static void test_context_positions(OakEngineProject *project) project, "org.olivevideoeditor.Olive.solidgenerator"); OakEngineNode *lut = oakengine_project_add_node( project, "org.olivevideoeditor.Olive.ociolut"); - assert(group != NULL && solid != NULL && lut != NULL); + EXPECT_TRUE(group != NULL && solid != NULL && lut != NULL); double x = 0, y = 0; int expanded = -1; // NULL safety. - assert(oakengine_node_context_contains_node(NULL, solid) == + EXPECT_TRUE(oakengine_node_context_contains_node(NULL, solid) == OAKENGINE_E_INVALID); - assert(oakengine_node_context_node_count(NULL) == OAKENGINE_E_INVALID); - assert(oakengine_node_context_node_at(NULL, 0, NULL, NULL, NULL) == NULL); - assert(oakengine_node_set_context_position(NULL, solid, 0, 0) == + EXPECT_TRUE(oakengine_node_context_node_count(NULL) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_node_context_node_at(NULL, 0, NULL, NULL, NULL) == NULL); + EXPECT_TRUE(oakengine_node_set_context_position(NULL, solid, 0, 0) == OAKENGINE_E_INVALID); - assert(oakengine_node_set_context_expanded(NULL, solid, 1) == + EXPECT_TRUE(oakengine_node_set_context_expanded(NULL, solid, 1) == OAKENGINE_E_INVALID); // A fresh group context is empty. - assert(oakengine_node_context_contains_node(group, solid) == 0); - assert(oakengine_node_context_node_count(group) == 0); - assert(oakengine_node_get_context_position(group, solid, &x, &y, + EXPECT_TRUE(oakengine_node_context_contains_node(group, solid) == 0); + EXPECT_TRUE(oakengine_node_context_node_count(group) == 0); + EXPECT_TRUE(oakengine_node_get_context_position(group, solid, &x, &y, &expanded) == OAKENGINE_E_NOT_FOUND); // set_context_position inserts like the C++ setter. - assert(oakengine_node_set_context_position(group, solid, 3.5, -2.0) == + EXPECT_TRUE(oakengine_node_set_context_position(group, solid, 3.5, -2.0) == OAKENGINE_OK); - assert(oakengine_node_context_contains_node(group, solid) == 1); - assert(oakengine_node_context_node_count(group) == 1); - assert(oakengine_node_get_context_position(group, solid, &x, &y, + EXPECT_TRUE(oakengine_node_context_contains_node(group, solid) == 1); + EXPECT_TRUE(oakengine_node_context_node_count(group) == 1); + EXPECT_TRUE(oakengine_node_get_context_position(group, solid, &x, &y, &expanded) == OAKENGINE_OK); - assert(x == 3.5 && y == -2.0 && expanded == 0); + EXPECT_TRUE(x == 3.5 && y == -2.0 && expanded == 0); // Expanded flag round-trips. - assert(oakengine_node_set_context_expanded(group, solid, 1) == + EXPECT_TRUE(oakengine_node_set_context_expanded(group, solid, 1) == OAKENGINE_OK); - assert(oakengine_node_get_context_position(group, solid, &x, &y, + EXPECT_TRUE(oakengine_node_get_context_position(group, solid, &x, &y, &expanded) == OAKENGINE_OK); - assert(expanded == 1); + EXPECT_TRUE(expanded == 1); // Moving keeps the expanded flag. - assert(oakengine_node_set_context_position(group, solid, 1.0, 2.0) == + EXPECT_TRUE(oakengine_node_set_context_position(group, solid, 1.0, 2.0) == OAKENGINE_OK); - assert(oakengine_node_get_context_position(group, solid, &x, &y, + EXPECT_TRUE(oakengine_node_get_context_position(group, solid, &x, &y, &expanded) == OAKENGINE_OK); - assert(x == 1.0 && y == 2.0 && expanded == 1); + EXPECT_TRUE(x == 1.0 && y == 2.0 && expanded == 1); - assert(oakengine_node_set_context_position(group, lut, -4.0, 5.0) == + EXPECT_TRUE(oakengine_node_set_context_position(group, lut, -4.0, 5.0) == OAKENGINE_OK); - assert(oakengine_node_context_node_count(group) == 2); + EXPECT_TRUE(oakengine_node_context_node_count(group) == 2); // Enumeration (order is the hash map's; find both by handle). OakEngineNode *seen0 = oakengine_node_context_node_at(group, 0, &x, &y, &expanded); OakEngineNode *seen1 = oakengine_node_context_node_at(group, 1, NULL, NULL, NULL); - assert(seen0 != NULL && seen1 != NULL && seen0 != seen1); - assert((seen0 == solid || seen0 == lut) && + EXPECT_TRUE(seen0 != NULL && seen1 != NULL && seen0 != seen1); + EXPECT_TRUE((seen0 == solid || seen0 == lut) && (seen1 == solid || seen1 == lut)); - assert(oakengine_node_context_node_at(group, 2, NULL, NULL, NULL) == + EXPECT_TRUE(oakengine_node_context_node_at(group, 2, NULL, NULL, NULL) == NULL); - assert(oakengine_node_context_node_at(group, -1, NULL, NULL, NULL) == + EXPECT_TRUE(oakengine_node_context_node_at(group, -1, NULL, NULL, NULL) == NULL); - assert(oakengine_project_remove_node(project, group) == OAKENGINE_OK); - assert(oakengine_project_remove_node(project, solid) == OAKENGINE_OK); - assert(oakengine_project_remove_node(project, lut) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_remove_node(project, group) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_remove_node(project, solid) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_remove_node(project, lut) == OAKENGINE_OK); } // ---- Effect input ------------------------------------------------------------ @@ -633,26 +634,26 @@ static void test_get_effect_input(OakEngineProject *project) project, "org.olivevideoeditor.Olive.ociolut"); OakEngineNode *solid = oakengine_project_add_node( project, "org.olivevideoeditor.Olive.solidgenerator"); - assert(lut != NULL && solid != NULL); + EXPECT_TRUE(lut != NULL && solid != NULL); char buf[64]; int element = 99; - assert(oakengine_node_get_effect_input(NULL, buf, sizeof(buf), + EXPECT_TRUE(oakengine_node_get_effect_input(NULL, buf, sizeof(buf), &element) == OAKENGINE_E_INVALID); // OCIO LUT declares its texture input as the effect input. - assert(oakengine_node_get_effect_input(lut, buf, sizeof(buf), + EXPECT_TRUE(oakengine_node_get_effect_input(lut, buf, sizeof(buf), &element) >= 0); - assert(strcmp(buf, "tex_in") == 0 && element == -1); + EXPECT_TRUE(strcmp(buf, "tex_in") == 0 && element == -1); // The solid generator has no effect input. - assert(oakengine_node_get_effect_input(solid, buf, sizeof(buf), + EXPECT_TRUE(oakengine_node_get_effect_input(solid, buf, sizeof(buf), &element) == OAKENGINE_E_NOT_FOUND); - assert(oakengine_project_remove_node(project, lut) == OAKENGINE_OK); - assert(oakengine_project_remove_node(project, solid) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_remove_node(project, lut) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_remove_node(project, solid) == OAKENGINE_OK); } // ---- Group nodes ------------------------------------------------------------- @@ -667,122 +668,122 @@ static void test_group(OakEngineProject *project) project, "org.olivevideoeditor.Olive.solidgenerator"); OakEngineNode *lut = oakengine_project_add_node( project, "org.olivevideoeditor.Olive.ociolut"); - assert(group != NULL && group2 != NULL && solid != NULL && lut != NULL); + EXPECT_TRUE(group != NULL && group2 != NULL && solid != NULL && lut != NULL); // Type probe. - assert(oakengine_node_is_group(group) == 1); - assert(oakengine_node_is_group(solid) == 0); - assert(oakengine_node_is_group(NULL) == 0); - assert(oakengine_group_input_passthrough_count(solid) == + EXPECT_TRUE(oakengine_node_is_group(group) == 1); + EXPECT_TRUE(oakengine_node_is_group(solid) == 0); + EXPECT_TRUE(oakengine_node_is_group(NULL) == 0); + EXPECT_TRUE(oakengine_group_input_passthrough_count(solid) == OAKENGINE_E_INVALID); - assert(oakengine_group_add_input_passthrough(solid, lut, "x", -1, NULL, + EXPECT_TRUE(oakengine_group_add_input_passthrough(solid, lut, "x", -1, NULL, NULL, 0) == OAKENGINE_E_INVALID); // Direct passthrough add: the generated id is returned. The group must // contain the inner node first (NodeGroup::add_input_passthrough // asserts context membership). - assert(oakengine_node_set_context_position(group, solid, 0, 0) == + EXPECT_TRUE(oakengine_node_set_context_position(group, solid, 0, 0) == OAKENGINE_OK); char idbuf[64]; - assert(oakengine_group_add_input_passthrough(group, solid, "color_in", + EXPECT_TRUE(oakengine_group_add_input_passthrough(group, solid, "color_in", -1, NULL, idbuf, sizeof(idbuf)) > 0); - assert(idbuf[0] != '\0'); - assert(oakengine_group_input_passthrough_count(group) == 1); + EXPECT_TRUE(idbuf[0] != '\0'); + EXPECT_TRUE(oakengine_group_input_passthrough_count(group) == 1); // Read back the passthrough. char id_at[64], input_at[64]; OakEngineNode *node_at = NULL; int element_at = 99; - assert(oakengine_group_input_passthrough_at(group, 0, id_at, + EXPECT_TRUE(oakengine_group_input_passthrough_at(group, 0, id_at, sizeof(id_at), &node_at, input_at, sizeof(input_at), &element_at) > 0); - assert(strcmp(id_at, idbuf) == 0 && node_at == solid && + EXPECT_TRUE(strcmp(id_at, idbuf) == 0 && node_at == solid && strcmp(input_at, "color_in") == 0 && element_at == -1); - assert(oakengine_group_input_passthrough_at(group, 1, NULL, 0, NULL, + EXPECT_TRUE(oakengine_group_input_passthrough_at(group, 1, NULL, 0, NULL, NULL, 0, NULL) == OAKENGINE_E_INVALID); // Id lookup by (node, input, element). char idq[64]; - assert(oakengine_group_get_id_of_passthrough(group, solid, "color_in", + EXPECT_TRUE(oakengine_group_get_id_of_passthrough(group, solid, "color_in", -1, idq, sizeof(idq)) > 0); - assert(strcmp(idq, idbuf) == 0); - assert(oakengine_group_get_id_of_passthrough(group, lut, "tex_in", -1, + EXPECT_TRUE(strcmp(idq, idbuf) == 0); + EXPECT_TRUE(oakengine_group_get_id_of_passthrough(group, lut, "tex_in", -1, idq, sizeof(idq)) == OAKENGINE_E_NOT_FOUND); // Output passthrough (direct variant). - assert(oakengine_group_get_output_passthrough(group) == NULL); - assert(oakengine_group_set_output_passthrough(group, solid) == + EXPECT_TRUE(oakengine_group_get_output_passthrough(group) == NULL); + EXPECT_TRUE(oakengine_group_set_output_passthrough(group, solid) == OAKENGINE_OK); - assert(oakengine_group_get_output_passthrough(group) == solid); + EXPECT_TRUE(oakengine_group_get_output_passthrough(group) == solid); // Resolve one level: (group, idbuf) -> (solid, color_in). OakEngineNode *resolved_node = NULL; char resolved_input[64]; int resolved_element = 99; - assert(oakengine_group_resolve_input(group, idbuf, -1, &resolved_node, + EXPECT_TRUE(oakengine_group_resolve_input(group, idbuf, -1, &resolved_node, resolved_input, sizeof(resolved_input), &resolved_element) >= 0); - assert(resolved_node == solid && strcmp(resolved_input, "color_in") == 0); + EXPECT_TRUE(resolved_node == solid && strcmp(resolved_input, "color_in") == 0); // Resolving a plain node input passes through unchanged. - assert(oakengine_group_resolve_input(solid, "color_in", -1, + EXPECT_TRUE(oakengine_group_resolve_input(solid, "color_in", -1, &resolved_node, resolved_input, sizeof(resolved_input), &resolved_element) >= 0); - assert(resolved_node == solid && strcmp(resolved_input, "color_in") == 0); + EXPECT_TRUE(resolved_node == solid && strcmp(resolved_input, "color_in") == 0); // Nested groups resolve to the innermost real input. char id2[64]; - assert(oakengine_node_set_context_position(group2, group, 0, 0) == + EXPECT_TRUE(oakengine_node_set_context_position(group2, group, 0, 0) == OAKENGINE_OK); - assert(oakengine_group_add_input_passthrough(group2, group, idbuf, -1, + EXPECT_TRUE(oakengine_group_add_input_passthrough(group2, group, idbuf, -1, NULL, id2, sizeof(id2)) > 0); - assert(oakengine_group_resolve_input(group2, id2, -1, &resolved_node, + EXPECT_TRUE(oakengine_group_resolve_input(group2, id2, -1, &resolved_node, resolved_input, sizeof(resolved_input), &resolved_element) >= 0); - assert(resolved_node == solid && strcmp(resolved_input, "color_in") == 0); + EXPECT_TRUE(resolved_node == solid && strcmp(resolved_input, "color_in") == 0); // Direct remove. - assert(oakengine_group_remove_input_passthrough(group, solid, "color_in", + EXPECT_TRUE(oakengine_group_remove_input_passthrough(group, solid, "color_in", -1) == OAKENGINE_OK); - assert(oakengine_group_input_passthrough_count(group) == 0); - assert(oakengine_group_remove_input_passthrough(group, solid, "color_in", + EXPECT_TRUE(oakengine_group_input_passthrough_count(group) == 0); + EXPECT_TRUE(oakengine_group_remove_input_passthrough(group, solid, "color_in", -1) == OAKENGINE_E_NOT_FOUND); // Undoable add: one command on the project undo stack. - assert(oakengine_node_set_context_position(group, lut, 0, 0) == + EXPECT_TRUE(oakengine_node_set_context_position(group, lut, 0, 0) == OAKENGINE_OK); - assert(oakengine_group_add_input_passthrough_undoable(group, lut, + EXPECT_TRUE(oakengine_group_add_input_passthrough_undoable(group, lut, "tex_in", -1, NULL) == OAKENGINE_OK); - assert(oakengine_group_input_passthrough_count(group) == 1); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_group_input_passthrough_count(group) == 0); - assert(oakengine_project_redo(project) == OAKENGINE_OK); - assert(oakengine_group_input_passthrough_count(group) == 1); + EXPECT_TRUE(oakengine_group_input_passthrough_count(group) == 1); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_group_input_passthrough_count(group) == 0); + EXPECT_TRUE(oakengine_project_redo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_group_input_passthrough_count(group) == 1); // Undoable output passthrough. - assert(oakengine_group_set_output_passthrough_undoable(group, lut) == + EXPECT_TRUE(oakengine_group_set_output_passthrough_undoable(group, lut) == OAKENGINE_OK); - assert(oakengine_group_get_output_passthrough(group) == lut); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_group_get_output_passthrough(group) == solid); - assert(oakengine_project_redo(project) == OAKENGINE_OK); - assert(oakengine_group_get_output_passthrough(group) == lut); + EXPECT_TRUE(oakengine_group_get_output_passthrough(group) == lut); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_group_get_output_passthrough(group) == solid); + EXPECT_TRUE(oakengine_project_redo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_group_get_output_passthrough(group) == lut); - assert(oakengine_project_remove_node(project, group) == OAKENGINE_OK); - assert(oakengine_project_remove_node(project, group2) == OAKENGINE_OK); - assert(oakengine_project_remove_node(project, solid) == OAKENGINE_OK); - assert(oakengine_project_remove_node(project, lut) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_remove_node(project, group) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_remove_node(project, group2) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_remove_node(project, solid) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_remove_node(project, lut) == OAKENGINE_OK); } // ---- Multi-camera nodes -------------------------------------------------------- @@ -793,68 +794,68 @@ static void test_multicam(OakEngineProject *project) project, "org.olivevideoeditor.Olive.multicam"); OakEngineNode *solid = oakengine_project_add_node( project, "org.olivevideoeditor.Olive.solidgenerator"); - assert(cam != NULL && solid != NULL); + EXPECT_TRUE(cam != NULL && solid != NULL); // Type probe. - assert(oakengine_node_is_multicam(cam) == 1); - assert(oakengine_node_is_multicam(solid) == 0); - assert(oakengine_node_is_multicam(NULL) == 0); + EXPECT_TRUE(oakengine_node_is_multicam(cam) == 1); + EXPECT_TRUE(oakengine_node_is_multicam(solid) == 0); + EXPECT_TRUE(oakengine_node_is_multicam(NULL) == 0); // Input id constants. const char *cur = oakengine_multicam_input_current(); const char *src = oakengine_multicam_input_sources(); const char *seq = oakengine_multicam_input_sequence(); const char *seqt = oakengine_multicam_input_sequence_type(); - assert(cur != NULL && src != NULL && seq != NULL && seqt != NULL); - assert(strcmp(cur, "current_in") == 0); - assert(strcmp(src, "sources_in") == 0); - assert(strcmp(seq, "sequence_in") == 0); - assert(strcmp(seqt, "sequence_type_in") == 0); + EXPECT_TRUE(cur != NULL && src != NULL && seq != NULL && seqt != NULL); + EXPECT_TRUE(strcmp(cur, "current_in") == 0); + EXPECT_TRUE(strcmp(src, "sources_in") == 0); + EXPECT_TRUE(strcmp(seq, "sequence_in") == 0); + EXPECT_TRUE(strcmp(seqt, "sequence_type_in") == 0); // A fresh multicam has no connected sources. - assert(oakengine_multicam_get_source_count(cam) == 0); - assert(oakengine_multicam_get_source_count(solid) == + EXPECT_TRUE(oakengine_multicam_get_source_count(cam) == 0); + EXPECT_TRUE(oakengine_multicam_get_source_count(solid) == OAKENGINE_E_INVALID); // Grid layout math (static, no node needed). int rows = 0, cols = 0; - assert(oakengine_multicam_get_rows_and_columns(-1, &rows, &cols) == + EXPECT_TRUE(oakengine_multicam_get_rows_and_columns(-1, &rows, &cols) == OAKENGINE_E_INVALID); - assert(oakengine_multicam_get_rows_and_columns(1, &rows, &cols) == + EXPECT_TRUE(oakengine_multicam_get_rows_and_columns(1, &rows, &cols) == OAKENGINE_OK); - assert(rows == 1 && cols == 1); - assert(oakengine_multicam_get_rows_and_columns(2, &rows, &cols) == + EXPECT_TRUE(rows == 1 && cols == 1); + EXPECT_TRUE(oakengine_multicam_get_rows_and_columns(2, &rows, &cols) == OAKENGINE_OK); - assert(rows == 1 && cols == 2); - assert(oakengine_multicam_get_rows_and_columns(4, &rows, &cols) == + EXPECT_TRUE(rows == 1 && cols == 2); + EXPECT_TRUE(oakengine_multicam_get_rows_and_columns(4, &rows, &cols) == OAKENGINE_OK); - assert(rows == 2 && cols == 2); - assert(oakengine_multicam_get_rows_and_columns(5, &rows, &cols) == + EXPECT_TRUE(rows == 2 && cols == 2); + EXPECT_TRUE(oakengine_multicam_get_rows_and_columns(5, &rows, &cols) == OAKENGINE_OK); - assert(rows == 2 && cols == 3); + EXPECT_TRUE(rows == 2 && cols == 3); // index <-> (row, col) is an inverse pair for every tile. for (int sources = 1; sources <= 9; sources++) { - assert(oakengine_multicam_get_rows_and_columns(sources, &rows, + EXPECT_TRUE(oakengine_multicam_get_rows_and_columns(sources, &rows, &cols) == OAKENGINE_OK); for (int index = 0; index < sources; index++) { int row = -1, col = -1; - assert(oakengine_multicam_index_to_row_cols(index, rows, cols, + EXPECT_TRUE(oakengine_multicam_index_to_row_cols(index, rows, cols, &row, &col) == OAKENGINE_OK); - assert(row >= 0 && row < rows && col >= 0 && col < cols); - assert(oakengine_multicam_rows_cols_to_index(row, col, rows, + EXPECT_TRUE(row >= 0 && row < rows && col >= 0 && col < cols); + EXPECT_TRUE(oakengine_multicam_rows_cols_to_index(row, col, rows, cols) == index); } } - assert(oakengine_multicam_index_to_row_cols(-1, 1, 1, &rows, &cols) == + EXPECT_TRUE(oakengine_multicam_index_to_row_cols(-1, 1, 1, &rows, &cols) == OAKENGINE_E_INVALID); - assert(oakengine_multicam_rows_cols_to_index(-1, 0, 1, 1) == + EXPECT_TRUE(oakengine_multicam_rows_cols_to_index(-1, 0, 1, 1) == OAKENGINE_E_INVALID); - assert(oakengine_project_remove_node(project, cam) == OAKENGINE_OK); - assert(oakengine_project_remove_node(project, solid) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_remove_node(project, cam) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_remove_node(project, solid) == OAKENGINE_OK); } // ---- Bulk graph deletion --------------------------------------------------- @@ -865,21 +866,21 @@ static void test_nodes_delete_many(OakEngineProject *project) // node). OakEngineNode *context = oakengine_project_add_node( project, "org.olivevideoeditor.Olive.group"); - assert(context != NULL); + EXPECT_TRUE(context != NULL); OakEngineNode *solid = oakengine_project_add_node( project, "org.olivevideoeditor.Olive.solidgenerator"); OakEngineNode *lut = oakengine_project_add_node( project, "org.olivevideoeditor.Olive.ociolut"); - assert(solid != NULL && lut != NULL); - assert(oakengine_node_connect(solid, lut, "tex_in") == OAKENGINE_OK); - assert(oakengine_node_set_context_position(context, solid, 1.0, 2.0) == + EXPECT_TRUE(solid != NULL && lut != NULL); + EXPECT_TRUE(oakengine_node_connect(solid, lut, "tex_in") == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_set_context_position(context, solid, 1.0, 2.0) == OAKENGINE_OK); - assert(oakengine_node_set_context_position(context, lut, 3.0, 4.0) == + EXPECT_TRUE(oakengine_node_set_context_position(context, lut, 3.0, 4.0) == OAKENGINE_OK); // Argument validation. - assert(oakengine_nodes_delete_many(NULL, NULL, 1, NULL, NULL, NULL, + EXPECT_TRUE(oakengine_nodes_delete_many(NULL, NULL, 1, NULL, NULL, NULL, NULL, 0) == OAKENGINE_E_INVALID); const int before = oakengine_project_node_count(project); @@ -890,33 +891,33 @@ static void test_nodes_delete_many(OakEngineProject *project) OakEngineNode *edge_input_nodes[1] = { lut }; const char *edge_input_ids[1] = { "tex_in" }; int edge_input_elements[1] = { -1 }; - assert(oakengine_nodes_delete_many(nodes, contexts, 2, edge_outputs, + EXPECT_TRUE(oakengine_nodes_delete_many(nodes, contexts, 2, edge_outputs, edge_input_nodes, edge_input_ids, edge_input_elements, 1) == OAKENGINE_OK); // Both nodes left the graph (no other context held them) and the edge // is gone. - assert(oakengine_project_node_count(project) == before - 2); - assert(oakengine_node_context_contains_node(context, solid) == 0); - assert(oakengine_node_context_contains_node(context, lut) == 0); + EXPECT_TRUE(oakengine_project_node_count(project) == before - 2); + EXPECT_TRUE(oakengine_node_context_contains_node(context, solid) == 0); + EXPECT_TRUE(oakengine_node_context_contains_node(context, lut) == 0); // One undo restores the nodes, their context positions and the edge. - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_project_node_count(project) == before); - assert(oakengine_node_context_contains_node(context, solid) == 1); - assert(oakengine_node_context_contains_node(context, lut) == 1); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_node_count(project) == before); + EXPECT_TRUE(oakengine_node_context_contains_node(context, solid) == 1); + EXPECT_TRUE(oakengine_node_context_contains_node(context, lut) == 1); double x = 0, y = 0; - assert(oakengine_node_get_context_position(context, solid, &x, &y, + EXPECT_TRUE(oakengine_node_get_context_position(context, solid, &x, &y, NULL) == OAKENGINE_OK); - assert(x == 1.0 && y == 2.0); - assert(oakengine_node_input_is_connected(lut, "tex_in") == 1); + EXPECT_TRUE(x == 1.0 && y == 2.0); + EXPECT_TRUE(oakengine_node_input_is_connected(lut, "tex_in") == 1); // Clean up. - assert(oakengine_node_disconnect(lut, "tex_in") == OAKENGINE_OK); - assert(oakengine_project_remove_node(project, solid) == OAKENGINE_OK); - assert(oakengine_project_remove_node(project, lut) == OAKENGINE_OK); - assert(oakengine_project_remove_node(project, context) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_disconnect(lut, "tex_in") == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_remove_node(project, solid) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_remove_node(project, lut) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_remove_node(project, context) == OAKENGINE_OK); } // ---- Node frame time base --------------------------------------------------- @@ -925,23 +926,23 @@ static void test_node_frame_time_base(OakEngineProject *project) { OakEngineNode *solid = oakengine_project_add_node( project, "org.olivevideoeditor.Olive.solidgenerator"); - assert(solid != NULL); + EXPECT_TRUE(solid != NULL); // NULL safety. int num = -1, den = -1; - assert(oakengine_node_frame_time_base(NULL, &num, &den) == + EXPECT_TRUE(oakengine_node_frame_time_base(NULL, &num, &den) == OAKENGINE_E_INVALID); // A solid node (not on a sequence) returns a sensible default. - assert(oakengine_node_frame_time_base(solid, NULL, NULL) == OAKENGINE_OK); - assert(oakengine_node_frame_time_base(solid, &num, NULL) == OAKENGINE_OK); - assert(num > 0); - assert(oakengine_node_frame_time_base(solid, NULL, &den) == OAKENGINE_OK); - assert(den > 0); - assert(oakengine_node_frame_time_base(solid, &num, &den) == OAKENGINE_OK); - assert(num > 0 && den > 0); + EXPECT_TRUE(oakengine_node_frame_time_base(solid, NULL, NULL) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_node_frame_time_base(solid, &num, NULL) == OAKENGINE_OK); + EXPECT_TRUE(num > 0); + EXPECT_TRUE(oakengine_node_frame_time_base(solid, NULL, &den) == OAKENGINE_OK); + EXPECT_TRUE(den > 0); + EXPECT_TRUE(oakengine_node_frame_time_base(solid, &num, &den) == OAKENGINE_OK); + EXPECT_TRUE(num > 0 && den > 0); - assert(oakengine_project_remove_node(project, solid) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_remove_node(project, solid) == OAKENGINE_OK); } // ---- Input property key iteration -------------------------------------------- @@ -950,36 +951,36 @@ static void test_node_input_get_property_key(OakEngineProject *project) { OakEngineNode *solid = oakengine_project_add_node( project, "org.olivevideoeditor.Olive.solidgenerator"); - assert(solid != NULL); + EXPECT_TRUE(solid != NULL); char buf[64]; // NULL safety. - assert(oakengine_node_input_get_property_key(NULL, "enabled_in", 0, buf, + EXPECT_TRUE(oakengine_node_input_get_property_key(NULL, "enabled_in", 0, buf, sizeof(buf)) == OAKENGINE_E_INVALID); - assert(oakengine_node_input_get_property_key(solid, NULL, 0, buf, + EXPECT_TRUE(oakengine_node_input_get_property_key(solid, NULL, 0, buf, sizeof(buf)) == OAKENGINE_E_INVALID); // Set a property, then read the key at index 0. - assert(oakengine_node_set_input_property_string(solid, "enabled_in", + EXPECT_TRUE(oakengine_node_set_input_property_string(solid, "enabled_in", "my_key", "my_value", 1) == OAKENGINE_OK); - assert(oakengine_node_input_get_property_key(solid, "enabled_in", 0, buf, + EXPECT_TRUE(oakengine_node_input_get_property_key(solid, "enabled_in", 0, buf, sizeof(buf)) > 0); - assert(strcmp(buf, "my_key") == 0); + EXPECT_TRUE(strcmp(buf, "my_key") == 0); // Out of range index. - assert(oakengine_node_input_get_property_key(solid, "enabled_in", 99, buf, + EXPECT_TRUE(oakengine_node_input_get_property_key(solid, "enabled_in", 99, buf, sizeof(buf)) == OAKENGINE_E_NOT_FOUND); // Query length mode. - assert(oakengine_node_input_get_property_key(solid, "enabled_in", 0, NULL, + EXPECT_TRUE(oakengine_node_input_get_property_key(solid, "enabled_in", 0, NULL, 0) == (int)strlen("my_key")); - assert(oakengine_project_remove_node(project, solid) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_remove_node(project, solid) == OAKENGINE_OK); } // ---- Keyframe best type at time --------------------------------------------- @@ -988,7 +989,7 @@ static void test_node_keyframe_best_type_at_time(OakEngineProject *project) { OakEngineNode *solid = oakengine_project_add_node( project, "org.olivevideoeditor.Olive.solidgenerator"); - assert(solid != NULL); + EXPECT_TRUE(solid != NULL); // Must not crash on NULL/invalid input. int type = oakengine_node_keyframe_best_type_at_time(NULL, "color_in", -1, @@ -1001,9 +1002,9 @@ static void test_node_keyframe_best_type_at_time(OakEngineProject *project) // Non-keyframed input returns the default easing type (>= 0). type = oakengine_node_keyframe_best_type_at_time(solid, "color_in", -1, 0, 0, 1); - assert(type >= 0); + EXPECT_TRUE(type >= 0); - assert(oakengine_project_remove_node(project, solid) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_remove_node(project, solid) == OAKENGINE_OK); } static void test_misc_node_facades(OakEngineProject *project) @@ -1011,51 +1012,51 @@ static void test_misc_node_facades(OakEngineProject *project) // Subtitle text getter/setter OakEngineNode *sub = oakengine_project_add_node( project, "org.olivevideoeditor.Olive.subtitle"); - assert(sub != NULL); - assert(oakengine_subtitle_set_text(sub, "Hello subtitles") == + EXPECT_TRUE(sub != NULL); + EXPECT_TRUE(oakengine_subtitle_set_text(sub, "Hello subtitles") == OAKENGINE_OK); char buf[64]; - assert(oakengine_subtitle_get_text(sub, buf, sizeof(buf)) == 15); - assert(strcmp(buf, "Hello subtitles") == 0); - assert(strcmp(oakengine_subtitle_text_input_id(), "text_in") == 0); + EXPECT_TRUE(oakengine_subtitle_get_text(sub, buf, sizeof(buf)) == 15); + EXPECT_TRUE(strcmp(buf, "Hello subtitles") == 0); + EXPECT_TRUE(strcmp(oakengine_subtitle_text_input_id(), "text_in") == 0); // Multicam current source defaults to 0 OakEngineNode *mc = oakengine_project_add_node( project, "org.olivevideoeditor.Olive.multicam"); - assert(mc != NULL); - assert(oakengine_multicam_get_current_source(mc) == 0); + EXPECT_TRUE(mc != NULL); + EXPECT_TRUE(oakengine_multicam_get_current_source(mc) == 0); // Shape rect: valid call with a dummy command should succeed. OakEngineNode *shape = oakengine_project_add_node( project, "org.olivevideoeditor.Olive.shape"); - assert(shape != NULL); + EXPECT_TRUE(shape != NULL); void *cmd = oakengine_undo_command_create_multi(); oak_video_params pod = {}; pod.width = 1920; pod.height = 1080; pod.format = 0; pod.divider = 1; - assert(oakengine_shape_set_rect_undoable(shape, 0, 0, 100, 100, &pod, + EXPECT_TRUE(oakengine_shape_set_rect_undoable(shape, 0, 0, 100, 100, &pod, cmd) == OAKENGINE_OK); oakengine_undo_command_free(cmd); } -int main(void) +TEST(OakEngineNode, Main) { make_tmpdir(); // Sandbox the config/cache/data locations (see oakengine_init_test). #if !defined(_WIN32) - assert(setenv("XDG_CONFIG_HOME", g_tmpdir, 1) == 0); - assert(setenv("XDG_CACHE_HOME", g_tmpdir, 1) == 0); - assert(setenv("XDG_DATA_HOME", g_tmpdir, 1) == 0); + EXPECT_TRUE(setenv("XDG_CONFIG_HOME", g_tmpdir, 1) == 0); + EXPECT_TRUE(setenv("XDG_CACHE_HOME", g_tmpdir, 1) == 0); + EXPECT_TRUE(setenv("XDG_DATA_HOME", g_tmpdir, 1) == 0); #endif - assert(oakengine_init(OAKENGINE_INIT_HEADLESS) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_init(OAKENGINE_INIT_HEADLESS) == OAKENGINE_OK); OakEngineProject *project = oakengine_project_create(); - assert(project != NULL); - assert(oakengine_project_new(project) == OAKENGINE_OK); + EXPECT_TRUE(project != NULL); + EXPECT_TRUE(oakengine_project_new(project) == OAKENGINE_OK); test_enumeration(project); @@ -1079,15 +1080,13 @@ int main(void) // Graph nodes are not timeline clips: a sequence's track list stays // empty no matter what the project graph holds. OakEngineSequence *seq = oakengine_sequence_new(project, "Seq"); - assert(seq != NULL); + EXPECT_TRUE(seq != NULL); int video = -1, audio = -1, subtitle = -1; - assert(oakengine_sequence_track_count(seq, &video, &audio, &subtitle) == + EXPECT_TRUE(oakengine_sequence_track_count(seq, &video, &audio, &subtitle) == OAKENGINE_OK); - assert(video == 0 && audio == 0 && subtitle == 0); + EXPECT_TRUE(video == 0 && audio == 0 && subtitle == 0); oakengine_project_free(project); - assert(oakengine_shutdown() == OAKENGINE_OK); + EXPECT_TRUE(oakengine_shutdown() == OAKENGINE_OK); - printf("oakengine_node_test: all assertions passed\n"); - return 0; } diff --git a/engine/tests/oakengine_nodevalue_test.cpp b/engine/tests/oakengine_nodevalue_test.cpp index 05c978e0a..defeefa75 100644 --- a/engine/tests/oakengine_nodevalue_test.cpp +++ b/engine/tests/oakengine_nodevalue_test.cpp @@ -25,6 +25,7 @@ // No engine init required: these wrap pure NodeValue statics. #include +#include #include #include @@ -32,15 +33,15 @@ static void test_track_count(void) { - assert(oakengine_node_value_keyframe_track_count(OAK_NODE_VALUE_INT) == + EXPECT_TRUE(oakengine_node_value_keyframe_track_count(OAK_NODE_VALUE_INT) == 1); - assert(oakengine_node_value_keyframe_track_count(OAK_NODE_VALUE_FLOAT) == + EXPECT_TRUE(oakengine_node_value_keyframe_track_count(OAK_NODE_VALUE_FLOAT) == 1); - assert(oakengine_node_value_keyframe_track_count(OAK_NODE_VALUE_VEC2) == + EXPECT_TRUE(oakengine_node_value_keyframe_track_count(OAK_NODE_VALUE_VEC2) == 2); - assert(oakengine_node_value_keyframe_track_count(OAK_NODE_VALUE_VEC3) == + EXPECT_TRUE(oakengine_node_value_keyframe_track_count(OAK_NODE_VALUE_VEC3) == 3); - assert(oakengine_node_value_keyframe_track_count(OAK_NODE_VALUE_VEC4) == + EXPECT_TRUE(oakengine_node_value_keyframe_track_count(OAK_NODE_VALUE_VEC4) == 4); } @@ -48,18 +49,18 @@ static void test_pretty_name(void) { char buf[64]; - assert(oakengine_node_value_pretty_type_name(OAK_NODE_VALUE_INT, buf, + EXPECT_TRUE(oakengine_node_value_pretty_type_name(OAK_NODE_VALUE_INT, buf, sizeof(buf)) > 0); - assert(buf[0] != '\0'); + EXPECT_TRUE(buf[0] != '\0'); /* two-phase: query length first */ const int len = oakengine_node_value_pretty_type_name(OAK_NODE_VALUE_FLOAT, nullptr, 0); - assert(len > 0); + EXPECT_TRUE(len > 0); /* unknown type reports -1 */ - assert(oakengine_node_value_pretty_type_name(9999, buf, sizeof(buf)) == + EXPECT_TRUE(oakengine_node_value_pretty_type_name(9999, buf, sizeof(buf)) == -1); } @@ -72,17 +73,17 @@ static void test_split_combine_vec3(void) normal.f[2] = 3.0; oak_node_value tracks[3] = {{0}}; - assert(oakengine_node_value_split_to_tracks(OAK_NODE_VALUE_VEC3, &normal, + EXPECT_TRUE(oakengine_node_value_split_to_tracks(OAK_NODE_VALUE_VEC3, &normal, tracks, 3) == OAKENGINE_OK); - assert(tracks[0].f[0] == 1.0); - assert(tracks[1].f[0] == 2.0); - assert(tracks[2].f[0] == 3.0); + EXPECT_TRUE(tracks[0].f[0] == 1.0); + EXPECT_TRUE(tracks[1].f[0] == 2.0); + EXPECT_TRUE(tracks[2].f[0] == 3.0); oak_node_value back = {0}; - assert(oakengine_node_value_combine_tracks(OAK_NODE_VALUE_VEC3, tracks, + EXPECT_TRUE(oakengine_node_value_combine_tracks(OAK_NODE_VALUE_VEC3, tracks, 3, &back) == OAKENGINE_OK); - assert(back.type == OAK_NODE_VALUE_VEC3); - assert(back.f[0] == 1.0 && back.f[1] == 2.0 && back.f[2] == 3.0); + EXPECT_TRUE(back.type == OAK_NODE_VALUE_VEC3); + EXPECT_TRUE(back.f[0] == 1.0 && back.f[1] == 2.0 && back.f[2] == 3.0); } static void test_split_combine_int(void) @@ -92,17 +93,17 @@ static void test_split_combine_int(void) normal.num = 42; oak_node_value track = {0}; - assert(oakengine_node_value_split_to_tracks(OAK_NODE_VALUE_INT, &normal, + EXPECT_TRUE(oakengine_node_value_split_to_tracks(OAK_NODE_VALUE_INT, &normal, &track, 1) == OAKENGINE_OK); /* scalar fields must survive the roundtrip (num, not only f[0]) */ - assert(track.type == OAK_NODE_VALUE_INT); - assert(track.num == 42); + EXPECT_TRUE(track.type == OAK_NODE_VALUE_INT); + EXPECT_TRUE(track.num == 42); oak_node_value back = {0}; - assert(oakengine_node_value_combine_tracks(OAK_NODE_VALUE_INT, &track, 1, + EXPECT_TRUE(oakengine_node_value_combine_tracks(OAK_NODE_VALUE_INT, &track, 1, &back) == OAKENGINE_OK); - assert(back.type == OAK_NODE_VALUE_INT); - assert(back.num == 42); + EXPECT_TRUE(back.type == OAK_NODE_VALUE_INT); + EXPECT_TRUE(back.num == 42); } static void test_split_combine_rational(void) @@ -113,38 +114,38 @@ static void test_split_combine_rational(void) normal.den = 1001; oak_node_value track = {0}; - assert(oakengine_node_value_split_to_tracks(OAK_NODE_VALUE_RATIONAL, + EXPECT_TRUE(oakengine_node_value_split_to_tracks(OAK_NODE_VALUE_RATIONAL, &normal, &track, 1) == OAKENGINE_OK); - assert(track.type == OAK_NODE_VALUE_RATIONAL); - assert(track.num == 30000 && track.den == 1001); + EXPECT_TRUE(track.type == OAK_NODE_VALUE_RATIONAL); + EXPECT_TRUE(track.num == 30000 && track.den == 1001); oak_node_value back = {0}; - assert(oakengine_node_value_combine_tracks(OAK_NODE_VALUE_RATIONAL, + EXPECT_TRUE(oakengine_node_value_combine_tracks(OAK_NODE_VALUE_RATIONAL, &track, 1, &back) == OAKENGINE_OK); - assert(back.num == 30000 && back.den == 1001); + EXPECT_TRUE(back.num == 30000 && back.den == 1001); } static void test_error_paths(void) { oak_node_value v = {0}; - assert(oakengine_node_value_split_to_tracks(OAK_NODE_VALUE_VEC3, nullptr, + EXPECT_TRUE(oakengine_node_value_split_to_tracks(OAK_NODE_VALUE_VEC3, nullptr, &v, 1) == OAKENGINE_E_INVALID); - assert(oakengine_node_value_split_to_tracks(OAK_NODE_VALUE_VEC3, &v, + EXPECT_TRUE(oakengine_node_value_split_to_tracks(OAK_NODE_VALUE_VEC3, &v, nullptr, 1) == OAKENGINE_E_INVALID); - assert(oakengine_node_value_split_to_tracks(OAK_NODE_VALUE_VEC3, &v, &v, + EXPECT_TRUE(oakengine_node_value_split_to_tracks(OAK_NODE_VALUE_VEC3, &v, &v, 0) == OAKENGINE_E_INVALID); - assert(oakengine_node_value_combine_tracks(OAK_NODE_VALUE_VEC3, nullptr, + EXPECT_TRUE(oakengine_node_value_combine_tracks(OAK_NODE_VALUE_VEC3, nullptr, 1, &v) == OAKENGINE_E_INVALID); - assert(oakengine_node_value_combine_tracks(OAK_NODE_VALUE_VEC3, &v, 1, + EXPECT_TRUE(oakengine_node_value_combine_tracks(OAK_NODE_VALUE_VEC3, &v, 1, nullptr) == OAKENGINE_E_INVALID); } -int main(void) +TEST(OakEngineNodevalue, Main) { test_track_count(); test_pretty_name(); @@ -152,5 +153,4 @@ int main(void) test_split_combine_int(); test_split_combine_rational(); test_error_paths(); - return 0; } diff --git a/engine/tests/oakengine_playback_test.cpp b/engine/tests/oakengine_playback_test.cpp index e13f70cbe..51e4fbc2d 100644 --- a/engine/tests/oakengine_playback_test.cpp +++ b/engine/tests/oakengine_playback_test.cpp @@ -33,6 +33,7 @@ // under a mutex (the documented marshalling duty of the consumer). #include +#include #include #include #include @@ -83,13 +84,13 @@ static void make_tmpdir(void) #if defined(_WIN32) char base[MAX_PATH]; const DWORD len = GetTempPathA(MAX_PATH, base); - assert(len > 0 && len < MAX_PATH); + EXPECT_TRUE(len > 0 && len < MAX_PATH); snprintf(g_tmpdir, sizeof(g_tmpdir), "%soakengine_playback_test_%lu", base, (unsigned long)GetCurrentProcessId()); - assert(_mkdir(g_tmpdir) == 0); + EXPECT_TRUE(_mkdir(g_tmpdir) == 0); #else strcpy(g_tmpdir, "/tmp/oakengine_playback_test_XXXXXX"); - assert(mkdtemp(g_tmpdir) != NULL); + EXPECT_TRUE(mkdtemp(g_tmpdir) != NULL); #endif } @@ -237,79 +238,79 @@ static bool not_playing(void *userdata) // Argument validation, idempotent pause/stop, initial position. No GL. static void test_validation(OakEngineSequence *seq) { - assert(oakengine_playback_create(NULL, 320, 180, 24, 1) == NULL); - assert(oakengine_playback_create(seq, 0, 180, 24, 1) == NULL); - assert(oakengine_playback_create(seq, 320, -1, 24, 1) == NULL); - assert(oakengine_playback_create(seq, 320, 180, 0, 1) == NULL); - assert(oakengine_playback_create(seq, 320, 180, 24, 0) == NULL); + EXPECT_TRUE(oakengine_playback_create(NULL, 320, 180, 24, 1) == NULL); + EXPECT_TRUE(oakengine_playback_create(seq, 0, 180, 24, 1) == NULL); + EXPECT_TRUE(oakengine_playback_create(seq, 320, -1, 24, 1) == NULL); + EXPECT_TRUE(oakengine_playback_create(seq, 320, 180, 0, 1) == NULL); + EXPECT_TRUE(oakengine_playback_create(seq, 320, 180, 24, 0) == NULL); OakEnginePlayback *p = oakengine_playback_create(seq, 320, 180, 24, 1); - assert(p != NULL); + EXPECT_TRUE(p != NULL); // Callback setters: NULL-safe, idempotent. - assert(oakengine_playback_set_frame_callback(NULL, on_frame, NULL) == + EXPECT_TRUE(oakengine_playback_set_frame_callback(NULL, on_frame, NULL) == OAKENGINE_E_INVALID); - assert(oakengine_playback_set_frame_callback(p, NULL, NULL) == + EXPECT_TRUE(oakengine_playback_set_frame_callback(p, NULL, NULL) == OAKENGINE_OK); - assert(oakengine_playback_set_audio_callback(NULL, on_audio, NULL) == + EXPECT_TRUE(oakengine_playback_set_audio_callback(NULL, on_audio, NULL) == OAKENGINE_E_INVALID); - assert(oakengine_playback_set_audio_callback(p, NULL, NULL) == + EXPECT_TRUE(oakengine_playback_set_audio_callback(p, NULL, NULL) == OAKENGINE_OK); // Position is 0 before the first start; pause/stop are idempotent. int64_t pos = -1; - assert(oakengine_playback_get_position(p, &pos) == OAKENGINE_OK); - assert(pos == 0); - assert(oakengine_playback_get_position(NULL, &pos) == + EXPECT_TRUE(oakengine_playback_get_position(p, &pos) == OAKENGINE_OK); + EXPECT_TRUE(pos == 0); + EXPECT_TRUE(oakengine_playback_get_position(NULL, &pos) == OAKENGINE_E_INVALID); - assert(oakengine_playback_get_position(p, NULL) == OAKENGINE_E_INVALID); - assert(oakengine_playback_is_playing(p) == 0); - assert(oakengine_playback_is_playing(NULL) == 0); - assert(oakengine_playback_pause(p) == OAKENGINE_OK); - assert(oakengine_playback_stop(p) == OAKENGINE_OK); - assert(oakengine_playback_is_playing(p) == 0); + EXPECT_TRUE(oakengine_playback_get_position(p, NULL) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_playback_is_playing(p) == 0); + EXPECT_TRUE(oakengine_playback_is_playing(NULL) == 0); + EXPECT_TRUE(oakengine_playback_pause(p) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_playback_stop(p) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_playback_is_playing(p) == 0); // Bad speeds are rejected with a readable reason; start without the // RENDER bit reports OAKENGINE_E_STATE. - assert(oakengine_playback_set_speed(p, 0.0) == OAKENGINE_E_INVALID); - assert(oakengine_playback_set_speed(p, -1.0) == OAKENGINE_E_INVALID); - assert(oakengine_playback_set_speed(NULL, 1.0) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_playback_set_speed(p, 0.0) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_playback_set_speed(p, -1.0) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_playback_set_speed(NULL, 1.0) == OAKENGINE_E_INVALID); char err[256]; - assert(oakengine_playback_last_error(p, err, sizeof(err)) > 0); - assert(oakengine_playback_start(p, 0, 0.0) == OAKENGINE_E_INVALID); - assert(oakengine_playback_start(p, 0, -2.0) == OAKENGINE_E_INVALID); - assert(oakengine_playback_start(p, -1, 1.0) == OAKENGINE_E_INVALID); - assert(oakengine_playback_start(p, 0, 1.0) == OAKENGINE_E_STATE); - assert(strstr(err, "OAKENGINE_INIT_RENDER") != NULL || + EXPECT_TRUE(oakengine_playback_last_error(p, err, sizeof(err)) > 0); + EXPECT_TRUE(oakengine_playback_start(p, 0, 0.0) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_playback_start(p, 0, -2.0) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_playback_start(p, -1, 1.0) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_playback_start(p, 0, 1.0) == OAKENGINE_E_STATE); + EXPECT_TRUE(strstr(err, "OAKENGINE_INIT_RENDER") != NULL || oakengine_playback_last_error(p, err, sizeof(err)) > 0); - assert(oakengine_playback_start(NULL, 0, 1.0) == OAKENGINE_E_INVALID); - assert(oakengine_playback_pause(NULL) == OAKENGINE_E_INVALID); - assert(oakengine_playback_stop(NULL) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_playback_start(NULL, 0, 1.0) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_playback_pause(NULL) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_playback_stop(NULL) == OAKENGINE_E_INVALID); oakengine_playback_free(p); oakengine_playback_free(NULL); } -int main(void) +TEST(OakEnginePlayback, Main) { make_tmpdir(); // Sandbox the config/cache/data locations (see oakengine_init_test). #if !defined(_WIN32) - assert(setenv("XDG_CONFIG_HOME", g_tmpdir, 1) == 0); - assert(setenv("XDG_CACHE_HOME", g_tmpdir, 1) == 0); - assert(setenv("XDG_DATA_HOME", g_tmpdir, 1) == 0); + EXPECT_TRUE(setenv("XDG_CONFIG_HOME", g_tmpdir, 1) == 0); + EXPECT_TRUE(setenv("XDG_CACHE_HOME", g_tmpdir, 1) == 0); + EXPECT_TRUE(setenv("XDG_DATA_HOME", g_tmpdir, 1) == 0); #endif // HEADLESS is enough for the validation part and creates the // application object the backend probe below depends on. - assert(oakengine_init(OAKENGINE_INIT_HEADLESS) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_init(OAKENGINE_INIT_HEADLESS) == OAKENGINE_OK); OakEngineProject *project = oakengine_project_create(); - assert(project != NULL); - assert(oakengine_project_new(project) == OAKENGINE_OK); + EXPECT_TRUE(project != NULL); + EXPECT_TRUE(oakengine_project_new(project) == OAKENGINE_OK); OakEngineSequence *seq = oakengine_sequence_new(project, "Playback"); - assert(seq != NULL); + EXPECT_TRUE(seq != NULL); test_validation(seq); @@ -319,20 +320,20 @@ int main(void) "available, playback assertions skipped\n"); oakengine_project_free(project); oakengine_shutdown(); - return 0; + return; } if (!worker_binary_exists()) { printf("oakengine_playback_test: SKIP: oak-render-worker binary not " "found, playback assertions skipped\n"); oakengine_project_free(project); oakengine_shutdown(); - return 0; + return; } // The engine renders through the backend requested in the config. olive::Config::current()[QStringLiteral("GraphicsBackend")] = QStringLiteral("opengl"); - assert(oakengine_init(OAKENGINE_INIT_HEADLESS | OAKENGINE_INIT_RENDER) == + EXPECT_TRUE(oakengine_init(OAKENGINE_INIT_HEADLESS | OAKENGINE_INIT_RENDER) == OAKENGINE_OK); // Build content through the facade (a real clip gives the sequence a @@ -340,54 +341,54 @@ int main(void) // tests/demo.mp4 placed from 0. const QString demo_path = QDir(QStringLiteral(OAK_TEST_SOURCE_DIR)) .filePath(QStringLiteral("tests/demo.mp4")); - assert(QFileInfo::exists(demo_path)); - assert(oakengine_sequence_add_track(seq, OAKENGINE_TRACK_TYPE_VIDEO) == + EXPECT_TRUE(QFileInfo::exists(demo_path)); + EXPECT_TRUE(oakengine_sequence_add_track(seq, OAKENGINE_TRACK_TYPE_VIDEO) == 0); OakEngineFootage *footage = oakengine_project_import_footage(project, demo_path.toUtf8().constData()); - assert(footage != NULL); + EXPECT_TRUE(footage != NULL); OakEngineClip *clip = oakengine_sequence_add_footage_clip( seq, footage, OAKENGINE_TRACK_TYPE_VIDEO, 0, 0, 480, 0); - assert(clip != NULL); + EXPECT_TRUE(clip != NULL); // Audio comes from an audio track: without one the sequence's samples // output is empty (the video track alone carries no samples). - assert(oakengine_sequence_add_track(seq, OAKENGINE_TRACK_TYPE_AUDIO) == + EXPECT_TRUE(oakengine_sequence_add_track(seq, OAKENGINE_TRACK_TYPE_AUDIO) == 0); OakEngineClip *aclip = oakengine_sequence_add_footage_clip( seq, footage, OAKENGINE_TRACK_TYPE_AUDIO, 0, 0, 480, 0); - assert(aclip != NULL); + EXPECT_TRUE(aclip != NULL); oakengine_footage_free(footage); FrameLog frames; AudioLog audio; OakEnginePlayback *p = oakengine_playback_create(seq, 320, 180, 30000, 1001); - assert(p != NULL); - assert(oakengine_playback_set_frame_callback(p, on_frame, &frames) == + EXPECT_TRUE(p != NULL); + EXPECT_TRUE(oakengine_playback_set_frame_callback(p, on_frame, &frames) == OAKENGINE_OK); - assert(oakengine_playback_set_audio_callback(p, on_audio, &audio) == + EXPECT_TRUE(oakengine_playback_set_audio_callback(p, on_audio, &audio) == OAKENGINE_OK); // Start at 1x: frames arrive monotonically with the right geometry, // audio blocks with the right layout. - assert(oakengine_playback_start(p, 0, 1.0) == OAKENGINE_OK); - assert(oakengine_playback_is_playing(p) == 1); - assert(wait_until(six_frames, &frames, 10000)); + EXPECT_TRUE(oakengine_playback_start(p, 0, 1.0) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_playback_is_playing(p) == 1); + EXPECT_TRUE(wait_until(six_frames, &frames, 10000)); // The first block(s) can land while the decoder is still warming up // (empty channels); require at least one well-formed block and a // consistent layout across all of them (generous for CI stability). - assert(wait_until(good_audio_block, &audio, 10000)); + EXPECT_TRUE(wait_until(good_audio_block, &audio, 10000)); { frames.mutex.lock(); const size_t n = frames.frames.size(); for (size_t i = 0; i < n; i++) { const oak_playback_frame &f = frames.frames.at(i); - assert(f.width == 320 && f.height == 180); - assert(f.format == 3); // f16 - assert(f.linesize >= 320 * 4 * 2); - assert(f.data != NULL); + EXPECT_TRUE(f.width == 320 && f.height == 180); + EXPECT_TRUE(f.format == 3); // f16 + EXPECT_TRUE(f.linesize >= 320 * 4 * 2); + EXPECT_TRUE(f.data != NULL); if (i > 0) { - assert(f.timestamp > frames.frames.at(i - 1).timestamp); + EXPECT_TRUE(f.timestamp > frames.frames.at(i - 1).timestamp); } } frames.mutex.unlock(); @@ -396,15 +397,15 @@ int main(void) audio.mutex.lock(); bool found_good = false; for (const oak_playback_audio &a : audio.blocks) { - assert(a.channels == 2); - assert(a.sample_rate == 48000); - assert(a.sample_count >= 0); + EXPECT_TRUE(a.channels == 2); + EXPECT_TRUE(a.sample_rate == 48000); + EXPECT_TRUE(a.sample_count >= 0); if (a.channel_data && a.channel_data[0] && a.channel_data[1] && a.sample_count > 0) { found_good = true; } } - assert(found_good); + EXPECT_TRUE(found_good); audio.mutex.unlock(); } @@ -412,86 +413,86 @@ int main(void) // instance exists in this process). pump_ms(400); int64_t pos_a = -1; - assert(oakengine_playback_get_position(p, &pos_a) == OAKENGINE_OK); - assert(pos_a > 0); + EXPECT_TRUE(oakengine_playback_get_position(p, &pos_a) == OAKENGINE_OK); + EXPECT_TRUE(pos_a > 0); // Pause freezes delivery and the position. - assert(oakengine_playback_pause(p) == OAKENGINE_OK); - assert(oakengine_playback_is_playing(p) == 0); + EXPECT_TRUE(oakengine_playback_pause(p) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_playback_is_playing(p) == 0); const size_t frozen_frames = frames.size(); int64_t frozen_pos = -1; - assert(oakengine_playback_get_position(p, &frozen_pos) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_playback_get_position(p, &frozen_pos) == OAKENGINE_OK); pump_ms(250); - assert(frames.size() <= frozen_frames + 1); // one in-flight may land + EXPECT_TRUE(frames.size() <= frozen_frames + 1); // one in-flight may land int64_t still_frozen = -1; - assert(oakengine_playback_get_position(p, &still_frozen) == OAKENGINE_OK); - assert(still_frozen == frozen_pos); + EXPECT_TRUE(oakengine_playback_get_position(p, &still_frozen) == OAKENGINE_OK); + EXPECT_TRUE(still_frozen == frozen_pos); // Resume at the frozen position: delivery continues. - assert(oakengine_playback_start(p, frozen_pos, 1.0) == OAKENGINE_OK); - assert(oakengine_playback_is_playing(p) == 1); + EXPECT_TRUE(oakengine_playback_start(p, frozen_pos, 1.0) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_playback_is_playing(p) == 1); pump_ms(300); - assert(frames.size() > frozen_frames); + EXPECT_TRUE(frames.size() > frozen_frames); // 2x advances the position (much) faster than 1x over the same wall // window (generous margins to stay CI-stable). - assert(oakengine_playback_get_position(p, &pos_a) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_playback_get_position(p, &pos_a) == OAKENGINE_OK); pump_ms(600); int64_t pos_b = -1; - assert(oakengine_playback_get_position(p, &pos_b) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_playback_get_position(p, &pos_b) == OAKENGINE_OK); const int64_t advance_1x = pos_b - pos_a; - assert(oakengine_playback_set_speed(p, 2.0) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_playback_set_speed(p, 2.0) == OAKENGINE_OK); pump_ms(600); int64_t pos_c = -1; - assert(oakengine_playback_get_position(p, &pos_c) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_playback_get_position(p, &pos_c) == OAKENGINE_OK); const int64_t advance_2x = pos_c - pos_b; - assert(advance_1x > 0); - assert(advance_2x > advance_1x + advance_1x / 2); + EXPECT_TRUE(advance_1x > 0); + EXPECT_TRUE(advance_2x > advance_1x + advance_1x / 2); // Stop resets to the last start timestamp; restarting from 0 replays. - assert(oakengine_playback_stop(p) == OAKENGINE_OK); - assert(oakengine_playback_is_playing(p) == 0); + EXPECT_TRUE(oakengine_playback_stop(p) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_playback_is_playing(p) == 0); int64_t stopped_pos = -1; - assert(oakengine_playback_get_position(p, &stopped_pos) == + EXPECT_TRUE(oakengine_playback_get_position(p, &stopped_pos) == OAKENGINE_OK); - assert(stopped_pos == frozen_pos); + EXPECT_TRUE(stopped_pos == frozen_pos); { frames.mutex.lock(); frames.frames.clear(); frames.mutex.unlock(); } - assert(oakengine_playback_start(p, 0, 1.0) == OAKENGINE_OK); - assert(wait_until(six_frames, &frames, 10000)); + EXPECT_TRUE(oakengine_playback_start(p, 0, 1.0) == OAKENGINE_OK); + EXPECT_TRUE(wait_until(six_frames, &frames, 10000)); { frames.mutex.lock(); - assert(frames.frames.front().timestamp < 30); + EXPECT_TRUE(frames.frames.front().timestamp < 30); frames.mutex.unlock(); } - assert(oakengine_playback_stop(p) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_playback_stop(p) == OAKENGINE_OK); // End of stream: start near the end at 4x, the engine auto-stops at // the sequence length and reports that as the position. int len_num = 0, len_den = 1; - assert(oakengine_sequence_get_length_rational(seq, &len_num, &len_den) == + EXPECT_TRUE(oakengine_sequence_get_length_rational(seq, &len_num, &len_den) == OAKENGINE_OK); const int64_t end_ts = int64_t( olive::core::Timecode::time_to_timestamp( olive::Rational(len_num, len_den), olive::Rational(1001, 30000), olive::core::Timecode::k_round)); const int64_t near_end = end_ts > 48 ? end_ts - 48 : 0; - assert(oakengine_playback_start(p, near_end, 4.0) == OAKENGINE_OK); - assert(wait_until(not_playing, p, 10000)); + EXPECT_TRUE(oakengine_playback_start(p, near_end, 4.0) == OAKENGINE_OK); + EXPECT_TRUE(wait_until(not_playing, p, 10000)); int64_t end_pos = -1; - assert(oakengine_playback_get_position(p, &end_pos) == OAKENGINE_OK); - assert(end_pos == end_ts); + EXPECT_TRUE(oakengine_playback_get_position(p, &end_pos) == OAKENGINE_OK); + EXPECT_TRUE(end_pos == end_ts); // Freeing during playback must not crash. OakEnginePlayback *p2 = oakengine_playback_create(seq, 320, 180, 30000, 1001); - assert(p2 != NULL); - assert(oakengine_playback_set_frame_callback(p2, on_frame, + EXPECT_TRUE(p2 != NULL); + EXPECT_TRUE(oakengine_playback_set_frame_callback(p2, on_frame, &frames) == OAKENGINE_OK); - assert(oakengine_playback_start(p2, 0, 1.0) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_playback_start(p2, 0, 1.0) == OAKENGINE_OK); pump_ms(50); oakengine_playback_free(p2); @@ -499,17 +500,15 @@ int main(void) // detaches, and free() from this thread waits its exit out. OakEnginePlayback *p3 = oakengine_playback_create(seq, 320, 180, 30000, 1001); - assert(p3 != NULL); - assert(oakengine_playback_set_frame_callback(p3, on_frame_stop, p3) == + EXPECT_TRUE(p3 != NULL); + EXPECT_TRUE(oakengine_playback_set_frame_callback(p3, on_frame_stop, p3) == OAKENGINE_OK); - assert(oakengine_playback_start(p3, 0, 1.0) == OAKENGINE_OK); - assert(wait_until(not_playing, p3, 10000)); + EXPECT_TRUE(oakengine_playback_start(p3, 0, 1.0) == OAKENGINE_OK); + EXPECT_TRUE(wait_until(not_playing, p3, 10000)); oakengine_playback_free(p3); oakengine_playback_free(p); oakengine_project_free(project); - assert(oakengine_shutdown() == OAKENGINE_OK); + EXPECT_TRUE(oakengine_shutdown() == OAKENGINE_OK); - printf("oakengine_playback_test: all assertions passed\n"); - return 0; } diff --git a/engine/tests/oakengine_preview_test.cpp b/engine/tests/oakengine_preview_test.cpp index b56b9e9f6..1f1b4b0ea 100644 --- a/engine/tests/oakengine_preview_test.cpp +++ b/engine/tests/oakengine_preview_test.cpp @@ -24,6 +24,7 @@ // (only the RENDER init bit). Uses the real media file tests/demo.mp4. #include +#include #include #include #include @@ -54,47 +55,47 @@ static void make_tmpdir(void) #if defined(_WIN32) char base[MAX_PATH]; const DWORD len = GetTempPathA(MAX_PATH, base); - assert(len > 0 && len < MAX_PATH); + EXPECT_TRUE(len > 0 && len < MAX_PATH); snprintf(g_tmpdir, sizeof(g_tmpdir), "%soakengine_preview_test_%lu", base, (unsigned long)GetCurrentProcessId()); - assert(_mkdir(g_tmpdir) == 0); + EXPECT_TRUE(_mkdir(g_tmpdir) == 0); #else strcpy(g_tmpdir, "/tmp/oakengine_preview_test_XXXXXX"); - assert(mkdtemp(g_tmpdir) != NULL); + EXPECT_TRUE(mkdtemp(g_tmpdir) != NULL); #endif } static void demo_path(char *dst, size_t cap) { const int n = snprintf(dst, cap, "%s/tests/demo.mp4", OAK_TEST_SOURCE_DIR); - assert(n > 0 && (size_t)n < cap); + EXPECT_TRUE(n > 0 && (size_t)n < cap); } static void test_loop_mode(OakEngineProject *project, OakEngineClip *clip) { - assert(oakengine_clip_get_loop_mode(clip) == OAKENGINE_LOOP_MODE_OFF); + EXPECT_TRUE(oakengine_clip_get_loop_mode(clip) == OAKENGINE_LOOP_MODE_OFF); - assert(oakengine_clip_set_loop_mode(clip, OAKENGINE_LOOP_MODE_LOOP) == + EXPECT_TRUE(oakengine_clip_set_loop_mode(clip, OAKENGINE_LOOP_MODE_LOOP) == OAKENGINE_OK); - assert(oakengine_clip_get_loop_mode(clip) == OAKENGINE_LOOP_MODE_LOOP); - assert(oakengine_clip_set_loop_mode(clip, OAKENGINE_LOOP_MODE_CLAMP) == + EXPECT_TRUE(oakengine_clip_get_loop_mode(clip) == OAKENGINE_LOOP_MODE_LOOP); + EXPECT_TRUE(oakengine_clip_set_loop_mode(clip, OAKENGINE_LOOP_MODE_CLAMP) == OAKENGINE_OK); - assert(oakengine_clip_get_loop_mode(clip) == OAKENGINE_LOOP_MODE_CLAMP); + EXPECT_TRUE(oakengine_clip_get_loop_mode(clip) == OAKENGINE_LOOP_MODE_CLAMP); // Unknown modes and NULL are rejected. - assert(oakengine_clip_set_loop_mode(clip, 3) == OAKENGINE_E_INVALID); - assert(oakengine_clip_set_loop_mode(clip, -1) == OAKENGINE_E_INVALID); - assert(oakengine_clip_set_loop_mode(NULL, 0) == OAKENGINE_E_INVALID); - assert(oakengine_clip_get_loop_mode(NULL) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_clip_set_loop_mode(clip, 3) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_clip_set_loop_mode(clip, -1) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_clip_set_loop_mode(NULL, 0) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_clip_get_loop_mode(NULL) == OAKENGINE_E_INVALID); // Undoable: undo restores LOOP then OFF, redo restores LOOP then CLAMP. - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_clip_get_loop_mode(clip) == OAKENGINE_LOOP_MODE_LOOP); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_clip_get_loop_mode(clip) == OAKENGINE_LOOP_MODE_OFF); - assert(oakengine_project_redo(project) == OAKENGINE_OK); - assert(oakengine_project_redo(project) == OAKENGINE_OK); - assert(oakengine_clip_get_loop_mode(clip) == OAKENGINE_LOOP_MODE_CLAMP); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_clip_get_loop_mode(clip) == OAKENGINE_LOOP_MODE_LOOP); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_clip_get_loop_mode(clip) == OAKENGINE_LOOP_MODE_OFF); + EXPECT_TRUE(oakengine_project_redo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_redo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_clip_get_loop_mode(clip) == OAKENGINE_LOOP_MODE_CLAMP); } // Generate a loud test tone (440 Hz stereo sine, 2 s) with the ffmpeg @@ -105,15 +106,15 @@ static void test_loop_mode(OakEngineProject *project, OakEngineClip *clip) static void make_tone(char *dst, size_t cap) { const int n = snprintf(dst, cap, "%s/tone.wav", g_tmpdir); - assert(n > 0 && (size_t)n < cap); + EXPECT_TRUE(n > 0 && (size_t)n < cap); char cmd[4608]; snprintf(cmd, sizeof(cmd), "ffmpeg -v error -y -f lavfi -i " "\"sine=frequency=440:duration=2\" -ar 48000 -ac 2 \"%s\"", dst); - assert(system(cmd) == 0); + EXPECT_TRUE(system(cmd) == 0); FILE *f = fopen(dst, "rb"); - assert(f != NULL); + EXPECT_TRUE(f != NULL); fclose(f); } @@ -124,22 +125,22 @@ static void test_levels(OakEngineSequence *seq) // Inside the clip (30 frames at 30000/1001): a loud sine on both // channels. RMS of a full-scale sine is ~0.707. const int written = oakengine_preview_get_audio_levels(seq, 10, levels, 4); - assert(written == 2); - assert(levels[2] == 0.0 && levels[3] == 0.0); // beyond channel count + EXPECT_TRUE(written == 2); + EXPECT_TRUE(levels[2] == 0.0 && levels[3] == 0.0); // beyond channel count // Past the end of the track: exact silence. double silent[2] = { -1.0, -1.0 }; - assert(oakengine_preview_get_audio_levels(seq, 35, silent, 2) >= 0); - assert(silent[0] == 0.0 && silent[1] == 0.0); + EXPECT_TRUE(oakengine_preview_get_audio_levels(seq, 35, silent, 2) >= 0); + EXPECT_TRUE(silent[0] == 0.0 && silent[1] == 0.0); // Error paths. - assert(oakengine_preview_get_audio_levels(NULL, 10, levels, 2) == + EXPECT_TRUE(oakengine_preview_get_audio_levels(NULL, 10, levels, 2) == OAKENGINE_E_INVALID); - assert(oakengine_preview_get_audio_levels(seq, -1, levels, 2) == + EXPECT_TRUE(oakengine_preview_get_audio_levels(seq, -1, levels, 2) == OAKENGINE_E_INVALID); - assert(oakengine_preview_get_audio_levels(seq, 10, NULL, 2) == + EXPECT_TRUE(oakengine_preview_get_audio_levels(seq, 10, NULL, 2) == OAKENGINE_E_INVALID); - assert(oakengine_preview_get_audio_levels(seq, 10, levels, 0) == + EXPECT_TRUE(oakengine_preview_get_audio_levels(seq, 10, levels, 0) == OAKENGINE_E_INVALID); } @@ -149,23 +150,23 @@ static void test_waveform(OakEngineFootage *tone, OakEngineFootage *demo, double mins[16], maxs[16]; // The tone in 10 buckets over one second: every bucket swings. - assert(oakengine_preview_get_waveform_summary(tone, 0, 0, 30, mins, + EXPECT_TRUE(oakengine_preview_get_waveform_summary(tone, 0, 0, 30, mins, maxs, 10) == OAKENGINE_OK); for (int i = 0; i < 10; i++) { - assert(mins[i] <= maxs[i]); + EXPECT_TRUE(mins[i] <= maxs[i]); } // Error paths. - assert(oakengine_preview_get_waveform_summary(probed, 0, 0, 30, mins, + EXPECT_TRUE(oakengine_preview_get_waveform_summary(probed, 0, 0, 30, mins, maxs, 10) == OAKENGINE_E_INVALID); - assert(oakengine_preview_get_waveform_summary(tone, 99, 0, 30, mins, + EXPECT_TRUE(oakengine_preview_get_waveform_summary(tone, 99, 0, 30, mins, maxs, 10) == OAKENGINE_E_INVALID); - assert(oakengine_preview_get_waveform_summary(tone, 0, 0, 30, mins, + EXPECT_TRUE(oakengine_preview_get_waveform_summary(tone, 0, 0, 30, mins, maxs, 0) == OAKENGINE_E_INVALID); - assert(oakengine_preview_get_waveform_summary(NULL, 0, 0, 30, mins, maxs, + EXPECT_TRUE(oakengine_preview_get_waveform_summary(NULL, 0, 0, 30, mins, maxs, 10) == OAKENGINE_E_INVALID); } @@ -174,7 +175,7 @@ static void test_waveform(OakEngineFootage *tone, OakEngineFootage *demo, static void test_waveform_max_sample_rate(void) { int rate = oakengine_waveform_max_sample_rate(); - assert(rate > 0); + EXPECT_TRUE(rate > 0); (void) rate; } @@ -184,68 +185,68 @@ static void test_audio_analyze_levels(void) float ch1[] = {0.0f, 0.0f, 0.0f, 0.0f}; const float *data[] = {ch0, ch1}; double levels[2] = {-1.0, -1.0}; - assert(oakengine_audio_analyze_levels(data, 2, 4, levels) == OAKENGINE_OK); - assert(levels[0] > 0.0); - assert(levels[1] == 0.0); - assert(oakengine_audio_analyze_levels(NULL, 2, 4, levels) == OAKENGINE_E_INVALID); - assert(oakengine_audio_analyze_levels(data, 0, 4, levels) == OAKENGINE_E_INVALID); - assert(oakengine_audio_analyze_levels(data, 2, 0, levels) == OAKENGINE_E_INVALID); - assert(oakengine_audio_analyze_levels(data, 2, 4, NULL) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_audio_analyze_levels(data, 2, 4, levels) == OAKENGINE_OK); + EXPECT_TRUE(levels[0] > 0.0); + EXPECT_TRUE(levels[1] == 0.0); + EXPECT_TRUE(oakengine_audio_analyze_levels(NULL, 2, 4, levels) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_audio_analyze_levels(data, 0, 4, levels) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_audio_analyze_levels(data, 2, 0, levels) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_audio_analyze_levels(data, 2, 4, NULL) == OAKENGINE_E_INVALID); } static void test_cacher_null_state(void) { - assert(oakengine_preview_cacher_set_playhead(0, 1) == OAKENGINE_E_STATE); - assert(oakengine_preview_cacher_set_thumbnails_paused(1) == OAKENGINE_E_STATE); - assert(oakengine_preview_cacher_clear_single_frame_renders(0) == OAKENGINE_E_STATE); - assert(oakengine_preview_cacher_force_cache_range(NULL, 0, 1, 1, 1) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_preview_cacher_set_playhead(0, 1) == OAKENGINE_E_STATE); + EXPECT_TRUE(oakengine_preview_cacher_set_thumbnails_paused(1) == OAKENGINE_E_STATE); + EXPECT_TRUE(oakengine_preview_cacher_clear_single_frame_renders(0) == OAKENGINE_E_STATE); + EXPECT_TRUE(oakengine_preview_cacher_force_cache_range(NULL, 0, 1, 1, 1) == OAKENGINE_E_INVALID); } static void test_preview_request_null(void) { - assert(oakengine_preview_request_single_frame(NULL, 0, 1, 0) == NULL); - assert(oakengine_preview_request_audio_range(NULL, 0, 1, 1, 1) == NULL); - assert(oakengine_preview_request_is_done(NULL) == 0); - assert(oakengine_preview_request_has_result(NULL) == 0); - assert(oakengine_preview_request_set_finished_callback(NULL, NULL, NULL) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_preview_request_single_frame(NULL, 0, 1, 0) == NULL); + EXPECT_TRUE(oakengine_preview_request_audio_range(NULL, 0, 1, 1, 1) == NULL); + EXPECT_TRUE(oakengine_preview_request_is_done(NULL) == 0); + EXPECT_TRUE(oakengine_preview_request_has_result(NULL) == 0); + EXPECT_TRUE(oakengine_preview_request_set_finished_callback(NULL, NULL, NULL) == OAKENGINE_E_INVALID); oak_playback_frame frame; memset(&frame, 0, sizeof(frame)); - assert(oakengine_preview_request_get_frame(NULL, &frame) == OAKENGINE_E_INVALID); - assert(oakengine_preview_request_get_audio_channel_count(NULL) == 0); - assert(oakengine_preview_request_get_audio_sample_rate(NULL) == 0); - assert(oakengine_preview_request_get_audio_samples(NULL, 0, NULL, 0) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_preview_request_get_frame(NULL, &frame) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_preview_request_get_audio_channel_count(NULL) == 0); + EXPECT_TRUE(oakengine_preview_request_get_audio_sample_rate(NULL) == 0); + EXPECT_TRUE(oakengine_preview_request_get_audio_samples(NULL, 0, NULL, 0) == OAKENGINE_E_INVALID); oakengine_preview_request_free(NULL); } static void test_render_manager_null(void) { - assert(oakengine_render_manager_set_aggressive_garbage_collection(1) == OAKENGINE_E_STATE); + EXPECT_TRUE(oakengine_render_manager_set_aggressive_garbage_collection(1) == OAKENGINE_E_STATE); oakengine_render_manager_requested_backend(); char buf[64]; int len = oakengine_render_manager_backend_to_string(0, buf, sizeof(buf)); - assert(len >= 0); + EXPECT_TRUE(len >= 0); } static void test_playback_cache_null(void) { - assert(oakengine_viewer_get_playback_cache(NULL) == NULL); - assert(oakengine_playback_cache_indicator_height() > 0); - assert(oakengine_playback_cache_valid_ranges(NULL, NULL, 0) == OAKENGINE_E_INVALID); - assert(oakengine_viewer_get_frame_cache(NULL) == NULL); + EXPECT_TRUE(oakengine_viewer_get_playback_cache(NULL) == NULL); + EXPECT_TRUE(oakengine_playback_cache_indicator_height() > 0); + EXPECT_TRUE(oakengine_playback_cache_valid_ranges(NULL, NULL, 0) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_viewer_get_frame_cache(NULL) == NULL); } -int main(void) +TEST(OakEnginePreview, Main) { make_tmpdir(); // Sandbox the config/cache/data locations (see oakengine_init_test). #if !defined(_WIN32) - assert(setenv("XDG_CONFIG_HOME", g_tmpdir, 1) == 0); - assert(setenv("XDG_CACHE_HOME", g_tmpdir, 1) == 0); - assert(setenv("XDG_DATA_HOME", g_tmpdir, 1) == 0); + EXPECT_TRUE(setenv("XDG_CONFIG_HOME", g_tmpdir, 1) == 0); + EXPECT_TRUE(setenv("XDG_CACHE_HOME", g_tmpdir, 1) == 0); + EXPECT_TRUE(setenv("XDG_DATA_HOME", g_tmpdir, 1) == 0); #endif - assert(oakengine_init(OAKENGINE_INIT_HEADLESS) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_init(OAKENGINE_INIT_HEADLESS) == OAKENGINE_OK); // B9c: pure functions that don't need RenderManager test_waveform_max_sample_rate(); @@ -256,37 +257,37 @@ int main(void) test_playback_cache_null(); OakEngineProject *project = oakengine_project_create(); - assert(project != NULL); - assert(oakengine_project_new(project) == OAKENGINE_OK); + EXPECT_TRUE(project != NULL); + EXPECT_TRUE(oakengine_project_new(project) == OAKENGINE_OK); OakEngineSequence *seq = oakengine_sequence_new(project, "Preview"); - assert(seq != NULL); + EXPECT_TRUE(seq != NULL); char path[4096], tone_path[4096]; demo_path(path, sizeof(path)); make_tone(tone_path, sizeof(tone_path)); OakEngineFootage *tone = oakengine_project_import_footage(project, tone_path); - assert(tone != NULL); + EXPECT_TRUE(tone != NULL); OakEngineFootage *demo = oakengine_project_import_footage(project, path); - assert(demo != NULL); + EXPECT_TRUE(demo != NULL); OakEngineFootage *probed = oakengine_footage_probe(path); - assert(probed != NULL); + EXPECT_TRUE(probed != NULL); // Loop mode works headless already. OakEngineClip *clip = NULL; - assert(oakengine_sequence_add_track(seq, OAKENGINE_TRACK_TYPE_VIDEO) == 0); - assert(oakengine_sequence_add_track(seq, OAKENGINE_TRACK_TYPE_AUDIO) == 0); + EXPECT_TRUE(oakengine_sequence_add_track(seq, OAKENGINE_TRACK_TYPE_VIDEO) == 0); + EXPECT_TRUE(oakengine_sequence_add_track(seq, OAKENGINE_TRACK_TYPE_AUDIO) == 0); clip = oakengine_sequence_add_footage_clip( seq, demo, OAKENGINE_TRACK_TYPE_VIDEO, 0, 0, 30, 0); - assert(clip != NULL); + EXPECT_TRUE(clip != NULL); OakEngineClip *aclip = oakengine_sequence_add_footage_clip( seq, tone, OAKENGINE_TRACK_TYPE_AUDIO, 0, 0, 30, 0); - assert(aclip != NULL); + EXPECT_TRUE(aclip != NULL); test_loop_mode(project, clip); // Upgrade to RENDER for the audio readouts (audio needs no GL). - assert(oakengine_init(OAKENGINE_INIT_HEADLESS | OAKENGINE_INIT_RENDER) == + EXPECT_TRUE(oakengine_init(OAKENGINE_INIT_HEADLESS | OAKENGINE_INIT_RENDER) == OAKENGINE_OK); test_levels(seq); test_waveform(tone, demo, probed); @@ -295,8 +296,6 @@ int main(void) oakengine_footage_free(demo); oakengine_footage_free(tone); oakengine_project_free(project); - assert(oakengine_shutdown() == OAKENGINE_OK); + EXPECT_TRUE(oakengine_shutdown() == OAKENGINE_OK); - printf("oakengine_preview_test: all assertions passed\n"); - return 0; } diff --git a/engine/tests/oakengine_proxy_test.cpp b/engine/tests/oakengine_proxy_test.cpp index f48754651..cb3fb4b46 100644 --- a/engine/tests/oakengine_proxy_test.cpp +++ b/engine/tests/oakengine_proxy_test.cpp @@ -22,6 +22,7 @@ // Runs headless; no GPU required. #include +#include #include #include @@ -30,10 +31,10 @@ static void test_instance_lifecycle(void) { - assert(oakengine_proxy_create_instance() == OAKENGINE_OK); - assert(oakengine_proxy_destroy_instance() == OAKENGINE_OK); + EXPECT_TRUE(oakengine_proxy_create_instance() == OAKENGINE_OK); + EXPECT_TRUE(oakengine_proxy_destroy_instance() == OAKENGINE_OK); // Destroying again is a no-op. - assert(oakengine_proxy_destroy_instance() == OAKENGINE_OK); + EXPECT_TRUE(oakengine_proxy_destroy_instance() == OAKENGINE_OK); } static void test_params_from_config(void) @@ -41,53 +42,53 @@ static void test_params_from_config(void) oak_proxy_params params; memset(¶ms, 0xFF, sizeof(params)); - assert(oakengine_proxy_create_instance() == OAKENGINE_OK); - assert(oakengine_proxy_params_from_config(¶ms) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_proxy_create_instance() == OAKENGINE_OK); + EXPECT_TRUE(oakengine_proxy_params_from_config(¶ms) == OAKENGINE_OK); // Sanity defaults from ProxyManager::proxy_params_from_config(). - assert(params.width > 0); - assert(params.height > 0); - assert(params.divider >= 1); - assert(params.version >= 1); - assert(params.crf >= 0); - assert(params.include_audio == 0 || params.include_audio == 1); - assert(strlen(params.extension) > 0); - assert(strlen(params.preset) > 0); + EXPECT_TRUE(params.width > 0); + EXPECT_TRUE(params.height > 0); + EXPECT_TRUE(params.divider >= 1); + EXPECT_TRUE(params.version >= 1); + EXPECT_TRUE(params.crf >= 0); + EXPECT_TRUE(params.include_audio == 0 || params.include_audio == 1); + EXPECT_TRUE(strlen(params.extension) > 0); + EXPECT_TRUE(strlen(params.preset) > 0); - assert(oakengine_proxy_params_from_config(NULL) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_proxy_params_from_config(NULL) == OAKENGINE_E_INVALID); - assert(oakengine_proxy_destroy_instance() == OAKENGINE_OK); + EXPECT_TRUE(oakengine_proxy_destroy_instance() == OAKENGINE_OK); } static void test_state_string_round_trip(void) { char buf[64]; - assert(oakengine_proxy_state_to_string(OAKENGINE_PROXY_STATE_MISSING, buf, + EXPECT_TRUE(oakengine_proxy_state_to_string(OAKENGINE_PROXY_STATE_MISSING, buf, sizeof(buf)) > 0); - assert(strlen(buf) > 0); + EXPECT_TRUE(strlen(buf) > 0); - assert(oakengine_proxy_state_to_string(OAKENGINE_PROXY_STATE_GENERATING, + EXPECT_TRUE(oakengine_proxy_state_to_string(OAKENGINE_PROXY_STATE_GENERATING, buf, sizeof(buf)) > 0); - assert(strlen(buf) > 0); + EXPECT_TRUE(strlen(buf) > 0); - assert(oakengine_proxy_state_to_string(OAKENGINE_PROXY_STATE_READY, buf, + EXPECT_TRUE(oakengine_proxy_state_to_string(OAKENGINE_PROXY_STATE_READY, buf, sizeof(buf)) > 0); - assert(strlen(buf) > 0); + EXPECT_TRUE(strlen(buf) > 0); - assert(oakengine_proxy_state_to_string(OAKENGINE_PROXY_STATE_FAILED, buf, + EXPECT_TRUE(oakengine_proxy_state_to_string(OAKENGINE_PROXY_STATE_FAILED, buf, sizeof(buf)) > 0); - assert(strlen(buf) > 0); + EXPECT_TRUE(strlen(buf) > 0); // Unknown state returns an error. - assert(oakengine_proxy_state_to_string(999, buf, sizeof(buf)) < 0); + EXPECT_TRUE(oakengine_proxy_state_to_string(999, buf, sizeof(buf)) < 0); } static void test_state_query(void) { - assert(oakengine_proxy_get_state(NULL) == OAKENGINE_PROXY_STATE_MISSING); - assert(oakengine_proxy_get_state("") == OAKENGINE_PROXY_STATE_MISSING); - assert(oakengine_proxy_get_state("/nonexistent/path/proxy.mp4") == + EXPECT_TRUE(oakengine_proxy_get_state(NULL) == OAKENGINE_PROXY_STATE_MISSING); + EXPECT_TRUE(oakengine_proxy_get_state("") == OAKENGINE_PROXY_STATE_MISSING); + EXPECT_TRUE(oakengine_proxy_get_state("/nonexistent/path/proxy.mp4") == OAKENGINE_PROXY_STATE_MISSING); } @@ -97,7 +98,7 @@ static void test_get_or_start_null(void) memset(&result, 0xFF, sizeof(result)); // NULL cache_path should not crash; returns an error. - assert(oakengine_proxy_get_or_start(NULL, NULL, 0, NULL, &result) != + EXPECT_TRUE(oakengine_proxy_get_or_start(NULL, NULL, 0, NULL, &result) != OAKENGINE_OK); } @@ -107,16 +108,16 @@ static void test_get_working_filename(void) int len = oakengine_proxy_get_working_filename("/tmp/test.proxy", buf, sizeof(buf)); // Should return a filename derived from input, even if file doesn't exist. - assert(len > 0); - assert(strlen(buf) > 0); + EXPECT_TRUE(len > 0); + EXPECT_TRUE(strlen(buf) > 0); // NULL safety. - assert(oakengine_proxy_get_working_filename(NULL, buf, sizeof(buf)) < 0); + EXPECT_TRUE(oakengine_proxy_get_working_filename(NULL, buf, sizeof(buf)) < 0); } -int main(void) +TEST(OakEngineProxy, Main) { - assert(oakengine_init(OAKENGINE_INIT_HEADLESS) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_init(OAKENGINE_INIT_HEADLESS) == OAKENGINE_OK); test_instance_lifecycle(); test_params_from_config(); @@ -125,6 +126,5 @@ int main(void) test_get_or_start_null(); test_get_working_filename(); - assert(oakengine_shutdown() == OAKENGINE_OK); - return 0; + EXPECT_TRUE(oakengine_shutdown() == OAKENGINE_OK); } diff --git a/engine/tests/oakengine_renderer_test.cpp b/engine/tests/oakengine_renderer_test.cpp index 7fab6760f..fe7e1449d 100644 --- a/engine/tests/oakengine_renderer_test.cpp +++ b/engine/tests/oakengine_renderer_test.cpp @@ -32,6 +32,7 @@ // footage tests/demo.mp4 feeds its samples input. #include +#include #include #include #include @@ -81,13 +82,13 @@ static void make_tmpdir(void) #if defined(_WIN32) char base[MAX_PATH]; const DWORD len = GetTempPathA(MAX_PATH, base); - assert(len > 0 && len < MAX_PATH); + EXPECT_TRUE(len > 0 && len < MAX_PATH); snprintf(g_tmpdir, sizeof(g_tmpdir), "%soakengine_renderer_test_%lu", base, (unsigned long)GetCurrentProcessId()); - assert(_mkdir(g_tmpdir) == 0); + EXPECT_TRUE(_mkdir(g_tmpdir) == 0); #else strcpy(g_tmpdir, "/tmp/oakengine_renderer_test_XXXXXX"); - assert(mkdtemp(g_tmpdir) != NULL); + EXPECT_TRUE(mkdtemp(g_tmpdir) != NULL); #endif } @@ -158,40 +159,40 @@ static int frame_nonzero_bytes(const OakEngineFrame *frame) static void test_validation(OakEngineSequence *seq) { // create() argument validation. - assert(oakengine_renderer_create(NULL, 320, 180, 4, 30000, 1001, NULL) == + EXPECT_TRUE(oakengine_renderer_create(NULL, 320, 180, 4, 30000, 1001, NULL) == NULL); - assert(oakengine_renderer_create(seq, 0, 180, 4, 30000, 1001, NULL) == + EXPECT_TRUE(oakengine_renderer_create(seq, 0, 180, 4, 30000, 1001, NULL) == NULL); - assert(oakengine_renderer_create(seq, 320, -1, 4, 30000, 1001, NULL) == + EXPECT_TRUE(oakengine_renderer_create(seq, 320, -1, 4, 30000, 1001, NULL) == NULL); - assert(oakengine_renderer_create(seq, 320, 180, 4, 0, 1001, NULL) == + EXPECT_TRUE(oakengine_renderer_create(seq, 320, 180, 4, 0, 1001, NULL) == NULL); - assert(oakengine_renderer_create(seq, 320, 180, 4, 30000, -1001, NULL) == + EXPECT_TRUE(oakengine_renderer_create(seq, 320, 180, 4, 30000, -1001, NULL) == NULL); - assert(oakengine_renderer_create(seq, 320, 180, -1, 30000, 1001, NULL) == + EXPECT_TRUE(oakengine_renderer_create(seq, 320, 180, -1, 30000, 1001, NULL) == NULL); - assert(oakengine_renderer_create(seq, 320, 180, 5, 30000, 1001, NULL) == + EXPECT_TRUE(oakengine_renderer_create(seq, 320, 180, 5, 30000, 1001, NULL) == NULL); OakEngineRenderer *r = oakengine_renderer_create(seq, 320, 180, 4, 30000, 1001, NULL); - assert(r != NULL); + EXPECT_TRUE(r != NULL); // Mode follows olive::RenderMode: 0/1 accepted, everything else rejected. - assert(oakengine_renderer_set_mode(r, 0) == OAKENGINE_OK); - assert(oakengine_renderer_set_mode(r, 1) == OAKENGINE_OK); - assert(oakengine_renderer_set_mode(r, -1) == OAKENGINE_E_INVALID); - assert(oakengine_renderer_set_mode(r, 2) == OAKENGINE_E_INVALID); - assert(oakengine_renderer_set_mode(NULL, 0) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_renderer_set_mode(r, 0) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_renderer_set_mode(r, 1) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_renderer_set_mode(r, -1) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_renderer_set_mode(r, 2) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_renderer_set_mode(NULL, 0) == OAKENGINE_E_INVALID); // Renders fail while the engine lacks the RENDER bit, with a // human-readable reason. - assert(oakengine_renderer_render_frame(r, 0) == NULL); + EXPECT_TRUE(oakengine_renderer_render_frame(r, 0) == NULL); char err[256]; - assert(oakengine_renderer_last_error(r, err, sizeof(err)) > 0); - assert(strstr(err, "OAKENGINE_INIT_RENDER") != NULL); - assert(oakengine_renderer_render_audio(r, 0, 30) == NULL); - assert(oakengine_renderer_last_error(r, err, sizeof(err)) > 0); + EXPECT_TRUE(oakengine_renderer_last_error(r, err, sizeof(err)) > 0); + EXPECT_TRUE(strstr(err, "OAKENGINE_INIT_RENDER") != NULL); + EXPECT_TRUE(oakengine_renderer_render_audio(r, 0, 30) == NULL); + EXPECT_TRUE(oakengine_renderer_last_error(r, err, sizeof(err)) > 0); // cancel is a no-op when nothing is in flight and is idempotent. oakengine_renderer_cancel(r); @@ -200,23 +201,23 @@ static void test_validation(OakEngineSequence *seq) oakengine_renderer_free(r); // NULL safety across all three handle families. - assert(oakengine_renderer_last_error(NULL, err, sizeof(err)) == + EXPECT_TRUE(oakengine_renderer_last_error(NULL, err, sizeof(err)) == OAKENGINE_E_INVALID); - assert(oakengine_renderer_render_frame(NULL, 0) == NULL); - assert(oakengine_renderer_render_audio(NULL, 0, 30) == NULL); + EXPECT_TRUE(oakengine_renderer_render_frame(NULL, 0) == NULL); + EXPECT_TRUE(oakengine_renderer_render_audio(NULL, 0, 30) == NULL); oakengine_renderer_cancel(NULL); oakengine_renderer_free(NULL); - assert(oakengine_frame_width(NULL) == 0); - assert(oakengine_frame_height(NULL) == 0); - assert(oakengine_frame_format(NULL) == -1); - assert(oakengine_frame_channel_count(NULL) == 0); - assert(oakengine_frame_linesize_bytes(NULL) == 0); - assert(oakengine_frame_data(NULL) == NULL); + EXPECT_TRUE(oakengine_frame_width(NULL) == 0); + EXPECT_TRUE(oakengine_frame_height(NULL) == 0); + EXPECT_TRUE(oakengine_frame_format(NULL) == -1); + EXPECT_TRUE(oakengine_frame_channel_count(NULL) == 0); + EXPECT_TRUE(oakengine_frame_linesize_bytes(NULL) == 0); + EXPECT_TRUE(oakengine_frame_data(NULL) == NULL); oakengine_frame_free(NULL); - assert(oakengine_audio_sample_rate(NULL) == 0); - assert(oakengine_audio_channel_count(NULL) == 0); - assert(oakengine_audio_sample_count(NULL) == 0); - assert(oakengine_audio_data(NULL, 0) == NULL); + EXPECT_TRUE(oakengine_audio_sample_rate(NULL) == 0); + EXPECT_TRUE(oakengine_audio_channel_count(NULL) == 0); + EXPECT_TRUE(oakengine_audio_sample_count(NULL) == 0); + EXPECT_TRUE(oakengine_audio_data(NULL, 0) == NULL); oakengine_audio_free(NULL); } @@ -224,32 +225,32 @@ static void test_render_cache_helpers(void) { // Without an active RenderManager, these return OAKENGINE_E_STATE rather // than crashing. - assert(oakengine_render_cache_set_display_color_processor(NULL) == + EXPECT_TRUE(oakengine_render_cache_set_display_color_processor(NULL) == OAKENGINE_E_STATE); - assert(oakengine_render_cache_set_multicam_node(NULL) == + EXPECT_TRUE(oakengine_render_cache_set_multicam_node(NULL) == OAKENGINE_E_STATE); } -int main(void) +TEST(OakEngineRenderer, Main) { make_tmpdir(); // Sandbox the config/cache/data locations (see oakengine_init_test). #if !defined(_WIN32) - assert(setenv("XDG_CONFIG_HOME", g_tmpdir, 1) == 0); - assert(setenv("XDG_CACHE_HOME", g_tmpdir, 1) == 0); - assert(setenv("XDG_DATA_HOME", g_tmpdir, 1) == 0); + EXPECT_TRUE(setenv("XDG_CONFIG_HOME", g_tmpdir, 1) == 0); + EXPECT_TRUE(setenv("XDG_CACHE_HOME", g_tmpdir, 1) == 0); + EXPECT_TRUE(setenv("XDG_DATA_HOME", g_tmpdir, 1) == 0); #endif // HEADLESS is enough for the validation part and creates the offscreen // application object the backend probe below depends on. - assert(oakengine_init(OAKENGINE_INIT_HEADLESS) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_init(OAKENGINE_INIT_HEADLESS) == OAKENGINE_OK); OakEngineProject *project = oakengine_project_create(); - assert(project != NULL); - assert(oakengine_project_new(project) == OAKENGINE_OK); + EXPECT_TRUE(project != NULL); + EXPECT_TRUE(oakengine_project_new(project) == OAKENGINE_OK); OakEngineSequence *seq = oakengine_sequence_new(project, "Render"); - assert(seq != NULL); + EXPECT_TRUE(seq != NULL); test_render_cache_helpers(); test_validation(seq); @@ -260,14 +261,14 @@ int main(void) "available, render assertions skipped\n"); oakengine_project_free(project); oakengine_shutdown(); - return 0; + return; } if (!worker_binary_exists()) { printf("oakengine_renderer_test: SKIP: oak-render-worker binary not " "found, render assertions skipped\n"); oakengine_project_free(project); oakengine_shutdown(); - return 0; + return; } // The engine renders through the backend requested in the config. @@ -275,9 +276,9 @@ int main(void) QStringLiteral("opengl"); // Upgrade HEADLESS -> HEADLESS|RENDER (idempotent flag add). - assert(oakengine_init(OAKENGINE_INIT_HEADLESS | OAKENGINE_INIT_RENDER) == + EXPECT_TRUE(oakengine_init(OAKENGINE_INIT_HEADLESS | OAKENGINE_INIT_RENDER) == OAKENGINE_OK); - assert(oakengine_init_flags() == + EXPECT_TRUE(oakengine_init_flags() == (OAKENGINE_INIT_HEADLESS | OAKENGINE_INIT_RENDER)); // Build content through the engine C++ API (engine-internal test; the @@ -296,10 +297,10 @@ int main(void) const QString demo_path = QDir(QStringLiteral(OAK_TEST_SOURCE_DIR)) .filePath(QStringLiteral("tests/demo.mp4")); - assert(QFileInfo::exists(demo_path)); + EXPECT_TRUE(QFileInfo::exists(demo_path)); auto *footage = new olive::Footage(demo_path); footage->setParent(proj); - assert(footage->is_valid()); + EXPECT_TRUE(footage->is_valid()); olive::Node::connect_edge( footage, olive::NodeInput(sequence, olive::ViewerOutput::k_samples_input)); @@ -307,7 +308,7 @@ int main(void) // render_frame: geometry/format and non-black pixels. OakEngineRenderer *renderer = oakengine_renderer_create(seq, 320, 180, 4, 30000, 1001, NULL); - assert(renderer != NULL); + EXPECT_TRUE(renderer != NULL); OakEngineFrame *frame = oakengine_renderer_render_frame(renderer, 0); char err[256]; if (!frame) { @@ -316,14 +317,14 @@ int main(void) err : "(no error)"); } - assert(frame != NULL); - assert(oakengine_frame_width(frame) == 320); - assert(oakengine_frame_height(frame) == 180); - assert(oakengine_frame_format(frame) == 4); // f32 - assert(oakengine_frame_channel_count(frame) == 4); - assert(oakengine_frame_linesize_bytes(frame) >= 320 * 4 * 4); - assert(oakengine_frame_data(frame) != NULL); - assert(frame_nonzero_bytes(frame) > 0); // solid red, not black + EXPECT_TRUE(frame != NULL); + EXPECT_TRUE(oakengine_frame_width(frame) == 320); + EXPECT_TRUE(oakengine_frame_height(frame) == 180); + EXPECT_TRUE(oakengine_frame_format(frame) == 4); // f32 + EXPECT_TRUE(oakengine_frame_channel_count(frame) == 4); + EXPECT_TRUE(oakengine_frame_linesize_bytes(frame) >= 320 * 4 * 4); + EXPECT_TRUE(oakengine_frame_data(frame) != NULL); + EXPECT_TRUE(frame_nonzero_bytes(frame) > 0); // solid red, not black oakengine_frame_free(frame); // render_audio: 30 frames at 1001/30000 = 1.001s at 48 kHz stereo. @@ -335,14 +336,14 @@ int main(void) err : "(no error)"); } - assert(audio != NULL); - assert(oakengine_audio_sample_rate(audio) == 48000); - assert(oakengine_audio_channel_count(audio) == 2); + EXPECT_TRUE(audio != NULL); + EXPECT_TRUE(oakengine_audio_sample_rate(audio) == 48000); + EXPECT_TRUE(oakengine_audio_channel_count(audio) == 2); const int64_t samples = oakengine_audio_sample_count(audio); - assert(samples > 48048 - 4800 && samples < 48048 + 4800); - assert(oakengine_audio_data(audio, 0) != NULL); - assert(oakengine_audio_data(audio, 1) != NULL); - assert(oakengine_audio_data(audio, 2) == NULL); // out of range + EXPECT_TRUE(samples > 48048 - 4800 && samples < 48048 + 4800); + EXPECT_TRUE(oakengine_audio_data(audio, 0) != NULL); + EXPECT_TRUE(oakengine_audio_data(audio, 1) != NULL); + EXPECT_TRUE(oakengine_audio_data(audio, 2) == NULL); // out of range oakengine_audio_free(audio); // Cancelling mid-render from another thread must not crash, and the @@ -355,14 +356,12 @@ int main(void) canceller.join(); oakengine_frame_free(maybe); // may be NULL (cancelled) or a frame OakEngineFrame *after = oakengine_renderer_render_frame(renderer, 0); - assert(after != NULL); + EXPECT_TRUE(after != NULL); oakengine_frame_free(after); oakengine_renderer_cancel(renderer); // idempotent no-op oakengine_renderer_free(renderer); oakengine_project_free(project); - assert(oakengine_shutdown() == OAKENGINE_OK); + EXPECT_TRUE(oakengine_shutdown() == OAKENGINE_OK); - printf("oakengine_renderer_test: all assertions passed\n"); - return 0; } diff --git a/engine/tests/oakengine_serializer_test.cpp b/engine/tests/oakengine_serializer_test.cpp index 4c4d286ca..2abf0978d 100644 --- a/engine/tests/oakengine_serializer_test.cpp +++ b/engine/tests/oakengine_serializer_test.cpp @@ -22,6 +22,7 @@ // (oakengine/serializer.h). Runs headless; no GPU required. #include +#include #include #include @@ -33,20 +34,20 @@ static void test_check_compressed_nonexistent(void) { - assert(oakengine_serializer_check_compressed( + EXPECT_TRUE(oakengine_serializer_check_compressed( "/nonexistent/path/project.ove") == 0); - assert(oakengine_serializer_check_compressed(NULL) == 0); - assert(oakengine_serializer_check_compressed("") == 0); + EXPECT_TRUE(oakengine_serializer_check_compressed(NULL) == 0); + EXPECT_TRUE(oakengine_serializer_check_compressed("") == 0); } static void test_clipboard_create_free(void) { OakEngineProject *project = oakengine_project_create(); - assert(project != NULL); + EXPECT_TRUE(project != NULL); OakEngineClipboard *cb = oakengine_clipboard_create(OAKENGINE_CLIPBOARD_NODES, project, NULL); - assert(cb != NULL); + EXPECT_TRUE(cb != NULL); oakengine_clipboard_free(cb); oakengine_project_free(project); @@ -55,14 +56,14 @@ static void test_clipboard_create_free(void) static void test_copy_empty_nodes(void) { OakEngineProject *project = oakengine_project_create(); - assert(project != NULL); + EXPECT_TRUE(project != NULL); OakEngineClipboard *cb = oakengine_clipboard_create(OAKENGINE_CLIPBOARD_NODES, project, NULL); - assert(cb != NULL); + EXPECT_TRUE(cb != NULL); // Copying zero nodes should not crash and should report success. - assert(oakengine_clipboard_copy(cb) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_clipboard_copy(cb) == OAKENGINE_OK); oakengine_clipboard_free(cb); oakengine_project_free(project); @@ -71,21 +72,21 @@ static void test_copy_empty_nodes(void) static void test_set_empty_sets(void) { OakEngineProject *project = oakengine_project_create(); - assert(project != NULL); + EXPECT_TRUE(project != NULL); OakEngineClipboard *cb = oakengine_clipboard_create(OAKENGINE_CLIPBOARD_NODES, project, NULL); - assert(cb != NULL); + EXPECT_TRUE(cb != NULL); // Setting empty arrays (count=0, array=NULL) should be OK. - assert(oakengine_clipboard_set_nodes(cb, NULL, 0) == OAKENGINE_OK); - assert(oakengine_clipboard_set_markers(cb, NULL, 0) == OAKENGINE_OK); - assert(oakengine_clipboard_set_keyframes(cb, NULL, 0) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_clipboard_set_nodes(cb, NULL, 0) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_clipboard_set_markers(cb, NULL, 0) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_clipboard_set_keyframes(cb, NULL, 0) == OAKENGINE_OK); // The clipboard with no content should still produce some XML. char buf[256]; int len = oakengine_clipboard_save_to_xml(cb, buf, sizeof(buf)); - assert(len > 0); + EXPECT_TRUE(len > 0); oakengine_clipboard_free(cb); oakengine_project_free(project); @@ -94,36 +95,36 @@ static void test_set_empty_sets(void) static void test_set_node_then_save_xml(void) { OakEngineProject *project = oakengine_project_create(); - assert(project != NULL); - assert(oakengine_project_new(project) == OAKENGINE_OK); + EXPECT_TRUE(project != NULL); + EXPECT_TRUE(oakengine_project_new(project) == OAKENGINE_OK); OakEngineNode *solid = oakengine_project_add_node( project, "org.olivevideoeditor.Olive.solidgenerator"); - assert(solid != NULL); + EXPECT_TRUE(solid != NULL); OakEngineClipboard *cb = oakengine_clipboard_create(OAKENGINE_CLIPBOARD_NODES, project, NULL); - assert(cb != NULL); + EXPECT_TRUE(cb != NULL); // Set one node on the clipboard. - assert(oakengine_clipboard_set_nodes(cb, (const OakEngineNode *const *)&solid, 1) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_clipboard_set_nodes(cb, (const OakEngineNode *const *)&solid, 1) == OAKENGINE_OK); // Set a property on that node. - assert(oakengine_clipboard_set_property(cb, solid, "pos_x", "100") == + EXPECT_TRUE(oakengine_clipboard_set_property(cb, solid, "pos_x", "100") == OAKENGINE_OK); // save_to_xml should return a non-empty XML document. char buf[4096]; int len = oakengine_clipboard_save_to_xml(cb, buf, sizeof(buf)); - assert(len > 0); - assert(len < (int)sizeof(buf)); + EXPECT_TRUE(len > 0); + EXPECT_TRUE(len < (int)sizeof(buf)); // Should contain the node type id and the property. - assert(strstr(buf, "solidgenerator") != NULL); - assert(strstr(buf, "pos_x") != NULL); + EXPECT_TRUE(strstr(buf, "solidgenerator") != NULL); + EXPECT_TRUE(strstr(buf, "pos_x") != NULL); // Query-length mode. int qlen = oakengine_clipboard_save_to_xml(cb, NULL, 0); - assert(qlen == len); + EXPECT_TRUE(qlen == len); oakengine_clipboard_free(cb); oakengine_project_free(project); @@ -132,36 +133,36 @@ static void test_set_node_then_save_xml(void) static void test_set_node_then_foreach_property(void) { OakEngineProject *project = oakengine_project_create(); - assert(project != NULL); - assert(oakengine_project_new(project) == OAKENGINE_OK); + EXPECT_TRUE(project != NULL); + EXPECT_TRUE(oakengine_project_new(project) == OAKENGINE_OK); OakEngineNode *solid = oakengine_project_add_node( project, "org.olivevideoeditor.Olive.solidgenerator"); - assert(solid != NULL); + EXPECT_TRUE(solid != NULL); // Save_data: set node + property, then copy to system clipboard (save_data // is serialized). The paste result populates load_data, which is what // foreach_property reads. OakEngineClipboard *cb_copy = oakengine_clipboard_create(OAKENGINE_CLIPBOARD_NODES, project, NULL); - assert(cb_copy != NULL); - assert(oakengine_clipboard_set_nodes(cb_copy, (const OakEngineNode *const *)&solid, 1) == OAKENGINE_OK); - assert(oakengine_clipboard_set_property(cb_copy, solid, "pos_x", "100") == + EXPECT_TRUE(cb_copy != NULL); + EXPECT_TRUE(oakengine_clipboard_set_nodes(cb_copy, (const OakEngineNode *const *)&solid, 1) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_clipboard_set_property(cb_copy, solid, "pos_x", "100") == OAKENGINE_OK); - assert(oakengine_clipboard_set_property(cb_copy, solid, "pos_y", "200") == + EXPECT_TRUE(oakengine_clipboard_set_property(cb_copy, solid, "pos_y", "200") == OAKENGINE_OK); - assert(oakengine_clipboard_copy(cb_copy) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_clipboard_copy(cb_copy) == OAKENGINE_OK); oakengine_clipboard_free(cb_copy); OakEngineClipboard *cb_paste = oakengine_clipboard_create(OAKENGINE_CLIPBOARD_NODES, project, NULL); - assert(cb_paste != NULL); + EXPECT_TRUE(cb_paste != NULL); int result_code = -1; - assert(oakengine_clipboard_paste(cb_paste, OAKENGINE_CLIPBOARD_NODES, + EXPECT_TRUE(oakengine_clipboard_paste(cb_paste, OAKENGINE_CLIPBOARD_NODES, project, &result_code, NULL, 0) == OAKENGINE_OK); - assert(result_code == OAKENGINE_SERIALIZER_OK); + EXPECT_TRUE(result_code == OAKENGINE_SERIALIZER_OK); // foreach_property should visit both pasted properties. int prop_seen = 0; @@ -177,8 +178,8 @@ static void test_set_node_then_foreach_property(void) return 0; }, &prop_seen); - assert(ret == OAKENGINE_OK); - assert(prop_seen >= 2); + EXPECT_TRUE(ret == OAKENGINE_OK); + EXPECT_TRUE(prop_seen >= 2); oakengine_clipboard_free(cb_paste); oakengine_project_free(project); @@ -187,39 +188,39 @@ static void test_set_node_then_foreach_property(void) static void test_clipboard_copy_paste_roundtrip(void) { OakEngineProject *project = oakengine_project_create(); - assert(project != NULL); - assert(oakengine_project_new(project) == OAKENGINE_OK); + EXPECT_TRUE(project != NULL); + EXPECT_TRUE(oakengine_project_new(project) == OAKENGINE_OK); OakEngineNode *solid = oakengine_project_add_node( project, "org.olivevideoeditor.Olive.solidgenerator"); - assert(solid != NULL); + EXPECT_TRUE(solid != NULL); // Create clipboard A for copy (type doesn't matter; set_nodes overrides). OakEngineClipboard *cb_copy = oakengine_clipboard_create(OAKENGINE_CLIPBOARD_NODES, project, NULL); - assert(cb_copy != NULL); - assert(oakengine_clipboard_set_nodes(cb_copy, (const OakEngineNode *const *)&solid, 1) == OAKENGINE_OK); - assert(oakengine_clipboard_copy(cb_copy) == OAKENGINE_OK); + EXPECT_TRUE(cb_copy != NULL); + EXPECT_TRUE(oakengine_clipboard_set_nodes(cb_copy, (const OakEngineNode *const *)&solid, 1) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_clipboard_copy(cb_copy) == OAKENGINE_OK); oakengine_clipboard_free(cb_copy); // Create clipboard B for paste. OakEngineClipboard *cb_paste = oakengine_clipboard_create(OAKENGINE_CLIPBOARD_NODES, project, NULL); - assert(cb_paste != NULL); + EXPECT_TRUE(cb_paste != NULL); int result_code = -1; int ret = oakengine_clipboard_paste(cb_paste, OAKENGINE_CLIPBOARD_NODES, project, &result_code, NULL, 0); - assert(ret == OAKENGINE_OK); - assert(result_code == OAKENGINE_SERIALIZER_OK); + EXPECT_TRUE(ret == OAKENGINE_OK); + EXPECT_TRUE(result_code == OAKENGINE_SERIALIZER_OK); // Verify loaded_* accessors. - assert(oakengine_clipboard_get_loaded_node_count(cb_paste) == 1); + EXPECT_TRUE(oakengine_clipboard_get_loaded_node_count(cb_paste) == 1); OakEngineNode *loaded = oakengine_clipboard_get_loaded_node_at(cb_paste, 0); - assert(loaded != NULL); - assert(loaded != solid); // pasted node should be a new copy - assert(oakengine_clipboard_get_loaded_node_at(cb_paste, -1) == NULL); - assert(oakengine_clipboard_get_loaded_node_at(cb_paste, 1) == NULL); + EXPECT_TRUE(loaded != NULL); + EXPECT_TRUE(loaded != solid); // pasted node should be a new copy + EXPECT_TRUE(oakengine_clipboard_get_loaded_node_at(cb_paste, -1) == NULL); + EXPECT_TRUE(oakengine_clipboard_get_loaded_node_at(cb_paste, 1) == NULL); oakengine_clipboard_free(cb_paste); oakengine_project_free(project); @@ -228,23 +229,23 @@ static void test_clipboard_copy_paste_roundtrip(void) static void test_clipboard_paste_with_map(void) { OakEngineProject *project = oakengine_project_create(); - assert(project != NULL); - assert(oakengine_project_new(project) == OAKENGINE_OK); + EXPECT_TRUE(project != NULL); + EXPECT_TRUE(oakengine_project_new(project) == OAKENGINE_OK); OakEngineNode *solid = oakengine_project_add_node( project, "org.olivevideoeditor.Olive.solidgenerator"); - assert(solid != NULL); + EXPECT_TRUE(solid != NULL); OakEngineClipboard *cb_copy = oakengine_clipboard_create(OAKENGINE_CLIPBOARD_NODES, project, NULL); - assert(cb_copy != NULL); - assert(oakengine_clipboard_set_nodes(cb_copy, (const OakEngineNode *const *)&solid, 1) == OAKENGINE_OK); - assert(oakengine_clipboard_copy(cb_copy) == OAKENGINE_OK); + EXPECT_TRUE(cb_copy != NULL); + EXPECT_TRUE(oakengine_clipboard_set_nodes(cb_copy, (const OakEngineNode *const *)&solid, 1) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_clipboard_copy(cb_copy) == OAKENGINE_OK); oakengine_clipboard_free(cb_copy); OakEngineClipboard *cb_paste = oakengine_clipboard_create(OAKENGINE_CLIPBOARD_NODES, project, NULL); - assert(cb_paste != NULL); + EXPECT_TRUE(cb_paste != NULL); int pair_count = 0; int result_code = -1; @@ -255,15 +256,15 @@ static void test_clipboard_paste_with_map(void) { auto *pc = (int *) userdata; (*pc)++; - assert(old_node != NULL); - assert(new_node != NULL); - assert(old_node != new_node); + EXPECT_TRUE(old_node != NULL); + EXPECT_TRUE(new_node != NULL); + EXPECT_TRUE(old_node != new_node); return 0; }, &pair_count, &result_code, NULL, 0); - assert(ret == OAKENGINE_OK); - assert(result_code == OAKENGINE_SERIALIZER_OK); - assert(pair_count == 1); + EXPECT_TRUE(ret == OAKENGINE_OK); + EXPECT_TRUE(result_code == OAKENGINE_SERIALIZER_OK); + EXPECT_TRUE(pair_count == 1); oakengine_clipboard_free(cb_paste); oakengine_project_free(project); @@ -272,40 +273,40 @@ static void test_clipboard_paste_with_map(void) static void test_clipboard_foreach_iterators(void) { OakEngineProject *project = oakengine_project_create(); - assert(project != NULL); - assert(oakengine_project_new(project) == OAKENGINE_OK); + EXPECT_TRUE(project != NULL); + EXPECT_TRUE(oakengine_project_new(project) == OAKENGINE_OK); OakEngineNode *solid = oakengine_project_add_node( project, "org.olivevideoeditor.Olive.solidgenerator"); - assert(solid != NULL); + EXPECT_TRUE(solid != NULL); // Copy with properties so the paste-result has properties, then verify // foreach_property, foreach_keyframe (should be 0) and foreach_connection // (should be 0 since nothing is connected). OakEngineClipboard *cb_copy = oakengine_clipboard_create(OAKENGINE_CLIPBOARD_NODES, project, NULL); - assert(cb_copy != NULL); - assert(oakengine_clipboard_set_nodes(cb_copy, (const OakEngineNode *const *)&solid, 1) == OAKENGINE_OK); - assert(oakengine_clipboard_set_property(cb_copy, solid, "pos_x", "50") == + EXPECT_TRUE(cb_copy != NULL); + EXPECT_TRUE(oakengine_clipboard_set_nodes(cb_copy, (const OakEngineNode *const *)&solid, 1) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_clipboard_set_property(cb_copy, solid, "pos_x", "50") == OAKENGINE_OK); - assert(oakengine_clipboard_set_property(cb_copy, solid, "pos_y", "75") == + EXPECT_TRUE(oakengine_clipboard_set_property(cb_copy, solid, "pos_y", "75") == OAKENGINE_OK); - assert(oakengine_clipboard_copy(cb_copy) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_clipboard_copy(cb_copy) == OAKENGINE_OK); oakengine_clipboard_free(cb_copy); OakEngineClipboard *cb_paste = oakengine_clipboard_create(OAKENGINE_CLIPBOARD_NODES, project, NULL); - assert(cb_paste != NULL); + EXPECT_TRUE(cb_paste != NULL); int result_code = -1; - assert(oakengine_clipboard_paste(cb_paste, OAKENGINE_CLIPBOARD_NODES, + EXPECT_TRUE(oakengine_clipboard_paste(cb_paste, OAKENGINE_CLIPBOARD_NODES, project, &result_code, NULL, 0) == OAKENGINE_OK); - assert(result_code == OAKENGINE_SERIALIZER_OK); + EXPECT_TRUE(result_code == OAKENGINE_SERIALIZER_OK); // foreach_property should visit the pasted properties. int prop_count = 0; - assert(oakengine_clipboard_foreach_property( + EXPECT_TRUE(oakengine_clipboard_foreach_property( cb_paste, [](OakEngineNode *node, const char *key, const char *value, void *userdata) -> int @@ -317,11 +318,11 @@ static void test_clipboard_foreach_iterators(void) return 0; }, &prop_count) == OAKENGINE_OK); - assert(prop_count >= 2); + EXPECT_TRUE(prop_count >= 2); // foreach_keyframe should visit 0 (solid has no keyframe data in this test). int kf_count = 0; - assert(oakengine_clipboard_foreach_keyframe( + EXPECT_TRUE(oakengine_clipboard_foreach_keyframe( cb_paste, [](const char *node_id, OakEngineKeyframe *keyframe, void *userdata) -> int @@ -335,7 +336,7 @@ static void test_clipboard_foreach_iterators(void) // foreach_connection should visit 0 (no connections copied). int conn_count = 0; - assert(oakengine_clipboard_foreach_connection( + EXPECT_TRUE(oakengine_clipboard_foreach_connection( cb_paste, [](OakEngineNode *output_node, OakEngineNode *input_node, const char *input_id, int element, void *userdata) -> int @@ -348,7 +349,7 @@ static void test_clipboard_foreach_iterators(void) return 0; }, &conn_count) == OAKENGINE_OK); - assert(conn_count == 0); + EXPECT_TRUE(conn_count == 0); oakengine_clipboard_free(cb_paste); oakengine_project_free(project); @@ -357,66 +358,66 @@ static void test_clipboard_foreach_iterators(void) static void test_clipboard_marker_keyframe_accessors(void) { OakEngineProject *project = oakengine_project_create(); - assert(project != NULL); - assert(oakengine_project_new(project) == OAKENGINE_OK); + EXPECT_TRUE(project != NULL); + EXPECT_TRUE(oakengine_project_new(project) == OAKENGINE_OK); // Create a sequence for its marker list. OakEngineSequence *seq = oakengine_sequence_new(project, "MarkerSrc"); - assert(seq != NULL); + EXPECT_TRUE(seq != NULL); // Add a marker to the sequence's marker list. OakEngineMarkerList *list = oakengine_viewer_get_marker_list((OakEngineNode *)seq); - assert(list != NULL); - assert(oakengine_marker_list_add(list, 1, 1, 2, 1, "Test", 0) == + EXPECT_TRUE(list != NULL); + EXPECT_TRUE(oakengine_marker_list_add(list, 1, 1, 2, 1, "Test", 0) == OAKENGINE_OK); OakEngineMarker *marker = oakengine_marker_list_at(list, 0); - assert(marker != NULL); + EXPECT_TRUE(marker != NULL); // Copy markers to clipboard and save_to_xml (tests set_markers + save). OakEngineClipboard *cb_copy = oakengine_clipboard_create(OAKENGINE_CLIPBOARD_MARKERS, project, NULL); - assert(cb_copy != NULL); - assert(oakengine_clipboard_set_markers( + EXPECT_TRUE(cb_copy != NULL); + EXPECT_TRUE(oakengine_clipboard_set_markers( cb_copy, (const OakEngineMarker *const *)&marker, 1) == OAKENGINE_OK); - assert(oakengine_clipboard_copy(cb_copy) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_clipboard_copy(cb_copy) == OAKENGINE_OK); oakengine_clipboard_free(cb_copy); // Paste back and verify get_loaded_marker accessors. OakEngineClipboard *cb_paste = oakengine_clipboard_create(OAKENGINE_CLIPBOARD_MARKERS, project, NULL); - assert(cb_paste != NULL); + EXPECT_TRUE(cb_paste != NULL); int result_code = -1; - assert(oakengine_clipboard_paste(cb_paste, OAKENGINE_CLIPBOARD_MARKERS, + EXPECT_TRUE(oakengine_clipboard_paste(cb_paste, OAKENGINE_CLIPBOARD_MARKERS, project, &result_code, NULL, 0) == OAKENGINE_OK); - assert(result_code == OAKENGINE_SERIALIZER_OK || + EXPECT_TRUE(result_code == OAKENGINE_SERIALIZER_OK || result_code == OAKENGINE_SERIALIZER_NO_DATA); // If paste succeeded, verify the accessors. if (result_code == OAKENGINE_SERIALIZER_OK) { int mc = oakengine_clipboard_get_loaded_marker_count(cb_paste); - assert(mc >= 0); + EXPECT_TRUE(mc >= 0); OakEngineMarker *pm = oakengine_clipboard_get_loaded_marker_at( cb_paste, 0); if (pm != NULL) { - assert(oakengine_clipboard_get_loaded_marker_at(cb_paste, -1) == + EXPECT_TRUE(oakengine_clipboard_get_loaded_marker_at(cb_paste, -1) == NULL); } } // get_loaded_keyframe accessors with 0 keyframes (no keyframes copied). - assert(oakengine_clipboard_get_loaded_keyframe_count(cb_paste) >= 0); - assert(oakengine_clipboard_get_loaded_keyframe_at(cb_paste, 0) == NULL); + EXPECT_TRUE(oakengine_clipboard_get_loaded_keyframe_count(cb_paste) >= 0); + EXPECT_TRUE(oakengine_clipboard_get_loaded_keyframe_at(cb_paste, 0) == NULL); oakengine_clipboard_free(cb_paste); oakengine_project_free(project); } -int main(void) +TEST(OakEngineSerializer, Main) { - assert(oakengine_init(OAKENGINE_INIT_HEADLESS) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_init(OAKENGINE_INIT_HEADLESS) == OAKENGINE_OK); test_check_compressed_nonexistent(); test_clipboard_create_free(); @@ -429,6 +430,5 @@ int main(void) test_clipboard_foreach_iterators(); test_clipboard_marker_keyframe_accessors(); - assert(oakengine_shutdown() == OAKENGINE_OK); - return 0; + EXPECT_TRUE(oakengine_shutdown() == OAKENGINE_OK); } diff --git a/engine/tests/oakengine_sync_test.cpp b/engine/tests/oakengine_sync_test.cpp index 2e7961d57..c54d0d5fb 100644 --- a/engine/tests/oakengine_sync_test.cpp +++ b/engine/tests/oakengine_sync_test.cpp @@ -25,6 +25,7 @@ // worker binary, SKIP with exit 0 when unavailable). #include +#include #include #include #include @@ -61,13 +62,13 @@ static void make_tmpdir(void) #if defined(_WIN32) char base[MAX_PATH]; const DWORD len = GetTempPathA(MAX_PATH, base); - assert(len > 0 && len < MAX_PATH); + EXPECT_TRUE(len > 0 && len < MAX_PATH); snprintf(g_tmpdir, sizeof(g_tmpdir), "%soakengine_sync_test_%lu", base, (unsigned long)GetCurrentProcessId()); - assert(_mkdir(g_tmpdir) == 0); + EXPECT_TRUE(_mkdir(g_tmpdir) == 0); #else strcpy(g_tmpdir, "/tmp/oakengine_sync_test_XXXXXX"); - assert(mkdtemp(g_tmpdir) != NULL); + EXPECT_TRUE(mkdtemp(g_tmpdir) != NULL); #endif } @@ -121,7 +122,7 @@ static void write_textured_wav(const QString &path, int seconds) const int block = rate / 20; // one gain value per envelope window QFile f(path); - assert(f.open(QFile::WriteOnly)); + EXPECT_TRUE(f.open(QFile::WriteOnly)); auto write_u32 = [&f](uint32_t v) { f.write(reinterpret_cast(&v), 4); }; @@ -181,48 +182,48 @@ static OakEngineClip *make_pair(OakEngineProject *project, const char *media_path, OakEngineClip **target_out) { - assert(oakengine_sequence_add_track(seq, OAKENGINE_TRACK_TYPE_AUDIO) == + EXPECT_TRUE(oakengine_sequence_add_track(seq, OAKENGINE_TRACK_TYPE_AUDIO) == 0); // A second audio track: placing the target on the SAME track would // overwrite (trim) the reference clip. - assert(oakengine_sequence_add_track(seq, OAKENGINE_TRACK_TYPE_AUDIO) == + EXPECT_TRUE(oakengine_sequence_add_track(seq, OAKENGINE_TRACK_TYPE_AUDIO) == 1); OakEngineFootage *footage = oakengine_project_import_footage(project, media_path); - assert(footage != NULL); + EXPECT_TRUE(footage != NULL); OakEngineClip *reference = oakengine_sequence_add_footage_clip( seq, footage, OAKENGINE_TRACK_TYPE_AUDIO, 0, 0, 160, 0); - assert(reference != NULL); + EXPECT_TRUE(reference != NULL); OakEngineClip *target = oakengine_sequence_add_footage_clip( seq, footage, OAKENGINE_TRACK_TYPE_AUDIO, 1, k_offset_frames, 160 + k_offset_frames, k_offset_frames); - assert(target != NULL); + EXPECT_TRUE(target != NULL); oakengine_footage_free(footage); *target_out = target; return reference; } -int main(void) +TEST(OakEngineSync, Main) { make_tmpdir(); // Sandbox the config/cache/data locations (see oakengine_init_test). #if !defined(_WIN32) - assert(setenv("XDG_CONFIG_HOME", g_tmpdir, 1) == 0); - assert(setenv("XDG_CACHE_HOME", g_tmpdir, 1) == 0); - assert(setenv("XDG_DATA_HOME", g_tmpdir, 1) == 0); + EXPECT_TRUE(setenv("XDG_CONFIG_HOME", g_tmpdir, 1) == 0); + EXPECT_TRUE(setenv("XDG_CACHE_HOME", g_tmpdir, 1) == 0); + EXPECT_TRUE(setenv("XDG_DATA_HOME", g_tmpdir, 1) == 0); #endif // HEADLESS is enough for the validation part. - assert(oakengine_init(OAKENGINE_INIT_HEADLESS) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_init(OAKENGINE_INIT_HEADLESS) == OAKENGINE_OK); OakEngineProject *project = oakengine_project_create(); - assert(project != NULL); - assert(oakengine_project_new(project) == OAKENGINE_OK); + EXPECT_TRUE(project != NULL); + EXPECT_TRUE(oakengine_project_new(project) == OAKENGINE_OK); OakEngineSequence *seq = oakengine_sequence_new(project, "Sync"); - assert(seq != NULL); + EXPECT_TRUE(seq != NULL); // 20 fps: one frame == one envelope window (1/20 s) exactly. - assert(oakengine_sequence_set_video_params(seq, -1, -1, 20, 1, -1, -1, + EXPECT_TRUE(oakengine_sequence_set_video_params(seq, -1, -1, 20, 1, -1, -1, -1, -1, 1) == OAKENGINE_OK); const QString noise_path = QDir(QString::fromUtf8(g_tmpdir)) @@ -234,26 +235,26 @@ int main(void) // ---- Validation (no GL) ------------------------------------------- double offset_s = -1, confidence = -1, stretch = -1; - assert(oakengine_sync_estimate_offset(NULL, reference, target, + EXPECT_TRUE(oakengine_sync_estimate_offset(NULL, reference, target, &offset_s, &confidence) == OAKENGINE_E_INVALID); - assert(oakengine_sync_estimate_offset(seq, NULL, target, &offset_s, + EXPECT_TRUE(oakengine_sync_estimate_offset(seq, NULL, target, &offset_s, &confidence) == OAKENGINE_E_INVALID); - assert(oakengine_sync_estimate_offset(seq, reference, NULL, &offset_s, + EXPECT_TRUE(oakengine_sync_estimate_offset(seq, reference, NULL, &offset_s, &confidence) == OAKENGINE_E_INVALID); - assert(oakengine_sync_estimate_stretch_offset(NULL, reference, target, + EXPECT_TRUE(oakengine_sync_estimate_stretch_offset(NULL, reference, target, &stretch, &offset_s, &confidence) == OAKENGINE_E_INVALID); char err[256]; - assert(oakengine_sync_last_error(err, sizeof(err)) > 0); + EXPECT_TRUE(oakengine_sync_last_error(err, sizeof(err)) > 0); // Valid handles but the engine lacks the RENDER bit: OAKENGINE_E_STATE // with a readable reason, nothing else changed. - assert(oakengine_sync_estimate_offset(seq, reference, target, &offset_s, + EXPECT_TRUE(oakengine_sync_estimate_offset(seq, reference, target, &offset_s, &confidence) == OAKENGINE_E_STATE); - assert(oakengine_sync_last_error(err, sizeof(err)) > 0); - assert(strstr(err, "OAKENGINE_INIT_RENDER") != NULL); + EXPECT_TRUE(oakengine_sync_last_error(err, sizeof(err)) > 0); + EXPECT_TRUE(strstr(err, "OAKENGINE_INIT_RENDER") != NULL); // ---- GL-gated estimation ------------------------------------------ if (!is_render_backend_available(QStringLiteral("opengl"))) { @@ -261,19 +262,19 @@ int main(void) "available, estimation assertions skipped\n"); oakengine_project_free(project); oakengine_shutdown(); - return 0; + return; } if (!worker_binary_exists()) { printf("oakengine_sync_test: SKIP: oak-render-worker binary not " "found, estimation assertions skipped\n"); oakengine_project_free(project); oakengine_shutdown(); - return 0; + return; } olive::Config::current()[QStringLiteral("GraphicsBackend")] = QStringLiteral("opengl"); - assert(oakengine_init(OAKENGINE_INIT_HEADLESS | OAKENGINE_INIT_RENDER) == + EXPECT_TRUE(oakengine_init(OAKENGINE_INIT_HEADLESS | OAKENGINE_INIT_RENDER) == OAKENGINE_OK); // The target's content starts k_offset_frames later in the source: @@ -293,22 +294,20 @@ int main(void) fprintf(stderr, "DEBUG est_rc=%d off=%f conf=%f err='%s'\n", est_rc, offset_s, confidence, est_err); } - assert(est_rc == OAKENGINE_OK); - assert(fabs(fabs(offset_s) - expected_s) < tolerance_s); - assert(offset_s < 0.0); // the target is delayed: it must move earlier - assert(confidence > 0.0 && confidence <= 1.0); + EXPECT_TRUE(est_rc == OAKENGINE_OK); + EXPECT_TRUE(fabs(fabs(offset_s) - expected_s) < tolerance_s); + EXPECT_TRUE(offset_s < 0.0); // the target is delayed: it must move earlier + EXPECT_TRUE(confidence > 0.0 && confidence <= 1.0); // Same-speed content: the stretch estimator reports rate ~1 and the // same offset. const int str_rc = oakengine_sync_estimate_stretch_offset( seq, reference, target, &stretch, &offset_s, &confidence); - assert(str_rc == OAKENGINE_OK); - assert(fabs(stretch - 1.0) < 0.01); - assert(fabs(fabs(offset_s) - expected_s) < tolerance_s); + EXPECT_TRUE(str_rc == OAKENGINE_OK); + EXPECT_TRUE(fabs(stretch - 1.0) < 0.01); + EXPECT_TRUE(fabs(fabs(offset_s) - expected_s) < tolerance_s); oakengine_project_free(project); - assert(oakengine_shutdown() == OAKENGINE_OK); + EXPECT_TRUE(oakengine_shutdown() == OAKENGINE_OK); - printf("oakengine_sync_test: all assertions passed\n"); - return 0; } diff --git a/engine/tests/oakengine_task_test.cpp b/engine/tests/oakengine_task_test.cpp index 02f295903..f4f7159e8 100644 --- a/engine/tests/oakengine_task_test.cpp +++ b/engine/tests/oakengine_task_test.cpp @@ -22,6 +22,7 @@ // (oakengine/task.h and oakengine/undo.h). Runs headless; no GPU required. #include +#include #include #include #include @@ -67,66 +68,66 @@ static void task_event_cb(const oakengine_event *event, void *userdata) static void test_manager_no_engine(void) { - assert(oakengine_task_manager_handle() == NULL); - assert(oakengine_task_manager_count() == OAKENGINE_E_INVALID); - assert(oakengine_task_manager_first() == NULL); - assert(oakengine_task_manager_add(NULL) == OAKENGINE_E_INVALID); - assert(oakengine_task_manager_cancel(NULL) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_task_manager_handle() == NULL); + EXPECT_TRUE(oakengine_task_manager_count() == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_task_manager_first() == NULL); + EXPECT_TRUE(oakengine_task_manager_add(NULL) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_task_manager_cancel(NULL) == OAKENGINE_E_INVALID); } static void test_manager_empty(void) { void *mgr = oakengine_task_manager_handle(); - assert(mgr != NULL); - assert(oakengine_task_manager_count() == 0); - assert(oakengine_task_manager_first() == NULL); + EXPECT_TRUE(mgr != NULL); + EXPECT_TRUE(oakengine_task_manager_count() == 0); + EXPECT_TRUE(oakengine_task_manager_first() == NULL); } static void test_task_null(void) { char buf[64]; - assert(oakengine_task_title(NULL, buf, sizeof(buf)) == OAKENGINE_E_INVALID); - assert(oakengine_task_error(NULL, buf, sizeof(buf)) == OAKENGINE_E_INVALID); - assert(oakengine_task_start_time(NULL) == OAKENGINE_E_INVALID); - assert(oakengine_task_is_cancelled(NULL) == OAKENGINE_E_INVALID); - assert(oakengine_task_cancel(NULL) == OAKENGINE_E_INVALID); - assert(oakengine_task_start_sync(NULL) == OAKENGINE_E_INVALID); - assert(oakengine_task_free(NULL) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_task_title(NULL, buf, sizeof(buf)) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_task_error(NULL, buf, sizeof(buf)) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_task_start_time(NULL) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_task_is_cancelled(NULL) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_task_cancel(NULL) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_task_start_sync(NULL) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_task_free(NULL) == OAKENGINE_E_INVALID); } static void test_import_error_path(void) { OakEngineProject *p = oakengine_project_create(); - assert(p != NULL); - assert(oakengine_project_new(p) == OAKENGINE_OK); + EXPECT_TRUE(p != NULL); + EXPECT_TRUE(oakengine_project_new(p) == OAKENGINE_OK); OakEngineNode *root = oakengine_project_root(p); - assert(root != NULL); + EXPECT_TRUE(root != NULL); // Empty URL list is rejected at creation. OakEngineTask *task = oakengine_task_create_project_import(root, NULL, 0); - assert(task == NULL); + EXPECT_TRUE(task == NULL); // Valid creation but with non-existent file gives zero footage/one invalid. const char *url = "file:///this/file/does/not/exist.mov"; task = oakengine_task_create_project_import(root, &url, 1); - assert(task != NULL); + EXPECT_TRUE(task != NULL); - assert(oakengine_task_import_file_count(task) == 1); + EXPECT_TRUE(oakengine_task_import_file_count(task) == 1); int result = oakengine_task_start_sync(task); (void) result; - assert(oakengine_task_import_footage_count(task) == 0); - assert(oakengine_task_import_invalid_files_count(task) == 1); + EXPECT_TRUE(oakengine_task_import_footage_count(task) == 0); + EXPECT_TRUE(oakengine_task_import_invalid_files_count(task) == 1); char buf[256]; int len = oakengine_task_import_invalid_file_at(task, 0, buf, sizeof(buf)); - assert(len > 0); - assert(strstr(buf, "exist.mov") != NULL); - assert(oakengine_task_import_invalid_file_at(task, 0, NULL, 0) == len); - assert(oakengine_task_import_invalid_file_at(task, 1, buf, sizeof(buf)) == + EXPECT_TRUE(len > 0); + EXPECT_TRUE(strstr(buf, "exist.mov") != NULL); + EXPECT_TRUE(oakengine_task_import_invalid_file_at(task, 0, NULL, 0) == len); + EXPECT_TRUE(oakengine_task_import_invalid_file_at(task, 1, buf, sizeof(buf)) == OAKENGINE_E_INVALID); - assert(oakengine_task_free(task) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_task_free(task) == OAKENGINE_OK); oakengine_project_free(p); } @@ -134,31 +135,31 @@ static void test_load_task_sync(void) { OakEngineTask *task = oakengine_task_create_project_load("/no/such/project.ove"); - assert(task != NULL); + EXPECT_TRUE(task != NULL); // No event subscription here; just confirm it reports failure cleanly. int ok = oakengine_task_start_sync(task); - assert(ok == 0); + EXPECT_TRUE(ok == 0); char err[256]; int len = oakengine_task_error(task, err, sizeof(err)); - assert(len > 0); + EXPECT_TRUE(len > 0); - assert(oakengine_task_free(task) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_task_free(task) == OAKENGINE_OK); } static void test_task_events(void) { OakEngineProject *p = oakengine_project_create(); - assert(p != NULL); - assert(oakengine_project_new(p) == OAKENGINE_OK); + EXPECT_TRUE(p != NULL); + EXPECT_TRUE(oakengine_project_new(p) == OAKENGINE_OK); OakEngineNode *root = oakengine_project_root(p); - assert(root != NULL); + EXPECT_TRUE(root != NULL); const char *url = "file:///this/file/does/not/exist.mov"; OakEngineTask *task = oakengine_task_create_project_import(root, &url, 1); - assert(task != NULL); + EXPECT_TRUE(task != NULL); void *mgr = oakengine_task_manager_handle(); int64_t sub_started = oakengine_event_subscribe( @@ -172,16 +173,16 @@ static void test_task_events(void) int64_t sub_removed = oakengine_event_subscribe( mgr, OAKENGINE_EVENT_TASK_MANAGER_TASK_REMOVED, task_event_cb, NULL); - assert(sub_started > 0); - assert(sub_progress > 0); - assert(sub_finished > 0); - assert(sub_added > 0); - assert(sub_removed > 0); + EXPECT_TRUE(sub_started > 0); + EXPECT_TRUE(sub_progress > 0); + EXPECT_TRUE(sub_finished > 0); + EXPECT_TRUE(sub_added > 0); + EXPECT_TRUE(sub_removed > 0); g_task_started = g_task_progress = g_task_finished = 0; g_task_succeeded = g_manager_added = g_manager_removed = 0; - assert(oakengine_task_manager_add(task) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_task_manager_add(task) == OAKENGINE_OK); // Wait for the task to finish. Manager tasks run on a worker thread and // emit events on that thread; spin briefly until the finished event fires. @@ -189,16 +190,16 @@ static void test_task_events(void) std::this_thread::sleep_for(std::chrono::milliseconds(10)); } - assert(g_manager_added == 1); - assert(g_task_started == 1); - assert(g_task_finished == 1); + EXPECT_TRUE(g_manager_added == 1); + EXPECT_TRUE(g_task_started == 1); + EXPECT_TRUE(g_task_finished == 1); // The import task may succeed even when all files are invalid; the event // payload only reports Task::finished() success, which is implementation // dependent. We only verify the event fired and had a boolean value. - assert(g_task_succeeded == 0 || g_task_succeeded == 1); + EXPECT_TRUE(g_task_succeeded == 0 || g_task_succeeded == 1); // Cancel returns OK whether the task is still running or already done. - assert(oakengine_task_manager_cancel(task) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_task_manager_cancel(task) == OAKENGINE_OK); oakengine_event_unsubscribe(sub_started); oakengine_event_unsubscribe(sub_progress); @@ -211,43 +212,43 @@ static void test_task_events(void) static void test_undo_round_trip(void) { - assert(oakengine_undo_handle() != NULL); - assert(oakengine_undo_count() == 1); // the empty "New Project" entry - assert(oakengine_undo_index() == 1); - assert(oakengine_undo_can_undo() == 0); - assert(oakengine_undo_can_redo() == 0); + EXPECT_TRUE(oakengine_undo_handle() != NULL); + EXPECT_TRUE(oakengine_undo_count() == 1); // the empty "New Project" entry + EXPECT_TRUE(oakengine_undo_index() == 1); + EXPECT_TRUE(oakengine_undo_can_undo() == 0); + EXPECT_TRUE(oakengine_undo_can_redo() == 0); char text[256]; int len = oakengine_undo_command_text(0, text, sizeof(text)); - assert(len > 0); + EXPECT_TRUE(len > 0); // Push a custom no-op command with a user-visible label. void *cmd = oakengine_undo_command_create( "Internal Name", NULL, NULL, NULL, NULL); - assert(cmd != NULL); - assert(oakengine_undo_push(cmd, "Test Command") == OAKENGINE_OK); - assert(oakengine_undo_count() == 2); - assert(oakengine_undo_index() == 2); - assert(oakengine_undo_can_undo() == 1); + EXPECT_TRUE(cmd != NULL); + EXPECT_TRUE(oakengine_undo_push(cmd, "Test Command") == OAKENGINE_OK); + EXPECT_TRUE(oakengine_undo_count() == 2); + EXPECT_TRUE(oakengine_undo_index() == 2); + EXPECT_TRUE(oakengine_undo_can_undo() == 1); len = oakengine_undo_command_text(1, text, sizeof(text)); - assert(len > 0); - assert(strstr(text, "Test Command") != NULL); + EXPECT_TRUE(len > 0); + EXPECT_TRUE(strstr(text, "Test Command") != NULL); - assert(oakengine_undo_command_is_done(1) == 1); - assert(oakengine_undo_jump(1) == OAKENGINE_OK); - assert(oakengine_undo_index() == 1); - assert(oakengine_undo_can_redo() == 1); - assert(oakengine_undo_command_is_done(1) == 0); + EXPECT_TRUE(oakengine_undo_command_is_done(1) == 1); + EXPECT_TRUE(oakengine_undo_jump(1) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_undo_index() == 1); + EXPECT_TRUE(oakengine_undo_can_redo() == 1); + EXPECT_TRUE(oakengine_undo_command_is_done(1) == 0); - assert(oakengine_undo_jump(2) == OAKENGINE_OK); - assert(oakengine_undo_index() == 2); - assert(oakengine_undo_can_undo() == 1); + EXPECT_TRUE(oakengine_undo_jump(2) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_undo_index() == 2); + EXPECT_TRUE(oakengine_undo_can_undo() == 1); - assert(oakengine_undo_clear() == OAKENGINE_OK); - assert(oakengine_undo_count() == 1); - assert(oakengine_undo_index() == 1); - assert(oakengine_undo_can_undo() == 0); + EXPECT_TRUE(oakengine_undo_clear() == OAKENGINE_OK); + EXPECT_TRUE(oakengine_undo_count() == 1); + EXPECT_TRUE(oakengine_undo_index() == 1); + EXPECT_TRUE(oakengine_undo_can_undo() == 0); } static void test_custom_command_multi(void) @@ -264,31 +265,31 @@ static void test_custom_command_multi(void) [](void *ud) { (void) ud; g_undo++; }, [](void *ud) { (void) ud; g_free++; }, NULL); - assert(cmd != NULL); + EXPECT_TRUE(cmd != NULL); - assert(oakengine_undo_command_redo_now(cmd) == OAKENGINE_OK); - assert(g_redo == 1); - assert(g_undo == 0); + EXPECT_TRUE(oakengine_undo_command_redo_now(cmd) == OAKENGINE_OK); + EXPECT_TRUE(g_redo == 1); + EXPECT_TRUE(g_undo == 0); - assert(oakengine_undo_command_undo_now(cmd) == OAKENGINE_OK); - assert(g_undo == 1); + EXPECT_TRUE(oakengine_undo_command_undo_now(cmd) == OAKENGINE_OK); + EXPECT_TRUE(g_undo == 1); void *multi = oakengine_undo_command_create_multi(); - assert(multi != NULL); - assert(oakengine_undo_command_multi_child_count(multi) == 0); - assert(oakengine_undo_command_multi_add_child(multi, cmd) == OAKENGINE_OK); - assert(oakengine_undo_command_multi_child_count(multi) == 1); - assert(oakengine_undo_command_multi_add_child(multi, NULL) == + EXPECT_TRUE(multi != NULL); + EXPECT_TRUE(oakengine_undo_command_multi_child_count(multi) == 0); + EXPECT_TRUE(oakengine_undo_command_multi_add_child(multi, cmd) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_undo_command_multi_child_count(multi) == 1); + EXPECT_TRUE(oakengine_undo_command_multi_add_child(multi, NULL) == OAKENGINE_E_INVALID); - assert(oakengine_undo_command_multi_add_child(NULL, cmd) == + EXPECT_TRUE(oakengine_undo_command_multi_add_child(NULL, cmd) == OAKENGINE_E_INVALID); // Remove the child from the multi-command and free it directly to verify // the custom command's free callback. (MultiUndoCommand does not own its // children, so freeing the multi-command alone would leak the child.) - assert(oakengine_undo_command_multi_child_count(multi) == 1); + EXPECT_TRUE(oakengine_undo_command_multi_child_count(multi) == 1); oakengine_undo_command_free(cmd); - assert(g_free == 1); + EXPECT_TRUE(g_free == 1); // The now-empty multi-command can be freed safely. oakengine_undo_command_free(multi); @@ -299,23 +300,23 @@ static void test_custom_command_multi(void) static void test_save_task_creation(void) { OakEngineProject *p = oakengine_project_create(); - assert(p != NULL); - assert(oakengine_project_new(p) == OAKENGINE_OK); + EXPECT_TRUE(p != NULL); + EXPECT_TRUE(oakengine_project_new(p) == OAKENGINE_OK); // Create a save task with NULL override and NULL layout. OakEngineTask *task = oakengine_task_create_project_save( p, 1, NULL, NULL); - assert(task != NULL); + EXPECT_TRUE(task != NULL); // task_save_get_project should return the project we passed. - assert(oakengine_task_save_get_project(task) == p); - assert(oakengine_task_save_get_project(NULL) == NULL); + EXPECT_TRUE(oakengine_task_save_get_project(task) == p); + EXPECT_TRUE(oakengine_task_save_get_project(NULL) == NULL); // Running sync on an untitled project: may succeed or fail gracefully. int ok = oakengine_task_start_sync(task); (void) ok; // must not crash - assert(oakengine_task_free(task) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_task_free(task) == OAKENGINE_OK); oakengine_project_free(p); } @@ -328,7 +329,7 @@ static void test_other_task_creation(void) OakEngineTask *task = oakengine_task_create_project_load_otio( "/nonexistent.otio"); if (task != NULL) { - assert(oakengine_task_free(task) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_task_free(task) == OAKENGINE_OK); } // OTIO save: same. @@ -336,10 +337,10 @@ static void test_other_task_creation(void) // Passing NULL project may return NULL. // Export: NULL sequence, NULL params. - assert(oakengine_task_create_export(NULL, NULL) == NULL); + EXPECT_TRUE(oakengine_task_create_export(NULL, NULL) == NULL); // Proxy: NULL footage. - assert(oakengine_task_create_proxy(NULL) == NULL); + EXPECT_TRUE(oakengine_task_create_proxy(NULL) == NULL); } // ---- Import result accessors (extending test_import_error_path) -------------- @@ -347,24 +348,24 @@ static void test_other_task_creation(void) static void test_import_result_accessors(void) { OakEngineProject *p = oakengine_project_create(); - assert(p != NULL); - assert(oakengine_project_new(p) == OAKENGINE_OK); + EXPECT_TRUE(p != NULL); + EXPECT_TRUE(oakengine_project_new(p) == OAKENGINE_OK); OakEngineNode *root = oakengine_project_root(p); - assert(root != NULL); + EXPECT_TRUE(root != NULL); const char *url = "file:///this/file/does/not/exist.mov"; OakEngineTask *task = oakengine_task_create_project_import(root, &url, 1); - assert(task != NULL); + EXPECT_TRUE(task != NULL); int ok = oakengine_task_start_sync(task); - assert(ok == 0 || ok == 1); + EXPECT_TRUE(ok == 0 || ok == 1); (void) ok; // Import of invalid file: footage_at should return 0/NULL. - assert(oakengine_task_import_footage_count(task) == 0); - assert(oakengine_task_import_footage_at(task, 0) == NULL); - assert(oakengine_task_import_footage_at(task, -1) == NULL); - assert(oakengine_task_import_footage_at(NULL, 0) == NULL); + EXPECT_TRUE(oakengine_task_import_footage_count(task) == 0); + EXPECT_TRUE(oakengine_task_import_footage_at(task, 0) == NULL); + EXPECT_TRUE(oakengine_task_import_footage_at(task, -1) == NULL); + EXPECT_TRUE(oakengine_task_import_footage_at(NULL, 0) == NULL); // import_get_command: should be non-NULL (the import built a command // even when all files failed) or NULL (no data to build). @@ -373,7 +374,7 @@ static void test_import_result_accessors(void) oakengine_undo_command_free(cmd); } - assert(oakengine_task_free(task) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_task_free(task) == OAKENGINE_OK); oakengine_project_free(p); } @@ -382,18 +383,18 @@ static void test_import_result_accessors(void) static void test_undo_actions(void) { // update_actions should not crash. - assert(oakengine_undo_update_actions() == OAKENGINE_OK); + EXPECT_TRUE(oakengine_undo_update_actions() == OAKENGINE_OK); // undo_action / redo_action return QAction* as void* (may be NULL). oakengine_undo_undo_action(); oakengine_undo_redo_action(); } -int main(void) +TEST(OakEngineTask, Main) { test_manager_no_engine(); - assert(oakengine_init(OAKENGINE_INIT_HEADLESS) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_init(OAKENGINE_INIT_HEADLESS) == OAKENGINE_OK); test_manager_empty(); test_task_null(); @@ -407,6 +408,5 @@ int main(void) test_import_result_accessors(); test_undo_actions(); - assert(oakengine_shutdown() == OAKENGINE_OK); - return 0; + EXPECT_TRUE(oakengine_shutdown() == OAKENGINE_OK); } diff --git a/engine/tests/oakengine_timeline_edit_test.cpp b/engine/tests/oakengine_timeline_edit_test.cpp index 5d4f75126..295470b3e 100644 --- a/engine/tests/oakengine_timeline_edit_test.cpp +++ b/engine/tests/oakengine_timeline_edit_test.cpp @@ -24,6 +24,7 @@ // tests/demo.mp4. No GL required. #include +#include #include #include #include @@ -53,57 +54,57 @@ static void make_tmpdir(void) #if defined(_WIN32) char base[MAX_PATH]; const DWORD len = GetTempPathA(MAX_PATH, base); - assert(len > 0 && len < MAX_PATH); + EXPECT_TRUE(len > 0 && len < MAX_PATH); snprintf(g_tmpdir, sizeof(g_tmpdir), "%soakengine_tl_edit_test_%lu", base, (unsigned long)GetCurrentProcessId()); - assert(_mkdir(g_tmpdir) == 0); + EXPECT_TRUE(_mkdir(g_tmpdir) == 0); #else strcpy(g_tmpdir, "/tmp/oakengine_tl_edit_test_XXXXXX"); - assert(mkdtemp(g_tmpdir) != NULL); + EXPECT_TRUE(mkdtemp(g_tmpdir) != NULL); #endif } static void demo_path(char *dst, size_t cap) { const int n = snprintf(dst, cap, "%s/tests/demo.mp4", OAK_TEST_SOURCE_DIR); - assert(n > 0 && (size_t)n < cap); + EXPECT_TRUE(n > 0 && (size_t)n < cap); } static void test_add_track(OakEngineProject *project, OakEngineSequence *seq) { int video = -1, audio = -1, subtitle = -1; - assert(oakengine_sequence_track_count(seq, &video, &audio, &subtitle) == + EXPECT_TRUE(oakengine_sequence_track_count(seq, &video, &audio, &subtitle) == OAKENGINE_OK); - assert(video == 0 && audio == 0 && subtitle == 0); + EXPECT_TRUE(video == 0 && audio == 0 && subtitle == 0); - assert(oakengine_sequence_add_track(seq, OAKENGINE_TRACK_TYPE_VIDEO) == 0); - assert(oakengine_sequence_add_track(seq, OAKENGINE_TRACK_TYPE_AUDIO) == 0); - assert(oakengine_sequence_add_track(seq, OAKENGINE_TRACK_TYPE_SUBTITLE) == + EXPECT_TRUE(oakengine_sequence_add_track(seq, OAKENGINE_TRACK_TYPE_VIDEO) == 0); + EXPECT_TRUE(oakengine_sequence_add_track(seq, OAKENGINE_TRACK_TYPE_AUDIO) == 0); + EXPECT_TRUE(oakengine_sequence_add_track(seq, OAKENGINE_TRACK_TYPE_SUBTITLE) == 0); - assert(oakengine_sequence_add_track(seq, OAKENGINE_TRACK_TYPE_VIDEO) == 1); + EXPECT_TRUE(oakengine_sequence_add_track(seq, OAKENGINE_TRACK_TYPE_VIDEO) == 1); - assert(oakengine_sequence_track_count(seq, &video, &audio, &subtitle) == + EXPECT_TRUE(oakengine_sequence_track_count(seq, &video, &audio, &subtitle) == OAKENGINE_OK); - assert(video == 2 && audio == 1 && subtitle == 1); + EXPECT_TRUE(video == 2 && audio == 1 && subtitle == 1); // Invalid track types are rejected. - assert(oakengine_sequence_add_track(seq, -1) == OAKENGINE_E_INVALID); - assert(oakengine_sequence_add_track(seq, 3) == OAKENGINE_E_INVALID); - assert(oakengine_sequence_add_track(NULL, OAKENGINE_TRACK_TYPE_VIDEO) == + EXPECT_TRUE(oakengine_sequence_add_track(seq, -1) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_sequence_add_track(seq, 3) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_sequence_add_track(NULL, OAKENGINE_TRACK_TYPE_VIDEO) == OAKENGINE_E_INVALID); // Track adds are undoable: undo the second video track, then redo it. - assert(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); video = audio = subtitle = -1; - assert(oakengine_sequence_track_count(seq, &video, &audio, &subtitle) == + EXPECT_TRUE(oakengine_sequence_track_count(seq, &video, &audio, &subtitle) == OAKENGINE_OK); - assert(video == 1 && audio == 1 && subtitle == 1); - assert(oakengine_project_redo(project) == OAKENGINE_OK); + EXPECT_TRUE(video == 1 && audio == 1 && subtitle == 1); + EXPECT_TRUE(oakengine_project_redo(project) == OAKENGINE_OK); video = audio = subtitle = -1; - assert(oakengine_sequence_track_count(seq, &video, &audio, &subtitle) == + EXPECT_TRUE(oakengine_sequence_track_count(seq, &video, &audio, &subtitle) == OAKENGINE_OK); - assert(video == 2 && audio == 1 && subtitle == 1); + EXPECT_TRUE(video == 2 && audio == 1 && subtitle == 1); } static void test_add_clip(OakEngineProject *project, OakEngineSequence *seq, @@ -113,105 +114,105 @@ static void test_add_clip(OakEngineProject *project, OakEngineSequence *seq, // Probe handles carry no project node and cannot be placed. OakEngineFootage *probed = oakengine_footage_probe(media_path); - assert(probed != NULL); - assert(oakengine_sequence_add_footage_clip(seq, probed, + EXPECT_TRUE(probed != NULL); + EXPECT_TRUE(oakengine_sequence_add_footage_clip(seq, probed, OAKENGINE_TRACK_TYPE_VIDEO, 0, 0, 30, 0) == NULL); - assert(oakengine_sequence_last_error(err, sizeof(err)) > 0); + EXPECT_TRUE(oakengine_sequence_last_error(err, sizeof(err)) > 0); oakengine_footage_free(probed); // Import the media into the project. OakEngineFootage *footage = oakengine_project_import_footage(project, media_path); - assert(footage != NULL); + EXPECT_TRUE(footage != NULL); // No subtitle clips. - assert(oakengine_sequence_add_footage_clip(seq, footage, + EXPECT_TRUE(oakengine_sequence_add_footage_clip(seq, footage, OAKENGINE_TRACK_TYPE_SUBTITLE, 0, 0, 30, 0) == NULL); // Out-of-range track indexes are rejected without creating tracks. - assert(oakengine_sequence_add_footage_clip(seq, footage, + EXPECT_TRUE(oakengine_sequence_add_footage_clip(seq, footage, OAKENGINE_TRACK_TYPE_VIDEO, 5, 0, 30, 0) == NULL); - assert(oakengine_sequence_last_error(err, sizeof(err)) > 0); - assert(oakengine_sequence_add_footage_clip(seq, footage, + EXPECT_TRUE(oakengine_sequence_last_error(err, sizeof(err)) > 0); + EXPECT_TRUE(oakengine_sequence_add_footage_clip(seq, footage, OAKENGINE_TRACK_TYPE_VIDEO, -1, 0, 30, 0) == NULL); // Bad ranges: out <= in, negative in / media_in. - assert(oakengine_sequence_add_footage_clip(seq, footage, + EXPECT_TRUE(oakengine_sequence_add_footage_clip(seq, footage, OAKENGINE_TRACK_TYPE_VIDEO, 0, 30, 30, 0) == NULL); - assert(oakengine_sequence_add_footage_clip(seq, footage, + EXPECT_TRUE(oakengine_sequence_add_footage_clip(seq, footage, OAKENGINE_TRACK_TYPE_VIDEO, 0, 30, 10, 0) == NULL); - assert(oakengine_sequence_add_footage_clip(seq, footage, + EXPECT_TRUE(oakengine_sequence_add_footage_clip(seq, footage, OAKENGINE_TRACK_TYPE_VIDEO, 0, -1, 30, 0) == NULL); - assert(oakengine_sequence_add_footage_clip(seq, footage, + EXPECT_TRUE(oakengine_sequence_add_footage_clip(seq, footage, OAKENGINE_TRACK_TYPE_VIDEO, 0, 0, 30, -1) == NULL); // NULL safety. - assert(oakengine_sequence_add_footage_clip(NULL, footage, + EXPECT_TRUE(oakengine_sequence_add_footage_clip(NULL, footage, OAKENGINE_TRACK_TYPE_VIDEO, 0, 0, 30, 0) == NULL); - assert(oakengine_sequence_add_footage_clip(seq, NULL, + EXPECT_TRUE(oakengine_sequence_add_footage_clip(seq, NULL, OAKENGINE_TRACK_TYPE_VIDEO, 0, 0, 30, 0) == NULL); // clip_count reports OAKENGINE_E_NOT_FOUND for a missing track. - assert(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, + EXPECT_TRUE(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, 99) == OAKENGINE_E_NOT_FOUND); - assert(oakengine_sequence_clip_count(NULL, OAKENGINE_TRACK_TYPE_VIDEO, + EXPECT_TRUE(oakengine_sequence_clip_count(NULL, OAKENGINE_TRACK_TYPE_VIDEO, 0) == OAKENGINE_E_INVALID); // Place a video clip on track 0: frames 10..40, media in-point 5. OakEngineClip *clip = oakengine_sequence_add_footage_clip( seq, footage, OAKENGINE_TRACK_TYPE_VIDEO, 0, 10, 40, 5); - assert(clip != NULL); - assert(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, + EXPECT_TRUE(clip != NULL); + EXPECT_TRUE(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0) == 1); OakEngineClip *at = oakengine_sequence_clip_at( seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 0); - assert(at == clip); - assert(oakengine_sequence_clip_at(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, + EXPECT_TRUE(at == clip); + EXPECT_TRUE(oakengine_sequence_clip_at(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 1) == NULL); - assert(oakengine_sequence_clip_at(seq, OAKENGINE_TRACK_TYPE_VIDEO, 9, + EXPECT_TRUE(oakengine_sequence_clip_at(seq, OAKENGINE_TRACK_TYPE_VIDEO, 9, 0) == NULL); int64_t in = -1, out = -1, media_in = -1; - assert(oakengine_clip_get_range(clip, &in, &out, &media_in) == + EXPECT_TRUE(oakengine_clip_get_range(clip, &in, &out, &media_in) == OAKENGINE_OK); - assert(in == 10 && out == 40 && media_in == 5); - assert(oakengine_clip_get_range(NULL, &in, &out, &media_in) == + EXPECT_TRUE(in == 10 && out == 40 && media_in == 5); + EXPECT_TRUE(oakengine_clip_get_range(NULL, &in, &out, &media_in) == OAKENGINE_E_INVALID); // And an audio clip on audio track 0 (same footage, whole range). OakEngineClip *aclip = oakengine_sequence_add_footage_clip( seq, footage, OAKENGINE_TRACK_TYPE_AUDIO, 0, 0, 30, 0); - assert(aclip != NULL); - assert(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_AUDIO, + EXPECT_TRUE(aclip != NULL); + EXPECT_TRUE(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_AUDIO, 0) == 1); // Undo/redo both clip adds (the audio clip is on top of the undo stack, // the video clip right below it). - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_AUDIO, + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_AUDIO, 0) == 0); - assert(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, + EXPECT_TRUE(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0) == 0); - assert(oakengine_project_redo(project) == OAKENGINE_OK); - assert(oakengine_project_redo(project) == OAKENGINE_OK); - assert(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, + EXPECT_TRUE(oakengine_project_redo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_redo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0) == 1); - assert(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_AUDIO, + EXPECT_TRUE(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_AUDIO, 0) == 1); oakengine_footage_free(footage); // wrapper only; node stays - assert(oakengine_project_footage_count(project) == 1); + EXPECT_TRUE(oakengine_project_footage_count(project) == 1); } // Footage imported into one project must not be placed into another. @@ -219,25 +220,25 @@ static void test_cross_project_rejected(const char *media_path) { OakEngineProject *a = oakengine_project_create(); OakEngineProject *b = oakengine_project_create(); - assert(a != NULL && b != NULL); - assert(oakengine_project_new(a) == OAKENGINE_OK); - assert(oakengine_project_new(b) == OAKENGINE_OK); + EXPECT_TRUE(a != NULL && b != NULL); + EXPECT_TRUE(oakengine_project_new(a) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_new(b) == OAKENGINE_OK); OakEngineFootage *footage = oakengine_project_import_footage(a, media_path); - assert(footage != NULL); + EXPECT_TRUE(footage != NULL); OakEngineSequence *seq_b = oakengine_sequence_new(b, "B"); - assert(seq_b != NULL); - assert(oakengine_sequence_add_track(seq_b, OAKENGINE_TRACK_TYPE_VIDEO) == + EXPECT_TRUE(seq_b != NULL); + EXPECT_TRUE(oakengine_sequence_add_track(seq_b, OAKENGINE_TRACK_TYPE_VIDEO) == 0); char err[512]; - assert(oakengine_sequence_add_footage_clip(seq_b, footage, + EXPECT_TRUE(oakengine_sequence_add_footage_clip(seq_b, footage, OAKENGINE_TRACK_TYPE_VIDEO, 0, 0, 30, 0) == NULL); - assert(oakengine_sequence_last_error(err, sizeof(err)) > 0); - assert(oakengine_sequence_clip_count(seq_b, OAKENGINE_TRACK_TYPE_VIDEO, + EXPECT_TRUE(oakengine_sequence_last_error(err, sizeof(err)) > 0); + EXPECT_TRUE(oakengine_sequence_clip_count(seq_b, OAKENGINE_TRACK_TYPE_VIDEO, 0) == 0); oakengine_footage_free(footage); @@ -250,25 +251,25 @@ static void test_cross_project_rejected(const char *media_path) static void test_edit_round2(const char *media_path) { OakEngineProject *project = oakengine_project_create(); - assert(project != NULL); - assert(oakengine_project_new(project) == OAKENGINE_OK); + EXPECT_TRUE(project != NULL); + EXPECT_TRUE(oakengine_project_new(project) == OAKENGINE_OK); OakEngineSequence *seq = oakengine_sequence_new(project, "Round2"); - assert(seq != NULL); - assert(oakengine_sequence_add_track(seq, OAKENGINE_TRACK_TYPE_VIDEO) == + EXPECT_TRUE(seq != NULL); + EXPECT_TRUE(oakengine_sequence_add_track(seq, OAKENGINE_TRACK_TYPE_VIDEO) == 0); OakEngineFootage *footage = oakengine_project_import_footage(project, media_path); - assert(footage != NULL); + EXPECT_TRUE(footage != NULL); // Two clips back to back: A [0,30] and B [30,60], both from media 0. OakEngineClip *clip_a = oakengine_sequence_add_footage_clip( seq, footage, OAKENGINE_TRACK_TYPE_VIDEO, 0, 0, 30, 0); - assert(clip_a != NULL); + EXPECT_TRUE(clip_a != NULL); OakEngineClip *clip_b = oakengine_sequence_add_footage_clip( seq, footage, OAKENGINE_TRACK_TYPE_VIDEO, 0, 30, 60, 0); - assert(clip_b != NULL); - assert(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, + EXPECT_TRUE(clip_b != NULL); + EXPECT_TRUE(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0) == 2); int64_t in = -1, out = -1, media_in = -1; @@ -276,172 +277,172 @@ static void test_edit_round2(const char *media_path) // ---- split ------------------------------------------------------------- // Bad split points: on the edges, outside, missing clip. - assert(oakengine_sequence_split_clip(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, + EXPECT_TRUE(oakengine_sequence_split_clip(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 0, 0) == OAKENGINE_E_INVALID); - assert(oakengine_sequence_split_clip(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, + EXPECT_TRUE(oakengine_sequence_split_clip(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 0, 30) == OAKENGINE_E_INVALID); - assert(oakengine_sequence_split_clip(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, + EXPECT_TRUE(oakengine_sequence_split_clip(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 0, -5) == OAKENGINE_E_INVALID); - assert(oakengine_sequence_split_clip(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, + EXPECT_TRUE(oakengine_sequence_split_clip(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 0, 99) == OAKENGINE_E_INVALID); - assert(oakengine_sequence_split_clip(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, + EXPECT_TRUE(oakengine_sequence_split_clip(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 99, 15) == OAKENGINE_E_NOT_FOUND); - assert(oakengine_sequence_split_clip(NULL, OAKENGINE_TRACK_TYPE_VIDEO, 0, + EXPECT_TRUE(oakengine_sequence_split_clip(NULL, OAKENGINE_TRACK_TYPE_VIDEO, 0, 0, 15) == OAKENGINE_E_INVALID); // Split A [0,30] at 15 -> [0,15] + [15,30] with aligned media in-points. - assert(oakengine_sequence_split_clip(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, + EXPECT_TRUE(oakengine_sequence_split_clip(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 0, 15) == OAKENGINE_OK); - assert(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, + EXPECT_TRUE(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0) == 3); OakEngineClip *left = oakengine_sequence_clip_at(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 0); OakEngineClip *right = oakengine_sequence_clip_at(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 1); - assert(left == clip_a); - assert(oakengine_clip_get_range(left, &in, &out, &media_in) == + EXPECT_TRUE(left == clip_a); + EXPECT_TRUE(oakengine_clip_get_range(left, &in, &out, &media_in) == OAKENGINE_OK); - assert(in == 0 && out == 15 && media_in == 0); - assert(oakengine_clip_get_range(right, &in, &out, &media_in) == + EXPECT_TRUE(in == 0 && out == 15 && media_in == 0); + EXPECT_TRUE(oakengine_clip_get_range(right, &in, &out, &media_in) == OAKENGINE_OK); - assert(in == 15 && out == 30 && media_in == 15); + EXPECT_TRUE(in == 15 && out == 30 && media_in == 15); // Undo merges them back, redo splits again. - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0) == 2); - assert(oakengine_clip_get_range(clip_a, &in, &out, &media_in) == + EXPECT_TRUE(oakengine_clip_get_range(clip_a, &in, &out, &media_in) == OAKENGINE_OK); - assert(in == 0 && out == 30 && media_in == 0); - assert(oakengine_project_redo(project) == OAKENGINE_OK); - assert(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, + EXPECT_TRUE(in == 0 && out == 30 && media_in == 0); + EXPECT_TRUE(oakengine_project_redo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0) == 3); right = oakengine_sequence_clip_at(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 1); - assert(oakengine_clip_get_range(right, &in, &out, &media_in) == + EXPECT_TRUE(oakengine_clip_get_range(right, &in, &out, &media_in) == OAKENGINE_OK); - assert(in == 15 && out == 30 && media_in == 15); + EXPECT_TRUE(in == 15 && out == 30 && media_in == 15); // ---- trim -------------------------------------------------------------- // Bad trim ranges. - assert(oakengine_clip_trim(NULL, 0, 10) == OAKENGINE_E_INVALID); - assert(oakengine_clip_trim(right, 30, 20) == OAKENGINE_E_INVALID); - assert(oakengine_clip_trim(right, -1, 20) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_clip_trim(NULL, 0, 10) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_clip_trim(right, 30, 20) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_clip_trim(right, -1, 20) == OAKENGINE_E_INVALID); // Trim the right part's in-point 15 -> 20: media_in follows 15 -> 20. - assert(oakengine_clip_trim(right, 20, 30) == OAKENGINE_OK); - assert(oakengine_clip_get_range(right, &in, &out, &media_in) == + EXPECT_TRUE(oakengine_clip_trim(right, 20, 30) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_clip_get_range(right, &in, &out, &media_in) == OAKENGINE_OK); - assert(in == 20 && out == 30 && media_in == 20); + EXPECT_TRUE(in == 20 && out == 30 && media_in == 20); // The leading clip is untouched (a gap absorbs the difference). - assert(oakengine_clip_get_range(clip_a, &in, &out, &media_in) == + EXPECT_TRUE(oakengine_clip_get_range(clip_a, &in, &out, &media_in) == OAKENGINE_OK); - assert(in == 0 && out == 15 && media_in == 0); + EXPECT_TRUE(in == 0 && out == 15 && media_in == 0); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_clip_get_range(right, &in, &out, &media_in) == + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_clip_get_range(right, &in, &out, &media_in) == OAKENGINE_OK); - assert(in == 15 && out == 30 && media_in == 15); - assert(oakengine_project_redo(project) == OAKENGINE_OK); - assert(oakengine_clip_get_range(right, &in, &out, &media_in) == + EXPECT_TRUE(in == 15 && out == 30 && media_in == 15); + EXPECT_TRUE(oakengine_project_redo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_clip_get_range(right, &in, &out, &media_in) == OAKENGINE_OK); - assert(in == 20 && out == 30 && media_in == 20); + EXPECT_TRUE(in == 20 && out == 30 && media_in == 20); // Trim the out-point 30 -> 25 (media in-point stays). - assert(oakengine_clip_trim(right, 20, 25) == OAKENGINE_OK); - assert(oakengine_clip_get_range(right, &in, &out, &media_in) == + EXPECT_TRUE(oakengine_clip_trim(right, 20, 25) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_clip_get_range(right, &in, &out, &media_in) == OAKENGINE_OK); - assert(in == 20 && out == 25 && media_in == 20); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_clip_get_range(right, &in, &out, &media_in) == + EXPECT_TRUE(in == 20 && out == 25 && media_in == 20); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_clip_get_range(right, &in, &out, &media_in) == OAKENGINE_OK); - assert(in == 20 && out == 30 && media_in == 20); + EXPECT_TRUE(in == 20 && out == 30 && media_in == 20); // No-op trim is accepted and does nothing. - assert(oakengine_clip_trim(right, 20, 30) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_clip_trim(right, 20, 30) == OAKENGINE_OK); // Both ends in one command: [20,30] -> [22,28], media_in follows. - assert(oakengine_clip_trim(right, 22, 28) == OAKENGINE_OK); - assert(oakengine_clip_get_range(right, &in, &out, &media_in) == + EXPECT_TRUE(oakengine_clip_trim(right, 22, 28) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_clip_get_range(right, &in, &out, &media_in) == OAKENGINE_OK); - assert(in == 22 && out == 28 && media_in == 22); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_clip_get_range(right, &in, &out, &media_in) == + EXPECT_TRUE(in == 22 && out == 28 && media_in == 22); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_clip_get_range(right, &in, &out, &media_in) == OAKENGINE_OK); - assert(in == 20 && out == 30 && media_in == 20); + EXPECT_TRUE(in == 20 && out == 30 && media_in == 20); // ---- move --------------------------------------------------------------- - assert(oakengine_sequence_move_clip(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 1, + EXPECT_TRUE(oakengine_sequence_move_clip(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 1, -1) == OAKENGINE_E_INVALID); - assert(oakengine_sequence_move_clip(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, + EXPECT_TRUE(oakengine_sequence_move_clip(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 99, 50) == OAKENGINE_E_NOT_FOUND); // Move the second clip [20,30] to 70 (past everything): position shifts, // length and media in-point are preserved, the other clips stay put. - assert(oakengine_sequence_move_clip(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 1, + EXPECT_TRUE(oakengine_sequence_move_clip(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 1, 70) == OAKENGINE_OK); // After the move the moved clip is the LAST one on the track. right = oakengine_sequence_clip_at(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 2); - assert(oakengine_clip_get_range(right, &in, &out, &media_in) == + EXPECT_TRUE(oakengine_clip_get_range(right, &in, &out, &media_in) == OAKENGINE_OK); - assert(in == 70 && out == 80 && media_in == 20); - assert(oakengine_clip_get_range(clip_a, &in, &out, &media_in) == + EXPECT_TRUE(in == 70 && out == 80 && media_in == 20); + EXPECT_TRUE(oakengine_clip_get_range(clip_a, &in, &out, &media_in) == OAKENGINE_OK); - assert(in == 0 && out == 15 && media_in == 0); - assert(oakengine_clip_get_range(clip_b, &in, &out, &media_in) == + EXPECT_TRUE(in == 0 && out == 15 && media_in == 0); + EXPECT_TRUE(oakengine_clip_get_range(clip_b, &in, &out, &media_in) == OAKENGINE_OK); - assert(in == 30 && out == 60 && media_in == 0); + EXPECT_TRUE(in == 30 && out == 60 && media_in == 0); - assert(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); right = oakengine_sequence_clip_at(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 1); - assert(oakengine_clip_get_range(right, &in, &out, &media_in) == + EXPECT_TRUE(oakengine_clip_get_range(right, &in, &out, &media_in) == OAKENGINE_OK); - assert(in == 20 && out == 30 && media_in == 20); - assert(oakengine_project_redo(project) == OAKENGINE_OK); + EXPECT_TRUE(in == 20 && out == 30 && media_in == 20); + EXPECT_TRUE(oakengine_project_redo(project) == OAKENGINE_OK); right = oakengine_sequence_clip_at(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 2); - assert(oakengine_clip_get_range(right, &in, &out, &media_in) == + EXPECT_TRUE(oakengine_clip_get_range(right, &in, &out, &media_in) == OAKENGINE_OK); - assert(in == 70 && out == 80 && media_in == 20); + EXPECT_TRUE(in == 70 && out == 80 && media_in == 20); // ---- ripple delete ------------------------------------------------------- - assert(oakengine_sequence_ripple_delete_clip( + EXPECT_TRUE(oakengine_sequence_ripple_delete_clip( seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 99) == OAKENGINE_E_NOT_FOUND); - assert(oakengine_sequence_ripple_delete_clip(NULL, + EXPECT_TRUE(oakengine_sequence_ripple_delete_clip(NULL, OAKENGINE_TRACK_TYPE_VIDEO, 0, 0) == OAKENGINE_E_INVALID); // Delete the first clip [0,15]: both following clips shift left by 15. - assert(oakengine_sequence_ripple_delete_clip( + EXPECT_TRUE(oakengine_sequence_ripple_delete_clip( seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 0) == OAKENGINE_OK); - assert(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, + EXPECT_TRUE(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0) == 2); right = oakengine_sequence_clip_at(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 0); - assert(oakengine_clip_get_range(right, &in, &out, &media_in) == + EXPECT_TRUE(oakengine_clip_get_range(right, &in, &out, &media_in) == OAKENGINE_OK); - assert(in == 15 && out == 45 && media_in == 0); // clip_b was [30,60] + EXPECT_TRUE(in == 15 && out == 45 && media_in == 0); // clip_b was [30,60] right = oakengine_sequence_clip_at(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 1); - assert(oakengine_clip_get_range(right, &in, &out, &media_in) == + EXPECT_TRUE(oakengine_clip_get_range(right, &in, &out, &media_in) == OAKENGINE_OK); - assert(in == 55 && out == 65 && media_in == 20); // was [70,80] + EXPECT_TRUE(in == 55 && out == 65 && media_in == 20); // was [70,80] - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0) == 3); right = oakengine_sequence_clip_at(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 0); - assert(oakengine_clip_get_range(right, &in, &out, &media_in) == + EXPECT_TRUE(oakengine_clip_get_range(right, &in, &out, &media_in) == OAKENGINE_OK); - assert(in == 0 && out == 15 && media_in == 0); + EXPECT_TRUE(in == 0 && out == 15 && media_in == 0); right = oakengine_sequence_clip_at(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 1); - assert(oakengine_clip_get_range(right, &in, &out, &media_in) == + EXPECT_TRUE(oakengine_clip_get_range(right, &in, &out, &media_in) == OAKENGINE_OK); - assert(in == 30 && out == 60 && media_in == 0); + EXPECT_TRUE(in == 30 && out == 60 && media_in == 0); right = oakengine_sequence_clip_at(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 2); - assert(oakengine_clip_get_range(right, &in, &out, &media_in) == + EXPECT_TRUE(oakengine_clip_get_range(right, &in, &out, &media_in) == OAKENGINE_OK); - assert(in == 70 && out == 80 && media_in == 20); + EXPECT_TRUE(in == 70 && out == 80 && media_in == 20); oakengine_footage_free(footage); // wrapper only; node stays - assert(oakengine_project_footage_count(project) == 1); + EXPECT_TRUE(oakengine_project_footage_count(project) == 1); } // Footage imported into one project must not be placed into another. @@ -451,120 +452,120 @@ static void test_edit_round2(const char *media_path) static void test_track_structure(const char *media_path) { OakEngineProject *project = oakengine_project_create(); - assert(project != NULL); - assert(oakengine_project_new(project) == OAKENGINE_OK); + EXPECT_TRUE(project != NULL); + EXPECT_TRUE(oakengine_project_new(project) == OAKENGINE_OK); OakEngineSequence *seq = oakengine_sequence_new(project, "Tracks"); - assert(seq != NULL); - assert(oakengine_sequence_add_track(seq, OAKENGINE_TRACK_TYPE_VIDEO) == + EXPECT_TRUE(seq != NULL); + EXPECT_TRUE(oakengine_sequence_add_track(seq, OAKENGINE_TRACK_TYPE_VIDEO) == 0); - assert(oakengine_sequence_add_track(seq, OAKENGINE_TRACK_TYPE_VIDEO) == + EXPECT_TRUE(oakengine_sequence_add_track(seq, OAKENGINE_TRACK_TYPE_VIDEO) == 1); OakEngineFootage *footage = oakengine_project_import_footage(project, media_path); - assert(footage != NULL); + EXPECT_TRUE(footage != NULL); // Distinctive clips per track so track order is observable. OakEngineClip *clip_a = oakengine_sequence_add_footage_clip( seq, footage, OAKENGINE_TRACK_TYPE_VIDEO, 0, 0, 10, 0); OakEngineClip *clip_b = oakengine_sequence_add_footage_clip( seq, footage, OAKENGINE_TRACK_TYPE_VIDEO, 1, 20, 30, 0); - assert(clip_a != NULL && clip_b != NULL); + EXPECT_TRUE(clip_a != NULL && clip_b != NULL); int64_t in = -1, out = -1, media_in = -1; double height = 0.0; // move_track swaps their positions; the clips move with the tracks. - assert(oakengine_sequence_move_track(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, + EXPECT_TRUE(oakengine_sequence_move_track(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 1) == OAKENGINE_OK); OakEngineClip *now = oakengine_sequence_clip_at( seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 0); - assert(now == clip_b); - assert(oakengine_clip_get_range(now, &in, &out, &media_in) == + EXPECT_TRUE(now == clip_b); + EXPECT_TRUE(oakengine_clip_get_range(now, &in, &out, &media_in) == OAKENGINE_OK); - assert(in == 20 && out == 30); + EXPECT_TRUE(in == 20 && out == 30); now = oakengine_sequence_clip_at(seq, OAKENGINE_TRACK_TYPE_VIDEO, 1, 0); - assert(now == clip_a); - assert(oakengine_clip_get_range(now, &in, &out, &media_in) == + EXPECT_TRUE(now == clip_a); + EXPECT_TRUE(oakengine_clip_get_range(now, &in, &out, &media_in) == OAKENGINE_OK); - assert(in == 0 && out == 10); + EXPECT_TRUE(in == 0 && out == 10); // Undo/redo restore the order both ways. - assert(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); now = oakengine_sequence_clip_at(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 0); - assert(now == clip_a); - assert(oakengine_project_redo(project) == OAKENGINE_OK); + EXPECT_TRUE(now == clip_a); + EXPECT_TRUE(oakengine_project_redo(project) == OAKENGINE_OK); now = oakengine_sequence_clip_at(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 0); - assert(now == clip_b); + EXPECT_TRUE(now == clip_b); // No-op move and out-of-range indexes. - assert(oakengine_sequence_move_track(seq, OAKENGINE_TRACK_TYPE_VIDEO, 1, + EXPECT_TRUE(oakengine_sequence_move_track(seq, OAKENGINE_TRACK_TYPE_VIDEO, 1, 1) == OAKENGINE_OK); - assert(oakengine_sequence_move_track(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, + EXPECT_TRUE(oakengine_sequence_move_track(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 5) == OAKENGINE_E_NOT_FOUND); - assert(oakengine_sequence_move_track(seq, OAKENGINE_TRACK_TYPE_VIDEO, 5, + EXPECT_TRUE(oakengine_sequence_move_track(seq, OAKENGINE_TRACK_TYPE_VIDEO, 5, 0) == OAKENGINE_E_NOT_FOUND); - assert(oakengine_sequence_move_track(NULL, OAKENGINE_TRACK_TYPE_VIDEO, 0, + EXPECT_TRUE(oakengine_sequence_move_track(NULL, OAKENGINE_TRACK_TYPE_VIDEO, 0, 1) == OAKENGINE_E_INVALID); // Height: default is positive, round-trip, direct (not undoable). - assert(oakengine_track_get_height(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, + EXPECT_TRUE(oakengine_track_get_height(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, &height) == OAKENGINE_OK); const double default_height = height; - assert(default_height > 0.0); - assert(oakengine_track_set_height(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, + EXPECT_TRUE(default_height > 0.0); + EXPECT_TRUE(oakengine_track_set_height(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 3.0) == OAKENGINE_OK); - assert(oakengine_track_get_height(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, + EXPECT_TRUE(oakengine_track_get_height(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, &height) == OAKENGINE_OK); - assert(height == 3.0); - assert(oakengine_track_set_height(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, + EXPECT_TRUE(height == 3.0); + EXPECT_TRUE(oakengine_track_set_height(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 0.0) == OAKENGINE_E_INVALID); - assert(oakengine_track_get_height(seq, OAKENGINE_TRACK_TYPE_VIDEO, 99, + EXPECT_TRUE(oakengine_track_get_height(seq, OAKENGINE_TRACK_TYPE_VIDEO, 99, &height) == OAKENGINE_E_NOT_FOUND); - assert(oakengine_track_get_height(NULL, OAKENGINE_TRACK_TYPE_VIDEO, 0, + EXPECT_TRUE(oakengine_track_get_height(NULL, OAKENGINE_TRACK_TYPE_VIDEO, 0, &height) == OAKENGINE_E_INVALID); // Mute and lock toggles, direct (not undoable). - assert(oakengine_track_is_muted(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0) == 0); - assert(oakengine_track_set_muted(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, + EXPECT_TRUE(oakengine_track_is_muted(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0) == 0); + EXPECT_TRUE(oakengine_track_set_muted(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 1) == OAKENGINE_OK); - assert(oakengine_track_is_muted(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0) == 1); - assert(oakengine_track_set_muted(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, + EXPECT_TRUE(oakengine_track_is_muted(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0) == 1); + EXPECT_TRUE(oakengine_track_set_muted(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 0) == OAKENGINE_OK); - assert(oakengine_track_is_muted(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0) == 0); - assert(oakengine_track_set_muted(seq, OAKENGINE_TRACK_TYPE_VIDEO, 99, + EXPECT_TRUE(oakengine_track_is_muted(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0) == 0); + EXPECT_TRUE(oakengine_track_set_muted(seq, OAKENGINE_TRACK_TYPE_VIDEO, 99, 1) == OAKENGINE_E_NOT_FOUND); - assert(oakengine_track_is_locked(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0) == + EXPECT_TRUE(oakengine_track_is_locked(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0) == 0); - assert(oakengine_track_set_locked(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, + EXPECT_TRUE(oakengine_track_set_locked(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 1) == OAKENGINE_OK); - assert(oakengine_track_is_locked(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0) == + EXPECT_TRUE(oakengine_track_is_locked(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0) == 1); - assert(oakengine_track_set_locked(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, + EXPECT_TRUE(oakengine_track_set_locked(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 0) == OAKENGINE_OK); - assert(oakengine_track_set_locked(NULL, OAKENGINE_TRACK_TYPE_VIDEO, 0, + EXPECT_TRUE(oakengine_track_set_locked(NULL, OAKENGINE_TRACK_TYPE_VIDEO, 0, 1) == OAKENGINE_E_INVALID); // remove_track drops the track and its content; undo brings both back. int video = -1, audio = -1, subtitle = -1; - assert(oakengine_sequence_remove_track(seq, OAKENGINE_TRACK_TYPE_VIDEO, + EXPECT_TRUE(oakengine_sequence_remove_track(seq, OAKENGINE_TRACK_TYPE_VIDEO, 1) == OAKENGINE_OK); - assert(oakengine_sequence_track_count(seq, &video, &audio, &subtitle) == + EXPECT_TRUE(oakengine_sequence_track_count(seq, &video, &audio, &subtitle) == OAKENGINE_OK); - assert(video == 1); - assert(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, + EXPECT_TRUE(video == 1); + EXPECT_TRUE(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0) == 1); - assert(oakengine_sequence_remove_track(seq, OAKENGINE_TRACK_TYPE_VIDEO, + EXPECT_TRUE(oakengine_sequence_remove_track(seq, OAKENGINE_TRACK_TYPE_VIDEO, 9) == OAKENGINE_E_NOT_FOUND); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_sequence_track_count(seq, &video, &audio, &subtitle) == + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_sequence_track_count(seq, &video, &audio, &subtitle) == OAKENGINE_OK); - assert(video == 2); - assert(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, + EXPECT_TRUE(video == 2); + EXPECT_TRUE(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, 1) == 1); - assert(oakengine_project_redo(project) == OAKENGINE_OK); - assert(oakengine_sequence_track_count(seq, &video, &audio, &subtitle) == + EXPECT_TRUE(oakengine_project_redo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_sequence_track_count(seq, &video, &audio, &subtitle) == OAKENGINE_OK); - assert(video == 1); + EXPECT_TRUE(video == 1); oakengine_footage_free(footage); oakengine_project_free(project); @@ -573,71 +574,71 @@ static void test_track_structure(const char *media_path) static void test_markers(void) { OakEngineProject *project = oakengine_project_create(); - assert(project != NULL); - assert(oakengine_project_new(project) == OAKENGINE_OK); + EXPECT_TRUE(project != NULL); + EXPECT_TRUE(oakengine_project_new(project) == OAKENGINE_OK); OakEngineSequence *seq = oakengine_sequence_new(project, "Markers"); - assert(seq != NULL); + EXPECT_TRUE(seq != NULL); int64_t ts = -1; char name[64]; - assert(oakengine_sequence_marker_count(seq) == 0); - assert(oakengine_sequence_marker_add(seq, 30, "Chapter 1") == + EXPECT_TRUE(oakengine_sequence_marker_count(seq) == 0); + EXPECT_TRUE(oakengine_sequence_marker_add(seq, 30, "Chapter 1") == OAKENGINE_OK); - assert(oakengine_sequence_marker_count(seq) == 1); - assert(oakengine_sequence_marker_at(seq, 0, &ts, name, sizeof(name), NULL) == + EXPECT_TRUE(oakengine_sequence_marker_count(seq) == 1); + EXPECT_TRUE(oakengine_sequence_marker_at(seq, 0, &ts, name, sizeof(name), NULL) == OAKENGINE_OK); - assert(ts == 30 && strcmp(name, "Chapter 1") == 0); + EXPECT_TRUE(ts == 30 && strcmp(name, "Chapter 1") == 0); // Duplicate time: the engine forbids two markers at one time. - assert(oakengine_sequence_marker_add(seq, 30, "dup") == + EXPECT_TRUE(oakengine_sequence_marker_add(seq, 30, "dup") == OAKENGINE_E_STATE); // Earlier marker sorts in front. - assert(oakengine_sequence_marker_add(seq, 10, "Intro") == OAKENGINE_OK); - assert(oakengine_sequence_marker_count(seq) == 2); - assert(oakengine_sequence_marker_at(seq, 0, &ts, name, sizeof(name), NULL) == + EXPECT_TRUE(oakengine_sequence_marker_add(seq, 10, "Intro") == OAKENGINE_OK); + EXPECT_TRUE(oakengine_sequence_marker_count(seq) == 2); + EXPECT_TRUE(oakengine_sequence_marker_at(seq, 0, &ts, name, sizeof(name), NULL) == OAKENGINE_OK); - assert(ts == 10 && strcmp(name, "Intro") == 0); - assert(oakengine_sequence_marker_at(seq, 1, &ts, name, sizeof(name), NULL) == + EXPECT_TRUE(ts == 10 && strcmp(name, "Intro") == 0); + EXPECT_TRUE(oakengine_sequence_marker_at(seq, 1, &ts, name, sizeof(name), NULL) == OAKENGINE_OK); - assert(ts == 30 && strcmp(name, "Chapter 1") == 0); - assert(oakengine_sequence_marker_at(seq, 2, &ts, name, sizeof(name), NULL) == + EXPECT_TRUE(ts == 30 && strcmp(name, "Chapter 1") == 0); + EXPECT_TRUE(oakengine_sequence_marker_at(seq, 2, &ts, name, sizeof(name), NULL) == OAKENGINE_E_NOT_FOUND); // Rename with undo/redo. - assert(oakengine_sequence_marker_rename(seq, 30, "Chapter 2") == + EXPECT_TRUE(oakengine_sequence_marker_rename(seq, 30, "Chapter 2") == OAKENGINE_OK); - assert(oakengine_sequence_marker_at(seq, 1, &ts, name, sizeof(name), NULL) == + EXPECT_TRUE(oakengine_sequence_marker_at(seq, 1, &ts, name, sizeof(name), NULL) == OAKENGINE_OK); - assert(strcmp(name, "Chapter 2") == 0); - assert(oakengine_sequence_marker_rename(seq, 77, "nope") == + EXPECT_TRUE(strcmp(name, "Chapter 2") == 0); + EXPECT_TRUE(oakengine_sequence_marker_rename(seq, 77, "nope") == OAKENGINE_E_NOT_FOUND); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_sequence_marker_at(seq, 1, &ts, name, sizeof(name), NULL) == + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_sequence_marker_at(seq, 1, &ts, name, sizeof(name), NULL) == OAKENGINE_OK); - assert(strcmp(name, "Chapter 1") == 0); - assert(oakengine_project_redo(project) == OAKENGINE_OK); - assert(oakengine_sequence_marker_at(seq, 1, &ts, name, sizeof(name), NULL) == + EXPECT_TRUE(strcmp(name, "Chapter 1") == 0); + EXPECT_TRUE(oakengine_project_redo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_sequence_marker_at(seq, 1, &ts, name, sizeof(name), NULL) == OAKENGINE_OK); - assert(strcmp(name, "Chapter 2") == 0); + EXPECT_TRUE(strcmp(name, "Chapter 2") == 0); // Remove with undo; removing again reports not found. - assert(oakengine_sequence_marker_remove(seq, 10) == OAKENGINE_OK); - assert(oakengine_sequence_marker_count(seq) == 1); - assert(oakengine_sequence_marker_remove(seq, 10) == + EXPECT_TRUE(oakengine_sequence_marker_remove(seq, 10) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_sequence_marker_count(seq) == 1); + EXPECT_TRUE(oakengine_sequence_marker_remove(seq, 10) == OAKENGINE_E_NOT_FOUND); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_sequence_marker_count(seq) == 2); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_sequence_marker_count(seq) == 2); // NULL safety. - assert(oakengine_sequence_marker_add(NULL, 0, "x") == + EXPECT_TRUE(oakengine_sequence_marker_add(NULL, 0, "x") == OAKENGINE_E_INVALID); - assert(oakengine_sequence_marker_remove(NULL, 0) == + EXPECT_TRUE(oakengine_sequence_marker_remove(NULL, 0) == OAKENGINE_E_INVALID); - assert(oakengine_sequence_marker_rename(NULL, 0, "x") == + EXPECT_TRUE(oakengine_sequence_marker_rename(NULL, 0, "x") == OAKENGINE_E_INVALID); - assert(oakengine_sequence_remove_track(NULL, OAKENGINE_TRACK_TYPE_VIDEO, + EXPECT_TRUE(oakengine_sequence_remove_track(NULL, OAKENGINE_TRACK_TYPE_VIDEO, 0) == OAKENGINE_E_INVALID); oakengine_project_free(project); @@ -646,133 +647,133 @@ static void test_markers(void) static void test_sequence_params(void) { OakEngineProject *project = oakengine_project_create(); - assert(project != NULL); - assert(oakengine_project_new(project) == OAKENGINE_OK); + EXPECT_TRUE(project != NULL); + EXPECT_TRUE(oakengine_project_new(project) == OAKENGINE_OK); OakEngineSequence *seq = oakengine_sequence_new(project, "Params"); - assert(seq != NULL); + EXPECT_TRUE(seq != NULL); int w = 0, h = 0, fn = 0, fd = 0, pn = 0, pd = 0, il = -1, fmt = -1, div = 0; - assert(oakengine_sequence_get_video_params_ex(seq, &w, &h, &fn, &fd, &pn, + EXPECT_TRUE(oakengine_sequence_get_video_params_ex(seq, &w, &h, &fn, &fd, &pn, &pd, &il, &fmt, &div) == OAKENGINE_OK); const int base_w = w, base_h = h, base_div = div; - assert(base_w > 0 && base_h > 0 && fn > 0 && fd > 0 && div >= 1); - assert(oakengine_sequence_get_video_params_ex(NULL, &w, &h, &fn, &fd, + EXPECT_TRUE(base_w > 0 && base_h > 0 && fn > 0 && fd > 0 && div >= 1); + EXPECT_TRUE(oakengine_sequence_get_video_params_ex(NULL, &w, &h, &fn, &fd, &pn, &pd, &il, &fmt, &div) == OAKENGINE_E_INVALID); // Full video parameter write (f32 = 4, bottom-first = 2) + readback. - assert(oakengine_sequence_set_video_params(seq, 1280, 720, 24, 1, 1, 1, 2, + EXPECT_TRUE(oakengine_sequence_set_video_params(seq, 1280, 720, 24, 1, 1, 1, 2, 4, 1) == OAKENGINE_OK); - assert(oakengine_sequence_get_video_params_ex(seq, &w, &h, &fn, &fd, &pn, + EXPECT_TRUE(oakengine_sequence_get_video_params_ex(seq, &w, &h, &fn, &fd, &pn, &pd, &il, &fmt, &div) == OAKENGINE_OK); - assert(w == 1280 && h == 720 && fn == 24 && fd == 1); - assert(pn == 1 && pd == 1 && il == 2 && fmt == 4 && div == base_div); + EXPECT_TRUE(w == 1280 && h == 720 && fn == 24 && fd == 1); + EXPECT_TRUE(pn == 1 && pd == 1 && il == 2 && fmt == 4 && div == base_div); int gn = 0, gd = 0; - assert(oakengine_sequence_get_frame_rate(seq, &gn, &gd) == OAKENGINE_OK); - assert(gn == 24 && gd == 1); + EXPECT_TRUE(oakengine_sequence_get_frame_rate(seq, &gn, &gd) == OAKENGINE_OK); + EXPECT_TRUE(gn == 24 && gd == 1); // Partial update: -1 leaves the other fields unchanged. - assert(oakengine_sequence_set_video_params(seq, 640, -1, -1, -1, -1, -1, + EXPECT_TRUE(oakengine_sequence_set_video_params(seq, 640, -1, -1, -1, -1, -1, -1, -1, 1) == OAKENGINE_OK); - assert(oakengine_sequence_get_video_params_ex(seq, &w, &h, &fn, &fd, &pn, + EXPECT_TRUE(oakengine_sequence_get_video_params_ex(seq, &w, &h, &fn, &fd, &pn, &pd, &il, &fmt, &div) == OAKENGINE_OK); - assert(w == 640 && h == 720 && fn == 24 && il == 2); + EXPECT_TRUE(w == 640 && h == 720 && fn == 24 && il == 2); // Invalid values: zero size, half a rational pair, out-of-range enum. - assert(oakengine_sequence_set_video_params(seq, 0, 720, -1, -1, -1, -1, + EXPECT_TRUE(oakengine_sequence_set_video_params(seq, 0, 720, -1, -1, -1, -1, -1, -1, 1) == OAKENGINE_E_INVALID); - assert(oakengine_sequence_set_video_params(seq, -1, -1, 24, -1, -1, -1, + EXPECT_TRUE(oakengine_sequence_set_video_params(seq, -1, -1, 24, -1, -1, -1, -1, -1, 1) == OAKENGINE_E_INVALID); - assert(oakengine_sequence_set_video_params(seq, -1, -1, -1, -1, -1, -1, 3, + EXPECT_TRUE(oakengine_sequence_set_video_params(seq, -1, -1, -1, -1, -1, -1, 3, -1, 1) == OAKENGINE_E_INVALID); - assert(oakengine_sequence_set_video_params(seq, -1, -1, -1, -1, -1, -1, + EXPECT_TRUE(oakengine_sequence_set_video_params(seq, -1, -1, -1, -1, -1, -1, -1, 5, 1) == OAKENGINE_E_INVALID); - assert(oakengine_sequence_set_video_params(NULL, 1, 1, -1, -1, -1, -1, -1, + EXPECT_TRUE(oakengine_sequence_set_video_params(NULL, 1, 1, -1, -1, -1, -1, -1, -1, 1) == OAKENGINE_E_INVALID); // Undo restores step by step (partial write, then full write). - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_sequence_get_video_params_ex(seq, &w, &h, &fn, &fd, &pn, + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_sequence_get_video_params_ex(seq, &w, &h, &fn, &fd, &pn, &pd, &il, &fmt, &div) == OAKENGINE_OK); - assert(w == 1280 && h == 720); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_sequence_get_video_params_ex(seq, &w, &h, &fn, &fd, &pn, + EXPECT_TRUE(w == 1280 && h == 720); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_sequence_get_video_params_ex(seq, &w, &h, &fn, &fd, &pn, &pd, &il, &fmt, &div) == OAKENGINE_OK); - assert(w == base_w && h == base_h); + EXPECT_TRUE(w == base_w && h == base_h); // Audio round trip; 0 / <= 0 leaves the field unchanged. int sr = 0; uint64_t layout = 0; - assert(oakengine_sequence_get_audio_params(seq, &sr, &layout) == + EXPECT_TRUE(oakengine_sequence_get_audio_params(seq, &sr, &layout) == OAKENGINE_OK); - assert(sr > 0 && layout != 0); + EXPECT_TRUE(sr > 0 && layout != 0); const int base_sr = sr; const uint64_t base_layout = layout; - assert(oakengine_sequence_set_audio_params(seq, 44100, 3, 1) == + EXPECT_TRUE(oakengine_sequence_set_audio_params(seq, 44100, 3, 1) == OAKENGINE_OK); - assert(oakengine_sequence_get_audio_params(seq, &sr, &layout) == + EXPECT_TRUE(oakengine_sequence_get_audio_params(seq, &sr, &layout) == OAKENGINE_OK); - assert(sr == 44100 && layout == 3); - assert(oakengine_sequence_set_audio_params(seq, 48000, 0, 1) == + EXPECT_TRUE(sr == 44100 && layout == 3); + EXPECT_TRUE(oakengine_sequence_set_audio_params(seq, 48000, 0, 1) == OAKENGINE_OK); - assert(oakengine_sequence_get_audio_params(seq, &sr, &layout) == + EXPECT_TRUE(oakengine_sequence_get_audio_params(seq, &sr, &layout) == OAKENGINE_OK); - assert(sr == 48000 && layout == 3); - assert(oakengine_sequence_set_audio_params(NULL, 48000, 3, 1) == + EXPECT_TRUE(sr == 48000 && layout == 3); + EXPECT_TRUE(oakengine_sequence_set_audio_params(NULL, 48000, 3, 1) == OAKENGINE_E_INVALID); - assert(oakengine_sequence_get_audio_params(NULL, &sr, &layout) == + EXPECT_TRUE(oakengine_sequence_get_audio_params(NULL, &sr, &layout) == OAKENGINE_E_INVALID); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_sequence_get_audio_params(seq, &sr, &layout) == + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_sequence_get_audio_params(seq, &sr, &layout) == OAKENGINE_OK); - assert(sr == base_sr && layout == base_layout); + EXPECT_TRUE(sr == base_sr && layout == base_layout); // Preview divider; the other video params stay untouched. - assert(oakengine_sequence_get_preview_divider(seq) == base_div); - assert(oakengine_sequence_set_preview_divider(seq, 4, 1) == OAKENGINE_OK); - assert(oakengine_sequence_get_preview_divider(seq) == 4); - assert(oakengine_sequence_set_preview_divider(seq, 0, 1) == + EXPECT_TRUE(oakengine_sequence_get_preview_divider(seq) == base_div); + EXPECT_TRUE(oakengine_sequence_set_preview_divider(seq, 4, 1) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_sequence_get_preview_divider(seq) == 4); + EXPECT_TRUE(oakengine_sequence_set_preview_divider(seq, 0, 1) == OAKENGINE_E_INVALID); - assert(oakengine_sequence_set_preview_divider(NULL, 1, 1) == + EXPECT_TRUE(oakengine_sequence_set_preview_divider(NULL, 1, 1) == OAKENGINE_E_INVALID); - assert(oakengine_sequence_get_preview_divider(NULL) == 0); - assert(oakengine_sequence_get_video_params_ex(seq, &w, &h, &fn, &fd, &pn, + EXPECT_TRUE(oakengine_sequence_get_preview_divider(NULL) == 0); + EXPECT_TRUE(oakengine_sequence_get_video_params_ex(seq, &w, &h, &fn, &fd, &pn, &pd, &il, &fmt, &div) == OAKENGINE_OK); - assert(w == base_w && h == base_h && div == 4); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_sequence_get_preview_divider(seq) == base_div); + EXPECT_TRUE(w == base_w && h == base_h && div == 4); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_sequence_get_preview_divider(seq) == base_div); // Auto-cache flag: the engine accessors are stubs (read always 0, write // ignored), so there is nothing to undo here. - assert(oakengine_sequence_get_video_auto_cache(seq) == 0); - assert(oakengine_sequence_set_video_auto_cache(seq, 1, 1) == OAKENGINE_OK); - assert(oakengine_sequence_get_video_auto_cache(seq) == 0); - assert(oakengine_sequence_get_video_auto_cache(NULL) == 0); - assert(oakengine_sequence_set_video_auto_cache(NULL, 1, 1) == + EXPECT_TRUE(oakengine_sequence_get_video_auto_cache(seq) == 0); + EXPECT_TRUE(oakengine_sequence_set_video_auto_cache(seq, 1, 1) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_sequence_get_video_auto_cache(seq) == 0); + EXPECT_TRUE(oakengine_sequence_get_video_auto_cache(NULL) == 0); + EXPECT_TRUE(oakengine_sequence_set_video_auto_cache(NULL, 1, 1) == OAKENGINE_E_INVALID); // Label through the node family with the undoable flag. - assert(oakengine_node_set_label_ex((OakEngineNode *)seq, "Renamed", 1) == + EXPECT_TRUE(oakengine_node_set_label_ex((OakEngineNode *)seq, "Renamed", 1) == OAKENGINE_OK); char name[64]; - assert(oakengine_sequence_name(seq, name, sizeof(name)) > 0); - assert(strcmp(name, "Renamed") == 0); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_sequence_name(seq, name, sizeof(name)) > 0); - assert(strcmp(name, "Params") == 0); + EXPECT_TRUE(oakengine_sequence_name(seq, name, sizeof(name)) > 0); + EXPECT_TRUE(strcmp(name, "Renamed") == 0); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_sequence_name(seq, name, sizeof(name)) > 0); + EXPECT_TRUE(strcmp(name, "Params") == 0); oakengine_project_free(project); @@ -780,49 +781,49 @@ static void test_sequence_params(void) // the creation is undone first so the stack is empty (the node stays // alive under its creation command). OakEngineProject *p2 = oakengine_project_create(); - assert(p2 != NULL); - assert(oakengine_project_new(p2) == OAKENGINE_OK); + EXPECT_TRUE(p2 != NULL); + EXPECT_TRUE(oakengine_project_new(p2) == OAKENGINE_OK); OakEngineSequence *s2 = oakengine_sequence_new(p2, "Direct"); - assert(s2 != NULL); - assert(oakengine_project_undo(p2) == OAKENGINE_OK); - assert(oakengine_project_can_undo(p2) == 0); - assert(oakengine_sequence_set_video_params(s2, 800, 600, -1, -1, -1, -1, + EXPECT_TRUE(s2 != NULL); + EXPECT_TRUE(oakengine_project_undo(p2) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_can_undo(p2) == 0); + EXPECT_TRUE(oakengine_sequence_set_video_params(s2, 800, 600, -1, -1, -1, -1, -1, -1, 0) == OAKENGINE_OK); - assert(oakengine_sequence_get_video_params_ex(s2, &w, &h, &fn, &fd, &pn, + EXPECT_TRUE(oakengine_sequence_get_video_params_ex(s2, &w, &h, &fn, &fd, &pn, &pd, &il, &fmt, &div) == OAKENGINE_OK); - assert(w == 800 && h == 600); - assert(oakengine_project_can_undo(p2) == 0); - assert(oakengine_sequence_set_audio_params(s2, 22050, 0, 0) == + EXPECT_TRUE(w == 800 && h == 600); + EXPECT_TRUE(oakengine_project_can_undo(p2) == 0); + EXPECT_TRUE(oakengine_sequence_set_audio_params(s2, 22050, 0, 0) == OAKENGINE_OK); - assert(oakengine_sequence_get_audio_params(s2, &sr, &layout) == + EXPECT_TRUE(oakengine_sequence_get_audio_params(s2, &sr, &layout) == OAKENGINE_OK); - assert(sr == 22050); - assert(oakengine_project_can_undo(p2) == 0); - assert(oakengine_sequence_set_preview_divider(s2, 2, 0) == OAKENGINE_OK); - assert(oakengine_sequence_get_preview_divider(s2) == 2); - assert(oakengine_project_can_undo(p2) == 0); - assert(oakengine_node_set_label_ex((OakEngineNode *)s2, "NoUndo", 0) == + EXPECT_TRUE(sr == 22050); + EXPECT_TRUE(oakengine_project_can_undo(p2) == 0); + EXPECT_TRUE(oakengine_sequence_set_preview_divider(s2, 2, 0) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_sequence_get_preview_divider(s2) == 2); + EXPECT_TRUE(oakengine_project_can_undo(p2) == 0); + EXPECT_TRUE(oakengine_node_set_label_ex((OakEngineNode *)s2, "NoUndo", 0) == OAKENGINE_OK); - assert(oakengine_sequence_name(s2, name, sizeof(name)) > 0); - assert(strcmp(name, "NoUndo") == 0); - assert(oakengine_project_can_undo(p2) == 0); + EXPECT_TRUE(oakengine_sequence_name(s2, name, sizeof(name)) > 0); + EXPECT_TRUE(strcmp(name, "NoUndo") == 0); + EXPECT_TRUE(oakengine_project_can_undo(p2) == 0); oakengine_project_free(p2); } static void test_batch_editing(const char *media_path) { OakEngineProject *project = oakengine_project_create(); - assert(project != NULL); - assert(oakengine_project_new(project) == OAKENGINE_OK); + EXPECT_TRUE(project != NULL); + EXPECT_TRUE(oakengine_project_new(project) == OAKENGINE_OK); OakEngineSequence *seq = oakengine_sequence_new(project, "Batch"); - assert(seq != NULL); - assert(oakengine_sequence_add_track(seq, OAKENGINE_TRACK_TYPE_VIDEO) == + EXPECT_TRUE(seq != NULL); + EXPECT_TRUE(oakengine_sequence_add_track(seq, OAKENGINE_TRACK_TYPE_VIDEO) == 0); OakEngineFootage *footage = oakengine_project_import_footage(project, media_path); - assert(footage != NULL); + EXPECT_TRUE(footage != NULL); int64_t in = -1, out = -1; @@ -831,133 +832,133 @@ static void test_batch_editing(const char *media_path) seq, footage, OAKENGINE_TRACK_TYPE_VIDEO, 0, 0, 100, 0); OakEngineClip *c1 = oakengine_sequence_add_footage_clip( seq, footage, OAKENGINE_TRACK_TYPE_VIDEO, 0, 100, 160, 0); - assert(c0 != NULL && c1 != NULL); - assert(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, + EXPECT_TRUE(c0 != NULL && c1 != NULL); + EXPECT_TRUE(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0) == 2); // split_clips at 50: the first clip splits in two. { OakEngineClip *arr[1] = { c0 }; - assert(oakengine_sequence_split_clips(seq, arr, 1, 50) == + EXPECT_TRUE(oakengine_sequence_split_clips(seq, arr, 1, 50) == OAKENGINE_OK); } - assert(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, + EXPECT_TRUE(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0) == 3); OakEngineClip *left = oakengine_sequence_clip_at( seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 0); OakEngineClip *right = oakengine_sequence_clip_at( seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 1); - assert(oakengine_clip_get_range(left, &in, &out, NULL) == OAKENGINE_OK); - assert(in == 0 && out == 50); - assert(oakengine_clip_get_range(right, &in, &out, NULL) == OAKENGINE_OK); - assert(in == 50 && out == 100); + EXPECT_TRUE(oakengine_clip_get_range(left, &in, &out, NULL) == OAKENGINE_OK); + EXPECT_TRUE(in == 0 && out == 50); + EXPECT_TRUE(oakengine_clip_get_range(right, &in, &out, NULL) == OAKENGINE_OK); + EXPECT_TRUE(in == 50 && out == 100); // Nothing spans 200; invalid arrays are rejected. { OakEngineClip *arr[2] = { left, right }; - assert(oakengine_sequence_split_clips(seq, arr, 2, 200) == + EXPECT_TRUE(oakengine_sequence_split_clips(seq, arr, 2, 200) == OAKENGINE_E_NOT_FOUND); - assert(oakengine_sequence_split_clips(seq, NULL, 1, 50) == + EXPECT_TRUE(oakengine_sequence_split_clips(seq, NULL, 1, 50) == OAKENGINE_E_INVALID); - assert(oakengine_sequence_split_clips(seq, arr, 0, 50) == + EXPECT_TRUE(oakengine_sequence_split_clips(seq, arr, 0, 50) == OAKENGINE_E_INVALID); - assert(oakengine_sequence_split_clips(NULL, arr, 1, 50) == + EXPECT_TRUE(oakengine_sequence_split_clips(NULL, arr, 1, 50) == OAKENGINE_E_INVALID); } // Undo the split. - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0) == 2); // delete_clips without ripple: a gap is left, the second clip stays. int rippled = -1; { OakEngineClip *arr[1] = { c0 }; - assert(oakengine_sequence_delete_clips(seq, arr, 1, 0, NULL, 0, + EXPECT_TRUE(oakengine_sequence_delete_clips(seq, arr, 1, 0, NULL, 0, &rippled) == OAKENGINE_OK); } - assert(rippled == 0); - assert(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, + EXPECT_TRUE(rippled == 0); + EXPECT_TRUE(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0) == 1); - assert(oakengine_clip_get_range(c1, &in, &out, NULL) == OAKENGINE_OK); - assert(in == 100 && out == 160); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, + EXPECT_TRUE(oakengine_clip_get_range(c1, &in, &out, NULL) == OAKENGINE_OK); + EXPECT_TRUE(in == 100 && out == 160); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0) == 2); // delete_clips with ripple (auto ranges): the second clip shifts left. rippled = -1; { OakEngineClip *arr[1] = { c0 }; - assert(oakengine_sequence_delete_clips(seq, arr, 1, 1, NULL, 0, + EXPECT_TRUE(oakengine_sequence_delete_clips(seq, arr, 1, 1, NULL, 0, &rippled) == OAKENGINE_OK); } - assert(rippled == 1); - assert(oakengine_clip_get_range(c1, &in, &out, NULL) == OAKENGINE_OK); - assert(in == 0 && out == 60); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_clip_get_range(c1, &in, &out, NULL) == OAKENGINE_OK); - assert(in == 100 && out == 160); + EXPECT_TRUE(rippled == 1); + EXPECT_TRUE(oakengine_clip_get_range(c1, &in, &out, NULL) == OAKENGINE_OK); + EXPECT_TRUE(in == 0 && out == 60); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_clip_get_range(c1, &in, &out, NULL) == OAKENGINE_OK); + EXPECT_TRUE(in == 100 && out == 160); // delete_clips with an explicit ripple range: same shift. rippled = -1; { OakEngineClip *arr[1] = { c0 }; const int64_t ranges[4] = { OAKENGINE_TRACK_TYPE_VIDEO, 0, 0, 100 }; - assert(oakengine_sequence_delete_clips(seq, arr, 1, 1, ranges, 1, + EXPECT_TRUE(oakengine_sequence_delete_clips(seq, arr, 1, 1, ranges, 1, &rippled) == OAKENGINE_OK); } - assert(rippled == 1); - assert(oakengine_clip_get_range(c1, &in, &out, NULL) == OAKENGINE_OK); - assert(in == 0 && out == 60); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, + EXPECT_TRUE(rippled == 1); + EXPECT_TRUE(oakengine_clip_get_range(c1, &in, &out, NULL) == OAKENGINE_OK); + EXPECT_TRUE(in == 0 && out == 60); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0) == 2); // A bad explicit range coordinate is rejected without side effects. { OakEngineClip *arr[1] = { c0 }; const int64_t bad[4] = { OAKENGINE_TRACK_TYPE_VIDEO, 9, 0, 100 }; - assert(oakengine_sequence_delete_clips(seq, arr, 1, 1, bad, 1, + EXPECT_TRUE(oakengine_sequence_delete_clips(seq, arr, 1, 1, bad, 1, NULL) == OAKENGINE_E_NOT_FOUND); } - assert(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, + EXPECT_TRUE(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0) == 2); - assert(oakengine_sequence_delete_clips(NULL, NULL, 0, 0, NULL, 0, + EXPECT_TRUE(oakengine_sequence_delete_clips(NULL, NULL, 0, 0, NULL, 0, NULL) == OAKENGINE_E_INVALID); // ripple_delete_range over [0, 100): the area is removed from every // track and the following content shifts left. - assert(oakengine_sequence_ripple_delete_range(seq, 0, 100) == + EXPECT_TRUE(oakengine_sequence_ripple_delete_range(seq, 0, 100) == OAKENGINE_OK); - assert(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, + EXPECT_TRUE(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0) == 1); OakEngineClip *remaining = oakengine_sequence_clip_at( seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 0); - assert(oakengine_clip_get_range(remaining, &in, &out, NULL) == + EXPECT_TRUE(oakengine_clip_get_range(remaining, &in, &out, NULL) == OAKENGINE_OK); - assert(in == 0 && out == 60); - assert(oakengine_sequence_ripple_delete_range(seq, 100, 100) == + EXPECT_TRUE(in == 0 && out == 60); + EXPECT_TRUE(oakengine_sequence_ripple_delete_range(seq, 100, 100) == OAKENGINE_E_INVALID); - assert(oakengine_sequence_ripple_delete_range(seq, -1, 5) == + EXPECT_TRUE(oakengine_sequence_ripple_delete_range(seq, -1, 5) == OAKENGINE_E_INVALID); - assert(oakengine_sequence_ripple_delete_range(NULL, 0, 1) == + EXPECT_TRUE(oakengine_sequence_ripple_delete_range(NULL, 0, 1) == OAKENGINE_E_INVALID); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0) == 2); // Marker with an explicit color. - assert(oakengine_sequence_marker_add_ex(seq, 10, "colored", 5) == + EXPECT_TRUE(oakengine_sequence_marker_add_ex(seq, 10, "colored", 5) == OAKENGINE_OK); int color = -1; int64_t ts = -1; - assert(oakengine_sequence_marker_at(seq, 0, &ts, NULL, 0, &color) == + EXPECT_TRUE(oakengine_sequence_marker_at(seq, 0, &ts, NULL, 0, &color) == OAKENGINE_OK); - assert(ts == 10 && color == 5); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_sequence_marker_count(seq) == 0); + EXPECT_TRUE(ts == 10 && color == 5); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_sequence_marker_count(seq) == 0); oakengine_footage_free(footage); oakengine_project_free(project); @@ -966,163 +967,163 @@ static void test_batch_editing(const char *media_path) static void test_batch_editing_round2(const char *media_path) { OakEngineProject *project = oakengine_project_create(); - assert(project != NULL); - assert(oakengine_project_new(project) == OAKENGINE_OK); + EXPECT_TRUE(project != NULL); + EXPECT_TRUE(oakengine_project_new(project) == OAKENGINE_OK); OakEngineSequence *seq = oakengine_sequence_new(project, "Batch2"); - assert(seq != NULL); - assert(oakengine_sequence_add_track(seq, OAKENGINE_TRACK_TYPE_VIDEO) == + EXPECT_TRUE(seq != NULL); + EXPECT_TRUE(oakengine_sequence_add_track(seq, OAKENGINE_TRACK_TYPE_VIDEO) == 0); OakEngineFootage *footage = oakengine_project_import_footage(project, media_path); - assert(footage != NULL); + EXPECT_TRUE(footage != NULL); int64_t in = -1, out = -1; OakEngineClip *c0 = oakengine_sequence_add_footage_clip( seq, footage, OAKENGINE_TRACK_TYPE_VIDEO, 0, 0, 100, 0); - assert(c0 != NULL); + EXPECT_TRUE(c0 != NULL); // trim_clips_to: out-edge to 60, then in-edge to 40 (one clip each). - assert(oakengine_sequence_trim_clips_to(seq, 1, 60) == 1); - assert(oakengine_clip_get_range(c0, &in, &out, NULL) == OAKENGINE_OK); - assert(in == 0 && out == 60); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_clip_get_range(c0, &in, &out, NULL) == OAKENGINE_OK); - assert(in == 0 && out == 100); - assert(oakengine_sequence_trim_clips_to(seq, 0, 40) == 1); - assert(oakengine_clip_get_range(c0, &in, &out, NULL) == OAKENGINE_OK); - assert(in == 40 && out == 100); - assert(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_sequence_trim_clips_to(seq, 1, 60) == 1); + EXPECT_TRUE(oakengine_clip_get_range(c0, &in, &out, NULL) == OAKENGINE_OK); + EXPECT_TRUE(in == 0 && out == 60); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_clip_get_range(c0, &in, &out, NULL) == OAKENGINE_OK); + EXPECT_TRUE(in == 0 && out == 100); + EXPECT_TRUE(oakengine_sequence_trim_clips_to(seq, 0, 40) == 1); + EXPECT_TRUE(oakengine_clip_get_range(c0, &in, &out, NULL) == OAKENGINE_OK); + EXPECT_TRUE(in == 40 && out == 100); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); // Already at the point: nothing qualifies, 0 and no command. - assert(oakengine_sequence_trim_clips_to(seq, 1, 100) == 0); + EXPECT_TRUE(oakengine_sequence_trim_clips_to(seq, 1, 100) == 0); // Past the content there is no block under the point either (the // application's edit_to only shortens blocks containing the point). - assert(oakengine_sequence_trim_clips_to(seq, 1, 200) == 0); - assert(oakengine_sequence_trim_clips_to(seq, 0, 200) == 0); + EXPECT_TRUE(oakengine_sequence_trim_clips_to(seq, 1, 200) == 0); + EXPECT_TRUE(oakengine_sequence_trim_clips_to(seq, 0, 200) == 0); // Invalid arguments. - assert(oakengine_sequence_trim_clips_to(seq, 2, 60) == + EXPECT_TRUE(oakengine_sequence_trim_clips_to(seq, 2, 60) == OAKENGINE_E_INVALID); - assert(oakengine_sequence_trim_clips_to(seq, 1, -1) == + EXPECT_TRUE(oakengine_sequence_trim_clips_to(seq, 1, -1) == OAKENGINE_E_INVALID); - assert(oakengine_sequence_trim_clips_to(NULL, 1, 60) == + EXPECT_TRUE(oakengine_sequence_trim_clips_to(NULL, 1, 60) == OAKENGINE_E_INVALID); - assert(oakengine_clip_get_range(c0, &in, &out, NULL) == OAKENGINE_OK); - assert(in == 0 && out == 100); + EXPECT_TRUE(oakengine_clip_get_range(c0, &in, &out, NULL) == OAKENGINE_OK); + EXPECT_TRUE(in == 0 && out == 100); // ripple_delete_in_to_out (ripple): area removed, workarea disabled, // one undo entry restores everything including the workarea. - assert(oakengine_sequence_set_workarea(seq, 1, 20, 80) == OAKENGINE_OK); - assert(oakengine_sequence_workarea_is_enabled(seq) == 1); - assert(oakengine_sequence_ripple_delete_in_to_out(seq, 1, 20, 80) == + EXPECT_TRUE(oakengine_sequence_set_workarea(seq, 1, 20, 80) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_sequence_workarea_is_enabled(seq) == 1); + EXPECT_TRUE(oakengine_sequence_ripple_delete_in_to_out(seq, 1, 20, 80) == OAKENGINE_OK); - assert(oakengine_sequence_workarea_is_enabled(seq) == 0); - assert(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, + EXPECT_TRUE(oakengine_sequence_workarea_is_enabled(seq) == 0); + EXPECT_TRUE(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0) == 2); OakEngineClip *piece0 = oakengine_sequence_clip_at( seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 0); OakEngineClip *piece1 = oakengine_sequence_clip_at( seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 1); - assert(oakengine_clip_get_range(piece0, &in, &out, NULL) == + EXPECT_TRUE(oakengine_clip_get_range(piece0, &in, &out, NULL) == OAKENGINE_OK); - assert(in == 0 && out == 20); - assert(oakengine_clip_get_range(piece1, &in, &out, NULL) == + EXPECT_TRUE(in == 0 && out == 20); + EXPECT_TRUE(oakengine_clip_get_range(piece1, &in, &out, NULL) == OAKENGINE_OK); - assert(in == 20 && out == 40); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_sequence_workarea_is_enabled(seq) == 1); - assert(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, + EXPECT_TRUE(in == 20 && out == 40); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_sequence_workarea_is_enabled(seq) == 1); + EXPECT_TRUE(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0) == 1); - assert(oakengine_clip_get_range(c0, &in, &out, NULL) == OAKENGINE_OK); - assert(in == 0 && out == 100); + EXPECT_TRUE(oakengine_clip_get_range(c0, &in, &out, NULL) == OAKENGINE_OK); + EXPECT_TRUE(in == 0 && out == 100); // ripple_delete_in_to_out (no ripple): a gap fills the area, later // content shifts right by the range length. - assert(oakengine_sequence_ripple_delete_in_to_out(seq, 0, 20, 80) == + EXPECT_TRUE(oakengine_sequence_ripple_delete_in_to_out(seq, 0, 20, 80) == OAKENGINE_OK); - assert(oakengine_sequence_workarea_is_enabled(seq) == 0); - assert(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, + EXPECT_TRUE(oakengine_sequence_workarea_is_enabled(seq) == 0); + EXPECT_TRUE(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0) == 2); piece0 = oakengine_sequence_clip_at(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 0); piece1 = oakengine_sequence_clip_at(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 1); - assert(oakengine_clip_get_range(piece0, &in, &out, NULL) == + EXPECT_TRUE(oakengine_clip_get_range(piece0, &in, &out, NULL) == OAKENGINE_OK); - assert(in == 0 && out == 20); - assert(oakengine_clip_get_range(piece1, &in, &out, NULL) == + EXPECT_TRUE(in == 0 && out == 20); + EXPECT_TRUE(oakengine_clip_get_range(piece1, &in, &out, NULL) == OAKENGINE_OK); - assert(in == 80 && out == 100); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, + EXPECT_TRUE(in == 80 && out == 100); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0) == 1); // Workarea disabled: rejected; bad range: invalid (range is validated // before the workarea state). - assert(oakengine_sequence_set_workarea(seq, 0, 20, 80) == OAKENGINE_OK); - assert(oakengine_sequence_ripple_delete_in_to_out(seq, 1, 20, 80) == + EXPECT_TRUE(oakengine_sequence_set_workarea(seq, 0, 20, 80) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_sequence_ripple_delete_in_to_out(seq, 1, 20, 80) == OAKENGINE_E_STATE); - assert(oakengine_sequence_ripple_delete_in_to_out(seq, 1, 80, 20) == + EXPECT_TRUE(oakengine_sequence_ripple_delete_in_to_out(seq, 1, 80, 20) == OAKENGINE_E_INVALID); - assert(oakengine_sequence_ripple_delete_in_to_out(NULL, 1, 20, 80) == + EXPECT_TRUE(oakengine_sequence_ripple_delete_in_to_out(NULL, 1, 20, 80) == OAKENGINE_E_INVALID); // delete_empty_tracks: add an empty audio and an empty subtitle track. - assert(oakengine_sequence_add_track(seq, OAKENGINE_TRACK_TYPE_AUDIO) == + EXPECT_TRUE(oakengine_sequence_add_track(seq, OAKENGINE_TRACK_TYPE_AUDIO) == 0); - assert(oakengine_sequence_add_track(seq, OAKENGINE_TRACK_TYPE_SUBTITLE) == + EXPECT_TRUE(oakengine_sequence_add_track(seq, OAKENGINE_TRACK_TYPE_SUBTITLE) == 0); int v = 0, a = 0, s = 0; - assert(oakengine_sequence_track_count(seq, &v, &a, &s) == OAKENGINE_OK); - assert(v == 1 && a == 1 && s == 1); + EXPECT_TRUE(oakengine_sequence_track_count(seq, &v, &a, &s) == OAKENGINE_OK); + EXPECT_TRUE(v == 1 && a == 1 && s == 1); // Type-filtered purge first: only the audio track goes. - assert(oakengine_sequence_delete_empty_tracks( + EXPECT_TRUE(oakengine_sequence_delete_empty_tracks( seq, OAKENGINE_TRACK_TYPE_AUDIO) == 1); - assert(oakengine_sequence_track_count(seq, &v, &a, &s) == OAKENGINE_OK); - assert(v == 1 && a == 0 && s == 1); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_sequence_track_count(seq, &v, &a, &s) == OAKENGINE_OK); - assert(v == 1 && a == 1 && s == 1); + EXPECT_TRUE(oakengine_sequence_track_count(seq, &v, &a, &s) == OAKENGINE_OK); + EXPECT_TRUE(v == 1 && a == 0 && s == 1); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_sequence_track_count(seq, &v, &a, &s) == OAKENGINE_OK); + EXPECT_TRUE(v == 1 && a == 1 && s == 1); // All types at once (the application's behavior). - assert(oakengine_sequence_delete_empty_tracks(seq, -1) == 2); - assert(oakengine_sequence_track_count(seq, &v, &a, &s) == OAKENGINE_OK); - assert(v == 1 && a == 0 && s == 0); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_sequence_track_count(seq, &v, &a, &s) == OAKENGINE_OK); - assert(v == 1 && a == 1 && s == 1); + EXPECT_TRUE(oakengine_sequence_delete_empty_tracks(seq, -1) == 2); + EXPECT_TRUE(oakengine_sequence_track_count(seq, &v, &a, &s) == OAKENGINE_OK); + EXPECT_TRUE(v == 1 && a == 0 && s == 0); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_sequence_track_count(seq, &v, &a, &s) == OAKENGINE_OK); + EXPECT_TRUE(v == 1 && a == 1 && s == 1); // Nothing empty: 0, no command; invalid type rejected. - assert(oakengine_sequence_delete_empty_tracks( + EXPECT_TRUE(oakengine_sequence_delete_empty_tracks( seq, OAKENGINE_TRACK_TYPE_VIDEO) == 0); - assert(oakengine_sequence_delete_empty_tracks(seq, 3) == + EXPECT_TRUE(oakengine_sequence_delete_empty_tracks(seq, 3) == OAKENGINE_E_INVALID); - assert(oakengine_sequence_delete_empty_tracks(NULL, -1) == + EXPECT_TRUE(oakengine_sequence_delete_empty_tracks(NULL, -1) == OAKENGINE_E_INVALID); // marker_remove_many: batch delete by time, one undo entry. - assert(oakengine_sequence_marker_add_ex(seq, 10, "m1", 0) == + EXPECT_TRUE(oakengine_sequence_marker_add_ex(seq, 10, "m1", 0) == OAKENGINE_OK); - assert(oakengine_sequence_marker_add_ex(seq, 20, "m2", 0) == + EXPECT_TRUE(oakengine_sequence_marker_add_ex(seq, 20, "m2", 0) == OAKENGINE_OK); - assert(oakengine_sequence_marker_add_ex(seq, 30, "m3", 0) == + EXPECT_TRUE(oakengine_sequence_marker_add_ex(seq, 30, "m3", 0) == OAKENGINE_OK); - assert(oakengine_sequence_marker_count(seq) == 3); + EXPECT_TRUE(oakengine_sequence_marker_count(seq) == 3); { const int64_t times[2] = { 10, 30 }; - assert(oakengine_sequence_marker_remove_many(seq, times, 2) == 2); + EXPECT_TRUE(oakengine_sequence_marker_remove_many(seq, times, 2) == 2); } - assert(oakengine_sequence_marker_count(seq) == 1); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_sequence_marker_count(seq) == 3); + EXPECT_TRUE(oakengine_sequence_marker_count(seq) == 1); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_sequence_marker_count(seq) == 3); { const int64_t bad[1] = { 99 }; - assert(oakengine_sequence_marker_remove_many(seq, bad, 1) == + EXPECT_TRUE(oakengine_sequence_marker_remove_many(seq, bad, 1) == OAKENGINE_E_NOT_FOUND); } - assert(oakengine_sequence_marker_count(seq) == 3); - assert(oakengine_sequence_marker_remove_many(seq, NULL, 1) == + EXPECT_TRUE(oakengine_sequence_marker_count(seq) == 3); + EXPECT_TRUE(oakengine_sequence_marker_remove_many(seq, NULL, 1) == OAKENGINE_E_INVALID); - assert(oakengine_sequence_marker_remove_many(seq, NULL, 0) == 0); - assert(oakengine_sequence_marker_remove_many(NULL, NULL, 0) == + EXPECT_TRUE(oakengine_sequence_marker_remove_many(seq, NULL, 0) == 0); + EXPECT_TRUE(oakengine_sequence_marker_remove_many(NULL, NULL, 0) == OAKENGINE_E_INVALID); oakengine_footage_free(footage); @@ -1132,15 +1133,15 @@ static void test_batch_editing_round2(const char *media_path) static void test_batch_editing_round3(const char *media_path) { OakEngineProject *project = oakengine_project_create(); - assert(project != NULL); - assert(oakengine_project_new(project) == OAKENGINE_OK); + EXPECT_TRUE(project != NULL); + EXPECT_TRUE(oakengine_project_new(project) == OAKENGINE_OK); OakEngineSequence *seq = oakengine_sequence_new(project, "Batch3"); - assert(seq != NULL); - assert(oakengine_sequence_add_track(seq, OAKENGINE_TRACK_TYPE_VIDEO) == + EXPECT_TRUE(seq != NULL); + EXPECT_TRUE(oakengine_sequence_add_track(seq, OAKENGINE_TRACK_TYPE_VIDEO) == 0); OakEngineFootage *footage = oakengine_project_import_footage(project, media_path); - assert(footage != NULL); + EXPECT_TRUE(footage != NULL); int64_t in = -1, out = -1; @@ -1149,57 +1150,57 @@ static void test_batch_editing_round3(const char *media_path) seq, footage, OAKENGINE_TRACK_TYPE_VIDEO, 0, 0, 60, 0); OakEngineClip *c1 = oakengine_sequence_add_footage_clip( seq, footage, OAKENGINE_TRACK_TYPE_VIDEO, 0, 60, 100, 0); - assert(c0 != NULL && c1 != NULL); + EXPECT_TRUE(c0 != NULL && c1 != NULL); OakEngineClip *two[2] = { c0, c1 }; // toggle_enabled flips each clip in one undoable command. - assert(oakengine_clip_is_enabled(c0) == 1 && + EXPECT_TRUE(oakengine_clip_is_enabled(c0) == 1 && oakengine_clip_is_enabled(c1) == 1); - assert(oakengine_clip_toggle_enabled(two, 2) == 2); - assert(oakengine_clip_is_enabled(c0) == 0 && + EXPECT_TRUE(oakengine_clip_toggle_enabled(two, 2) == 2); + EXPECT_TRUE(oakengine_clip_is_enabled(c0) == 0 && oakengine_clip_is_enabled(c1) == 0); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_clip_is_enabled(c0) == 1 && + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_clip_is_enabled(c0) == 1 && oakengine_clip_is_enabled(c1) == 1); - assert(oakengine_clip_toggle_enabled(NULL, 1) == OAKENGINE_E_INVALID); - assert(oakengine_clip_toggle_enabled(two, 0) == 0); - assert(oakengine_clip_is_enabled(NULL) == 0); + EXPECT_TRUE(oakengine_clip_toggle_enabled(NULL, 1) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_clip_toggle_enabled(two, 0) == 0); + EXPECT_TRUE(oakengine_clip_is_enabled(NULL) == 0); // set_linked: link and unlink are one undoable command each. - assert(oakengine_clip_are_linked(c0, c1) == 0); - assert(oakengine_clip_set_linked(two, 2, 1) == OAKENGINE_OK); - assert(oakengine_clip_are_linked(c0, c1) == 1); - assert(oakengine_clip_set_linked(two, 2, 0) == OAKENGINE_OK); - assert(oakengine_clip_are_linked(c0, c1) == 0); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_clip_are_linked(c0, c1) == 1); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_clip_are_linked(c0, c1) == 0); - assert(oakengine_clip_are_linked(c0, NULL) == 0); - assert(oakengine_clip_set_linked(NULL, 1, 1) == OAKENGINE_E_INVALID); - assert(oakengine_clip_set_linked(two, 0, 1) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_clip_are_linked(c0, c1) == 0); + EXPECT_TRUE(oakengine_clip_set_linked(two, 2, 1) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_clip_are_linked(c0, c1) == 1); + EXPECT_TRUE(oakengine_clip_set_linked(two, 2, 0) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_clip_are_linked(c0, c1) == 0); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_clip_are_linked(c0, c1) == 1); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_clip_are_linked(c0, c1) == 0); + EXPECT_TRUE(oakengine_clip_are_linked(c0, NULL) == 0); + EXPECT_TRUE(oakengine_clip_set_linked(NULL, 1, 1) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_clip_set_linked(two, 0, 1) == OAKENGINE_OK); // add_default_transition: an in-transition before c0, a dual between // the adjacent pair and an out-transition after c1 shrink both clips; // one undo restores the exact ranges. - assert(oakengine_clip_get_range(c0, &in, &out, NULL) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_clip_get_range(c0, &in, &out, NULL) == OAKENGINE_OK); const int64_t c0_in = in, c0_len = out - in; - assert(oakengine_clip_get_range(c1, &in, &out, NULL) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_clip_get_range(c1, &in, &out, NULL) == OAKENGINE_OK); const int64_t c1_len = out - in; - assert(oakengine_sequence_add_default_transition(seq, two, 2) == + EXPECT_TRUE(oakengine_sequence_add_default_transition(seq, two, 2) == OAKENGINE_OK); - assert(oakengine_clip_get_range(c0, &in, &out, NULL) == OAKENGINE_OK); - assert(in > c0_in && out - in < c0_len); - assert(oakengine_clip_get_range(c1, &in, &out, NULL) == OAKENGINE_OK); - assert(out - in < c1_len); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_clip_get_range(c0, &in, &out, NULL) == OAKENGINE_OK); - assert(in == c0_in && out - in == c0_len); - assert(oakengine_clip_get_range(c1, &in, &out, NULL) == OAKENGINE_OK); - assert(out - in == c1_len); - assert(oakengine_sequence_add_default_transition(seq, NULL, 0) == + EXPECT_TRUE(oakengine_clip_get_range(c0, &in, &out, NULL) == OAKENGINE_OK); + EXPECT_TRUE(in > c0_in && out - in < c0_len); + EXPECT_TRUE(oakengine_clip_get_range(c1, &in, &out, NULL) == OAKENGINE_OK); + EXPECT_TRUE(out - in < c1_len); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_clip_get_range(c0, &in, &out, NULL) == OAKENGINE_OK); + EXPECT_TRUE(in == c0_in && out - in == c0_len); + EXPECT_TRUE(oakengine_clip_get_range(c1, &in, &out, NULL) == OAKENGINE_OK); + EXPECT_TRUE(out - in == c1_len); + EXPECT_TRUE(oakengine_sequence_add_default_transition(seq, NULL, 0) == OAKENGINE_OK); - assert(oakengine_sequence_add_default_transition(NULL, two, 2) == + EXPECT_TRUE(oakengine_sequence_add_default_transition(NULL, two, 2) == OAKENGINE_E_INVALID); oakengine_footage_free(footage); @@ -1209,79 +1210,79 @@ static void test_batch_editing_round3(const char *media_path) static void test_sequence_clip(void) { OakEngineProject *project = oakengine_project_create(); - assert(project != NULL); - assert(oakengine_project_new(project) == OAKENGINE_OK); + EXPECT_TRUE(project != NULL); + EXPECT_TRUE(oakengine_project_new(project) == OAKENGINE_OK); OakEngineSequence *seq = oakengine_sequence_new(project, "Outer"); - assert(seq != NULL); - assert(oakengine_sequence_add_track(seq, OAKENGINE_TRACK_TYPE_VIDEO) == + EXPECT_TRUE(seq != NULL); + EXPECT_TRUE(oakengine_sequence_add_track(seq, OAKENGINE_TRACK_TYPE_VIDEO) == 0); OakEngineSequence *nested = oakengine_sequence_new(project, "Nested"); - assert(nested != NULL); + EXPECT_TRUE(nested != NULL); int64_t in = -1, out = -1, media_in = -1; // Place the nested sequence as a clip; undo/redo ride the stack. OakEngineClip *clip = oakengine_sequence_add_sequence_clip( seq, nested, OAKENGINE_TRACK_TYPE_VIDEO, 0, 10, 40, 5); - assert(clip != NULL); - assert(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, + EXPECT_TRUE(clip != NULL); + EXPECT_TRUE(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0) == 1); - assert(oakengine_sequence_clip_at(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, + EXPECT_TRUE(oakengine_sequence_clip_at(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 0) == clip); - assert(oakengine_clip_get_range(clip, &in, &out, &media_in) == + EXPECT_TRUE(oakengine_clip_get_range(clip, &in, &out, &media_in) == OAKENGINE_OK); - assert(in == 10 && out == 40 && media_in == 5); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, + EXPECT_TRUE(in == 10 && out == 40 && media_in == 5); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0) == 0); - assert(oakengine_project_redo(project) == OAKENGINE_OK); - assert(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, + EXPECT_TRUE(oakengine_project_redo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0) == 1); - assert(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); // A sequence cannot nest into itself or into a sequence that // (indirectly) receives it: place Outer into Nested first, then // placing Nested into Outer must be refused, all without side // effects. - assert(oakengine_sequence_add_track(nested, OAKENGINE_TRACK_TYPE_VIDEO) == + EXPECT_TRUE(oakengine_sequence_add_track(nested, OAKENGINE_TRACK_TYPE_VIDEO) == 0); - assert(oakengine_sequence_add_sequence_clip( + EXPECT_TRUE(oakengine_sequence_add_sequence_clip( seq, seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 0, 10, 0) == NULL); - assert(oakengine_sequence_add_sequence_clip( + EXPECT_TRUE(oakengine_sequence_add_sequence_clip( nested, seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 0, 10, 0) != NULL); - assert(oakengine_sequence_add_sequence_clip( + EXPECT_TRUE(oakengine_sequence_add_sequence_clip( seq, nested, OAKENGINE_TRACK_TYPE_VIDEO, 0, 0, 10, 0) == NULL); char err[256]; - assert(oakengine_sequence_last_error(err, sizeof(err)) > 0); - assert(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, + EXPECT_TRUE(oakengine_sequence_last_error(err, sizeof(err)) > 0); + EXPECT_TRUE(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0) == 0); // Validation: cross-project, bad track type/index and bad ranges are // all rejected without side effects. OakEngineProject *other = oakengine_project_create(); - assert(other != NULL); - assert(oakengine_project_new(other) == OAKENGINE_OK); + EXPECT_TRUE(other != NULL); + EXPECT_TRUE(oakengine_project_new(other) == OAKENGINE_OK); OakEngineSequence *foreign = oakengine_sequence_new(other, "Foreign"); - assert(foreign != NULL); - assert(oakengine_sequence_add_sequence_clip( + EXPECT_TRUE(foreign != NULL); + EXPECT_TRUE(oakengine_sequence_add_sequence_clip( seq, foreign, OAKENGINE_TRACK_TYPE_VIDEO, 0, 0, 10, 0) == NULL); oakengine_project_free(other); - assert(oakengine_sequence_add_sequence_clip( + EXPECT_TRUE(oakengine_sequence_add_sequence_clip( seq, nested, OAKENGINE_TRACK_TYPE_SUBTITLE, 0, 0, 10, 0) == NULL); - assert(oakengine_sequence_add_sequence_clip( + EXPECT_TRUE(oakengine_sequence_add_sequence_clip( seq, nested, OAKENGINE_TRACK_TYPE_VIDEO, 5, 0, 10, 0) == NULL); - assert(oakengine_sequence_add_sequence_clip( + EXPECT_TRUE(oakengine_sequence_add_sequence_clip( seq, nested, OAKENGINE_TRACK_TYPE_VIDEO, 0, 10, 10, 0) == NULL); - assert(oakengine_sequence_add_sequence_clip( + EXPECT_TRUE(oakengine_sequence_add_sequence_clip( seq, nested, OAKENGINE_TRACK_TYPE_VIDEO, 0, -1, 10, 0) == NULL); - assert(oakengine_sequence_add_sequence_clip( + EXPECT_TRUE(oakengine_sequence_add_sequence_clip( seq, nested, OAKENGINE_TRACK_TYPE_VIDEO, 0, 0, 10, -1) == NULL); - assert(oakengine_sequence_add_sequence_clip( + EXPECT_TRUE(oakengine_sequence_add_sequence_clip( NULL, nested, OAKENGINE_TRACK_TYPE_VIDEO, 0, 0, 10, 0) == NULL); - assert(oakengine_sequence_add_sequence_clip( + EXPECT_TRUE(oakengine_sequence_add_sequence_clip( seq, NULL, OAKENGINE_TRACK_TYPE_VIDEO, 0, 0, 10, 0) == NULL); - assert(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, + EXPECT_TRUE(oakengine_sequence_clip_count(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0) == 0); oakengine_project_free(project); @@ -1293,71 +1294,71 @@ static void test_sequence_clip(void) static void test_track_queries(const char *media_path) { OakEngineProject *project = oakengine_project_create(); - assert(project != NULL); - assert(oakengine_project_new(project) == OAKENGINE_OK); + EXPECT_TRUE(project != NULL); + EXPECT_TRUE(oakengine_project_new(project) == OAKENGINE_OK); OakEngineSequence *seq = oakengine_sequence_new(project, "Queries"); - assert(seq != NULL); - assert(oakengine_sequence_add_track(seq, OAKENGINE_TRACK_TYPE_VIDEO) == + EXPECT_TRUE(seq != NULL); + EXPECT_TRUE(oakengine_sequence_add_track(seq, OAKENGINE_TRACK_TYPE_VIDEO) == 0); - assert(oakengine_sequence_add_track(seq, OAKENGINE_TRACK_TYPE_AUDIO) == + EXPECT_TRUE(oakengine_sequence_add_track(seq, OAKENGINE_TRACK_TYPE_AUDIO) == 0); OakEngineFootage *footage = oakengine_project_import_footage(project, media_path); - assert(footage != NULL); + EXPECT_TRUE(footage != NULL); // Clip at [10, 20) on the video track. OakEngineClip *clip = oakengine_sequence_add_footage_clip( seq, footage, OAKENGINE_TRACK_TYPE_VIDEO, 0, 10, 20, 0); - assert(clip != NULL); + EXPECT_TRUE(clip != NULL); // Type through the opaque handle. - assert(oakengine_track_type(NULL) == -1); + EXPECT_TRUE(oakengine_track_type(NULL) == -1); OakEngineTrack *vtrack = oakengine_sequence_track_at( seq, OAKENGINE_TRACK_TYPE_VIDEO, 0); OakEngineTrack *atrack = oakengine_sequence_track_at( seq, OAKENGINE_TRACK_TYPE_AUDIO, 0); - assert(vtrack != NULL && atrack != NULL); - assert(oakengine_track_type(vtrack) == OAKENGINE_TRACK_TYPE_VIDEO); - assert(oakengine_track_type(atrack) == OAKENGINE_TRACK_TYPE_AUDIO); - assert(oakengine_sequence_track_at(seq, OAKENGINE_TRACK_TYPE_VIDEO, 5) == + EXPECT_TRUE(vtrack != NULL && atrack != NULL); + EXPECT_TRUE(oakengine_track_type(vtrack) == OAKENGINE_TRACK_TYPE_VIDEO); + EXPECT_TRUE(oakengine_track_type(atrack) == OAKENGINE_TRACK_TYPE_AUDIO); + EXPECT_TRUE(oakengine_sequence_track_at(seq, OAKENGINE_TRACK_TYPE_VIDEO, 5) == NULL); - assert(oakengine_sequence_track_at(NULL, OAKENGINE_TRACK_TYPE_VIDEO, + EXPECT_TRUE(oakengine_sequence_track_at(NULL, OAKENGINE_TRACK_TYPE_VIDEO, 0) == NULL); // Length: the video track ends at 20, the empty audio track at 0. int64_t length = -1; - assert(oakengine_track_get_length(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, + EXPECT_TRUE(oakengine_track_get_length(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, &length) == OAKENGINE_OK); - assert(length == 20); - assert(oakengine_track_get_length(seq, OAKENGINE_TRACK_TYPE_AUDIO, 0, + EXPECT_TRUE(length == 20); + EXPECT_TRUE(oakengine_track_get_length(seq, OAKENGINE_TRACK_TYPE_AUDIO, 0, &length) == OAKENGINE_OK); - assert(length == 0); - assert(oakengine_track_get_length(seq, OAKENGINE_TRACK_TYPE_VIDEO, 5, + EXPECT_TRUE(length == 0); + EXPECT_TRUE(oakengine_track_get_length(seq, OAKENGINE_TRACK_TYPE_VIDEO, 5, &length) == OAKENGINE_E_NOT_FOUND); - assert(oakengine_track_get_length(NULL, OAKENGINE_TRACK_TYPE_VIDEO, 0, + EXPECT_TRUE(oakengine_track_get_length(NULL, OAKENGINE_TRACK_TYPE_VIDEO, 0, &length) == OAKENGINE_E_INVALID); // Range free: [0, 10) and [20, 30) are free, [15, 25) intersects the // clip, a zero-length probe at 15 also intersects. - assert(oakengine_track_is_range_free(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, + EXPECT_TRUE(oakengine_track_is_range_free(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 0, 10) == 1); - assert(oakengine_track_is_range_free(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, + EXPECT_TRUE(oakengine_track_is_range_free(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 20, 30) == 1); - assert(oakengine_track_is_range_free(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, + EXPECT_TRUE(oakengine_track_is_range_free(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 15, 25) == 0); - assert(oakengine_track_is_range_free(seq, OAKENGINE_TRACK_TYPE_AUDIO, 0, + EXPECT_TRUE(oakengine_track_is_range_free(seq, OAKENGINE_TRACK_TYPE_AUDIO, 0, 15, 25) == 1); - assert(oakengine_track_is_range_free(seq, OAKENGINE_TRACK_TYPE_VIDEO, 5, + EXPECT_TRUE(oakengine_track_is_range_free(seq, OAKENGINE_TRACK_TYPE_VIDEO, 5, 0, 10) == OAKENGINE_E_NOT_FOUND); - assert(oakengine_track_is_range_free(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, + EXPECT_TRUE(oakengine_track_is_range_free(seq, OAKENGINE_TRACK_TYPE_VIDEO, 0, 10, 5) == OAKENGINE_E_INVALID); - assert(oakengine_track_is_range_free(NULL, OAKENGINE_TRACK_TYPE_VIDEO, 0, + EXPECT_TRUE(oakengine_track_is_range_free(NULL, OAKENGINE_TRACK_TYPE_VIDEO, 0, 0, 10) == OAKENGINE_E_INVALID); // Height constants are positive (minimum 1.5, interval 0.5 in the // engine; only positivity is contract-level). - assert(oakengine_track_height_interval() > 0.0); - assert(oakengine_track_height_minimum() > 0.0); + EXPECT_TRUE(oakengine_track_height_interval() > 0.0); + EXPECT_TRUE(oakengine_track_height_minimum() > 0.0); oakengine_project_free(project); } @@ -1367,120 +1368,120 @@ static void test_track_queries(const char *media_path) static void test_marker_handle_family(void) { OakEngineProject *project = oakengine_project_create(); - assert(project != NULL); - assert(oakengine_project_new(project) == OAKENGINE_OK); + EXPECT_TRUE(project != NULL); + EXPECT_TRUE(oakengine_project_new(project) == OAKENGINE_OK); OakEngineSequence *seq = oakengine_sequence_new(project, "MarkerHandles"); - assert(seq != NULL); + EXPECT_TRUE(seq != NULL); OakEngineMarkerList *list = oakengine_viewer_get_marker_list((OakEngineNode *)seq); - assert(list != NULL); - assert(oakengine_viewer_get_marker_list(NULL) == NULL); - assert(oakengine_marker_list_count(list) == 0); - assert(oakengine_marker_list_count(NULL) == 0); + EXPECT_TRUE(list != NULL); + EXPECT_TRUE(oakengine_viewer_get_marker_list(NULL) == NULL); + EXPECT_TRUE(oakengine_marker_list_count(list) == 0); + EXPECT_TRUE(oakengine_marker_list_count(NULL) == 0); // Add two markers (rational seconds) through the list family. - assert(oakengine_marker_list_add(list, 4, 1, 6, 1, "Out", 2) == + EXPECT_TRUE(oakengine_marker_list_add(list, 4, 1, 6, 1, "Out", 2) == OAKENGINE_OK); - assert(oakengine_marker_list_add(list, 1, 1, 2, 1, "In", 0) == + EXPECT_TRUE(oakengine_marker_list_add(list, 1, 1, 2, 1, "In", 0) == OAKENGINE_OK); - assert(oakengine_marker_list_count(list) == 2); + EXPECT_TRUE(oakengine_marker_list_count(list) == 2); // Sorted by time: index 0 is the 1s marker. OakEngineMarker *m0 = oakengine_marker_list_at(list, 0); OakEngineMarker *m1 = oakengine_marker_list_at(list, 1); - assert(m0 != NULL && m1 != NULL && m0 != m1); - assert(oakengine_marker_list_at(list, 2) == NULL); - assert(oakengine_marker_list_at(list, -1) == NULL); + EXPECT_TRUE(m0 != NULL && m1 != NULL && m0 != m1); + EXPECT_TRUE(oakengine_marker_list_at(list, 2) == NULL); + EXPECT_TRUE(oakengine_marker_list_at(list, -1) == NULL); int64_t in_num = 0, in_den = 0, out_num = 0, out_den = 0; - assert(oakengine_marker_get_time(m0, &in_num, &in_den, &out_num, + EXPECT_TRUE(oakengine_marker_get_time(m0, &in_num, &in_den, &out_num, &out_den) == OAKENGINE_OK); - assert(in_num == 1 && in_den == 1 && out_num == 2 && out_den == 1); + EXPECT_TRUE(in_num == 1 && in_den == 1 && out_num == 2 && out_den == 1); char name[64]; - assert(oakengine_marker_get_name(m0, name, sizeof(name)) == 2); - assert(strcmp(name, "In") == 0); - assert(oakengine_marker_get_color(m0) == 0); - assert(oakengine_marker_get_color(m1) == 2); + EXPECT_TRUE(oakengine_marker_get_name(m0, name, sizeof(name)) == 2); + EXPECT_TRUE(strcmp(name, "In") == 0); + EXPECT_TRUE(oakengine_marker_get_color(m0) == 0); + EXPECT_TRUE(oakengine_marker_get_color(m1) == 2); // Lookup by exact in-point. - assert(oakengine_marker_list_marker_at_time(list, 4, 1) == m1); - assert(oakengine_marker_list_marker_at_time(list, 5, 1) == NULL); + EXPECT_TRUE(oakengine_marker_list_marker_at_time(list, 4, 1) == m1); + EXPECT_TRUE(oakengine_marker_list_marker_at_time(list, 5, 1) == NULL); // Sibling check: m0 has a sibling at 4s (m1), none at 3s. - assert(oakengine_marker_has_sibling_at_time(m0, 4, 1) == 1); - assert(oakengine_marker_has_sibling_at_time(m0, 3, 1) == 0); + EXPECT_TRUE(oakengine_marker_has_sibling_at_time(m0, 4, 1) == 1); + EXPECT_TRUE(oakengine_marker_has_sibling_at_time(m0, 3, 1) == 0); // Live (non-undo) resize, then the undoable commit with the old range. - assert(oakengine_marker_set_time_live(m0, 1, 1, 3, 1) == OAKENGINE_OK); - assert(oakengine_marker_get_time(m0, NULL, NULL, &out_num, &out_den) == + EXPECT_TRUE(oakengine_marker_set_time_live(m0, 1, 1, 3, 1) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_marker_get_time(m0, NULL, NULL, &out_num, &out_den) == OAKENGINE_OK); - assert(out_num == 3 && out_den == 1); - assert(oakengine_marker_commit_time(m0, 1, 1, 3, 1, 1, 1, 2, 1, + EXPECT_TRUE(out_num == 3 && out_den == 1); + EXPECT_TRUE(oakengine_marker_commit_time(m0, 1, 1, 3, 1, 1, 1, 2, 1, NULL) == OAKENGINE_OK); // Undo restores the pre-commit (live) state is NOT reverted (the live // edit was already applied; undo goes back to the old range). - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_marker_get_time(m0, NULL, NULL, &out_num, &out_den) == + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_marker_get_time(m0, NULL, NULL, &out_num, &out_den) == OAKENGINE_OK); - assert(out_num == 2 && out_den == 1); - assert(oakengine_project_redo(project) == OAKENGINE_OK); - assert(oakengine_marker_get_time(m0, NULL, NULL, &out_num, &out_den) == + EXPECT_TRUE(out_num == 2 && out_den == 1); + EXPECT_TRUE(oakengine_project_redo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_marker_get_time(m0, NULL, NULL, &out_num, &out_den) == OAKENGINE_OK); - assert(out_num == 3 && out_den == 1); + EXPECT_TRUE(out_num == 3 && out_den == 1); // Detached marker creation (used by the UI before adding to a list). OakEngineMarker *detached = oakengine_marker_create(3, 5, 1, 7, 1, "Detached"); - assert(detached != NULL); - assert(oakengine_marker_get_color(detached) == 3); - assert(oakengine_marker_get_name(detached, name, sizeof(name)) == 8); - assert(strcmp(name, "Detached") == 0); - assert(oakengine_marker_list_count(list) == 2); + EXPECT_TRUE(detached != NULL); + EXPECT_TRUE(oakengine_marker_get_color(detached) == 3); + EXPECT_TRUE(oakengine_marker_get_name(detached, name, sizeof(name)) == 8); + EXPECT_TRUE(strcmp(name, "Detached") == 0); + EXPECT_TRUE(oakengine_marker_list_count(list) == 2); oakengine_marker_free(detached); // Batch properties: recolor + rename both markers as ONE undo entry. OakEngineMarker *both[2] = { m0, m1 }; - assert(oakengine_marker_set_properties(both, 2, 7, "Same", 0, 0, 0, 0, + EXPECT_TRUE(oakengine_marker_set_properties(both, 2, 7, "Same", 0, 0, 0, 0, 0, NULL) == OAKENGINE_OK); - assert(oakengine_marker_get_color(m0) == 7); - assert(oakengine_marker_get_color(m1) == 7); - assert(oakengine_marker_get_name(m0, name, sizeof(name)) >= 0); - assert(strcmp(name, "Same") == 0); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_marker_get_color(m0) == 0); - assert(oakengine_marker_get_color(m1) == 2); - assert(oakengine_marker_get_name(m0, name, sizeof(name)) >= 0); - assert(strcmp(name, "In") == 0); - assert(oakengine_project_redo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_marker_get_color(m0) == 7); + EXPECT_TRUE(oakengine_marker_get_color(m1) == 7); + EXPECT_TRUE(oakengine_marker_get_name(m0, name, sizeof(name)) >= 0); + EXPECT_TRUE(strcmp(name, "Same") == 0); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_marker_get_color(m0) == 0); + EXPECT_TRUE(oakengine_marker_get_color(m1) == 2); + EXPECT_TRUE(oakengine_marker_get_name(m0, name, sizeof(name)) >= 0); + EXPECT_TRUE(strcmp(name, "In") == 0); + EXPECT_TRUE(oakengine_project_redo(project) == OAKENGINE_OK); // Single-marker time move through the same batch call. - assert(oakengine_marker_set_properties(both, 1, -1, NULL, 1, 10, 1, 12, + EXPECT_TRUE(oakengine_marker_set_properties(both, 1, -1, NULL, 1, 10, 1, 12, 1, NULL) == OAKENGINE_OK); - assert(oakengine_marker_get_time(m0, &in_num, NULL, &out_num, NULL) == + EXPECT_TRUE(oakengine_marker_get_time(m0, &in_num, NULL, &out_num, NULL) == OAKENGINE_OK); - assert(in_num == 10 && out_num == 12); - assert(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(in_num == 10 && out_num == 12); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); // Remove with undo. - assert(oakengine_marker_remove(m1) == OAKENGINE_OK); - assert(oakengine_marker_list_count(list) == 1); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_marker_list_count(list) == 2); + EXPECT_TRUE(oakengine_marker_remove(m1) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_marker_list_count(list) == 1); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_marker_list_count(list) == 2); // NULL safety. - assert(oakengine_marker_get_time(NULL, &in_num, NULL, NULL, NULL) == + EXPECT_TRUE(oakengine_marker_get_time(NULL, &in_num, NULL, NULL, NULL) == OAKENGINE_E_INVALID); - assert(oakengine_marker_get_name(NULL, name, sizeof(name)) == + EXPECT_TRUE(oakengine_marker_get_name(NULL, name, sizeof(name)) == OAKENGINE_E_INVALID); - assert(oakengine_marker_get_color(NULL) == -1); - assert(oakengine_marker_has_sibling_at_time(NULL, 1, 1) == 0); - assert(oakengine_marker_set_time_live(NULL, 0, 1, 1, 1) == + EXPECT_TRUE(oakengine_marker_get_color(NULL) == -1); + EXPECT_TRUE(oakengine_marker_has_sibling_at_time(NULL, 1, 1) == 0); + EXPECT_TRUE(oakengine_marker_set_time_live(NULL, 0, 1, 1, 1) == OAKENGINE_E_INVALID); - assert(oakengine_marker_list_add(NULL, 0, 1, 1, 1, "x", 0) == + EXPECT_TRUE(oakengine_marker_list_add(NULL, 0, 1, 1, 1, "x", 0) == OAKENGINE_E_INVALID); - assert(oakengine_marker_remove(NULL) == OAKENGINE_E_INVALID); - assert(oakengine_marker_set_properties(NULL, 1, 0, NULL, 0, 0, 0, 0, 0, + EXPECT_TRUE(oakengine_marker_remove(NULL) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_marker_set_properties(NULL, 1, 0, NULL, 0, 0, 0, 0, 0, NULL) == OAKENGINE_E_INVALID); oakengine_project_free(project); @@ -1491,77 +1492,77 @@ static void test_marker_handle_family(void) static void test_workarea_handle_family(void) { OakEngineProject *project = oakengine_project_create(); - assert(project != NULL); - assert(oakengine_project_new(project) == OAKENGINE_OK); + EXPECT_TRUE(project != NULL); + EXPECT_TRUE(oakengine_project_new(project) == OAKENGINE_OK); OakEngineSequence *seq = oakengine_sequence_new(project, "Workarea"); - assert(seq != NULL); + EXPECT_TRUE(seq != NULL); // Reset sentinels: k_reset_in is 0, k_reset_out is RATIONAL_MAX. int64_t ri_num = 0, ri_den = 0, ro_num = 0, ro_den = 0; oakengine_workarea_reset_in_out(&ri_num, &ri_den, &ro_num, &ro_den); - assert(ri_num == 0 && ri_den > 0); - assert(ro_num > 0 && ro_den > 0); + EXPECT_TRUE(ri_num == 0 && ri_den > 0); + EXPECT_TRUE(ro_num > 0 && ro_den > 0); OakEngineWorkarea *wa = oakengine_viewer_get_workarea_handle((OakEngineNode *)seq); - assert(wa != NULL); - assert(oakengine_viewer_get_workarea_handle(NULL) == NULL); + EXPECT_TRUE(wa != NULL); + EXPECT_TRUE(oakengine_viewer_get_workarea_handle(NULL) == NULL); // A fresh workarea is disabled. int enabled = -1; - assert(oakengine_workarea_get(wa, NULL, NULL, NULL, NULL, &enabled) == + EXPECT_TRUE(oakengine_workarea_get(wa, NULL, NULL, NULL, NULL, &enabled) == OAKENGINE_OK); - assert(enabled == 0); + EXPECT_TRUE(enabled == 0); // Undoable enable + range change. - assert(oakengine_workarea_set_enabled_undoable(wa, 1, NULL) == + EXPECT_TRUE(oakengine_workarea_set_enabled_undoable(wa, 1, NULL) == OAKENGINE_OK); - assert(oakengine_workarea_get(wa, NULL, NULL, NULL, NULL, &enabled) == + EXPECT_TRUE(oakengine_workarea_get(wa, NULL, NULL, NULL, NULL, &enabled) == OAKENGINE_OK); - assert(enabled == 1); - assert(oakengine_workarea_set_range_undoable(wa, 1, 2, 3, 2, ri_num, + EXPECT_TRUE(enabled == 1); + EXPECT_TRUE(oakengine_workarea_set_range_undoable(wa, 1, 2, 3, 2, ri_num, ri_den, ro_num, ro_den, NULL) == OAKENGINE_OK); int64_t in_num = 0, in_den = 0, out_num = 0, out_den = 0; - assert(oakengine_workarea_get(wa, &in_num, &in_den, &out_num, &out_den, + EXPECT_TRUE(oakengine_workarea_get(wa, &in_num, &in_den, &out_num, &out_den, NULL) == OAKENGINE_OK); - assert(in_num == 1 && in_den == 2 && out_num == 3 && out_den == 2); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_workarea_get(wa, &in_num, NULL, &out_num, NULL, + EXPECT_TRUE(in_num == 1 && in_den == 2 && out_num == 3 && out_den == 2); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_workarea_get(wa, &in_num, NULL, &out_num, NULL, NULL) == OAKENGINE_OK); - assert(in_num == ri_num && out_num == ro_num); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_workarea_get(wa, NULL, NULL, NULL, NULL, &enabled) == + EXPECT_TRUE(in_num == ri_num && out_num == ro_num); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_workarea_get(wa, NULL, NULL, NULL, NULL, &enabled) == OAKENGINE_OK); - assert(enabled == 0); - assert(oakengine_project_redo(project) == OAKENGINE_OK); - assert(oakengine_project_redo(project) == OAKENGINE_OK); + EXPECT_TRUE(enabled == 0); + EXPECT_TRUE(oakengine_project_redo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_redo(project) == OAKENGINE_OK); // Standalone workarea: enabled-undoable degrades to a direct apply // (no project owns it). OakEngineWorkarea *over = oakengine_workarea_create(); - assert(over != NULL); - assert(oakengine_workarea_set_enabled_undoable(over, 1, NULL) == + EXPECT_TRUE(over != NULL); + EXPECT_TRUE(oakengine_workarea_set_enabled_undoable(over, 1, NULL) == OAKENGINE_OK); - assert(oakengine_workarea_get(over, NULL, NULL, NULL, NULL, &enabled) == + EXPECT_TRUE(oakengine_workarea_get(over, NULL, NULL, NULL, NULL, &enabled) == OAKENGINE_OK); - assert(enabled == 1); - assert(oakengine_workarea_set_range(over, 0, 1, 5, 1) == OAKENGINE_OK); - assert(oakengine_workarea_get(over, NULL, NULL, &out_num, &out_den, + EXPECT_TRUE(enabled == 1); + EXPECT_TRUE(oakengine_workarea_set_range(over, 0, 1, 5, 1) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_workarea_get(over, NULL, NULL, &out_num, &out_den, NULL) == OAKENGINE_OK); - assert(out_num == 5 && out_den == 1); + EXPECT_TRUE(out_num == 5 && out_den == 1); oakengine_workarea_free(over); // NULL safety. - assert(oakengine_workarea_get(NULL, &in_num, NULL, NULL, NULL, NULL) == + EXPECT_TRUE(oakengine_workarea_get(NULL, &in_num, NULL, NULL, NULL, NULL) == OAKENGINE_E_INVALID); - assert(oakengine_workarea_set_range(NULL, 0, 1, 1, 1) == + EXPECT_TRUE(oakengine_workarea_set_range(NULL, 0, 1, 1, 1) == OAKENGINE_E_INVALID); - assert(oakengine_workarea_set_enabled(NULL, 1) == OAKENGINE_E_INVALID); - assert(oakengine_workarea_set_range_undoable(NULL, 0, 1, 1, 1, 0, 1, 1, + EXPECT_TRUE(oakengine_workarea_set_enabled(NULL, 1) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_workarea_set_range_undoable(NULL, 0, 1, 1, 1, 0, 1, 1, 1, NULL) == OAKENGINE_E_INVALID); - assert(oakengine_workarea_set_enabled_undoable(NULL, 1, NULL) == + EXPECT_TRUE(oakengine_workarea_set_enabled_undoable(NULL, 1, NULL) == OAKENGINE_E_INVALID); oakengine_project_free(project); @@ -1579,50 +1580,50 @@ static void test_clip_input_ids_and_media(void) oakengine_clip_loop_mode_input_id(), oakengine_clip_auto_cache_input_id() }; for (size_t i = 0; i < sizeof(ids) / sizeof(ids[0]); i++) { - assert(ids[i] != NULL && ids[i][0] != '\0'); + EXPECT_TRUE(ids[i] != NULL && ids[i][0] != '\0'); for (size_t j = i + 1; j < sizeof(ids) / sizeof(ids[0]); j++) { - assert(strcmp(ids[i], ids[j]) != 0); + EXPECT_TRUE(strcmp(ids[i], ids[j]) != 0); } } - assert(strcmp(oakengine_clip_speed_input_id(), ids[1]) == 0); + EXPECT_TRUE(strcmp(oakengine_clip_speed_input_id(), ids[1]) == 0); OakEngineProject *project = oakengine_project_create(); - assert(project != NULL); - assert(oakengine_project_new(project) == OAKENGINE_OK); + EXPECT_TRUE(project != NULL); + EXPECT_TRUE(oakengine_project_new(project) == OAKENGINE_OK); OakEngineSequence *seq = oakengine_sequence_new(project, "ClipMedia"); - assert(seq != NULL); - assert(oakengine_sequence_add_track(seq, OAKENGINE_TRACK_TYPE_VIDEO) == + EXPECT_TRUE(seq != NULL); + EXPECT_TRUE(oakengine_sequence_add_track(seq, OAKENGINE_TRACK_TYPE_VIDEO) == 0); char path[4096]; demo_path(path, sizeof(path)); OakEngineFootage *footage = oakengine_project_import_footage(project, path); - assert(footage != NULL); + EXPECT_TRUE(footage != NULL); OakEngineClip *clip = oakengine_sequence_add_footage_clip( seq, footage, OAKENGINE_TRACK_TYPE_VIDEO, 0, 0, 30, 0); - assert(clip != NULL); + EXPECT_TRUE(clip != NULL); // Media in-point: read via the range getter, write undoably. int64_t media_in = -1; - assert(oakengine_clip_get_range(clip, NULL, NULL, &media_in) == + EXPECT_TRUE(oakengine_clip_get_range(clip, NULL, NULL, &media_in) == OAKENGINE_OK); - assert(media_in == 0); - assert(oakengine_clip_set_media_in(clip, 5, 1) == OAKENGINE_OK); - assert(oakengine_clip_get_range(clip, NULL, NULL, &media_in) == + EXPECT_TRUE(media_in == 0); + EXPECT_TRUE(oakengine_clip_set_media_in(clip, 5, 1) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_clip_get_range(clip, NULL, NULL, &media_in) == OAKENGINE_OK); - assert(media_in == 5); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_clip_get_range(clip, NULL, NULL, &media_in) == + EXPECT_TRUE(media_in == 5); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_clip_get_range(clip, NULL, NULL, &media_in) == OAKENGINE_OK); - assert(media_in == 0); - assert(oakengine_project_redo(project) == OAKENGINE_OK); + EXPECT_TRUE(media_in == 0); + EXPECT_TRUE(oakengine_project_redo(project) == OAKENGINE_OK); // Non-undoable mode applies directly. - assert(oakengine_clip_set_media_in(clip, 2, 0) == OAKENGINE_OK); - assert(oakengine_clip_get_range(clip, NULL, NULL, &media_in) == + EXPECT_TRUE(oakengine_clip_set_media_in(clip, 2, 0) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_clip_get_range(clip, NULL, NULL, &media_in) == OAKENGINE_OK); - assert(media_in == 2); + EXPECT_TRUE(media_in == 2); // Cache entry points: smoke calls (headless, no caches to speak of). oakengine_clip_request_invalidate(clip, 0, 0, 0); @@ -1631,13 +1632,13 @@ static void test_clip_input_ids_and_media(void) oakengine_clip_discard_cache(clip); // NULL safety. - assert(oakengine_clip_set_media_in(NULL, 0, 1) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_clip_set_media_in(NULL, 0, 1) == OAKENGINE_E_INVALID); oakengine_clip_request_invalidate(NULL, 0, 0, 0); oakengine_clip_add_cache_passthrough(NULL, clip); oakengine_clip_add_cache_passthrough(clip, NULL); oakengine_clip_discard_cache(NULL); - assert(oakengine_block_is_enabled(NULL) == 0); - assert(oakengine_block_is_enabled((OakEngineBlock *)clip) == 1); + EXPECT_TRUE(oakengine_block_is_enabled(NULL) == 0); + EXPECT_TRUE(oakengine_block_is_enabled((OakEngineBlock *)clip) == 1); oakengine_footage_free(footage); oakengine_project_free(project); @@ -1647,44 +1648,44 @@ static void test_clip_input_ids_and_media(void) static void test_track_height_helpers(void) { - assert(oakengine_track_height_default() > 0.0); + EXPECT_TRUE(oakengine_track_height_default() > 0.0); // Round-trip through the pixel conversion. const int px = oakengine_track_default_height_in_pixels(); - assert(px > 0); - assert(oakengine_track_height_internal_to_pixels( + EXPECT_TRUE(px > 0); + EXPECT_TRUE(oakengine_track_height_internal_to_pixels( oakengine_track_height_pixels_to_internal(px)) == px); - assert(oakengine_track_height_internal_to_pixels( + EXPECT_TRUE(oakengine_track_height_internal_to_pixels( oakengine_track_height_default()) == px); } static void test_add_default_nodes(void) { OakEngineProject *project = oakengine_project_create(); - assert(project != NULL); - assert(oakengine_project_new(project) == OAKENGINE_OK); + EXPECT_TRUE(project != NULL); + EXPECT_TRUE(oakengine_project_new(project) == OAKENGINE_OK); OakEngineSequence *seq = oakengine_sequence_new(project, "Defaults"); - assert(seq != NULL); + EXPECT_TRUE(seq != NULL); int video = -1, audio = -1; - assert(oakengine_sequence_track_count(seq, &video, &audio, NULL) == + EXPECT_TRUE(oakengine_sequence_track_count(seq, &video, &audio, NULL) == OAKENGINE_OK); - assert(video == 0 && audio == 0); + EXPECT_TRUE(video == 0 && audio == 0); // Adds one video + one audio track as ONE undo entry. - assert(oakengine_sequence_add_default_nodes(seq) == OAKENGINE_OK); - assert(oakengine_sequence_track_count(seq, &video, &audio, NULL) == + EXPECT_TRUE(oakengine_sequence_add_default_nodes(seq) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_sequence_track_count(seq, &video, &audio, NULL) == OAKENGINE_OK); - assert(video == 1 && audio == 1); - assert(oakengine_project_undo(project) == OAKENGINE_OK); - assert(oakengine_sequence_track_count(seq, &video, &audio, NULL) == + EXPECT_TRUE(video == 1 && audio == 1); + EXPECT_TRUE(oakengine_project_undo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_sequence_track_count(seq, &video, &audio, NULL) == OAKENGINE_OK); - assert(video == 0 && audio == 0); - assert(oakengine_project_redo(project) == OAKENGINE_OK); - assert(oakengine_sequence_track_count(seq, &video, &audio, NULL) == + EXPECT_TRUE(video == 0 && audio == 0); + EXPECT_TRUE(oakengine_project_redo(project) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_sequence_track_count(seq, &video, &audio, NULL) == OAKENGINE_OK); - assert(video == 1 && audio == 1); + EXPECT_TRUE(video == 1 && audio == 1); - assert(oakengine_sequence_add_default_nodes(NULL) == + EXPECT_TRUE(oakengine_sequence_add_default_nodes(NULL) == OAKENGINE_E_INVALID); oakengine_project_free(project); @@ -1695,39 +1696,39 @@ static void test_add_default_nodes(void) static void test_clip_get_media_range_rational(void) { OakEngineProject *project = oakengine_project_create(); - assert(project != NULL); - assert(oakengine_project_new(project) == OAKENGINE_OK); + EXPECT_TRUE(project != NULL); + EXPECT_TRUE(oakengine_project_new(project) == OAKENGINE_OK); OakEngineSequence *seq = oakengine_sequence_new(project, "MediaRange"); - assert(seq != NULL); - assert(oakengine_sequence_add_track(seq, OAKENGINE_TRACK_TYPE_VIDEO) == 0); + EXPECT_TRUE(seq != NULL); + EXPECT_TRUE(oakengine_sequence_add_track(seq, OAKENGINE_TRACK_TYPE_VIDEO) == 0); char path[4096]; demo_path(path, sizeof(path)); OakEngineFootage *footage = oakengine_project_import_footage(project, path); - assert(footage != NULL); + EXPECT_TRUE(footage != NULL); OakEngineClip *clip = oakengine_sequence_add_footage_clip( seq, footage, OAKENGINE_TRACK_TYPE_VIDEO, 0, 0, 30, 0); - assert(clip != NULL); + EXPECT_TRUE(clip != NULL); // NULL handle. - assert(oakengine_clip_get_media_range_rational(NULL, NULL, NULL, NULL, + EXPECT_TRUE(oakengine_clip_get_media_range_rational(NULL, NULL, NULL, NULL, NULL) == OAKENGINE_E_INVALID); // Valid clip: media range should have a non-zero duration. int64_t in_num = -1, in_den = -1, out_num = -1, out_den = -1; - assert(oakengine_clip_get_media_range_rational(clip, &in_num, &in_den, + EXPECT_TRUE(oakengine_clip_get_media_range_rational(clip, &in_num, &in_den, &out_num, &out_den) == OAKENGINE_OK); - assert(in_num >= 0 && in_den > 0 && out_num > in_num); + EXPECT_TRUE(in_num >= 0 && in_den > 0 && out_num > in_num); // Partial output pointers (any may be NULL). - assert(oakengine_clip_get_media_range_rational(clip, NULL, &in_den, + EXPECT_TRUE(oakengine_clip_get_media_range_rational(clip, NULL, &in_den, &out_num, NULL) == OAKENGINE_OK); - assert(oakengine_clip_get_media_range_rational(clip, NULL, NULL, NULL, + EXPECT_TRUE(oakengine_clip_get_media_range_rational(clip, NULL, NULL, NULL, NULL) == OAKENGINE_OK); oakengine_project_free(project); @@ -1738,23 +1739,23 @@ static void test_clip_get_media_range_rational(void) static void test_multicam_basic(void) { OakEngineProject *project = oakengine_project_create(); - assert(project != NULL); - assert(oakengine_project_new(project) == OAKENGINE_OK); + EXPECT_TRUE(project != NULL); + EXPECT_TRUE(oakengine_project_new(project) == OAKENGINE_OK); // clip_find_multicam: NULL clip returns NULL. - assert(oakengine_clip_find_multicam(NULL) == NULL); + EXPECT_TRUE(oakengine_clip_find_multicam(NULL) == NULL); // A non-clip node (Solid) returns NULL. OakEngineNode *solid = oakengine_project_add_node( project, "org.olivevideoeditor.Olive.solidgenerator"); - assert(solid != NULL); - assert(oakengine_clip_find_multicam(solid) == NULL); + EXPECT_TRUE(solid != NULL); + EXPECT_TRUE(oakengine_clip_find_multicam(solid) == NULL); // multicam_switch_source: NULL args. - assert(oakengine_multicam_switch_source(NULL, NULL, 0, 0, 0.0, NULL) == + EXPECT_TRUE(oakengine_multicam_switch_source(NULL, NULL, 0, 0, 0.0, NULL) == OAKENGINE_E_INVALID); - assert(oakengine_project_remove_node(project, solid) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_project_remove_node(project, solid) == OAKENGINE_OK); oakengine_project_free(project); } @@ -1763,57 +1764,57 @@ static void test_multicam_basic(void) static void test_marker_list_add_existing(void) { OakEngineProject *project = oakengine_project_create(); - assert(project != NULL); - assert(oakengine_project_new(project) == OAKENGINE_OK); + EXPECT_TRUE(project != NULL); + EXPECT_TRUE(oakengine_project_new(project) == OAKENGINE_OK); OakEngineSequence *seq = oakengine_sequence_new(project, "MarkerAdopt"); - assert(seq != NULL); + EXPECT_TRUE(seq != NULL); OakEngineMarkerList *list = oakengine_viewer_get_marker_list((OakEngineNode *)seq); - assert(list != NULL); + EXPECT_TRUE(list != NULL); // Add a marker to the list, get its handle. - assert(oakengine_marker_list_add(list, 0, 1, 2, 1, "Test", 0) == + EXPECT_TRUE(oakengine_marker_list_add(list, 0, 1, 2, 1, "Test", 0) == OAKENGINE_OK); OakEngineMarker *marker = oakengine_marker_list_at(list, 0); - assert(marker != NULL); + EXPECT_TRUE(marker != NULL); // Remove it from the list. - assert(oakengine_marker_remove(marker) == OAKENGINE_OK); - assert(oakengine_marker_list_count(list) == 0); + EXPECT_TRUE(oakengine_marker_remove(marker) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_marker_list_count(list) == 0); // add_existing to re-add it. - assert(oakengine_marker_list_add_existing(list, marker) == + EXPECT_TRUE(oakengine_marker_list_add_existing(list, marker) == OAKENGINE_OK); - assert(oakengine_marker_list_count(list) == 1); + EXPECT_TRUE(oakengine_marker_list_count(list) == 1); // NULL list or marker. - assert(oakengine_marker_list_add_existing(NULL, marker) == + EXPECT_TRUE(oakengine_marker_list_add_existing(NULL, marker) == OAKENGINE_E_INVALID); - assert(oakengine_marker_list_add_existing(list, NULL) == + EXPECT_TRUE(oakengine_marker_list_add_existing(list, NULL) == OAKENGINE_E_INVALID); oakengine_project_free(project); } -int main(void) +TEST(OakEngineTimelineEdit, Main) { make_tmpdir(); // Sandbox the config/cache/data locations (see oakengine_init_test). #if !defined(_WIN32) - assert(setenv("XDG_CONFIG_HOME", g_tmpdir, 1) == 0); - assert(setenv("XDG_CACHE_HOME", g_tmpdir, 1) == 0); - assert(setenv("XDG_DATA_HOME", g_tmpdir, 1) == 0); + EXPECT_TRUE(setenv("XDG_CONFIG_HOME", g_tmpdir, 1) == 0); + EXPECT_TRUE(setenv("XDG_CACHE_HOME", g_tmpdir, 1) == 0); + EXPECT_TRUE(setenv("XDG_DATA_HOME", g_tmpdir, 1) == 0); #endif - assert(oakengine_init(OAKENGINE_INIT_HEADLESS) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_init(OAKENGINE_INIT_HEADLESS) == OAKENGINE_OK); OakEngineProject *project = oakengine_project_create(); - assert(project != NULL); - assert(oakengine_project_new(project) == OAKENGINE_OK); + EXPECT_TRUE(project != NULL); + EXPECT_TRUE(oakengine_project_new(project) == OAKENGINE_OK); OakEngineSequence *seq = oakengine_sequence_new(project, "Edit"); - assert(seq != NULL); + EXPECT_TRUE(seq != NULL); char path[4096]; demo_path(path, sizeof(path)); @@ -1840,8 +1841,6 @@ int main(void) test_marker_list_add_existing(); oakengine_project_free(project); - assert(oakengine_shutdown() == OAKENGINE_OK); + EXPECT_TRUE(oakengine_shutdown() == OAKENGINE_OK); - printf("oakengine_timeline_edit_test: all assertions passed\n"); - return 0; } diff --git a/engine/tests/oakengine_traverse_test.cpp b/engine/tests/oakengine_traverse_test.cpp index ae2d9d6dc..78c0b26d1 100644 --- a/engine/tests/oakengine_traverse_test.cpp +++ b/engine/tests/oakengine_traverse_test.cpp @@ -28,6 +28,7 @@ // needed. #include +#include #include #include #include @@ -51,13 +52,13 @@ static void make_tmpdir(void) #if defined(_WIN32) char base[MAX_PATH]; const DWORD len = GetTempPathA(MAX_PATH, base); - assert(len > 0 && len < MAX_PATH); + EXPECT_TRUE(len > 0 && len < MAX_PATH); snprintf(g_tmpdir, sizeof(g_tmpdir), "%soakengine_traverse_test_%lu", base, (unsigned long)GetCurrentProcessId()); - assert(_mkdir(g_tmpdir) == 0); + EXPECT_TRUE(_mkdir(g_tmpdir) == 0); #else strcpy(g_tmpdir, "/tmp/oakengine_traverse_test_XXXXXX"); - assert(mkdtemp(g_tmpdir) != NULL); + EXPECT_TRUE(mkdtemp(g_tmpdir) != NULL); #endif } @@ -67,46 +68,46 @@ static void test_null_robustness(OakEngineNode *solid) { double m[6]; - assert(oakengine_traverse_generate_database(NULL, 0, 1, 1, 1) == NULL); - assert(oakengine_traverse_generate_table(NULL, 0, 1, 1, 1) == NULL); + EXPECT_TRUE(oakengine_traverse_generate_database(NULL, 0, 1, 1, 1) == NULL); + EXPECT_TRUE(oakengine_traverse_generate_table(NULL, 0, 1, 1, 1) == NULL); // Zero denominators are invalid rationals. - assert(oakengine_traverse_generate_database(solid, 0, 0, 1, 1) == NULL); - assert(oakengine_traverse_generate_table(solid, 0, 1, 1, 0) == NULL); + EXPECT_TRUE(oakengine_traverse_generate_database(solid, 0, 0, 1, 1) == NULL); + EXPECT_TRUE(oakengine_traverse_generate_table(solid, 0, 1, 1, 0) == NULL); oakengine_traverse_db_free(NULL); // no-op - assert(oakengine_traverse_db_input_count(NULL) == 0); - assert(oakengine_traverse_db_input_id(NULL, 0) == NULL); - assert(oakengine_traverse_db_row_count(NULL, 0) == 0); - assert(oakengine_traverse_row_type(NULL, 0, 0) == OAK_NODE_VALUE_NONE); - assert(oakengine_traverse_row_source(NULL, 0, 0) == NULL); - assert(oakengine_traverse_row_tag(NULL, 0, 0) != NULL); // never NULL - assert(oakengine_traverse_row_value_string(NULL, 0, 0) == NULL); - assert(oakengine_traverse_row_split_count(NULL, 0, 0) == 0); - assert(oakengine_traverse_row_split_string(NULL, 0, 0, 0) == NULL); + EXPECT_TRUE(oakengine_traverse_db_input_count(NULL) == 0); + EXPECT_TRUE(oakengine_traverse_db_input_id(NULL, 0) == NULL); + EXPECT_TRUE(oakengine_traverse_db_row_count(NULL, 0) == 0); + EXPECT_TRUE(oakengine_traverse_row_type(NULL, 0, 0) == OAK_NODE_VALUE_NONE); + EXPECT_TRUE(oakengine_traverse_row_source(NULL, 0, 0) == NULL); + EXPECT_TRUE(oakengine_traverse_row_tag(NULL, 0, 0) != NULL); // never NULL + EXPECT_TRUE(oakengine_traverse_row_value_string(NULL, 0, 0) == NULL); + EXPECT_TRUE(oakengine_traverse_row_split_count(NULL, 0, 0) == 0); + EXPECT_TRUE(oakengine_traverse_row_split_string(NULL, 0, 0, 0) == NULL); - assert(oakengine_traverse_table_element_index_for_hint(NULL, "x", -1, + EXPECT_TRUE(oakengine_traverse_table_element_index_for_hint(NULL, "x", -1, NULL) == -1); // generate_row: the C side can only exercise the error paths -- the // real output is an olive::NodeValueRow (a C++ QHash typedef), which a // pure C test cannot allocate. The filled-row path is covered by the // application (the viewer display gizmo drag-start path). - assert(oakengine_traverse_generate_row(NULL, 0, 1, 1, 1, NULL, 0, 0, + EXPECT_TRUE(oakengine_traverse_generate_row(NULL, 0, 1, 1, 1, NULL, 0, 0, (void *)1) == OAKENGINE_E_INVALID); - assert(oakengine_traverse_generate_row(solid, 0, 1, 1, 1, NULL, 0, 0, + EXPECT_TRUE(oakengine_traverse_generate_row(solid, 0, 1, 1, 1, NULL, 0, 0, NULL) == OAKENGINE_E_INVALID); - assert(oakengine_traverse_transform(NULL, solid, 0, 1, 1, 1, NULL, m) == + EXPECT_TRUE(oakengine_traverse_transform(NULL, solid, 0, 1, 1, 1, NULL, m) == OAKENGINE_E_INVALID); - assert(oakengine_traverse_transform(solid, NULL, 0, 1, 1, 1, NULL, m) == + EXPECT_TRUE(oakengine_traverse_transform(solid, NULL, 0, 1, 1, 1, NULL, m) == OAKENGINE_E_INVALID); - assert(oakengine_traverse_transform(solid, solid, 0, 1, 1, 1, NULL, + EXPECT_TRUE(oakengine_traverse_transform(solid, solid, 0, 1, 1, 1, NULL, NULL) == OAKENGINE_E_INVALID); - assert(oakengine_node_set_value_hint(NULL, "x", -1, OAK_NODE_VALUE_COLOR, + EXPECT_TRUE(oakengine_node_set_value_hint(NULL, "x", -1, OAK_NODE_VALUE_COLOR, 0, NULL) == OAKENGINE_E_INVALID); - assert(oakengine_node_set_value_hint(solid, NULL, -1, + EXPECT_TRUE(oakengine_node_set_value_hint(solid, NULL, -1, OAK_NODE_VALUE_COLOR, 0, NULL) == OAKENGINE_E_INVALID); } @@ -119,58 +120,58 @@ static void test_database(OakEngineNode *solid) OakEngineTraverseDb *db = oakengine_traverse_generate_database(solid, 0, 1, 1, 1); - assert(db != NULL); + EXPECT_TRUE(db != NULL); // One entry per node input, in the node's input order (deterministic). const int node_inputs = oakengine_node_input_count(solid); - assert(node_inputs >= 2); - assert(oakengine_traverse_db_input_count(db) == node_inputs); + EXPECT_TRUE(node_inputs >= 2); + EXPECT_TRUE(oakengine_traverse_db_input_count(db) == node_inputs); for (int i = 0; i < node_inputs; i++) { - assert(oakengine_node_input_id(solid, i, buf, sizeof(buf)) > 0); + EXPECT_TRUE(oakengine_node_input_id(solid, i, buf, sizeof(buf)) > 0); const char *id = oakengine_traverse_db_input_id(db, i); - assert(id != NULL); - assert(strcmp(id, buf) == 0); + EXPECT_TRUE(id != NULL); + EXPECT_TRUE(strcmp(id, buf) == 0); // Every input of an unconnected Solid generator produces one row // (its standard value). const int rows = oakengine_traverse_db_row_count(db, i); - assert(rows >= 1); + EXPECT_TRUE(rows >= 1); for (int r = 0; r < rows; r++) { // Type is a valid facade value type for plain inputs // (enabled_in is BOOL, color_in is COLOR). const int type = oakengine_traverse_row_type(db, i, r); - assert(type > OAK_NODE_VALUE_NONE); + EXPECT_TRUE(type > OAK_NODE_VALUE_NONE); // Source: the value's originating node, or NULL; the solid's // standard values are sourced from the node itself. OakEngineNode *src = oakengine_traverse_row_source(db, i, r); - assert(src == NULL || src == solid); + EXPECT_TRUE(src == NULL || src == solid); // Tag may be empty but never NULL. - assert(oakengine_traverse_row_tag(db, i, r) != NULL); + EXPECT_TRUE(oakengine_traverse_row_tag(db, i, r) != NULL); // Value string is non-empty for these value types. const char *vs = oakengine_traverse_row_value_string(db, i, r); - assert(vs != NULL); - assert(vs[0] != '\0'); + EXPECT_TRUE(vs != NULL); + EXPECT_TRUE(vs[0] != '\0'); // Split values: at least one track, each with a string. const int splits = oakengine_traverse_row_split_count(db, i, r); - assert(splits >= 1); + EXPECT_TRUE(splits >= 1); for (int s = 0; s < splits; s++) { - assert(oakengine_traverse_row_split_string(db, i, r, s) != + EXPECT_TRUE(oakengine_traverse_row_split_string(db, i, r, s) != NULL); } - assert(oakengine_traverse_row_split_string(db, i, r, splits) == + EXPECT_TRUE(oakengine_traverse_row_split_string(db, i, r, splits) == NULL); } } // Out-of-range accessors fail cleanly. - assert(oakengine_traverse_db_input_id(db, node_inputs) == NULL); - assert(oakengine_traverse_db_row_count(db, node_inputs) == 0); - assert(oakengine_traverse_row_type(db, node_inputs, 0) == + EXPECT_TRUE(oakengine_traverse_db_input_id(db, node_inputs) == NULL); + EXPECT_TRUE(oakengine_traverse_db_row_count(db, node_inputs) == 0); + EXPECT_TRUE(oakengine_traverse_row_type(db, node_inputs, 0) == OAK_NODE_VALUE_NONE); // A multi-entry database is not a generate_table result: the hint // lookup rejects it. - assert(oakengine_traverse_table_element_index_for_hint(solid, "color_in", + EXPECT_TRUE(oakengine_traverse_table_element_index_for_hint(solid, "color_in", -1, db) == -1); oakengine_traverse_db_free(db); @@ -182,35 +183,35 @@ static void test_table_and_hints(OakEngineNode *solid, OakEngineNode *lut) { OakEngineTraverseDb *db = oakengine_traverse_generate_table(solid, 0, 1, 1, 1); - assert(db != NULL); - assert(oakengine_traverse_db_input_count(db) == 1); + EXPECT_TRUE(db != NULL); + EXPECT_TRUE(oakengine_traverse_db_input_count(db) == 1); // The single output table is keyed by an empty input id. const char *id = oakengine_traverse_db_input_id(db, 0); - assert(id != NULL); - assert(id[0] == '\0'); - assert(oakengine_traverse_db_row_count(db, 0) >= 1); + EXPECT_TRUE(id != NULL); + EXPECT_TRUE(id[0] == '\0'); + EXPECT_TRUE(oakengine_traverse_db_row_count(db, 0) >= 1); // set_value_hint: unknown input ids and bogus types are rejected. - assert(oakengine_node_set_value_hint(solid, "not_an_input", -1, + EXPECT_TRUE(oakengine_node_set_value_hint(solid, "not_an_input", -1, OAK_NODE_VALUE_COLOR, 0, NULL) == OAKENGINE_E_NOT_FOUND); - assert(oakengine_node_set_value_hint(solid, "color_in", -1, 999, 0, + EXPECT_TRUE(oakengine_node_set_value_hint(solid, "color_in", -1, 999, 0, NULL) == OAKENGINE_E_INVALID); // The solid's output table holds texture rows. A hint preferring COLOR // values (set on the lut's texture input) matches nothing -> -1. - assert(oakengine_node_set_value_hint(lut, "tex_in", -1, + EXPECT_TRUE(oakengine_node_set_value_hint(lut, "tex_in", -1, OAK_NODE_VALUE_COLOR, -1, NULL) == OAKENGINE_OK); - assert(oakengine_traverse_table_element_index_for_hint(lut, "tex_in", -1, + EXPECT_TRUE(oakengine_traverse_table_element_index_for_hint(lut, "tex_in", -1, db) == -1); // An untyped hint falls back to the input's declared type (k_texture // for "tex_in"), which does have a row in the table. - assert(oakengine_node_set_value_hint(lut, "tex_in", -1, + EXPECT_TRUE(oakengine_node_set_value_hint(lut, "tex_in", -1, OAK_NODE_VALUE_NONE, -1, NULL) == OAKENGINE_OK); - assert(oakengine_traverse_table_element_index_for_hint(lut, "tex_in", -1, + EXPECT_TRUE(oakengine_traverse_table_element_index_for_hint(lut, "tex_in", -1, db) >= 0); oakengine_traverse_db_free(db); @@ -223,46 +224,46 @@ static void test_transform(OakEngineNode *solid, OakEngineNode *lut) double m[6] = { 0, 0, 0, 0, 0, 0 }; // No transform-generating nodes between start and end: identity matrix. - assert(oakengine_traverse_transform(solid, solid, 0, 1, 1, 1, NULL, m) == + EXPECT_TRUE(oakengine_traverse_transform(solid, solid, 0, 1, 1, 1, NULL, m) == OAKENGINE_OK); - assert(m[0] == 1.0 && m[1] == 0.0 && m[2] == 0.0 && m[3] == 1.0); - assert(m[4] == 0.0 && m[5] == 0.0); + EXPECT_TRUE(m[0] == 1.0 && m[1] == 0.0 && m[2] == 0.0 && m[3] == 1.0); + EXPECT_TRUE(m[4] == 0.0 && m[5] == 0.0); // Same through an edge, with explicit cache params. oak_video_params vp; memset(&vp, 0, sizeof(vp)); - assert(oakengine_video_params_make(&vp, 1920, 1080, 1001, 30000, 0, 1, 1, + EXPECT_TRUE(oakengine_video_params_make(&vp, 1920, 1080, 1001, 30000, 0, 1, 1, 0, 0, 1) == OAKENGINE_OK); memset(m, 0, sizeof(m)); - assert(oakengine_traverse_transform(solid, lut, 0, 1, 1, 1, &vp, m) == + EXPECT_TRUE(oakengine_traverse_transform(solid, lut, 0, 1, 1, 1, &vp, m) == OAKENGINE_OK); - assert(m[0] == 1.0 && m[1] == 0.0 && m[2] == 0.0 && m[3] == 1.0); - assert(m[4] == 0.0 && m[5] == 0.0); + EXPECT_TRUE(m[0] == 1.0 && m[1] == 0.0 && m[2] == 0.0 && m[3] == 1.0); + EXPECT_TRUE(m[4] == 0.0 && m[5] == 0.0); } -int main(void) +TEST(OakEngineTraverse, Main) { make_tmpdir(); // Sandbox the config/cache/data locations. #if !defined(_WIN32) - assert(setenv("XDG_CONFIG_HOME", g_tmpdir, 1) == 0); - assert(setenv("XDG_CACHE_HOME", g_tmpdir, 1) == 0); - assert(setenv("XDG_DATA_HOME", g_tmpdir, 1) == 0); + EXPECT_TRUE(setenv("XDG_CONFIG_HOME", g_tmpdir, 1) == 0); + EXPECT_TRUE(setenv("XDG_CACHE_HOME", g_tmpdir, 1) == 0); + EXPECT_TRUE(setenv("XDG_DATA_HOME", g_tmpdir, 1) == 0); #endif - assert(oakengine_init(OAKENGINE_INIT_HEADLESS) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_init(OAKENGINE_INIT_HEADLESS) == OAKENGINE_OK); OakEngineProject *project = oakengine_project_create(); - assert(project != NULL); - assert(oakengine_project_new(project) == OAKENGINE_OK); + EXPECT_TRUE(project != NULL); + EXPECT_TRUE(oakengine_project_new(project) == OAKENGINE_OK); OakEngineNode *solid = oakengine_project_add_node( project, "org.olivevideoeditor.Olive.solidgenerator"); - assert(solid != NULL); + EXPECT_TRUE(solid != NULL); OakEngineNode *lut = oakengine_project_add_node( project, "org.olivevideoeditor.Olive.ociolut"); - assert(lut != NULL); + EXPECT_TRUE(lut != NULL); test_null_robustness(solid); test_database(solid); @@ -270,8 +271,6 @@ int main(void) test_transform(solid, lut); oakengine_project_free(project); - assert(oakengine_shutdown() == OAKENGINE_OK); + EXPECT_TRUE(oakengine_shutdown() == OAKENGINE_OK); - printf("oakengine_traverse_test: all assertions passed\n"); - return 0; } diff --git a/engine/tests/oakengine_viewer_test.cpp b/engine/tests/oakengine_viewer_test.cpp index 92308332d..ec47fc7db 100644 --- a/engine/tests/oakengine_viewer_test.cpp +++ b/engine/tests/oakengine_viewer_test.cpp @@ -27,6 +27,7 @@ // sequence real content length. #include +#include #include #include #include @@ -57,20 +58,20 @@ static void make_tmpdir(void) #if defined(_WIN32) char base[MAX_PATH]; const DWORD len = GetTempPathA(MAX_PATH, base); - assert(len > 0 && len < MAX_PATH); + EXPECT_TRUE(len > 0 && len < MAX_PATH); snprintf(g_tmpdir, sizeof(g_tmpdir), "%soakengine_viewer_test_%lu", base, (unsigned long)GetCurrentProcessId()); - assert(_mkdir(g_tmpdir) == 0); + EXPECT_TRUE(_mkdir(g_tmpdir) == 0); #else strcpy(g_tmpdir, "/tmp/oakengine_viewer_test_XXXXXX"); - assert(mkdtemp(g_tmpdir) != NULL); + EXPECT_TRUE(mkdtemp(g_tmpdir) != NULL); #endif } static void demo_path(char *dst, size_t cap) { const int n = snprintf(dst, cap, "%s/tests/demo.mp4", OAK_TEST_SOURCE_DIR); - assert(n > 0 && (size_t)n < cap); + EXPECT_TRUE(n > 0 && (size_t)n < cap); } // A sequence handle is the same engine object pointer as its node handle @@ -88,26 +89,26 @@ static void test_from_node(OakEngineProject *project, OakEngineSequence *seq) OakEngineNode *seq_node = as_node(seq); OakEngineNode *solid = oakengine_project_add_node( project, "org.olivevideoeditor.Olive.solidgenerator"); - assert(solid != NULL); + EXPECT_TRUE(solid != NULL); - assert(oakengine_viewer_from_node(NULL) == NULL); - assert(oakengine_viewer_from_node(solid) == NULL); - assert(oakengine_viewer_from_node(seq_node) == seq_node); + EXPECT_TRUE(oakengine_viewer_from_node(NULL) == NULL); + EXPECT_TRUE(oakengine_viewer_from_node(solid) == NULL); + EXPECT_TRUE(oakengine_viewer_from_node(seq_node) == seq_node); - assert(oakengine_viewer_from_const_node(NULL) == NULL); - assert(oakengine_viewer_from_const_node((const OakEngineNode *)solid) == + EXPECT_TRUE(oakengine_viewer_from_const_node(NULL) == NULL); + EXPECT_TRUE(oakengine_viewer_from_const_node((const OakEngineNode *)solid) == NULL); - assert(oakengine_viewer_from_const_node((const OakEngineNode *)seq_node) == + EXPECT_TRUE(oakengine_viewer_from_const_node((const OakEngineNode *)seq_node) == (const OakEngineNode *)seq_node); // The input id constants are static, non-empty strings. - assert(oakengine_viewer_video_params_input_id() != NULL); - assert(oakengine_viewer_video_params_input_id()[0] != '\0'); - assert(oakengine_viewer_audio_params_input_id()[0] != '\0'); - assert(oakengine_viewer_subtitle_params_input_id()[0] != '\0'); - assert(oakengine_viewer_texture_input_id()[0] != '\0'); - assert(oakengine_viewer_samples_input_id()[0] != '\0'); - assert(oakengine_viewer_default_sample_format() >= 0); + EXPECT_TRUE(oakengine_viewer_video_params_input_id() != NULL); + EXPECT_TRUE(oakengine_viewer_video_params_input_id()[0] != '\0'); + EXPECT_TRUE(oakengine_viewer_audio_params_input_id()[0] != '\0'); + EXPECT_TRUE(oakengine_viewer_subtitle_params_input_id()[0] != '\0'); + EXPECT_TRUE(oakengine_viewer_texture_input_id()[0] != '\0'); + EXPECT_TRUE(oakengine_viewer_samples_input_id()[0] != '\0'); + EXPECT_TRUE(oakengine_viewer_default_sample_format() >= 0); } // ---- Playhead / length ------------------------------------------------------ @@ -116,35 +117,35 @@ static void test_playhead(OakEngineSequence *seq) { int64_t num = -1, den = -1; - assert(oakengine_viewer_get_playhead(NULL, &num, &den) == + EXPECT_TRUE(oakengine_viewer_get_playhead(NULL, &num, &den) == OAKENGINE_E_INVALID); - assert(oakengine_viewer_get_playhead(as_node(seq), &num, &den) == + EXPECT_TRUE(oakengine_viewer_get_playhead(as_node(seq), &num, &den) == OAKENGINE_OK); - assert(num == 0); + EXPECT_TRUE(num == 0); - assert(oakengine_viewer_set_playhead(NULL, 1, 1) == OAKENGINE_E_INVALID); - assert(oakengine_viewer_set_playhead(as_node(seq), 2, 1) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_viewer_set_playhead(NULL, 1, 1) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_viewer_set_playhead(as_node(seq), 2, 1) == OAKENGINE_OK); num = den = -1; - assert(oakengine_viewer_get_playhead(as_node(seq), &num, &den) == + EXPECT_TRUE(oakengine_viewer_get_playhead(as_node(seq), &num, &den) == OAKENGINE_OK); - assert(num == 2 && den == 1); + EXPECT_TRUE(num == 2 && den == 1); } static void test_lengths(OakEngineSequence *seq) { int64_t num = -1, den = -1; - assert(oakengine_viewer_get_length(NULL, &num, &den) == + EXPECT_TRUE(oakengine_viewer_get_length(NULL, &num, &den) == OAKENGINE_E_INVALID); - assert(oakengine_viewer_get_length(as_node(seq), &num, &den) == + EXPECT_TRUE(oakengine_viewer_get_length(as_node(seq), &num, &den) == OAKENGINE_OK); - assert(num == 0); - assert(oakengine_viewer_get_video_length(as_node(seq), &num, &den) == + EXPECT_TRUE(num == 0); + EXPECT_TRUE(oakengine_viewer_get_video_length(as_node(seq), &num, &den) == OAKENGINE_OK); - assert(num == 0); - assert(oakengine_viewer_get_audio_length(as_node(seq), &num, &den) == + EXPECT_TRUE(num == 0); + EXPECT_TRUE(oakengine_viewer_get_audio_length(as_node(seq), &num, &den) == OAKENGINE_OK); - assert(num == 0); + EXPECT_TRUE(num == 0); } // ---- Stream parameters -------------------------------------------------------- @@ -156,58 +157,58 @@ static void test_stream_params(OakEngineSequence *seq) int sr = -1, format = -1; uint64_t layout = 1; - assert(oakengine_viewer_get_video_params(NULL, 0, &vp) == + EXPECT_TRUE(oakengine_viewer_get_video_params(NULL, 0, &vp) == OAKENGINE_E_INVALID); - assert(oakengine_viewer_get_video_params(node, 0, NULL) == + EXPECT_TRUE(oakengine_viewer_get_video_params(node, 0, NULL) == OAKENGINE_E_INVALID); // A fresh sequence has one video and one audio stream, no subtitles. - assert(oakengine_viewer_get_video_stream_count(NULL) == 0); - assert(oakengine_viewer_get_video_stream_count(node) == 1); - assert(oakengine_viewer_get_audio_stream_count(node) == 1); - assert(oakengine_viewer_get_subtitle_stream_count(node) == 0); + EXPECT_TRUE(oakengine_viewer_get_video_stream_count(NULL) == 0); + EXPECT_TRUE(oakengine_viewer_get_video_stream_count(node) == 1); + EXPECT_TRUE(oakengine_viewer_get_audio_stream_count(node) == 1); + EXPECT_TRUE(oakengine_viewer_get_subtitle_stream_count(node) == 0); // In-range video params come from the sequence defaults. - assert(oakengine_viewer_get_video_params(node, 0, &vp) == OAKENGINE_OK); - assert(vp.width > 0 && vp.height > 0); - assert(vp.time_base_num > 0 && vp.time_base_den > 0); + EXPECT_TRUE(oakengine_viewer_get_video_params(node, 0, &vp) == OAKENGINE_OK); + EXPECT_TRUE(vp.width > 0 && vp.height > 0); + EXPECT_TRUE(vp.time_base_num > 0 && vp.time_base_den > 0); // Out-of-range yields a zeroed struct (documented in viewer.h). memset(&vp, 0xFF, sizeof(vp)); - assert(oakengine_viewer_get_video_params(node, 99, &vp) == OAKENGINE_OK); - assert(vp.width == 0 && vp.height == 0); + EXPECT_TRUE(oakengine_viewer_get_video_params(node, 99, &vp) == OAKENGINE_OK); + EXPECT_TRUE(vp.width == 0 && vp.height == 0); // Audio params; out-of-range yields 0/0/0. - assert(oakengine_viewer_get_audio_params(NULL, 0, &sr, &layout, + EXPECT_TRUE(oakengine_viewer_get_audio_params(NULL, 0, &sr, &layout, &format) == OAKENGINE_E_INVALID); - assert(oakengine_viewer_get_audio_params(node, 0, &sr, &layout, + EXPECT_TRUE(oakengine_viewer_get_audio_params(node, 0, &sr, &layout, &format) == OAKENGINE_OK); - assert(sr > 0 && layout != 0); + EXPECT_TRUE(sr > 0 && layout != 0); sr = -1; layout = 1; format = -1; - assert(oakengine_viewer_get_audio_params(node, 99, &sr, &layout, + EXPECT_TRUE(oakengine_viewer_get_audio_params(node, 99, &sr, &layout, &format) == OAKENGINE_OK); - assert(sr == 0 && layout == 0 && format == 0); + EXPECT_TRUE(sr == 0 && layout == 0 && format == 0); // Per-stream enabled flags: video/audio stream 0 are enabled by // default; subtitle has no stream 0. - assert(oakengine_viewer_get_stream_enabled(NULL, OAKENGINE_TRACK_TYPE_VIDEO, + EXPECT_TRUE(oakengine_viewer_get_stream_enabled(NULL, OAKENGINE_TRACK_TYPE_VIDEO, 0) == OAKENGINE_E_INVALID); - assert(oakengine_viewer_get_stream_enabled(node, OAKENGINE_TRACK_TYPE_VIDEO, + EXPECT_TRUE(oakengine_viewer_get_stream_enabled(node, OAKENGINE_TRACK_TYPE_VIDEO, 0) == 1); - assert(oakengine_viewer_get_stream_enabled(node, OAKENGINE_TRACK_TYPE_AUDIO, + EXPECT_TRUE(oakengine_viewer_get_stream_enabled(node, OAKENGINE_TRACK_TYPE_AUDIO, 0) == 1); - assert(oakengine_viewer_get_stream_enabled( + EXPECT_TRUE(oakengine_viewer_get_stream_enabled( node, OAKENGINE_TRACK_TYPE_SUBTITLE, 0) == 0); - assert(oakengine_viewer_get_stream_enabled(node, 99, 0) == + EXPECT_TRUE(oakengine_viewer_get_stream_enabled(node, 99, 0) == OAKENGINE_E_INVALID); // Subtitle access: no subtitle streams on a fresh sequence. - assert(oakengine_viewer_get_subtitle_count(NULL, 0) == OAKENGINE_E_INVALID); - assert(oakengine_viewer_get_subtitle_count(node, 0) == OAKENGINE_E_INVALID); - assert(oakengine_viewer_get_subtitle_at(NULL, 0, 0) == NULL); - assert(oakengine_viewer_get_subtitle_at(node, 0, 0) == NULL); + EXPECT_TRUE(oakengine_viewer_get_subtitle_count(NULL, 0) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_viewer_get_subtitle_count(node, 0) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_viewer_get_subtitle_at(NULL, 0, 0) == NULL); + EXPECT_TRUE(oakengine_viewer_get_subtitle_at(node, 0, 0) == NULL); } static void test_enabled_streams(OakEngineSequence *seq) @@ -215,57 +216,57 @@ static void test_enabled_streams(OakEngineSequence *seq) const OakEngineNode *node = (const OakEngineNode *)as_node(seq); oak_video_params vp; - assert(oakengine_viewer_has_enabled_streams(NULL, + EXPECT_TRUE(oakengine_viewer_has_enabled_streams(NULL, OAKENGINE_TRACK_TYPE_VIDEO) == 0); - assert(oakengine_viewer_has_enabled_streams(node, + EXPECT_TRUE(oakengine_viewer_has_enabled_streams(node, OAKENGINE_TRACK_TYPE_VIDEO) == 1); - assert(oakengine_viewer_has_enabled_streams(node, + EXPECT_TRUE(oakengine_viewer_has_enabled_streams(node, OAKENGINE_TRACK_TYPE_AUDIO) == 1); - assert(oakengine_viewer_has_enabled_streams( + EXPECT_TRUE(oakengine_viewer_has_enabled_streams( node, OAKENGINE_TRACK_TYPE_SUBTITLE) == 0); - assert(oakengine_viewer_has_enabled_streams(node, 99) == 0); + EXPECT_TRUE(oakengine_viewer_has_enabled_streams(node, 99) == 0); - assert(oakengine_viewer_get_first_enabled_video_stream(NULL, &vp) == + EXPECT_TRUE(oakengine_viewer_get_first_enabled_video_stream(NULL, &vp) == OAKENGINE_E_INVALID); - assert(oakengine_viewer_get_first_enabled_video_stream(node, &vp) == + EXPECT_TRUE(oakengine_viewer_get_first_enabled_video_stream(node, &vp) == OAKENGINE_OK); - assert(vp.width > 0 && vp.height > 0); + EXPECT_TRUE(vp.width > 0 && vp.height > 0); // Enabled stream references: video:0 and audio:0. - assert(oakengine_viewer_get_enabled_stream_count(NULL) == 0); + EXPECT_TRUE(oakengine_viewer_get_enabled_stream_count(NULL) == 0); const int count = oakengine_viewer_get_enabled_stream_count(node); - assert(count == 2); + EXPECT_TRUE(count == 2); // Query form (max = 0, NULL arrays) returns the total count. - assert(oakengine_viewer_get_enabled_streams(node, NULL, NULL, 0) == count); + EXPECT_TRUE(oakengine_viewer_get_enabled_streams(node, NULL, NULL, 0) == count); int types[8]; int indices[8]; memset(types, -1, sizeof(types)); memset(indices, -1, sizeof(indices)); - assert(oakengine_viewer_get_enabled_streams(node, types, indices, 8) == + EXPECT_TRUE(oakengine_viewer_get_enabled_streams(node, types, indices, 8) == count); int saw_video = 0, saw_audio = 0; for (int i = 0; i < count; i++) { - assert(indices[i] == 0); + EXPECT_TRUE(indices[i] == 0); if (types[i] == OAKENGINE_TRACK_TYPE_VIDEO) { saw_video = 1; } else if (types[i] == OAKENGINE_TRACK_TYPE_AUDIO) { saw_audio = 1; } else { - assert(0); // unexpected stream type + EXPECT_TRUE(0); // unexpected stream type } } - assert(saw_video && saw_audio); + EXPECT_TRUE(saw_video && saw_audio); // A smaller max truncates the write but still returns the total. types[0] = types[1] = -1; indices[0] = indices[1] = -1; - assert(oakengine_viewer_get_enabled_streams(node, types, indices, 1) == + EXPECT_TRUE(oakengine_viewer_get_enabled_streams(node, types, indices, 1) == count); - assert(types[0] != -1 && types[1] == -1); + EXPECT_TRUE(types[0] != -1 && types[1] == -1); } // ---- Workarea ------------------------------------------------------------------ @@ -275,29 +276,29 @@ static void test_workarea(OakEngineSequence *seq) OakEngineNode *node = as_node(seq); oakengine_viewer_workarea wa; - assert(oakengine_viewer_get_workarea(NULL, &wa) == OAKENGINE_E_INVALID); - assert(oakengine_viewer_get_workarea(node, NULL) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_viewer_get_workarea(NULL, &wa) == OAKENGINE_E_INVALID); + EXPECT_TRUE(oakengine_viewer_get_workarea(node, NULL) == OAKENGINE_E_INVALID); memset(&wa, 0xFF, sizeof(wa)); - assert(oakengine_viewer_get_workarea(node, &wa) == OAKENGINE_OK); - assert(wa.enabled == 0); + EXPECT_TRUE(oakengine_viewer_get_workarea(node, &wa) == OAKENGINE_OK); + EXPECT_TRUE(wa.enabled == 0); - assert(oakengine_viewer_set_workarea_range(NULL, 0, 1, 1, 1) == + EXPECT_TRUE(oakengine_viewer_set_workarea_range(NULL, 0, 1, 1, 1) == OAKENGINE_E_INVALID); - assert(oakengine_viewer_set_workarea_range(node, 1, 1, 5, 1) == + EXPECT_TRUE(oakengine_viewer_set_workarea_range(node, 1, 1, 5, 1) == OAKENGINE_OK); - assert(oakengine_viewer_set_workarea_enabled(NULL, 1) == + EXPECT_TRUE(oakengine_viewer_set_workarea_enabled(NULL, 1) == OAKENGINE_E_INVALID); - assert(oakengine_viewer_set_workarea_enabled(node, 1) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_viewer_set_workarea_enabled(node, 1) == OAKENGINE_OK); memset(&wa, 0, sizeof(wa)); - assert(oakengine_viewer_get_workarea(node, &wa) == OAKENGINE_OK); - assert(wa.in_num == 1 && wa.in_den == 1); - assert(wa.out_num == 5 && wa.out_den == 1); - assert(wa.enabled == 1); + EXPECT_TRUE(oakengine_viewer_get_workarea(node, &wa) == OAKENGINE_OK); + EXPECT_TRUE(wa.in_num == 1 && wa.in_den == 1); + EXPECT_TRUE(wa.out_num == 5 && wa.out_den == 1); + EXPECT_TRUE(wa.enabled == 1); - assert(oakengine_viewer_set_workarea_enabled(node, 0) == OAKENGINE_OK); - assert(oakengine_viewer_get_workarea(node, &wa) == OAKENGINE_OK); - assert(wa.enabled == 0); + EXPECT_TRUE(oakengine_viewer_set_workarea_enabled(node, 0) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_viewer_get_workarea(node, &wa) == OAKENGINE_OK); + EXPECT_TRUE(wa.enabled == 0); } // ---- Parameter setup / waveform ------------------------------------------------- @@ -307,43 +308,43 @@ static void test_parameter_setup(OakEngineProject *project, { OakEngineNode *node = as_node(seq); - assert(oakengine_viewer_set_default_parameters(NULL) == + EXPECT_TRUE(oakengine_viewer_set_default_parameters(NULL) == OAKENGINE_E_INVALID); - assert(oakengine_viewer_set_default_parameters(node) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_viewer_set_default_parameters(node) == OAKENGINE_OK); // set_parameters_from_footage accepts any viewer handles; a second // sequence stands in for the footage array here. OakEngineSequence *other = oakengine_sequence_new(project, "Other"); - assert(other != NULL); + EXPECT_TRUE(other != NULL); OakEngineNode *other_node = as_node(other); - assert(oakengine_viewer_set_parameters_from_footage(NULL, &other_node, + EXPECT_TRUE(oakengine_viewer_set_parameters_from_footage(NULL, &other_node, 1) == OAKENGINE_E_INVALID); - assert(oakengine_viewer_set_parameters_from_footage(node, NULL, 1) == + EXPECT_TRUE(oakengine_viewer_set_parameters_from_footage(node, NULL, 1) == OAKENGINE_E_INVALID); // An empty array is a valid no-op. - assert(oakengine_viewer_set_parameters_from_footage(node, NULL, 0) == + EXPECT_TRUE(oakengine_viewer_set_parameters_from_footage(node, NULL, 0) == OAKENGINE_OK); // One invalid element rejects the whole call. OakEngineNode *solid = oakengine_project_add_node( project, "org.olivevideoeditor.Olive.solidgenerator"); - assert(solid != NULL); + EXPECT_TRUE(solid != NULL); OakEngineNode *mixed[2] = { other_node, solid }; - assert(oakengine_viewer_set_parameters_from_footage(node, mixed, 2) == + EXPECT_TRUE(oakengine_viewer_set_parameters_from_footage(node, mixed, 2) == OAKENGINE_E_INVALID); // All viewers: OK, and the params are adopted. OakEngineNode *viewers[1] = { other_node }; - assert(oakengine_viewer_set_parameters_from_footage(node, viewers, 1) == + EXPECT_TRUE(oakengine_viewer_set_parameters_from_footage(node, viewers, 1) == OAKENGINE_OK); // Waveform toggle; nothing is connected to the samples input, so the // connected waveform is NULL. - assert(oakengine_viewer_set_waveform_enabled(NULL, 1) == + EXPECT_TRUE(oakengine_viewer_set_waveform_enabled(NULL, 1) == OAKENGINE_E_INVALID); - assert(oakengine_viewer_set_waveform_enabled(node, 1) == OAKENGINE_OK); - assert(oakengine_viewer_set_waveform_enabled(node, 0) == OAKENGINE_OK); - assert(oakengine_viewer_get_connected_waveform(NULL) == NULL); - assert(oakengine_viewer_get_connected_waveform( + EXPECT_TRUE(oakengine_viewer_set_waveform_enabled(node, 1) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_viewer_set_waveform_enabled(node, 0) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_viewer_get_connected_waveform(NULL) == NULL); + EXPECT_TRUE(oakengine_viewer_get_connected_waveform( (const OakEngineNode *)node) == NULL); } @@ -374,7 +375,7 @@ struct EventLog { static void record_event(const oakengine_event *event, void *userdata) { struct EventLog *log = (struct EventLog *)userdata; - assert(event != NULL); + EXPECT_TRUE(event != NULL); switch (event->id) { case OAKENGINE_EVENT_VIEWER_PLAYHEAD_CHANGED: log->playhead_events++; @@ -418,7 +419,7 @@ static void record_event(const oakengine_event *event, void *userdata) log->waveform_events++; break; default: - assert(0); // unexpected event id on this subscription + EXPECT_TRUE(0); // unexpected event id on this subscription } } @@ -426,7 +427,7 @@ static int64_t subscribe_checked(OakEngineNode *node, int32_t id, struct EventLog *log) { const int64_t sub = oakengine_event_subscribe(node, id, record_event, log); - assert(sub > 0); + EXPECT_TRUE(sub > 0); return sub; } @@ -440,8 +441,8 @@ static void test_events(OakEngineProject *project, OakEngineSequence *seq, // Family mismatch: a viewer event on a non-viewer node must fail. OakEngineNode *solid = oakengine_project_add_node( project, "org.olivevideoeditor.Olive.solidgenerator"); - assert(solid != NULL); - assert(oakengine_event_subscribe(solid, + EXPECT_TRUE(solid != NULL); + EXPECT_TRUE(oakengine_event_subscribe(solid, OAKENGINE_EVENT_VIEWER_PLAYHEAD_CHANGED, record_event, &log) == 0); @@ -471,65 +472,65 @@ static void test_events(OakEngineProject *project, OakEngineSequence *seq, node, OAKENGINE_EVENT_VIEWER_CONNECTED_WAVEFORM_CHANGED, &log); // Playhead. - assert(oakengine_viewer_set_playhead(node, 3, 1) == OAKENGINE_OK); - assert(log.playhead_events == 1); - assert(log.playhead_num == 3 && log.playhead_den == 1); + EXPECT_TRUE(oakengine_viewer_set_playhead(node, 3, 1) == OAKENGINE_OK); + EXPECT_TRUE(log.playhead_events == 1); + EXPECT_TRUE(log.playhead_num == 3 && log.playhead_den == 1); // Length: placing a real clip makes verify_length() emit // length_changed with the new content length. OakEngineFootage *footage = oakengine_project_import_footage(project, media_path); - assert(footage != NULL); - assert(oakengine_sequence_add_track(seq, OAKENGINE_TRACK_TYPE_VIDEO) == 0); + EXPECT_TRUE(footage != NULL); + EXPECT_TRUE(oakengine_sequence_add_track(seq, OAKENGINE_TRACK_TYPE_VIDEO) == 0); OakEngineClip *clip = oakengine_sequence_add_footage_clip( seq, footage, OAKENGINE_TRACK_TYPE_VIDEO, 0, 0, 30, 0); - assert(clip != NULL); - assert(log.length_events >= 1); - assert(log.length_num > 0 && log.length_den > 0); + EXPECT_TRUE(clip != NULL); + EXPECT_TRUE(log.length_events >= 1); + EXPECT_TRUE(log.length_num > 0 && log.length_den > 0); int64_t len_num = -1, len_den = -1; - assert(oakengine_viewer_get_length(node, &len_num, &len_den) == + EXPECT_TRUE(oakengine_viewer_get_length(node, &len_num, &len_den) == OAKENGINE_OK); - assert(len_num == log.length_num && len_den == log.length_den); + EXPECT_TRUE(len_num == log.length_num && len_den == log.length_den); // Video params: changing the size emits size_changed (with the new // dimensions as a/b) and video_params_changed. - assert(oakengine_sequence_set_video_params(seq, 1280, 720, -1, -1, -1, -1, + EXPECT_TRUE(oakengine_sequence_set_video_params(seq, 1280, 720, -1, -1, -1, -1, -1, -1, 0) == OAKENGINE_OK); - assert(log.size_events == 1); - assert(log.size_w == 1280 && log.size_h == 720); - assert(log.video_params_events == 1); - assert(log.frame_rate_events == 0); - assert(log.pixel_aspect_events == 0); - assert(log.interlacing_events == 0); + EXPECT_TRUE(log.size_events == 1); + EXPECT_TRUE(log.size_w == 1280 && log.size_h == 720); + EXPECT_TRUE(log.video_params_events == 1); + EXPECT_TRUE(log.frame_rate_events == 0); + EXPECT_TRUE(log.pixel_aspect_events == 0); + EXPECT_TRUE(log.interlacing_events == 0); // Pixel aspect and interlacing changes fire their own events. - assert(oakengine_sequence_set_video_params(seq, -1, -1, -1, -1, 4, 3, -1, + EXPECT_TRUE(oakengine_sequence_set_video_params(seq, -1, -1, -1, -1, 4, 3, -1, -1, 0) == OAKENGINE_OK); - assert(log.pixel_aspect_events == 1); - assert(oakengine_sequence_set_video_params(seq, -1, -1, -1, -1, -1, -1, 1, + EXPECT_TRUE(log.pixel_aspect_events == 1); + EXPECT_TRUE(oakengine_sequence_set_video_params(seq, -1, -1, -1, -1, -1, -1, 1, -1, 0) == OAKENGINE_OK); - assert(log.interlacing_events == 1); - assert(log.interlacing_mode == 1); + EXPECT_TRUE(log.interlacing_events == 1); + EXPECT_TRUE(log.interlacing_mode == 1); // Audio params: a new sample rate emits sample_rate_changed (a = rate) // and audio_params_changed. - assert(oakengine_sequence_set_audio_params(seq, 44100, 0, 0) == + EXPECT_TRUE(oakengine_sequence_set_audio_params(seq, 44100, 0, 0) == OAKENGINE_OK); - assert(log.sample_rate_events == 1); - assert(log.sample_rate == 44100); - assert(log.audio_params_events == 1); + EXPECT_TRUE(log.sample_rate_events == 1); + EXPECT_TRUE(log.sample_rate == 44100); + EXPECT_TRUE(log.audio_params_events == 1); // Texture input: the placed clip's track auto-connected the viewer's // texture input, so disconnect it first, then connect a node and check // that texture_input_changed fired. - assert(oakengine_node_disconnect(node, + EXPECT_TRUE(oakengine_node_disconnect(node, oakengine_viewer_texture_input_id()) == OAKENGINE_OK); - assert(oakengine_node_connect(solid, node, + EXPECT_TRUE(oakengine_node_connect(solid, node, oakengine_viewer_texture_input_id()) == OAKENGINE_OK); - assert(log.texture_events >= 1); - assert(oakengine_node_disconnect(node, + EXPECT_TRUE(log.texture_events >= 1); + EXPECT_TRUE(oakengine_node_disconnect(node, oakengine_viewer_texture_input_id()) == OAKENGINE_OK); @@ -538,29 +539,29 @@ static void test_events(OakEngineProject *project, OakEngineSequence *seq, // so only the subscription itself is exercised above. while (n > 0) { - assert(oakengine_event_unsubscribe(subs[--n]) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_event_unsubscribe(subs[--n]) == OAKENGINE_OK); } } -int main(void) +TEST(OakEngineViewer, Main) { make_tmpdir(); // Sandbox the config/cache/data locations. #if !defined(_WIN32) - assert(setenv("XDG_CONFIG_HOME", g_tmpdir, 1) == 0); - assert(setenv("XDG_CACHE_HOME", g_tmpdir, 1) == 0); - assert(setenv("XDG_DATA_HOME", g_tmpdir, 1) == 0); + EXPECT_TRUE(setenv("XDG_CONFIG_HOME", g_tmpdir, 1) == 0); + EXPECT_TRUE(setenv("XDG_CACHE_HOME", g_tmpdir, 1) == 0); + EXPECT_TRUE(setenv("XDG_DATA_HOME", g_tmpdir, 1) == 0); #endif - assert(oakengine_init(OAKENGINE_INIT_HEADLESS) == OAKENGINE_OK); + EXPECT_TRUE(oakengine_init(OAKENGINE_INIT_HEADLESS) == OAKENGINE_OK); OakEngineProject *project = oakengine_project_create(); - assert(project != NULL); - assert(oakengine_project_new(project) == OAKENGINE_OK); + EXPECT_TRUE(project != NULL); + EXPECT_TRUE(oakengine_project_new(project) == OAKENGINE_OK); OakEngineSequence *seq = oakengine_sequence_new(project, "ViewerSeq"); - assert(seq != NULL); + EXPECT_TRUE(seq != NULL); test_from_node(project, seq); test_playhead(seq); @@ -577,16 +578,14 @@ int main(void) // the (empty, sandboxed) user config and may leave invalid params // behind (same hazard oakengine_sequence_new() backfills against). // Restore known-good params so the clip/timebase paths work. - assert(oakengine_sequence_set_video_params(seq, 1920, 1080, 30000, 1001, + EXPECT_TRUE(oakengine_sequence_set_video_params(seq, 1920, 1080, 30000, 1001, 1, 1, 0, -1, 0) == OAKENGINE_OK); - assert(oakengine_sequence_set_audio_params(seq, 48000, 3, 0) == + EXPECT_TRUE(oakengine_sequence_set_audio_params(seq, 48000, 3, 0) == OAKENGINE_OK); test_events(project, seq, media); oakengine_project_free(project); - assert(oakengine_shutdown() == OAKENGINE_OK); + EXPECT_TRUE(oakengine_shutdown() == OAKENGINE_OK); - printf("oakengine_viewer_test: all assertions passed\n"); - return 0; } diff --git a/engine/tests/oakengine_worker_test.cpp b/engine/tests/oakengine_worker_test.cpp index 7776e1480..815181630 100644 --- a/engine/tests/oakengine_worker_test.cpp +++ b/engine/tests/oakengine_worker_test.cpp @@ -26,6 +26,7 @@ // here is a validation/error path that never touches a render backend. #include +#include #include #include #include @@ -39,11 +40,11 @@ static char *handle(OakWorkerSession *session, const char *line) { const int needed = oakengine_worker_session_handle_json(session, line, NULL, 0); - assert(needed >= 0); + EXPECT_TRUE(needed >= 0); char *buf = static_cast(malloc(size_t(needed) + 1)); const int written = oakengine_worker_session_handle_json( session, line, buf, needed + 1); - assert(written == needed); + EXPECT_TRUE(written == needed); buf[needed] = '\0'; return buf; } @@ -55,7 +56,7 @@ static void assert_is_error_with(const char *response, const char *needle) fprintf(stderr, "expected error response containing \"%s\", got: %s\n", needle, response); - assert(0); + EXPECT_TRUE(0); } } @@ -65,51 +66,51 @@ static void test_create_destroy(void) const char *backends[] = { NULL, "", "none", "NONE" }; for (size_t i = 0; i < sizeof(backends) / sizeof(backends[0]); ++i) { OakWorkerSession *s = oakengine_worker_session_create(backends[i]); - assert(s); - assert(oakengine_worker_session_has_renderer(s) == 0); - assert(oakengine_worker_session_shutdown_requested(s) == 0); + EXPECT_TRUE(s); + EXPECT_TRUE(oakengine_worker_session_has_renderer(s) == 0); + EXPECT_TRUE(oakengine_worker_session_shutdown_requested(s) == 0); oakengine_worker_session_free(s); } // NULL tolerance oakengine_worker_session_free(NULL); - assert(oakengine_worker_session_has_renderer(NULL) == 0); - assert(oakengine_worker_session_shutdown_requested(NULL) == 0); - assert(oakengine_worker_session_handle_json(NULL, "{}", NULL, 0) == -1); + EXPECT_TRUE(oakengine_worker_session_has_renderer(NULL) == 0); + EXPECT_TRUE(oakengine_worker_session_shutdown_requested(NULL) == 0); + EXPECT_TRUE(oakengine_worker_session_handle_json(NULL, "{}", NULL, 0) == -1); } static void test_startup_handshake(void) { OakWorkerSession *s = oakengine_worker_session_create("none"); - assert(s); + EXPECT_TRUE(s); // buf/size query convention const int needed = oakengine_worker_session_startup_handshake(s, NULL, 0); - assert(needed > 0); + EXPECT_TRUE(needed > 0); char *buf = static_cast(malloc(size_t(needed) + 1)); - assert(oakengine_worker_session_startup_handshake(s, buf, needed + 1) == + EXPECT_TRUE(oakengine_worker_session_startup_handshake(s, buf, needed + 1) == needed); buf[needed] = '\0'; - assert(strstr(buf, "\"type\":\"handshake\"")); - assert(strstr(buf, "\"protocol_version\":1")); + EXPECT_TRUE(strstr(buf, "\"type\":\"handshake\"")); + EXPECT_TRUE(strstr(buf, "\"protocol_version\":1")); // No renderer -> no GL version announced - assert(!strstr(buf, "gl_major")); + EXPECT_TRUE(!strstr(buf, "gl_major")); free(buf); - assert(oakengine_worker_session_startup_handshake(NULL, NULL, 0) == -1); + EXPECT_TRUE(oakengine_worker_session_startup_handshake(NULL, NULL, 0) == -1); oakengine_worker_session_free(s); } static void test_initialize_runtime(void) { // NULL tolerance - assert(oakengine_worker_session_initialize_runtime(NULL) == 0); + EXPECT_TRUE(oakengine_worker_session_initialize_runtime(NULL) == 0); // Runtime init (EngineCore, factories, managers) must succeed without a // renderer; the session stays usable for control messages afterwards. OakWorkerSession *s = oakengine_worker_session_create("none"); - assert(s); - assert(oakengine_worker_session_initialize_runtime(s) == 1); + EXPECT_TRUE(s); + EXPECT_TRUE(oakengine_worker_session_initialize_runtime(s) == 1); char *r = handle(s, "{\"type\":\"teleport\"}"); assert_is_error_with(r, "unknown message type"); free(r); @@ -165,7 +166,7 @@ static void test_render_frame_before_load_graph(void) "\"node_uuid\":\"abc\",\"time_num\":0,\"time_den\":1}"); assert_is_error_with(r, "render_frame received before load_graph"); // The error carries the ticket id so the caller can correlate - assert(strstr(r, "\"ticket\":7")); + EXPECT_TRUE(strstr(r, "\"ticket\":7")); free(r); oakengine_worker_session_free(s); } @@ -194,15 +195,15 @@ static void test_shutdown_idempotent(void) // Shutdown produces no response and latches the flag char *r = handle(s, "{\"type\":\"shutdown\"}"); - assert(r[0] == '\0'); + EXPECT_TRUE(r[0] == '\0'); free(r); - assert(oakengine_worker_session_shutdown_requested(s) == 1); + EXPECT_TRUE(oakengine_worker_session_shutdown_requested(s) == 1); // Repeating it is a harmless no-op r = handle(s, "{\"type\":\"shutdown\"}"); - assert(r[0] == '\0'); + EXPECT_TRUE(r[0] == '\0'); free(r); - assert(oakengine_worker_session_shutdown_requested(s) == 1); + EXPECT_TRUE(oakengine_worker_session_shutdown_requested(s) == 1); // The session still answers other messages afterwards r = handle(s, "{\"type\":\"teleport\"}"); @@ -216,12 +217,12 @@ static void test_cancel_is_silent(void) { OakWorkerSession *s = oakengine_worker_session_create("none"); char *r = handle(s, "{\"type\":\"cancel\",\"ticket\":3}"); - assert(r[0] == '\0'); + EXPECT_TRUE(r[0] == '\0'); free(r); oakengine_worker_session_free(s); } -int main(void) +TEST(OakEngineWorker, Main) { test_create_destroy(); test_startup_handshake(); @@ -233,5 +234,4 @@ int main(void) test_load_graph_missing_file(); test_shutdown_idempotent(); test_cancel_is_silent(); - return 0; } diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 109bd5a70..0e364753a 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -15,76 +15,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -function(olive_add_test GROUP NAME SOURCE) - file(READ "${SOURCE}" TEST_FILE_CONTENT) - string(REGEX MATCHALL "OAK_ADD_TEST\(.[A-Za-z0-9_]+\)" TEST_FUNCTIONS ${TEST_FILE_CONTENT}) - set(TEST_BODY "int main(int argc, char** argv)\n{\n int ret;(void)ret;") - set(TEST_INDEX 1) - list(LENGTH TEST_FUNCTIONS TEST_COUNT) - foreach (TEST_FUNC ${TEST_FUNCTIONS}) - string(REPLACE "OAK_ADD_TEST(" "" TEST_FUNC "${TEST_FUNC}") - string(APPEND TEST_BODY " std::cout << \"[${TEST_INDEX}/${TEST_COUNT}] ${GROUP} - ${TEST_FUNC}\";\n") - string(APPEND TEST_BODY " if ((ret = olive::Test${TEST_FUNC}()) == OLIVE_TEST_SUCCESS) {std::cout << \" - PASSED\" << std::endl;}else{std::cout << \" - FAILED AT LINE \" << ret << std::endl;return 1;}\n") - MATH(EXPR TEST_INDEX "${TEST_INDEX}+1") - endforeach() - string(APPEND TEST_BODY " return 0;\n}") +# The legacy OAK_ADD_TEST macro framework (olive_add_test) has been retired; +# its timeline/compositing/general suites were migrated to Google Test under +# tests/gtest (see docs/zh/plans/gtest-migration-guide.md). - set_property( - DIRECTORY - APPEND - PROPERTY CMAKE_CONFIGURE_DEPENDS ${SOURCE} - ) - - set(OUTPUT_FILE "${CMAKE_CURRENT_BINARY_DIR}/${SOURCE}") - - string(APPEND TEST_FILE_CONTENT "\n${TEST_BODY}") - file(WRITE "${OUTPUT_FILE}" "${TEST_FILE_CONTENT}") - - add_executable(${NAME} ${OUTPUT_FILE} $ $) - target_include_directories( - ${NAME} - PRIVATE - ${CMAKE_SOURCE_DIR}/app - ${CMAKE_SOURCE_DIR}/tests - ${CMAKE_SOURCE_DIR}/third_party/openfx/include - ${CMAKE_SOURCE_DIR}/third_party/openfx/HostSupport/include - ${OLIVE_INCLUDE_DIRS} - ) - target_link_libraries( - ${NAME} - PRIVATE - oakengine-obj - ${OLIVE_LIBRARIES} - ) - # Export symbols so dlopen'd render backend plugins can resolve engine objects - if (UNIX AND NOT APPLE) - target_link_options(${NAME} PRIVATE "LINKER:--export-dynamic") - endif() - target_compile_definitions( - ${NAME} - PRIVATE - ${OLIVE_DEFINITIONS} - ) - target_compile_options( - ${NAME} - PRIVATE - ${OLIVE_COMPILE_OPTIONS} - ) - if (MSVC) - add_test("Olive.${GROUP}.${NAME}" ${NAME}) - else() - add_test(${NAME} ${NAME}) - endif() - - if (WIN32) - # Windows has no RPATH: ffmpeg_bridge.dll must sit next to the executable - add_custom_command(TARGET ${NAME} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different - $ $) - endif() -endfunction() - -add_subdirectory(compositing) -add_subdirectory(general) -add_subdirectory(timeline) add_subdirectory(gtest) diff --git a/tests/compositing/CMakeLists.txt b/tests/compositing/CMakeLists.txt deleted file mode 100644 index 2dbef7f6b..000000000 --- a/tests/compositing/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -# Olive - Non-Linear Video Editor -# Copyright (C) 2022 Olive Team -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -olive_add_test(Node compositing-tests compositing-tests.cpp) diff --git a/tests/compositing/compositing-tests.cpp b/tests/compositing/compositing-tests.cpp deleted file mode 100644 index f516a63e1..000000000 --- a/tests/compositing/compositing-tests.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/*** - - Olive - Non-Linear video Editor - Copyright (c) 2022 Olive Team - Modifications Copyright (c) 2025 mikesolar - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -***/ - -#include "testutil.h" - -#include "node/distort/crop/cropdistortnode.h" -#include "node/distort/transform/transformdistortnode.h" -#include "node/generator/solid/solid.h" -#include "node/math/merge/merge.h" -#include "node/project.h" -#include "render/rendermanager.h" - -namespace olive -{ - -} diff --git a/tests/general/CMakeLists.txt b/tests/general/CMakeLists.txt deleted file mode 100644 index a41a69ea4..000000000 --- a/tests/general/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -# Olive - Non-Linear Video Editor -# Copyright (C) 2022 Olive Team -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -olive_add_test(General common-tests common-tests.cpp) diff --git a/tests/general/common-tests.cpp b/tests/general/common-tests.cpp deleted file mode 100644 index a13f33b58..000000000 --- a/tests/general/common-tests.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/*** - - Olive - Non-Linear video Editor - Copyright (c) 2022 Olive Team - Modifications Copyright (c) 2025 mikesolar - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -***/ - -#include "testutil.h" - -#include "common/digit.h" - -namespace olive -{ - -OAK_ADD_TEST(DigitTest) -{ - OAK_ASSERT(get_digit_count(1) == 1); - OAK_ASSERT(get_digit_count(69) == 2); - OAK_ASSERT(get_digit_count(420) == 3); - OAK_ASSERT(get_digit_count(1337) == 4); - OAK_ASSERT(get_digit_count(80085) == 5); - OAK_ASSERT(get_digit_count(555555) == 6); - OAK_ASSERT(get_digit_count(8675309) == 7); - OAK_ASSERT(get_digit_count(78956423) == 8); - OAK_ASSERT(get_digit_count(148497523) == 9); - OAK_ASSERT(get_digit_count(4845821233) == 10); - OAK_ASSERT(get_digit_count(18002738255) == 11); - OAK_ASSERT(get_digit_count(180027382556) == 12); - OAK_ASSERT(get_digit_count(1800273825568) == 13); - OAK_ASSERT(get_digit_count(18002738255685) == 14); - OAK_ASSERT(get_digit_count(180027382556857) == 15); - OAK_ASSERT(get_digit_count(1800273825564857) == 16); - - OAK_TEST_END; -} - -} diff --git a/tests/gtest/CMakeLists.txt b/tests/gtest/CMakeLists.txt index 20db1338b..941afc097 100644 --- a/tests/gtest/CMakeLists.txt +++ b/tests/gtest/CMakeLists.txt @@ -119,6 +119,7 @@ add_executable(olive-gtest cli_test.cpp timeline_undo_test.cpp timeline_undo_general_test.cpp + timeline_legacy_test.cpp task_project_test.cpp task_cache_test.cpp codec_oiio_test.cpp diff --git a/tests/gtest/common_digit_test.cpp b/tests/gtest/common_digit_test.cpp index e423c4093..20a9f5fc8 100644 --- a/tests/gtest/common_digit_test.cpp +++ b/tests/gtest/common_digit_test.cpp @@ -21,3 +21,24 @@ TEST(CommonDigit, LargeValue) { EXPECT_EQ(olive::get_digit_count(123456789012345LL), 15); } + +// Migrated from the legacy OAK_ADD_TEST framework (tests/general/common-tests.cpp) +TEST(CommonDigit, LegacyExhaustive) +{ + EXPECT_EQ(olive::get_digit_count(1), 1); + EXPECT_EQ(olive::get_digit_count(69), 2); + EXPECT_EQ(olive::get_digit_count(420), 3); + EXPECT_EQ(olive::get_digit_count(1337), 4); + EXPECT_EQ(olive::get_digit_count(80085), 5); + EXPECT_EQ(olive::get_digit_count(555555), 6); + EXPECT_EQ(olive::get_digit_count(8675309), 7); + EXPECT_EQ(olive::get_digit_count(78956423), 8); + EXPECT_EQ(olive::get_digit_count(148497523), 9); + EXPECT_EQ(olive::get_digit_count(4845821233LL), 10); + EXPECT_EQ(olive::get_digit_count(18002738255LL), 11); + EXPECT_EQ(olive::get_digit_count(180027382556LL), 12); + EXPECT_EQ(olive::get_digit_count(1800273825568LL), 13); + EXPECT_EQ(olive::get_digit_count(18002738255685LL), 14); + EXPECT_EQ(olive::get_digit_count(180027382556857LL), 15); + EXPECT_EQ(olive::get_digit_count(1800273825564857LL), 16); +} diff --git a/tests/gtest/panel_test.cpp b/tests/gtest/panel_test.cpp index b5d7ba6e1..710cf4dd4 100644 --- a/tests/gtest/panel_test.cpp +++ b/tests/gtest/panel_test.cpp @@ -424,7 +424,7 @@ TEST_F(PanelTest, ParamPanelConstructionAndContexts) ParamPanel panel; EXPECT_EQ(panel.objectName(), QStringLiteral("ParamPanel")); - EXPECT_EQ(panel.title(), QStringLiteral("Parameter Editor")); + EXPECT_EQ(panel.title(), QStringLiteral("Inspector")); ASSERT_NE(panel.get_param_view(), nullptr); EXPECT_TRUE(panel.get_contexts().isEmpty()); diff --git a/tests/testutil.h b/tests/testutil.h deleted file mode 100644 index 641be6a24..000000000 --- a/tests/testutil.h +++ /dev/null @@ -1,38 +0,0 @@ -/*** - - Olive - Non-Linear Video Editor - Copyright (C) 2022 Olive Team - Modifications Copyright (C) 2025 mikesolar - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -***/ - -#include - -#define OLIVE_TEST_SUCCESS -1 - -#define OAK_ASSERT(x) \ - if (!(x)) \ - return __LINE__ -#define OAK_ASSERT_EQUAL(x, y) \ - if (x != y) { \ - std::cout << " - Equal assert failed: " << x << " != " << y; \ - return __LINE__; \ - } \ - void() -#define OAK_TEST_END return OLIVE_TEST_SUCCESS - -#define OAK_ADD_TEST(x) int Test##x() -#define OLIVE_ADD_DISABLED_TEST(x) int Test##x() diff --git a/tests/timeline/CMakeLists.txt b/tests/timeline/CMakeLists.txt deleted file mode 100644 index 8f13c1a59..000000000 --- a/tests/timeline/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -# Olive - Non-Linear Video Editor -# Copyright (C) 2022 Olive Team -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -olive_add_test(Timeline timeline-tests timeline-tests.cpp) diff --git a/tests/timeline/timeline-tests.cpp b/tests/timeline/timeline-tests.cpp deleted file mode 100644 index 5eef45c62..000000000 --- a/tests/timeline/timeline-tests.cpp +++ /dev/null @@ -1,632 +0,0 @@ -/*** - - Olive - Non-Linear video Editor - Copyright (c) 2022 Olive Team - Modifications Copyright (c) 2025 mikesolar - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -***/ - -#include "core.h" -#include "node/block/clip/clip.h" -#include "node/block/transition/crossdissolve/crossdissolvetransition.h" -#include "node/math/math/math.h" -#include "node/math/merge/merge.h" -#include "node/project.h" -#include "node/project/sequence/sequence.h" -#include "testutil.h" -#include "timeline/timelineundogeneral.h" -#include "timeline/timelineundopointer.h" -#include "undo/undocommand.h" - -namespace olive -{ - -#define TIMELINE_TEST_START \ - ColorManager::set_up_default_config(); \ - Project project; \ - Sequence sequence; \ - sequence.setParent(&project) - -OAK_ADD_TEST(add_track) -{ - TIMELINE_TEST_START; - - Track *first_video_track, *first_audio_track; - - { - // Test creating initial video track - first_video_track = TimelineAddTrackCommand::run_immediately( - sequence.track_list(Track::k_video)); - - OAK_ASSERT(sequence.get_connected_output(Sequence::k_texture_input) == - first_video_track); - OAK_ASSERT(sequence.track_list(Track::k_video)->get_track_count() == 1); - OAK_ASSERT(sequence.track_list(Track::k_video)->get_track_at(0) == - first_video_track); - } - - { - // Test creating initial audio track - first_audio_track = TimelineAddTrackCommand::run_immediately( - sequence.track_list(Track::k_audio)); - - OAK_ASSERT(sequence.get_connected_output(Sequence::k_samples_input) == - first_audio_track); - OAK_ASSERT(sequence.track_list(Track::k_audio)->get_track_count() == 1); - OAK_ASSERT(sequence.track_list(Track::k_audio)->get_track_at(0) == - first_audio_track); - } - - { - // Test creating second video track with merge - Track *second_video_track = TimelineAddTrackCommand::run_immediately( - sequence.track_list(Track::k_video), true); - OAK_ASSERT(sequence.get_connected_output(Sequence::k_texture_input) != - first_video_track); - OAK_ASSERT(sequence.get_connected_output(Sequence::k_texture_input) != - second_video_track); - OAK_ASSERT(sequence.track_list(Track::k_video)->get_track_count() == 2); - OAK_ASSERT(sequence.track_list(Track::k_video)->get_track_at(1) == - second_video_track); - - MergeNode *merge = dynamic_cast( - sequence.get_connected_output(Sequence::k_texture_input)); - OAK_ASSERT(merge); - OAK_ASSERT(merge->get_connected_output(MergeNode::k_base_in) == - first_video_track); - OAK_ASSERT(merge->get_connected_output(MergeNode::k_blend_in) == - second_video_track); - } - - { - // Test creating second audio track with merge - Track *second_audio_track = TimelineAddTrackCommand::run_immediately( - sequence.track_list(Track::k_audio), true); - OAK_ASSERT(sequence.get_connected_output(Sequence::k_samples_input) != - first_audio_track); - OAK_ASSERT(sequence.get_connected_output(Sequence::k_samples_input) != - second_audio_track); - OAK_ASSERT(sequence.track_list(Track::k_audio)->get_track_count() == 2); - OAK_ASSERT(sequence.track_list(Track::k_audio)->get_track_at(1) == - second_audio_track); - - MathNode *merge = dynamic_cast( - sequence.get_connected_output(Sequence::k_samples_input)); - OAK_ASSERT(merge); - OAK_ASSERT(merge->get_connected_output(MathNode::k_param_a_in) == - first_audio_track); - OAK_ASSERT(merge->get_connected_output(MathNode::k_param_b_in) == - second_audio_track); - } - - OAK_TEST_END; -} - -OAK_ADD_TEST(SequenceDefaults) -{ - TIMELINE_TEST_START; - - sequence.add_default_nodes(); - - OAK_ASSERT(sequence.get_tracks().size() == 2); - - Track *tex_connect = - dynamic_cast(sequence.get_connected_texture_output()); - OAK_ASSERT(tex_connect); - Track *smp_connect = - dynamic_cast(sequence.get_connected_sample_output()); - OAK_ASSERT(smp_connect); - OAK_ASSERT(tex_connect != smp_connect); - OAK_ASSERT(sequence.get_tracks().contains(tex_connect)); - OAK_ASSERT(sequence.get_tracks().contains(smp_connect)); - - OAK_TEST_END; -} - -OAK_ADD_TEST(Trim) -{ - TIMELINE_TEST_START; - - sequence.add_default_nodes(); - - Track *track = sequence.get_tracks().first(); - - ClipBlock *block1 = new ClipBlock(); - block1->set_length_and_media_out(2); - block1->setParent(&project); - track->append_block(block1); - - ClipBlock *block2 = new ClipBlock(); - block2->set_length_and_media_out(2); - block2->setParent(&project); - track->append_block(block2); - - // There should be two blocks right now - OAK_ASSERT(track->blocks().size() == 2); - - { - // Trim out point of second block - BlockTrimCommand command(track, block2, 1, Timeline::k_trim_out); - command.redo_now(); - - // No block should have been added - OAK_ASSERT(track->blocks().size() == 2); - OAK_ASSERT(block2->length() == 1); - OAK_ASSERT(block1->length() == 2); - - command.undo_now(); - - OAK_ASSERT(track->blocks().size() == 2); - OAK_ASSERT(block2->length() == 2); - OAK_ASSERT(block1->length() == 2); - } - - { - // Trim in point of second block - BlockTrimCommand command(track, block2, 1, Timeline::k_trim_in); - command.redo_now(); - - // Gap should be inserted in between - OAK_ASSERT(track->blocks().size() == 3); - GapBlock *gap = dynamic_cast(track->blocks().at(1)); - OAK_ASSERT(gap); - OAK_ASSERT(gap->length() == 1); - OAK_ASSERT(block2->length() == 1); - OAK_ASSERT(block1->length() == 2); - OAK_ASSERT(block1->next() == gap); - OAK_ASSERT(block2->previous() == gap); - - command.undo_now(); - - OAK_ASSERT(track->blocks().size() == 2); - OAK_ASSERT(block2->length() == 2); - OAK_ASSERT(block1->length() == 2); - } - - { - // Trim out point of first block - BlockTrimCommand command(track, block1, 1, Timeline::k_trim_out); - command.redo_now(); - - // Gap should be inserted in between - OAK_ASSERT(track->blocks().size() == 3); - GapBlock *gap = dynamic_cast(track->blocks().at(1)); - OAK_ASSERT(gap); - OAK_ASSERT(gap->length() == 1); - OAK_ASSERT(block1->length() == 1); - OAK_ASSERT(block2->length() == 2); - OAK_ASSERT(block1->next() == gap); - OAK_ASSERT(block2->previous() == gap); - - command.undo_now(); - - OAK_ASSERT(track->blocks().size() == 2); - OAK_ASSERT(block2->length() == 2); - OAK_ASSERT(block1->length() == 2); - } - - { - // Trim in point of first block - BlockTrimCommand command(track, block1, 1, Timeline::k_trim_in); - command.redo_now(); - - // Gap should be prepended to the start - OAK_ASSERT(track->blocks().size() == 3); - GapBlock *gap = dynamic_cast(track->blocks().at(0)); - OAK_ASSERT(gap); - OAK_ASSERT(gap->length() == 1); - OAK_ASSERT(block1->length() == 1); - OAK_ASSERT(block2->length() == 2); - OAK_ASSERT(block1->next() == block2); - OAK_ASSERT(block1->previous() == gap); - - command.undo_now(); - - OAK_ASSERT(track->blocks().size() == 2); - OAK_ASSERT(block2->length() == 2); - OAK_ASSERT(block1->length() == 2); - } - - OAK_TEST_END; -} - -OAK_ADD_TEST(ReplaceBlockWithGap_ClipsOnly) -{ - TIMELINE_TEST_START; - - // create a track that goes clip -> clip -> clip - sequence.add_default_nodes(); - Track *track = sequence.track_list(Track::k_video)->get_tracks().first(); - - ClipBlock *a = new ClipBlock(); - a->setParent(&project); - track->append_block(a); - - ClipBlock *b = new ClipBlock(); - b->setParent(&project); - track->append_block(b); - - ClipBlock *c = new ClipBlock(); - c->setParent(&project); - track->append_block(c); - - { - // Replace clip c with a gap - TrackReplaceBlockWithGapCommand command(track, c); - command.redo_now(); - - // Clip should be removed without any gap actually taking its place, since the clip is at the - // end of the track - OAK_ASSERT(track->blocks().size() == 2); - OAK_ASSERT(track->blocks().at(0) == a); - OAK_ASSERT(track->blocks().at(1) == b); - - command.undo_now(); - - OAK_ASSERT(track->blocks().size() == 3); - OAK_ASSERT(track->blocks().at(0) == a); - OAK_ASSERT(track->blocks().at(1) == b); - OAK_ASSERT(track->blocks().at(2) == c); - } - - { - // Replace clip B with a gap - TrackReplaceBlockWithGapCommand command(track, b); - command.redo_now(); - - // B should be replaced with a gap - OAK_ASSERT(track->blocks().size() == 3); - OAK_ASSERT(track->blocks().at(0) == a); - OAK_ASSERT(track->blocks().at(1) != b); - OAK_ASSERT(dynamic_cast(track->blocks().at(1))); - OAK_ASSERT(track->blocks().at(1)->length() == b->length()); - OAK_ASSERT(track->blocks().at(2) == c); - - command.undo_now(); - - OAK_ASSERT(track->blocks().size() == 3); - OAK_ASSERT(track->blocks().at(0) == a); - OAK_ASSERT(track->blocks().at(1) == b); - OAK_ASSERT(track->blocks().at(2) == c); - } - - OAK_TEST_END; -} - -OAK_ADD_TEST(ReplaceBlockWithGap_ClipsAndGaps) -{ - TIMELINE_TEST_START; - - // create a track that goes clip -> gap -> clip -> clip -> gap -> clip - sequence.add_default_nodes(); - Track *track = sequence.track_list(Track::k_video)->get_tracks().first(); - - ClipBlock *a = new ClipBlock(); - a->setParent(&project); - track->append_block(a); - - GapBlock *b = new GapBlock(); - b->setParent(&project); - track->append_block(b); - - ClipBlock *c = new ClipBlock(); - c->setParent(&project); - track->append_block(c); - - GapBlock *d = new GapBlock(); - d->setParent(&project); - track->append_block(d); - - ClipBlock *e = new ClipBlock(); - e->setParent(&project); - track->append_block(e); - - { - // Replace clip E with a gap - TrackReplaceBlockWithGapCommand command(track, e); - command.redo_now(); - - // Both clips D and E should be removed because this command should remove any trailing gaps - OAK_ASSERT(track->blocks().size() == 3); - OAK_ASSERT(track->blocks().at(0) == a); - OAK_ASSERT(track->blocks().at(1) == b); - OAK_ASSERT(track->blocks().at(2) == c); - - // Test undo - command.undo_now(); - - OAK_ASSERT(track->blocks().size() == 5); - OAK_ASSERT(track->blocks().at(0) == a); - OAK_ASSERT(track->blocks().at(1) == b); - OAK_ASSERT(track->blocks().at(2) == c); - OAK_ASSERT(track->blocks().at(3) == d); - OAK_ASSERT(track->blocks().at(4) == e); - } - - { - // Replace clip A with a gap - Rational original_length_of_a = a->length(); - Rational original_length_of_b = b->length(); - - TrackReplaceBlockWithGapCommand command(track, a); - command.redo_now(); - - // A should be removed and B should take its place - OAK_ASSERT(track->blocks().size() == 4); - - OAK_ASSERT(track->blocks().at(0) == b); - OAK_ASSERT(track->blocks().at(1) == c); - OAK_ASSERT(track->blocks().at(2) == d); - OAK_ASSERT(track->blocks().at(3) == e); - OAK_ASSERT(b->length() == - original_length_of_a + original_length_of_b); - - // Test undo - command.undo_now(); - - OAK_ASSERT(track->blocks().size() == 5); - OAK_ASSERT(track->blocks().at(0) == a); - OAK_ASSERT(track->blocks().at(1) == b); - OAK_ASSERT(track->blocks().at(2) == c); - OAK_ASSERT(track->blocks().at(3) == d); - OAK_ASSERT(track->blocks().at(4) == e); - OAK_ASSERT(a->length() == original_length_of_a); - OAK_ASSERT(b->length() == original_length_of_b); - } - - { - // Replace clip c with a gap - Rational original_length_of_b = b->length(); - Rational original_length_of_c = c->length(); - Rational original_length_of_d = d->length(); - - TrackReplaceBlockWithGapCommand command(track, c); - command.redo_now(); - - // c and D should be removed, and B should take both of their places - OAK_ASSERT(track->blocks().size() == 3); - OAK_ASSERT(track->blocks().at(0) == a); - OAK_ASSERT(track->blocks().at(1) == b); - OAK_ASSERT(track->blocks().at(2) == e); - OAK_ASSERT(b->length() == original_length_of_b + - original_length_of_c + - original_length_of_d); - - // Test undo - command.undo_now(); - - OAK_ASSERT(track->blocks().size() == 5); - OAK_ASSERT(track->blocks().at(0) == a); - OAK_ASSERT(track->blocks().at(1) == b); - OAK_ASSERT(track->blocks().at(2) == c); - OAK_ASSERT(track->blocks().at(3) == d); - OAK_ASSERT(track->blocks().at(4) == e); - OAK_ASSERT(b->length() == original_length_of_b); - OAK_ASSERT(c->length() == original_length_of_c); - OAK_ASSERT(d->length() == original_length_of_d); - } - - { - // add a fourth clip at the end of the track - ClipBlock *f = new ClipBlock(); - f->setParent(&project); - track->append_block(f); - - // Try replacing E with a block again - TrackReplaceBlockWithGapCommand command(track, e); - Rational original_length_of_d = d->length(); - Rational original_length_of_e = e->length(); - command.redo_now(); - - // E should be removed and D should have taken its place - OAK_ASSERT(track->blocks().size() == 5); - OAK_ASSERT(track->blocks().at(0) == a); - OAK_ASSERT(track->blocks().at(1) == b); - OAK_ASSERT(track->blocks().at(2) == c); - OAK_ASSERT(track->blocks().at(3) == d); - OAK_ASSERT(track->blocks().at(4) == f); - OAK_ASSERT(d->length() == - original_length_of_d + original_length_of_e); - - command.undo_now(); - - OAK_ASSERT(track->blocks().size() == 6); - OAK_ASSERT(track->blocks().at(0) == a); - OAK_ASSERT(track->blocks().at(1) == b); - OAK_ASSERT(track->blocks().at(2) == c); - OAK_ASSERT(track->blocks().at(3) == d); - OAK_ASSERT(track->blocks().at(4) == e); - OAK_ASSERT(track->blocks().at(5) == f); - OAK_ASSERT(d->length() == original_length_of_d); - OAK_ASSERT(e->length() == original_length_of_e); - } - - OAK_TEST_END; -} - -#define UsingTransition CrossDissolveTransition - -OAK_ADD_TEST(ReplaceBlockWithGap_ClipsAndTransitions) -{ - TIMELINE_TEST_START; - - // create a track that goes clip -> gap -> clip -> clip -> gap -> clip - sequence.add_default_nodes(); - Track *track = sequence.track_list(Track::k_video)->get_tracks().first(); - - UsingTransition *a_in = new UsingTransition(); - a_in->setParent(&project); - track->append_block(a_in); - - ClipBlock *a = new ClipBlock(); - a->setParent(&project); - track->append_block(a); - - UsingTransition *a_to_b = new UsingTransition(); - a_to_b->setParent(&project); - track->append_block(a_to_b); - - ClipBlock *b = new ClipBlock(); - b->setParent(&project); - track->append_block(b); - - UsingTransition *b_out = new UsingTransition(); - b_out->setParent(&project); - track->append_block(b_out); - - Node::connect_edge(a, NodeInput(a_in, UsingTransition::k_in_block_input)); - Node::connect_edge(a, NodeInput(a_to_b, UsingTransition::k_out_block_input)); - Node::connect_edge(b, NodeInput(a_to_b, UsingTransition::k_in_block_input)); - Node::connect_edge(b, NodeInput(b_out, UsingTransition::k_out_block_input)); - - { - // Replace A with gap - TrackReplaceBlockWithGapCommand command(track, a); - command.redo_now(); - - // A should be replaced with a gap and so should A_IN since A was the only clip connected to it. - // Also A_TO_B should only be connected to B now - OAK_ASSERT(track->blocks().size() == 4); - OAK_ASSERT(dynamic_cast(track->blocks().at(0))); - OAK_ASSERT(track->blocks().at(1) == a_to_b); - OAK_ASSERT(track->blocks().at(2) == b); - OAK_ASSERT(track->blocks().at(3) == b_out); - - command.undo_now(); - - OAK_ASSERT(track->blocks().size() == 5); - OAK_ASSERT(track->blocks().at(0) == a_in); - OAK_ASSERT(track->blocks().at(1) == a); - OAK_ASSERT(track->blocks().at(2) == a_to_b); - OAK_ASSERT(track->blocks().at(3) == b); - OAK_ASSERT(track->blocks().at(4) == b_out); - } - - OAK_TEST_END; -} - -OAK_ADD_TEST(InsertGaps_SingleTrack) -{ - TIMELINE_TEST_START; - - sequence.add_default_nodes(); - - TrackList *list = sequence.track_list(Track::k_video); - Track *track = list->get_tracks().first(); - - ClipBlock *a = new ClipBlock(); - a->set_length_and_media_out(1); - a->setParent(&project); - track->append_block(a); - - ClipBlock *b = new ClipBlock(); - b->set_length_and_media_out(1); - b->setParent(&project); - track->append_block(b); - - ClipBlock *c = new ClipBlock(); - c->set_length_and_media_out(1); - c->setParent(&project); - track->append_block(c); - - OAK_ASSERT(track->blocks().size() == 3); - OAK_ASSERT(track->blocks().at(0) == a); - OAK_ASSERT(track->blocks().at(1) == b); - OAK_ASSERT(track->blocks().at(2) == c); - - { - // insert gap at the start of the track, all blocks should be unsplit and shifted to the right - TrackListInsertGaps command(list, 0, 2); - command.redo_now(); - - OAK_ASSERT(track->blocks().size() == 4); - OAK_ASSERT(dynamic_cast(track->blocks().at(0))); - OAK_ASSERT(track->blocks().at(0)->length() == 2); - OAK_ASSERT(track->blocks().at(1) == a); - OAK_ASSERT(track->blocks().at(2) == b); - OAK_ASSERT(track->blocks().at(3) == c); - - command.undo_now(); - - OAK_ASSERT(track->blocks().size() == 3); - OAK_ASSERT(track->blocks().at(0) == a); - OAK_ASSERT(track->blocks().at(1) == b); - OAK_ASSERT(track->blocks().at(2) == c); - } - - { - // insert gap in the middle of block A, block A should be halved with a copy at 2 and the gap at 1 - TrackListInsertGaps command(list, Rational(1, 2), 2); - command.redo_now(); - - OAK_ASSERT(track->blocks().size() == 5); - OAK_ASSERT(track->blocks().at(0) == a); - OAK_ASSERT(track->blocks().at(0)->length() == Rational(1, 2)); - OAK_ASSERT(dynamic_cast(track->blocks().at(1))); - OAK_ASSERT(dynamic_cast(track->blocks().at(2))); - OAK_ASSERT(track->blocks().at(3) == b); - OAK_ASSERT(track->blocks().at(4) == c); - - command.undo_now(); - - OAK_ASSERT_EQUAL(track->blocks().size(), 3); - OAK_ASSERT_EQUAL(track->blocks().at(0), a); - OAK_ASSERT_EQUAL(track->blocks().at(0)->length(), 1); - OAK_ASSERT_EQUAL(track->blocks().at(1), b); - OAK_ASSERT_EQUAL(track->blocks().at(2), c); - } - - { - // insert gap between block A and B, blocks should be unsplit with a gap at 1 - TrackListInsertGaps command(list, 1, 2); - command.redo_now(); - - OAK_ASSERT(track->blocks().size() == 4); - OAK_ASSERT(track->blocks().at(0) == a); - OAK_ASSERT(dynamic_cast(track->blocks().at(1))); - OAK_ASSERT(track->blocks().at(2) == b); - OAK_ASSERT(track->blocks().at(3) == c); - - command.undo_now(); - - OAK_ASSERT(track->blocks().size() == 3); - OAK_ASSERT(track->blocks().at(0) == a); - OAK_ASSERT(track->blocks().at(1) == b); - OAK_ASSERT(track->blocks().at(2) == c); - } - - { - // insert gap at end, nothing should be added - TrackListInsertGaps command(list, 3, 2); - command.redo_now(); - - OAK_ASSERT(track->blocks().size() == 3); - OAK_ASSERT(track->blocks().at(0) == a); - OAK_ASSERT(track->blocks().at(1) == b); - OAK_ASSERT(track->blocks().at(2) == c); - - command.undo_now(); - - OAK_ASSERT(track->blocks().size() == 3); - OAK_ASSERT(track->blocks().at(0) == a); - OAK_ASSERT(track->blocks().at(1) == b); - OAK_ASSERT(track->blocks().at(2) == c); - } - - OAK_TEST_END; -} - -}