Files
oak-editor/tests/gtest/ui_icons_test.cpp
T
Mike-Solar bb40b4923e style: unify identifier naming per updated conventions
Automated with clang-tidy readability-identifier-naming (config added to
.clang-tidy) plus scripted passes, per the updated rules now documented
in CONTRIBUTING.md:

- types (class/struct/enum/alias/template params): PascalCase
- functions, variables, members: snake_case (incl. rational -> Rational)
- private/protected members: trailing underscore; static member
  variables likewise (instance_, available_themes_)
- constants and enum values: snake_case (kLinear -> k_linear,
  F32P -> f32p); ALL_CAPS reserved for macros
- macros: OAK_ prefix (OLIVE_ADD_TEST/OLIVE_ASSERT/OLIVE_CONFIG ->
  OAK_ADD_TEST/OAK_ASSERT/OAK_CONFIG, GL_PREAMBLE -> OAK_GL_PREAMBLE,
  include guards -> OAK_*)
- file names: all lowercase (Current/Plugin/OliveHost/OliveClip/
  OlivePluginInstance -> current/plugin/olivehost/oliveclip/
  oliveplugininstance)
- getters share the member name sans underscore, setters set_foo()
- Qt and third-party (OpenFX) virtual overrides and framework callbacks
  keep their original names (exempt in .clang-tidy)

Manual follow-ups required where automation could not reach:
- string-based QMetaObject/SIGNAL/SLOT references updated to renamed
  methods (AddTask, CreatedFile, DeleteSpecificFile, moveSelectionUp, ...)
- macro bodies referencing renamed methods (OLIVE_CONFIG,
  NODE_DEFAULT_DESTRUCTOR, MANAGEDDISPLAYWIDGET_*)
- self-shadowing locals renamed where signals/methods became same-named
  (size_changed, worker_count, selected_items, import param, filters)
- third_party OFX member/namespace usages restored (OFX::Host::*,
  _created, _clipPrefsDirty, createInstance, clearPersistentMessage)
- STL protocol aliases restored (const_iterator) with .clang-tidy
  ignore rules; qHash overloads restored

Full build and test suite pass: ctest 4/4, ~1960 gtest cases green.
2026-07-19 16:10:54 +08:00

122 lines
4.0 KiB
C++

#include <gtest/gtest.h>
#include <QFile>
#include <QIcon>
#include <QVector>
#include "ui/icons/icons.h"
TEST(UIIcons, ThemeResourcesAreRegistered)
{
// Both themes compile their icons into the binary via AUTORCC resources
EXPECT_TRUE(
QFile::exists(QStringLiteral(":/style/olive-dark/png/play.16.png")));
EXPECT_TRUE(
QFile::exists(QStringLiteral(":/style/olive-light/png/play.16.png")));
EXPECT_TRUE(QFile::exists(QStringLiteral(":/style/olive-dark/palette.ini")));
EXPECT_TRUE(QFile::exists(QStringLiteral(":/style/olive-dark/style.css")));
}
TEST(UIIcons, CreateLoadsAllSizes)
{
QIcon icon = olive::icon::create(QStringLiteral(":/style/olive-dark"),
QStringLiteral("play"));
ASSERT_FALSE(icon.isNull());
// genicons.sh generates 16/32/64/128 px variants of every icon
const QList<QSize> sizes = icon.availableSizes();
for (int sz : { 16, 32, 64, 128 }) {
EXPECT_TRUE(sizes.contains(QSize(sz, sz))) << "Missing size " << sz;
}
EXPECT_FALSE(icon.pixmap(QSize(32, 32)).isNull());
}
TEST(UIIcons, CreateWithUnknownNameYieldsNoUsableIcon)
{
QIcon icon = olive::icon::create(QStringLiteral(":/style/olive-dark"),
QStringLiteral("no-such-icon"));
// QIcon::addFile() differs across Qt builds in whether entries for
// nonexistent files keep the icon "null". What matters is that no usable
// pixmap can be produced for an unknown icon name.
EXPECT_TRUE(icon.availableSizes().isEmpty());
EXPECT_TRUE(icon.pixmap(QSize(16, 16)).isNull());
EXPECT_TRUE(icon.pixmap(32, 32, QIcon::Disabled).isNull());
}
TEST(UIIcons, LoadAllPopulatesGlobalIcons)
{
olive::icon::load_all(QStringLiteral(":/style/olive-dark"));
const QVector<QIcon *> all = { &olive::icon::go_to_start,
&olive::icon::prev_frame,
&olive::icon::play,
&olive::icon::pause,
&olive::icon::next_frame,
&olive::icon::go_to_end,
&olive::icon::New,
&olive::icon::open,
&olive::icon::save,
&olive::icon::undo,
&olive::icon::redo,
&olive::icon::tree_view,
&olive::icon::list_view,
&olive::icon::icon_view,
&olive::icon::tool_pointer,
&olive::icon::tool_edit,
&olive::icon::tool_ripple,
&olive::icon::tool_rolling,
&olive::icon::tool_razor,
&olive::icon::tool_slip,
&olive::icon::tool_slide,
&olive::icon::tool_hand,
&olive::icon::tool_transition,
&olive::icon::tool_track_select,
&olive::icon::folder,
&olive::icon::sequence,
&olive::icon::video,
&olive::icon::audio,
&olive::icon::image,
&olive::icon::mini_map,
&olive::icon::tri_up,
&olive::icon::tri_left,
&olive::icon::tri_down,
&olive::icon::tri_right,
&olive::icon::text_bold,
&olive::icon::text_italic,
&olive::icon::text_underline,
&olive::icon::text_strikethrough,
&olive::icon::text_small_caps,
&olive::icon::text_align_left,
&olive::icon::text_align_right,
&olive::icon::text_align_center,
&olive::icon::text_align_justify,
&olive::icon::text_align_top,
&olive::icon::text_align_bottom,
&olive::icon::text_align_middle,
&olive::icon::snapping,
&olive::icon::zoom_in,
&olive::icon::zoom_out,
&olive::icon::record,
&olive::icon::add,
&olive::icon::error,
&olive::icon::dir_up,
&olive::icon::clock,
&olive::icon::diamond,
&olive::icon::plus,
&olive::icon::minus,
&olive::icon::add_effect,
&olive::icon::eye_opened,
&olive::icon::eye_closed,
&olive::icon::lock_opened,
&olive::icon::lock_closed,
&olive::icon::pencil,
&olive::icon::subtitles,
&olive::icon::color_picker };
for (const QIcon *icon : all) {
EXPECT_FALSE(icon->isNull());
}
}