Skip to content

Commit

Permalink
Merge pull request #25310 from notspiff/add_guicontrol_factory_tests
Browse files Browse the repository at this point in the history
Add some tests for CGUIControlFactory
  • Loading branch information
notspiff committed Jun 23, 2024
2 parents 5069e47 + e9bdd97 commit 8d1bef6
Show file tree
Hide file tree
Showing 10 changed files with 990 additions and 5 deletions.
1 change: 1 addition & 0 deletions cmake/treedata/common/tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ xbmc/cores/VideoPlayer/VideoRenderers/VideoShaders/test test/videoshaders
xbmc/filesystem/test test/filesystem
xbmc/games/addons/input/test test/games/addons/input
xbmc/games/controllers/input/test test/games/controllers/input
xbmc/guilib/test test/guilib
xbmc/imagefiles/test test/imagefiles
xbmc/input/keyboard/test test/input/keyboard
xbmc/interfaces/python/test test/python
Expand Down
10 changes: 10 additions & 0 deletions xbmc/guilib/GUIAction.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ class CGUIAction
*/
void SetAction(const std::string& action);

bool operator==(const CExecutableAction& right) const
{
return m_condition == right.m_condition && m_action == right.m_action;
}

private:
/**
* Executable action default constructor
Expand Down Expand Up @@ -123,6 +128,11 @@ class CGUIAction
*/
void Reset();

bool operator==(const CGUIAction& rhs) const
{
return m_actions == rhs.m_actions && m_sendThreadMessages == rhs.m_sendThreadMessages;
}

private:
std::vector<CExecutableAction> m_actions;
bool m_sendThreadMessages = false;
Expand Down
7 changes: 6 additions & 1 deletion xbmc/guilib/GUIComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ CGUIComponent::CGUIComponent()
{
}

CGUIComponent::CGUIComponent(bool)
{
}

CGUIComponent::~CGUIComponent()
{
Deinit();
Expand All @@ -50,7 +54,8 @@ void CGUIComponent::Deinit()
{
CServiceBroker::UnregisterGUI();

m_pWindowManager->DeInitialize();
if (m_pWindowManager)
m_pWindowManager->DeInitialize();
}

CGUIWindowManager& CGUIComponent::GetWindowManager()
Expand Down
1 change: 1 addition & 0 deletions xbmc/guilib/GUIComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class CGUIComponent
{
public:
CGUIComponent();
explicit CGUIComponent(bool);
virtual ~CGUIComponent();
void Init();
void Deinit();
Expand Down
4 changes: 2 additions & 2 deletions xbmc/guilib/GUIControlFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,15 @@ class CGUIControlFactory
const std::string& scrollerTag,
CScroller& scroller);

private:
protected:
static std::string GetType(const TiXmlElement* pControlNode);
static bool GetMovingSpeedConfig(const TiXmlNode* pRootNode,
const char* strTag,
KODI::UTILS::MOVING_SPEED::MapEventConfig& movingSpeedCfg);
static bool GetConditionalVisibility(const TiXmlNode* control,
std::string& condition,
std::string& allowHiddenFocus);
bool GetString(const TiXmlNode* pRootNode, const char* strTag, std::string& strString);
static bool GetString(const TiXmlNode* pRootNode, const char* strTag, std::string& strString);
static bool GetFloatRange(const TiXmlNode* pRootNode,
const char* strTag,
float& iMinValue,
Expand Down
25 changes: 24 additions & 1 deletion xbmc/guilib/GUITexture.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,13 @@ class CAspectRatio
ratio = aspect;
align = ASPECT_ALIGN_CENTER | ASPECT_ALIGNY_CENTER;
scaleDiffuse = true;
};
}

CAspectRatio(ASPECT_RATIO aspect, uint32_t al, bool scaleD)
: ratio(aspect), align(al), scaleDiffuse(scaleD)
{
}

bool operator!=(const CAspectRatio &right) const
{
if (ratio != right.ratio) return true;
Expand All @@ -53,6 +59,23 @@ class CTextureInfo
public:
CTextureInfo();
explicit CTextureInfo(const std::string &file);
CTextureInfo(bool large,
CRect bord,
bool fill,
int orient,
std::string diff,
KODI::GUILIB::GUIINFO::CGUIInfoColor color,
std::string f)
: useLarge(large),
border(bord),
m_infill(fill),
orientation(orient),
diffuse(std::move(diff)),
diffuseColor(color),
filename(std::move(f))
{
}

bool useLarge;
CRect border; // scaled - unneeded if we get rid of scale on load
bool m_infill{
Expand Down
3 changes: 2 additions & 1 deletion xbmc/guilib/guiinfo/GUIInfoColor.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ namespace GUIINFO
class CGUIInfoColor
{
public:
constexpr CGUIInfoColor(KODI::UTILS::COLOR::Color color = 0) : m_color(color) {}
constexpr CGUIInfoColor(UTILS::COLOR::Color color = 0) : m_color(color) {}
constexpr CGUIInfoColor(UTILS::COLOR::Color color, int info) : m_info(info), m_color(color) {}

constexpr operator KODI::UTILS::COLOR::Color() const { return m_color; }

Expand Down
3 changes: 3 additions & 0 deletions xbmc/guilib/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
set(SOURCES TestGUIControlFactory.cpp)

core_add_test_library(guilib_test)
Loading

0 comments on commit 8d1bef6

Please sign in to comment.