diff --git a/README.md b/README.md index 2b430e9..b7cd74b 100755 --- a/README.md +++ b/README.md @@ -23,14 +23,14 @@ A simple and easy to use library for Philips Hue Lights ## How to use ### Searching for Bridges To start searching for a Hue Bridge you will need to choose an IHttpHandler and create one. The options are a "WinHttpHandler" (for windows) or a "LinHttpHandler" (for linux). -Then create a HueFinder object with the handler. +Then create a BridgeFinder object with the handler. The handler is needed, because it tells the finder which functions to use to communicate with a bridge or your local network. After that you can call FindBridges(), which will return a vector containing the ip and mac address of all found Bridges. ```C++ // For windows use std::make_shared(); handler = std::make_shared(); -hueplusplus::HueFinder finder(handler); -std::vector bridges = finder.FindBridges(); +hueplusplus::BridgeFinder finder(handler); +std::vector bridges = finder.FindBridges(); if (bridges.empty()) { std::cerr << "No bridges found\n"; @@ -44,32 +44,32 @@ If you have found the Bridge you were looking for, you can then move on with the To get a new username from the Bridge (for now) you simply call GetBridge(bridges[\]), where index is your preferred Bridge from the part [Searching for Bridges](#searchingBridges). ```C++ -hueplusplus::Hue bridge = finder.GetBridge(bridges[0]); +hueplusplus::Bridge bridge = finder.GetBridge(bridges[0]); ``` If you on the other hand already have a username you can add your bridge like so ```C++ finder.AddUsername(bridges[0].mac, ""); -hueplusplus::Hue bridge = finder.GetBridge(bridges[0]); +hueplusplus::Bridge bridge = finder.GetBridge(bridges[0]); ``` -If you do not want to use the HueFinder or you already know the ip and username of your bridge you have the option to create your own Hue object. +If you do not want to use the BridgeFinder or you already know the ip and username of your bridge you have the option to create your own Bridge object. Here you will need to provide the ip address, the port number, a username and an HttpHandler ```C++ // For windows use std::make_shared(); handler = std::make_shared(); -hueplusplus::Hue bridge("192.168.2.102", 80, "", handler); +hueplusplus::Bridge bridge("192.168.2.102", 80, "", handler); ``` ### Controlling lights If you have your Bridge all set up, you can now control its lights. -For that create a new HueLight object and call lights().get(\) on your bridge object to get a reference to a specific light, where id +For that create a new Light object and call lights().get(\) on your bridge object to get a reference to a specific light, where id is the id of the light set internally by the Hue Bridge. ```C++ -hueplusplus::HueLight light1 = bridge.lights().get(1); +hueplusplus::Light light1 = bridge.lights().get(1); ``` If you don't know the id of a specific light or want to get an overview over all lights that are controlled by your bridge, you can get a vector containing them by calling getAll(). If no lights are found the vector will be empty. ```C++ -std::vector> lights = bridge.lights().getAll(); +std::vector> lights = bridge.lights().getAll(); ``` If you now want to control a light, call a specific function of it. ```C++ diff --git a/doc/markdown/Mainpage.md b/doc/markdown/Mainpage.md index 3907bb3..78d7aab 100644 --- a/doc/markdown/Mainpage.md +++ b/doc/markdown/Mainpage.md @@ -19,14 +19,14 @@ A simple and easy to use library for Philips Hue Lights. ### Searching for Bridges To start searching for a Hue Bridge you will need to choose an IHttpHandler and create one. The options are a [WinHttpHandler](@ref hueplusplus::WinHttpHandler) (for windows) or a [LinHttpHandler](@ref hueplusplus::LinHttpHandler) (for linux or linux-like). -Then create a [HueFinder](@ref hueplusplus::HueFinder) object with the handler. +Then create a [BridgeFinder](@ref hueplusplus::BridgeFinder) object with the handler. The handler is needed, because it tells the finder which functions to use to communicate with a bridge or your local network. -After that you can call [FindBridges()](@ref hueplusplus::HueFinder::FindBridges), which will return a vector containing the ip and mac address of all found Bridges. +After that you can call [FindBridges()](@ref hueplusplus::BridgeFinder::FindBridges), which will return a vector containing the ip and mac address of all found Bridges. ```{.cpp} // For windows use std::make_shared(); handler = std::make_shared(); -hueplusplus::HueFinder finder(handler); -std::vector bridges = finder.FindBridges(); +hueplusplus::BridgeFinder finder(handler); +std::vector bridges = finder.FindBridges(); if (bridges.empty()) { std::cerr << "No bridges found\n"; @@ -37,35 +37,35 @@ if (bridges.empty()) ### Authenticate Bridges If you have found the Bridge you were looking for, you can then move on with the authentication process. -To get a new username from the Bridge (for now) you simply call [GetBridge(bridges[\])](@ref hueplusplus::HueFinder::GetBridge), +To get a new username from the Bridge (for now) you simply call [GetBridge(bridges[\])](@ref hueplusplus::BridgeFinder::GetBridge), where index is your preferred Bridge from the part [Searching for Bridges](#searchingBridges). This requires the user to press the link button. ```{.cpp} -hueplusplus::Hue bridge = finder.GetBridge(bridges[0]); +hueplusplus::Bridge bridge = finder.GetBridge(bridges[0]); ``` If you on the other hand already have a username you can add your bridge like so ```{.cpp} finder.AddUsername(bridges[0].mac, ""); -hueplusplus::Hue bridge = finder.GetBridge(bridges[0]); +hueplusplus::Bridge bridge = finder.GetBridge(bridges[0]); ``` -If you do not want to use the HueFinder or you already know the ip and username of your bridge you have the option to create your own Hue object. +If you do not want to use the BridgeFinder or you already know the ip and username of your bridge you have the option to create your own Bridge object. Here you will need to provide the ip address, the port number, a username and an HttpHandler ```{.cpp} // For windows use std::make_shared(); handler = std::make_shared(); -hueplusplus::Hue bridge("192.168.2.102", 80, "", handler); +hueplusplus::Bridge bridge("192.168.2.102", 80, "", handler); ``` ### Controlling lights If you have your Bridge all set up, you can now control its lights. -For that create a new HueLight object and call [lights().get(\)](@ref hueplusplus::ResourceList::get) on your bridge object to get a reference to a specific light, where id +For that create a new Light object and call [lights().get(\)](@ref hueplusplus::ResourceList::get) on your bridge object to get a reference to a specific light, where id is the id of the light set internally by the Hue Bridge. ```{.cpp} -hueplusplus::HueLight light1 = bridge.lights().get(1); +hueplusplus::Light light1 = bridge.lights().get(1); ``` If you don't know the id of a specific light or want to get an overview over all lights that are controlled by your bridge, you can get a vector containing them by calling [getAll()](@ref hueplusplus::ResourceList::getAll) on your bridge object. If no lights are found the vector will be empty. ```{.cpp} -std::vector> lights = bridge.lights().getAll(); +std::vector> lights = bridge.lights().getAll(); ``` If you now want to control a light, call a specific function of it. ```{.cpp} @@ -79,7 +79,7 @@ lights.at(1).setColorHue(4562); ``` But keep in mind that some light types do not have all functions available. So you might call a specific function, but nothing will happen. For that you might want to check what type -of a light you are controlling. For that you can call the function [getColorType()](@ref hueplusplus::HueLight::getColorType()), which will return +of a light you are controlling. For that you can call the function [getColorType()](@ref hueplusplus::Light::getColorType()), which will return a ColorType. ```{.cpp} hueplusplus::ColorType type1 = light1.getColorType(); diff --git a/include/hueplusplus/Hue.h b/include/hueplusplus/Bridge.h index d4ea928..24deaa1 100644 --- a/include/hueplusplus/Hue.h +++ b/include/hueplusplus/Bridge.h @@ -1,5 +1,5 @@ /** - \file Hue.h + \file Bridge.h Copyright Notice\n Copyright (C) 2017 Jan Rogall - developer\n Copyright (C) 2017 Moritz Wirger - developer\n @@ -37,12 +37,12 @@ #include "Group.h" #include "HueCommandAPI.h" #include "HueDeviceTypes.h" -#include "HueLight.h" -#include "HueSensor.h" #include "IHttpHandler.h" +#include "Light.h" #include "ResourceList.h" #include "Scene.h" #include "Schedule.h" +#include "Sensor.h" #include "Utils.h" #include "json/json.hpp" @@ -51,15 +51,15 @@ namespace hueplusplus { // forward declarations -class Hue; +class Bridge; //! //! Class to find all Hue bridges on the network and create usernames for them. //! -class HueFinder +class BridgeFinder { public: - struct HueIdentification + struct BridgeIdentification { std::string ip; int port = 80; @@ -67,10 +67,10 @@ public: }; public: - //! \brief Constructor of HueFinder class + //! \brief Constructor of BridgeFinder class //! //! \param handler HttpHandler of type \ref IHttpHandler for communication with the bridge - HueFinder(std::shared_ptr handler); + BridgeFinder(std::shared_ptr handler); //! \brief Finds all bridges in the network and returns them. //! @@ -78,17 +78,17 @@ public: //! \return vector containing ip and mac of all found bridges //! \throws std::system_error when system or socket operations fail //! \throws HueException when response contained no body - std::vector FindBridges() const; + std::vector FindBridges() const; - //! \brief Gets a \ref Hue bridge based on its identification + //! \brief Gets a Hue bridge based on its identification //! - //! \param identification \ref HueIdentification that specifies a bridge - //! \return \ref Hue class object + //! \param identification \ref BridgeIdentification that specifies a bridge + //! \return \ref Bridge class object //! \throws std::system_error when system or socket operations fail //! \throws HueException when response contained no body or username could not be requested //! \throws HueAPIResponseException when response contains an error //! \throws nlohmann::json::parse_error when response could not be parsed - Hue GetBridge(const HueIdentification& identification); + Bridge GetBridge(const BridgeIdentification& identification); //! \brief Function that adds a username to the usernames map //! @@ -116,26 +116,26 @@ private: static std::string ParseDescription(const std::string& description); std::map usernames; //!< Maps all macs to usernames added by \ref - //!< HueFinder::AddUsername + //!< BridgeFinder::AddUsername std::shared_ptr http_handler; }; -//! \brief Hue class for a bridge. +//! \brief Bridge class for a bridge. //! //! This is the main class used to interact with the Hue bridge. -class Hue +class Bridge { - friend class HueFinder; + friend class BridgeFinder; public: - using LightList = ResourceList; + using LightList = ResourceList; using GroupList = GroupResourceList; using ScheduleList = CreateableResourceList; using SceneList = CreateableResourceList; - using SensorList = ResourceList; + using SensorList = ResourceList; public: - //! \brief Constructor of Hue class + //! \brief Constructor of Bridge class //! //! \param ip IP address in dotted decimal notation like "192.168.2.1" //! \param port Port of the hue bridge @@ -143,7 +143,8 @@ public: //! the bridge. Can be left empty and acquired in \ref requestUsername. //! \param handler HttpHandler for communication with the bridge //! \param refreshDuration Time between refreshing the cached state. - Hue(const std::string& ip, const int port, const std::string& username, std::shared_ptr handler, + Bridge(const std::string& ip, const int port, const std::string& username, + std::shared_ptr handler, std::chrono::steady_clock::duration refreshDuration = std::chrono::seconds(10)); //! \brief Refreshes the bridge state. @@ -200,9 +201,9 @@ public: //! \note Does not refresh state. const BridgeConfig& config() const; - //! \brief Provides access to the HueLight%s on the bridge. + //! \brief Provides access to the Light%s on the bridge. LightList& lights(); - //! \brief Provides access to the HueLight%s on the bridge. + //! \brief Provides access to the Light%s on the bridge. //! \note Does not refresh state. const LightList& lights() const; @@ -224,9 +225,9 @@ public: //! \note Does not refresh state. const SceneList& scenes() const; - //! \brief Provides access to the HueSensor%s on the bridge. + //! \brief Provides access to the Sensor%s on the bridge. SensorList& sensors(); - //! \brief Provides access to the HueSensor%s on the bridge. + //! \brief Provides access to the Sensor%s on the bridge. //! \note Does not refresh state. const SensorList& sensors() const; @@ -236,7 +237,7 @@ private: //! //! The HttpHandler and HueCommandAPI are used for bridge communication. //! Resetting the HttpHandler should only be done when the username is first set, - //! before Hue is used. + //! before Bridge is used. //! Resets all caches and resource lists. void setHttpHandler(std::shared_ptr handler); diff --git a/include/hueplusplus/BrightnessStrategy.h b/include/hueplusplus/BrightnessStrategy.h index 9e935ed..65ee233 100644 --- a/include/hueplusplus/BrightnessStrategy.h +++ b/include/hueplusplus/BrightnessStrategy.h @@ -27,7 +27,7 @@ namespace hueplusplus { -class HueLight; +class Light; //! Virtual base class for all BrightnessStrategies class BrightnessStrategy @@ -40,19 +40,19 @@ public: //! \param transition The time it takes to fade to the new brightness in //! multiples of 100ms, 4 = 400ms and should be seen as the default \param //! light A reference of the light - virtual bool setBrightness(unsigned int bri, uint8_t transition, HueLight& light) const = 0; + virtual bool setBrightness(unsigned int bri, uint8_t transition, Light& light) const = 0; //! \brief Virtual function that returns the current brightnessof the light //! //! Should update the lights state by calling refreshState() //! \param light A reference of the light //! \return Unsigned int representing the brightness - virtual unsigned int getBrightness(HueLight& light) const = 0; + virtual unsigned int getBrightness(Light& light) const = 0; //! \brief Virtual function that returns the current brightness of the light //! //! \note This should not update the lights state //! \param light A const reference of the light //! \return Unsigned int representing the brightness - virtual unsigned int getBrightness(const HueLight& light) const = 0; + virtual unsigned int getBrightness(const Light& light) const = 0; //! \brief Virtual dtor virtual ~BrightnessStrategy() = default; }; diff --git a/include/hueplusplus/ColorHueStrategy.h b/include/hueplusplus/ColorHueStrategy.h index 9eee184..30304fb 100644 --- a/include/hueplusplus/ColorHueStrategy.h +++ b/include/hueplusplus/ColorHueStrategy.h @@ -30,7 +30,7 @@ namespace hueplusplus { -class HueLight; +class Light; //! Virtual base class for all ColorHueStrategies class ColorHueStrategy @@ -44,7 +44,7 @@ public: //! The time it takes to fade to the new color in multiples of 100ms, 4 = //! 400ms and should be seen as the default \param light A reference of the //! light - virtual bool setColorHue(uint16_t hue, uint8_t transition, HueLight& light) const = 0; + virtual bool setColorHue(uint16_t hue, uint8_t transition, Light& light) const = 0; //! \brief Virtual function for changing a lights color in saturation with a //! specified transition. //! @@ -53,7 +53,7 @@ public: //! color \param transition The time it takes to fade to the new color in //! multiples of 100ms, 4 = 400ms and should be seen as the default \param //! light A reference of the light - virtual bool setColorSaturation(uint8_t sat, uint8_t transition, HueLight& light) const = 0; + virtual bool setColorSaturation(uint8_t sat, uint8_t transition, Light& light) const = 0; //! \brief Virtual function for changing a lights color in hue and saturation //! format with a specified transition. //! @@ -61,7 +61,7 @@ public: //! \param transition The time it takes to fade to the new color in multiples of //! 100ms, 4 = 400ms and should be seen as the default //! \param light A reference of the light - virtual bool setColorHueSaturation(const HueSaturation& hueSat, uint8_t transition, HueLight& light) const = 0; + virtual bool setColorHueSaturation(const HueSaturation& hueSat, uint8_t transition, Light& light) const = 0; //! \brief Virtual function for changing a lights color in CIE format with a //! specified transition. //! @@ -69,7 +69,7 @@ public: //! \param transition The time it takes to fade to the new color in multiples //! of 100ms, 4 = 400ms and should be seen as the default \param light A //! reference of the light - virtual bool setColorXY(const XYBrightness& xy, uint8_t transition, HueLight& light) const = 0; + virtual bool setColorXY(const XYBrightness& xy, uint8_t transition, Light& light) const = 0; //! \brief Virtual function for turning on/off the color loop feature of a //! light. @@ -83,43 +83,43 @@ public: //! alternatively call Off() and then use any of the setter functions. \param //! on Boolean to turn this feature on or off, true/1 for on and false/0 for //! off \param light A reference of the light - virtual bool setColorLoop(bool on, HueLight& light) const = 0; + virtual bool setColorLoop(bool on, Light& light) const = 0; //! \brief Virtual function that lets the light perform one breath cycle in //! the specified color. //! //! \param hueSat The color in hue and saturation //! \param light A reference of the light - virtual bool alertHueSaturation(const HueSaturation& hueSat, HueLight& light) const = 0; + virtual bool alertHueSaturation(const HueSaturation& hueSat, Light& light) const = 0; //! \brief Virtual function that lets the light perform one breath cycle in //! the specified color. //! //! \param xy The color in XY and brightness //! \param light A reference of the light - virtual bool alertXY(const XYBrightness& xy, HueLight& light) const = 0; + virtual bool alertXY(const XYBrightness& xy, Light& light) const = 0; //! \brief Virtual function that returns the current color of the light as hue //! and saturation //! //! Should update the lights state by calling refreshState() //! \param light A reference of the light - virtual HueSaturation getColorHueSaturation(HueLight& light) const = 0; + virtual HueSaturation getColorHueSaturation(Light& light) const = 0; //! \brief Virtual function that returns the current color of the light as hue //! and saturation //! //! \note This should not update the lights state //! \param light A const reference of the light - virtual HueSaturation getColorHueSaturation(const HueLight& light) const = 0; + virtual HueSaturation getColorHueSaturation(const Light& light) const = 0; //! \brief Virtual function that returns the current color of the light as xy //! //! Should update the lights state by calling refreshState() //! \param light A reference of the light //! \return XY and brightness of current color - virtual XYBrightness getColorXY(HueLight& light) const = 0; + virtual XYBrightness getColorXY(Light& light) const = 0; //! \brief Virtual function that returns the current color of the light as xy //! //! \note This should not update the lights state //! \param light A const reference of the light //! \return XY and brightness of current color - virtual XYBrightness getColorXY(const HueLight& light) const = 0; + virtual XYBrightness getColorXY(const Light& light) const = 0; //! \brief Virtual dtor virtual ~ColorHueStrategy() = default; }; diff --git a/include/hueplusplus/ColorTemperatureStrategy.h b/include/hueplusplus/ColorTemperatureStrategy.h index 1a18662..0950447 100644 --- a/include/hueplusplus/ColorTemperatureStrategy.h +++ b/include/hueplusplus/ColorTemperatureStrategy.h @@ -27,7 +27,7 @@ namespace hueplusplus { -class HueLight; +class Light; //! Virtual base class for all ColorTemperatureStrategies class ColorTemperatureStrategy @@ -41,14 +41,14 @@ public: //! transition The time it takes to fade to the new color in multiples of //! 100ms, 4 = 400ms and should be seen as the default \param light A //! reference of the light - virtual bool setColorTemperature(unsigned int mired, uint8_t transition, HueLight& light) const = 0; + virtual bool setColorTemperature(unsigned int mired, uint8_t transition, Light& light) const = 0; //! \brief Virtual function that lets the light perform one breath cycle in //! the specified color. //! //! The color temperature in mired ranges from 153 to 500 whereas 153 is cold //! and 500 is warm. \param mired The color temperature in mired \param light //! A reference of the light - virtual bool alertTemperature(unsigned int mired, HueLight& light) const = 0; + virtual bool alertTemperature(unsigned int mired, Light& light) const = 0; //! \brief Virtual function that returns the current color temperature of the //! light //! @@ -56,7 +56,7 @@ public: //! The color temperature in mired ranges from 153 to 500 whereas 153 is cold //! and 500 is warm. \param light A reference of the light \return Unsigned //! int representing the color temperature in mired - virtual unsigned int getColorTemperature(HueLight& light) const = 0; + virtual unsigned int getColorTemperature(Light& light) const = 0; //! \brief Virtual function that returns the current color temperature of the //! light //! @@ -64,7 +64,7 @@ public: //! and 500 is warm. \note This should not update the lights state \param //! light A const reference of the light \return Unsigned int representing the //! color temperature in mired - virtual unsigned int getColorTemperature(const HueLight& light) const = 0; + virtual unsigned int getColorTemperature(const Light& light) const = 0; //! \brief Virtual dtor virtual ~ColorTemperatureStrategy() = default; }; diff --git a/include/hueplusplus/ExtendedColorHueStrategy.h b/include/hueplusplus/ExtendedColorHueStrategy.h index afcdc87..33ffae1 100644 --- a/include/hueplusplus/ExtendedColorHueStrategy.h +++ b/include/hueplusplus/ExtendedColorHueStrategy.h @@ -23,7 +23,7 @@ #ifndef INCLUDE_HUEPLUSPLUS_EXTENDED_COLOR_HUE_STRATEGY_H #define INCLUDE_HUEPLUSPLUS_EXTENDED_COLOR_HUE_STRATEGY_H -#include "HueLight.h" +#include "Light.h" #include "SimpleColorHueStrategy.h" namespace hueplusplus @@ -39,15 +39,15 @@ public: //! \param hueSat The color in hue and saturation //! \param light A reference of the light //! - //! Blocks for the time a \ref HueLight::alert() needs - bool alertHueSaturation(const HueSaturation& hueSat, HueLight& light) const override; + //! Blocks for the time a \ref Light::alert() needs + bool alertHueSaturation(const HueSaturation& hueSat, Light& light) const override; //! \brief Function that lets the light perform one breath cycle in the //! specified color. //! \param xy The color in XY and brightness //! \param light A reference of the light //! - //! Blocks for the time a \ref HueLight::alert() needs - bool alertXY(const XYBrightness& xy, HueLight& light) const override; + //! Blocks for the time a \ref Light::alert() needs + bool alertXY(const XYBrightness& xy, Light& light) const override; }; } // namespace hueplusplus diff --git a/include/hueplusplus/ExtendedColorTemperatureStrategy.h b/include/hueplusplus/ExtendedColorTemperatureStrategy.h index bce31ae..5b07202 100644 --- a/include/hueplusplus/ExtendedColorTemperatureStrategy.h +++ b/include/hueplusplus/ExtendedColorTemperatureStrategy.h @@ -23,7 +23,7 @@ #ifndef INCLUDE_HUEPLUSPLUS_EXTENDED_COLOR_TEMPERATURE_STRATEGY_H #define INCLUDE_HUEPLUSPLUS_EXTENDED_COLOR_TEMPERATURE_STRATEGY_H -#include "HueLight.h" +#include "Light.h" #include "SimpleColorTemperatureStrategy.h" namespace hueplusplus @@ -36,10 +36,10 @@ public: //! specified color. //! //! It uses this_thread::sleep_for to accomodate for the time an \ref - //! HueLight::alert() needs The color temperature in mired ranges from 153 to + //! Light::alert() needs The color temperature in mired ranges from 153 to //! 500 whereas 153 is cold and 500 is warm. \param mired The color //! temperature in mired \param light A reference of the light - bool alertTemperature(unsigned int mired, HueLight& light) const override; + bool alertTemperature(unsigned int mired, Light& light) const override; }; } // namespace hueplusplus diff --git a/include/hueplusplus/HueDeviceTypes.h b/include/hueplusplus/HueDeviceTypes.h index a1ae481..b44bb6f 100644 --- a/include/hueplusplus/HueDeviceTypes.h +++ b/include/hueplusplus/HueDeviceTypes.h @@ -26,27 +26,27 @@ #include #include -#include "HueLight.h" +#include "Light.h" namespace hueplusplus { -class HueLightFactory +class LightFactory { public: - //! \brief Create a factory for HueLight%s + //! \brief Create a factory for Light%s //! \param commands HueCommandAPI for communication with the bridge //! \param refreshDuration Time between refreshing the cached light state. - HueLightFactory(const HueCommandAPI& commands, std::chrono::steady_clock::duration refreshDuration); + LightFactory(const HueCommandAPI& commands, std::chrono::steady_clock::duration refreshDuration); - //! \brief Create a HueLight with the correct type from the JSON state. + //! \brief Create a Light with the correct type from the JSON state. //! \param lightState Light JSON as returned from the bridge (not only the "state" part of it). //! \param id Light id. - //! \returns HueLight with matching id, strategies and \ref ColorType. + //! \returns Light with matching id, strategies and \ref ColorType. //! \throws std::system_error when system or socket operations fail //! \throws HueException when light type is unknown //! \throws HueAPIResponseException when response contains an error //! \throws nlohmann::json::parse_error when response could not be parsed - HueLight createLight(const nlohmann::json& lightState, int id); + Light createLight(const nlohmann::json& lightState, int id); private: //! \brief Get color type from light JSON. diff --git a/include/hueplusplus/APIConfig.h b/include/hueplusplus/LibConfig.h index 3b1b4fa..88924b2 100644 --- a/include/hueplusplus/APIConfig.h +++ b/include/hueplusplus/LibConfig.h @@ -1,5 +1,5 @@ /** - \file APIConfig.h + \file LibConfig.h Copyright Notice\n Copyright (C) 2017 Jan Rogall - developer\n Copyright (C) 2017 Moritz Wirger - developer\n @@ -47,7 +47,7 @@ public: //! \brief Delay between bridge requests duration getBridgeRequestDelay() const { return bridgeRequestDelay; } - //! \brief Timeout for Hue::requestUsername, waits until link button was pressed + //! \brief Timeout for Bridge::requestUsername, waits until link button was pressed duration getRequestUsernameTimeout() const { return requestUsernameDelay; } //! \brief Interval in which username requests are attempted diff --git a/include/hueplusplus/HueLight.h b/include/hueplusplus/Light.h index a8d116d..45a8210 100644 --- a/include/hueplusplus/HueLight.h +++ b/include/hueplusplus/Light.h @@ -1,5 +1,5 @@ /** - \file HueLight.h + \file Light.h Copyright Notice\n Copyright (C) 2017 Jan Rogall - developer\n Copyright (C) 2017 Moritz Wirger - developer\n @@ -37,47 +37,6 @@ namespace hueplusplus { -/*enum ModelType -{ -UNDEFINED, // undefined model -LCT001, // Hue bulb A19, Color Gamut B, ECL -LCT007, // Hue bulb A19, Color Gamut B, ECL -LCT010, // Hue bulb A19, Color Gamut C, ECL -LCT014, // Hue bulb A19, Color Gamut C, ECL - -LCT002, // Hue Spot BR30, Color Gamut B, ECL -LCT003, // Hue Spot GU10, Color Gamut B, ECL - -LCT011, // Hue BR30, Color Gamut C, ECL - -LST001, // Hue LightStrips, Color Gamut A, CL -LST002, // Hue LightStrips Plus, Color Gamut C, ECL - -LLC010, // Hue Living Colors Iris, Color Gamut A, CL -LLC011, // Hue Living Colors Bloom, Color Gamut A, CL -LLC012, // Hue Living Colors Bloom, Color Gamut A, CL -LLC006, // Living Colors Gen3 Iris, Color Gamut A, CL, NO HUE FRIEND -LLC007, // Living Colors Gen3 Bloom, Aura, Color Gamut A, CL, NO HUE FRIEND -LLC013, // Disney Living Colors, Color Gamut A, CL - -LWB004, // Hue A19 Lux, Color Gamut -, DL -LWB006, // Hue A19 Lux, Color Gamut -, DL -LWB007, // Hue A19 Lux, Color Gamut -, DL -LWB010, // Hue A19 Lux, Color Gamut -, DL -LWB014, // Hue A19 Lux, Color Gamut -, DL - -LLM001, // Color Light Module, Color Gamut B, ECL -LLM010, // Color Temperature Module, Color Gamut 2200K-6500K, CTL -LLM011, // Color Temperature Module, Color Gamut 2200K-6500K, CTL -LLM012, // Color Temperature Module, Color Gamut 2200K-6500K, CTL - -LTW001, // Hue Spot BR30, Color Gamut 2200K-6500K, CTL -LTW004, // Hue Spot BR30, Color Gamut 2200K-6500K, CTL -LTW013, // Hue Spot BR30, Color Gamut 2200K-6500K, CTL -LTW014, // Hue Spot BR30, Color Gamut 2200K-6500K, CTL - -LLC020 // Hue Go, Color Gamut C, ECL -};*/ //! enum that specifies the color type of all HueLights enum class ColorType @@ -96,9 +55,9 @@ enum class ColorType //! \brief Class for Hue Light fixtures //! //! Provides methods to query and control lights. -class HueLight : public BaseDevice +class Light : public BaseDevice { - friend class HueLightFactory; + friend class LightFactory; friend class SimpleBrightnessStrategy; friend class SimpleColorHueStrategy; friend class ExtendedColorHueStrategy; @@ -595,15 +554,15 @@ public: ///@} protected: - //! \brief Protected ctor that is used by \ref Hue class. + //! \brief Protected ctor that is used by \ref Bridge class. //! //! \param id Integer that specifies the id of this light //! \param commands HueCommandAPI for communication with the bridge //! //! leaves strategies unset - HueLight(int id, const HueCommandAPI& commands); + Light(int id, const HueCommandAPI& commands); - //! \brief Protected ctor that is used by \ref Hue class, also sets + //! \brief Protected ctor that is used by \ref Bridge class, also sets //! strategies. //! //! \param id Integer that specifies the id of this light @@ -617,7 +576,7 @@ protected: //! \throws HueException when response contained no body //! \throws HueAPIResponseException when response contains an error //! \throws nlohmann::json::parse_error when response could not be parsed - HueLight(int id, const HueCommandAPI& commands, std::shared_ptr brightnessStrategy, + Light(int id, const HueCommandAPI& commands, std::shared_ptr brightnessStrategy, std::shared_ptr colorTempStrategy, std::shared_ptr colorHueStrategy, std::chrono::steady_clock::duration refreshDuration = std::chrono::seconds(10)); diff --git a/include/hueplusplus/HueSensor.h b/include/hueplusplus/Sensor.h index ba646e6..5e75bf5 100644 --- a/include/hueplusplus/HueSensor.h +++ b/include/hueplusplus/Sensor.h @@ -1,5 +1,5 @@ /** - \file HueSensor.h + \file Sensor.h Copyright Notice\n Copyright (C) 2020 Stefan Herbrechtsmeier - developer\n @@ -32,15 +32,15 @@ namespace hueplusplus { //! -//! Class for Hue Sensor fixtures +//! Class for Hue sensors //! -class HueSensor : public BaseDevice +class Sensor : public BaseDevice { - friend class Hue; + friend class Bridge; public: //! \brief std dtor - ~HueSensor() = default; + ~Sensor() = default; //! \brief Function to get button event //! @@ -85,12 +85,12 @@ public: virtual bool hasStatus() const; protected: - //! \brief Protected ctor that is used by \ref Hue class. + //! \brief Protected ctor that is used by \ref Bridge class. //! //! \param id Integer that specifies the id of this sensor //! \param commands HueCommandAPI for communication with the bridge //! \param refreshDuration Time between refreshing the cached state. - HueSensor(int id, const HueCommandAPI& commands, std::chrono::steady_clock::duration refreshDuration); + Sensor(int id, const HueCommandAPI& commands, std::chrono::steady_clock::duration refreshDuration); }; } // namespace hueplusplus diff --git a/include/hueplusplus/SimpleBrightnessStrategy.h b/include/hueplusplus/SimpleBrightnessStrategy.h index d2e2c1b..367a5ee 100644 --- a/include/hueplusplus/SimpleBrightnessStrategy.h +++ b/include/hueplusplus/SimpleBrightnessStrategy.h @@ -24,7 +24,7 @@ #define INCLUDE_HUEPLUSPLUS_SIMPLE_BRIGHTNESS_STRATEGY_H #include "BrightnessStrategy.h" -#include "HueLight.h" +#include "Light.h" namespace hueplusplus { @@ -39,19 +39,19 @@ public: //! \param transition The time it takes to fade to the new brightness in //! multiples of 100ms, 4 = 400ms and should be seen as the default \param //! light A reference of the light - bool setBrightness(unsigned int bri, uint8_t transition, HueLight& light) const override; + bool setBrightness(unsigned int bri, uint8_t transition, Light& light) const override; //! \brief Function that returns the current brightness of the light //! //! Updates the lights state by calling refreshState() //! \param light A reference of the light //! \return Unsigned int representing the brightness - unsigned int getBrightness(HueLight& light) const override; + unsigned int getBrightness(Light& light) const override; //! \brief Function that returns the current brightness of the light //! //! \note This does not update the lights state //! \param light A const reference of the light //! \return Unsigned int representing the brightness - unsigned int getBrightness(const HueLight& light) const override; + unsigned int getBrightness(const Light& light) const override; }; } // namespace hueplusplus diff --git a/include/hueplusplus/SimpleColorHueStrategy.h b/include/hueplusplus/SimpleColorHueStrategy.h index 5ee82e0..2117979 100644 --- a/include/hueplusplus/SimpleColorHueStrategy.h +++ b/include/hueplusplus/SimpleColorHueStrategy.h @@ -24,7 +24,7 @@ #define INCLUDE_HUEPLUSPLUS_SIMPLE_COLOR_HUE_STRATEGY_H #include "ColorHueStrategy.h" -#include "HueLight.h" +#include "Light.h" namespace hueplusplus { @@ -42,7 +42,7 @@ public: //! The time it takes to fade to the new color in multiples of 100ms, 4 = //! 400ms and should be seen as the default \param light A reference of the //! light - bool setColorHue(uint16_t hue, uint8_t transition, HueLight& light) const override; + bool setColorHue(uint16_t hue, uint8_t transition, Light& light) const override; //! \brief Function for changing a lights color in saturation with a specified //! transition. //! @@ -51,7 +51,7 @@ public: //! color \param transition The time it takes to fade to the new color in //! multiples of 100ms, 4 = 400ms and should be seen as the default \param //! light A reference of the light - bool setColorSaturation(uint8_t sat, uint8_t transition, HueLight& light) const override; + bool setColorSaturation(uint8_t sat, uint8_t transition, Light& light) const override; //! \brief Function for changing a lights color in hue and saturation format //! with a specified transition. //! @@ -59,7 +59,7 @@ public: //! \param transition The time it takes to fade to the new color in multiples of //! 100ms, 4 = 400ms and should be seen as the default //! \param light A reference of the light - bool setColorHueSaturation(const HueSaturation& hueSat, uint8_t transition, HueLight& light) const override; + bool setColorHueSaturation(const HueSaturation& hueSat, uint8_t transition, Light& light) const override; //! \brief Function for changing a lights color in CIE format with a specified //! transition. //! @@ -67,7 +67,7 @@ public: //! \param transition The time it takes to fade to the new color in multiples //! of 100ms, 4 = 400ms and should be seen as the default \param light A //! reference of the light - bool setColorXY(const XYBrightness& xy, uint8_t transition, HueLight& light) const override; + bool setColorXY(const XYBrightness& xy, uint8_t transition, Light& light) const override; //! \brief Function for turning on/off the color loop feature of a light. //! @@ -80,19 +80,19 @@ public: //! alternatively call Off() and then use any of the setter functions. //! \param on Boolean to turn this feature on or off, true/1 for on and //! false/0 for off \param light A reference of the light - bool setColorLoop(bool on, HueLight& light) const override; + bool setColorLoop(bool on, Light& light) const override; //! \brief Function that lets the light perform one breath cycle in the //! specified color. //! \param hueSat The color in hue and saturation //! \param light A reference of the light //! - //! Blocks for the time a \ref HueLight::alert() needs - bool alertHueSaturation(const HueSaturation& hueSat, HueLight& light) const override; + //! Blocks for the time a \ref Light::alert() needs + bool alertHueSaturation(const HueSaturation& hueSat, Light& light) const override; //! \brief Function that lets the light perform one breath cycle in the //! specified color. //! \param xy The color in XY and brightness //! \param light A reference of the light - bool alertXY(const XYBrightness& xy, HueLight& light) const override; + bool alertXY(const XYBrightness& xy, Light& light) const override; //! \brief Function that returns the current color of the light as hue and //! saturation //! @@ -100,7 +100,7 @@ public: //! \param light A reference of the light //! \return Pair containing the hue as first value and saturation as second //! value - HueSaturation getColorHueSaturation(HueLight& light) const override; + HueSaturation getColorHueSaturation(Light& light) const override; //! \brief Function that returns the current color of the light as hue and //! saturation //! @@ -108,19 +108,19 @@ public: //! \param light A const reference of the light //! \return Pair containing the hue as first value and saturation as second //! value - HueSaturation getColorHueSaturation(const HueLight& light) const override; + HueSaturation getColorHueSaturation(const Light& light) const override; //! \brief Function that returns the current color of the light as xy //! //! Updates the lights state by calling refreshState() //! \param light A reference of the light //! \return XY and brightness of current color - XYBrightness getColorXY(HueLight& light) const override; + XYBrightness getColorXY(Light& light) const override; //! \brief Function that returns the current color of the light as xy //! //! \note This does not update the lights state //! \param light A const reference of the light //! \return XY and brightness of current color - XYBrightness getColorXY(const HueLight& light) const override; + XYBrightness getColorXY(const Light& light) const override; }; } // namespace hueplusplus diff --git a/include/hueplusplus/SimpleColorTemperatureStrategy.h b/include/hueplusplus/SimpleColorTemperatureStrategy.h index 17a8148..469d995 100644 --- a/include/hueplusplus/SimpleColorTemperatureStrategy.h +++ b/include/hueplusplus/SimpleColorTemperatureStrategy.h @@ -24,7 +24,7 @@ #define INCLUDE_HUEPLUSPLUS_SIMPLE_COLOR_TEMPERATURE_STRATEGY_H #include "ColorTemperatureStrategy.h" -#include "HueLight.h" +#include "Light.h" namespace hueplusplus { @@ -40,29 +40,29 @@ public: //! transition The time it takes to fade to the new color in multiples of //! 100ms, 4 = 400ms and should be seen as the default \param light A //! reference of the light - bool setColorTemperature(unsigned int mired, uint8_t transition, HueLight& light) const override; + bool setColorTemperature(unsigned int mired, uint8_t transition, Light& light) const override; //! \brief Function that lets the light perform one breath cycle in the //! specified color. //! //! It uses this_thread::sleep_for to accomodate for the time an \ref - //! HueLight::alert() needs The color temperature in mired ranges from 153 to + //! Light::alert() needs The color temperature in mired ranges from 153 to //! 500 whereas 153 is cold and 500 is warm. \param mired The color //! temperature in mired \param light A reference of the light - bool alertTemperature(unsigned int mired, HueLight& light) const override; + bool alertTemperature(unsigned int mired, Light& light) const override; //! \brief Function that returns the current color temperature of the light //! //! Updates the lights state by calling refreshState() //! The color temperature in mired ranges from 153 to 500 whereas 153 is cold //! and 500 is warm. \param light A reference of the light \return Unsigned //! int representing the color temperature in mired - unsigned int getColorTemperature(HueLight& light) const override; + unsigned int getColorTemperature(Light& light) const override; //! \brief Function that returns the current color temperature of the light //! //! The color temperature in mired ranges from 153 to 500 whereas 153 is cold //! and 500 is warm. \note This does not update the lights state \param light //! A const reference of the light \return Unsigned int representing the color //! temperature in mired - unsigned int getColorTemperature(const HueLight& light) const override; + unsigned int getColorTemperature(const Light& light) const override; }; } // namespace hueplusplus diff --git a/include/hueplusplus/StateTransaction.h b/include/hueplusplus/StateTransaction.h index a265154..3e3502e 100644 --- a/include/hueplusplus/StateTransaction.h +++ b/include/hueplusplus/StateTransaction.h @@ -77,7 +77,7 @@ public: //! the current state are removed. This reduces load on the bridge. On the other hand, an outdated //! state might cause requests to be dropped unexpectedly. Has no effect on groups. //! \returns true on success or when no change was requested. - //! \note After changing the state of a HueLight or Group, + //! \note After changing the state of a Light or Group, //! refresh() must be called if the updated values are needed immediately. //! \throws std::system_error when system or socket operations fail //! \throws HueException when response contains no body diff --git a/src/Hue.cpp b/src/Bridge.cpp index 82e7301..d47ec8d 100644 --- a/src/Hue.cpp +++ b/src/Bridge.cpp @@ -1,5 +1,5 @@ /** - \file Hue.cpp + \file Bridge.cpp Copyright Notice\n Copyright (C) 2017 Jan Rogall - developer\n Copyright (C) 2017 Moritz Wirger - developer\n @@ -20,7 +20,7 @@ along with hueplusplus. If not, see . **/ -#include "hueplusplus/Hue.h" +#include "hueplusplus/Bridge.h" #include #include @@ -31,27 +31,27 @@ #include #include -#include "hueplusplus/APIConfig.h" +#include "hueplusplus/LibConfig.h" #include "hueplusplus/HueExceptionMacro.h" #include "hueplusplus/UPnP.h" #include "hueplusplus/Utils.h" namespace hueplusplus { -HueFinder::HueFinder(std::shared_ptr handler) : http_handler(std::move(handler)) { } +BridgeFinder::BridgeFinder(std::shared_ptr handler) : http_handler(std::move(handler)) { } -std::vector HueFinder::FindBridges() const +std::vector BridgeFinder::FindBridges() const { UPnP uplug; std::vector> foundDevices = uplug.getDevices(http_handler); - std::vector foundBridges; + std::vector foundBridges; for (const std::pair& p : foundDevices) { size_t found = p.second.find("IpBridge"); if (found != std::string::npos) { - HueIdentification bridge; + BridgeIdentification bridge; size_t start = p.first.find("//") + 2; size_t length = p.first.find(":", start) - start; bridge.ip = p.first.substr(start, length); @@ -68,15 +68,15 @@ std::vector HueFinder::FindBridges() const return foundBridges; } -Hue HueFinder::GetBridge(const HueIdentification& identification) +Bridge BridgeFinder::GetBridge(const BridgeIdentification& identification) { std::string normalizedMac = NormalizeMac(identification.mac); auto pos = usernames.find(normalizedMac); if (pos != usernames.end()) { - return Hue(identification.ip, identification.port, pos->second, http_handler); + return Bridge(identification.ip, identification.port, pos->second, http_handler); } - Hue bridge(identification.ip, identification.port, "", http_handler); + Bridge bridge(identification.ip, identification.port, "", http_handler); bridge.requestUsername(); if (bridge.getUsername().empty()) { @@ -88,17 +88,17 @@ Hue HueFinder::GetBridge(const HueIdentification& identification) return bridge; } -void HueFinder::AddUsername(const std::string& mac, const std::string& username) +void BridgeFinder::AddUsername(const std::string& mac, const std::string& username) { usernames[NormalizeMac(mac)] = username; } -const std::map& HueFinder::GetAllUsernames() const +const std::map& BridgeFinder::GetAllUsernames() const { return usernames; } -std::string HueFinder::NormalizeMac(std::string input) +std::string BridgeFinder::NormalizeMac(std::string input) { // Remove any non alphanumeric characters (e.g. ':' and whitespace) input.erase(std::remove_if(input.begin(), input.end(), [](char c) { return !std::isalnum(c, std::locale()); }), @@ -108,7 +108,7 @@ std::string HueFinder::NormalizeMac(std::string input) return input; } -std::string HueFinder::ParseDescription(const std::string& description) +std::string BridgeFinder::ParseDescription(const std::string& description) { const char* model = "Philips hue bridge"; const char* serialBegin = ""; @@ -130,7 +130,7 @@ std::string HueFinder::ParseDescription(const std::string& description) return std::string(); } -Hue::Hue(const std::string& ip, const int port, const std::string& username, +Bridge::Bridge(const std::string& ip, const int port, const std::string& username, std::shared_ptr handler, std::chrono::steady_clock::duration refreshDuration) : ip(ip), username(username), @@ -140,7 +140,7 @@ Hue::Hue(const std::string& ip, const int port, const std::string& username, stateCache(std::make_shared( "", HueCommandAPI(ip, port, username, http_handler), std::chrono::steady_clock::duration::max())), lightList(stateCache, "lights", refreshDuration, - [factory = HueLightFactory(stateCache->getCommandAPI(), refreshDuration)]( + [factory = LightFactory(stateCache->getCommandAPI(), refreshDuration)]( int id, const nlohmann::json& state) mutable { return factory.createLight(state, id); }), groupList(stateCache, "groups", refreshDuration), scheduleList(stateCache, "schedules", refreshDuration), @@ -149,22 +149,22 @@ Hue::Hue(const std::string& ip, const int port, const std::string& username, bridgeConfig(stateCache, refreshDuration) { } -void Hue::refresh() +void Bridge::refresh() { stateCache->refresh(); } -std::string Hue::getBridgeIP() const +std::string Bridge::getBridgeIP() const { return ip; } -int Hue::getBridgePort() const +int Bridge::getBridgePort() const { return port; } -std::string Hue::requestUsername() +std::string Bridge::requestUsername() { std::chrono::steady_clock::duration timeout = Config::instance().getRequestUsernameTimeout(); std::chrono::steady_clock::duration checkInterval = Config::instance().getRequestUsernameAttemptInterval(); @@ -207,87 +207,87 @@ std::string Hue::requestUsername() return username; } -std::string Hue::getUsername() const +std::string Bridge::getUsername() const { return username; } -void Hue::setIP(const std::string& ip) +void Bridge::setIP(const std::string& ip) { this->ip = ip; } -void Hue::setPort(const int port) +void Bridge::setPort(const int port) { this->port = port; } -BridgeConfig& Hue::config() +BridgeConfig& Bridge::config() { return bridgeConfig; } -const BridgeConfig& Hue::config() const +const BridgeConfig& Bridge::config() const { return bridgeConfig; } -Hue::LightList& Hue::lights() +Bridge::LightList& Bridge::lights() { return lightList; } -const Hue::LightList& Hue::lights() const +const Bridge::LightList& Bridge::lights() const { return lightList; } -Hue::GroupList& Hue::groups() +Bridge::GroupList& Bridge::groups() { return groupList; } -const Hue::GroupList& Hue::groups() const +const Bridge::GroupList& Bridge::groups() const { return groupList; } -Hue::ScheduleList& Hue::schedules() +Bridge::ScheduleList& Bridge::schedules() { return scheduleList; } -const Hue::ScheduleList& Hue::schedules() const +const Bridge::ScheduleList& Bridge::schedules() const { return scheduleList; } -Hue::SceneList& Hue::scenes() +Bridge::SceneList& Bridge::scenes() { return sceneList; } -const Hue::SceneList& Hue::scenes() const +const Bridge::SceneList& Bridge::scenes() const { return sceneList; } -Hue::SensorList& Hue::sensors() +Bridge::SensorList& Bridge::sensors() { return sensorList; } -const Hue::SensorList& Hue::sensors() const +const Bridge::SensorList& Bridge::sensors() const { return sensorList; } -void Hue::setHttpHandler(std::shared_ptr handler) +void Bridge::setHttpHandler(std::shared_ptr handler) { http_handler = handler; stateCache = std::make_shared("", HueCommandAPI(ip, port, username, handler), refreshDuration); - lightList = ResourceList(stateCache, "lights", refreshDuration, - [factory = HueLightFactory(stateCache->getCommandAPI(), refreshDuration)]( + lightList = ResourceList(stateCache, "lights", refreshDuration, + [factory = LightFactory(stateCache->getCommandAPI(), refreshDuration)]( int id, const nlohmann::json& state) mutable { return factory.createLight(state, id); }); groupList = GroupList(stateCache, "groups", refreshDuration); scheduleList = ScheduleList(stateCache, "schedules", refreshDuration); diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e31568a..89bef61 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,20 +2,20 @@ set(hueplusplus_SOURCES APICache.cpp BaseDevice.cpp BaseHttpHandler.cpp + Bridge.cpp BridgeConfig.cpp ColorUnits.cpp ExtendedColorHueStrategy.cpp ExtendedColorTemperatureStrategy.cpp Group.cpp - Hue.cpp HueCommandAPI.cpp HueDeviceTypes.cpp HueException.cpp - HueLight.cpp - HueSensor.cpp + Light.cpp ModelPictures.cpp Scene.cpp Schedule.cpp + Sensor.cpp SimpleBrightnessStrategy.cpp SimpleColorHueStrategy.cpp SimpleColorTemperatureStrategy.cpp diff --git a/src/ExtendedColorHueStrategy.cpp b/src/ExtendedColorHueStrategy.cpp index f16036d..8b666fe 100644 --- a/src/ExtendedColorHueStrategy.cpp +++ b/src/ExtendedColorHueStrategy.cpp @@ -26,11 +26,11 @@ #include #include -#include "hueplusplus/APIConfig.h" +#include "hueplusplus/LibConfig.h" namespace hueplusplus { -bool ExtendedColorHueStrategy::alertHueSaturation(const HueSaturation& hueSat, HueLight& light) const +bool ExtendedColorHueStrategy::alertHueSaturation(const HueSaturation& hueSat, Light& light) const { // Careful, only use state until any light function might refresh the value and invalidate the reference const nlohmann::json& state = light.state.getValue()["state"]; @@ -57,14 +57,14 @@ bool ExtendedColorHueStrategy::alertHueSaturation(const HueSaturation& hueSat, H } } -bool ExtendedColorHueStrategy::alertXY(const XYBrightness& xy, HueLight& light) const +bool ExtendedColorHueStrategy::alertXY(const XYBrightness& xy, Light& light) const { // Careful, only use state until any light function might refresh the value and invalidate the reference const nlohmann::json& state = light.state.getValue()["state"]; std::string cType = state["colormode"].get(); bool on = state["on"].get(); // const reference to prevent refreshes - const HueLight& cLight = light; + const Light& cLight = light; if (cType != "ct") { return SimpleColorHueStrategy::alertXY(xy, light); diff --git a/src/ExtendedColorTemperatureStrategy.cpp b/src/ExtendedColorTemperatureStrategy.cpp index d179ce1..947f68a 100644 --- a/src/ExtendedColorTemperatureStrategy.cpp +++ b/src/ExtendedColorTemperatureStrategy.cpp @@ -26,19 +26,19 @@ #include #include -#include "hueplusplus/APIConfig.h" +#include "hueplusplus/LibConfig.h" #include "hueplusplus/HueExceptionMacro.h" #include "hueplusplus/Utils.h" namespace hueplusplus { -bool ExtendedColorTemperatureStrategy::alertTemperature(unsigned int mired, HueLight& light) const +bool ExtendedColorTemperatureStrategy::alertTemperature(unsigned int mired, Light& light) const { // Careful, only use state until any light function might refresh the value and invalidate the reference const nlohmann::json& state = light.state.getValue()["state"]; std::string cType = state["colormode"].get(); bool on = state["on"].get(); - const HueLight& cLight = light; + const Light& cLight = light; if (cType == "ct") { return SimpleColorTemperatureStrategy::alertTemperature(mired, light); diff --git a/src/HueCommandAPI.cpp b/src/HueCommandAPI.cpp index 13e0727..868db5c 100644 --- a/src/HueCommandAPI.cpp +++ b/src/HueCommandAPI.cpp @@ -24,7 +24,7 @@ #include -#include "hueplusplus/APIConfig.h" +#include "hueplusplus/LibConfig.h" #include "hueplusplus/HueExceptionMacro.h" namespace hueplusplus diff --git a/src/HueDeviceTypes.cpp b/src/HueDeviceTypes.cpp index 206707e..05a5925 100644 --- a/src/HueDeviceTypes.cpp +++ b/src/HueDeviceTypes.cpp @@ -59,7 +59,7 @@ const std::set& getGamutATypes() } } // namespace -HueLightFactory::HueLightFactory(const HueCommandAPI& commands, std::chrono::steady_clock::duration refreshDuration) +LightFactory::LightFactory(const HueCommandAPI& commands, std::chrono::steady_clock::duration refreshDuration) : commands(commands), refreshDuration(refreshDuration), simpleBrightness(std::make_shared()), @@ -69,7 +69,7 @@ HueLightFactory::HueLightFactory(const HueCommandAPI& commands, std::chrono::ste extendedColorHue(std::make_shared()) {} -HueLight HueLightFactory::createLight(const nlohmann::json& lightState, int id) +Light LightFactory::createLight(const nlohmann::json& lightState, int id) { std::string type = lightState.value("type", ""); // Ignore case @@ -77,39 +77,39 @@ HueLight HueLightFactory::createLight(const nlohmann::json& lightState, int id) if (type == "on/off light" || type == "on/off plug-in unit") { - HueLight light(id, commands, nullptr, nullptr, nullptr, refreshDuration); + Light light(id, commands, nullptr, nullptr, nullptr, refreshDuration); light.colorType = ColorType::NONE; return light; } else if (type == "dimmable light" || type =="dimmable plug-in unit") { - HueLight light(id, commands, simpleBrightness, nullptr, nullptr, refreshDuration); + Light light(id, commands, simpleBrightness, nullptr, nullptr, refreshDuration); light.colorType = ColorType::NONE; return light; } else if (type == "color temperature light") { - HueLight light(id, commands, simpleBrightness, simpleColorTemperature, nullptr, refreshDuration); + Light light(id, commands, simpleBrightness, simpleColorTemperature, nullptr, refreshDuration); light.colorType = ColorType::TEMPERATURE; return light; } else if (type == "color light") { - HueLight light(id, commands, simpleBrightness, nullptr, simpleColorHue, refreshDuration); + Light light(id, commands, simpleBrightness, nullptr, simpleColorHue, refreshDuration); light.colorType = getColorType(lightState, false); return light; } else if (type == "extended color light") { - HueLight light(id, commands, simpleBrightness, extendedColorTemperature, extendedColorHue, refreshDuration); + Light light(id, commands, simpleBrightness, extendedColorTemperature, extendedColorHue, refreshDuration); light.colorType = getColorType(lightState, true); return light; } - std::cerr << "Could not determine HueLight type:" << type << "!\n"; - throw HueException(CURRENT_FILE_INFO, "Could not determine HueLight type!"); + std::cerr << "Could not determine Light type:" << type << "!\n"; + throw HueException(CURRENT_FILE_INFO, "Could not determine Light type!"); } -ColorType HueLightFactory::getColorType(const nlohmann::json& lightState, bool hasCt) const +ColorType LightFactory::getColorType(const nlohmann::json& lightState, bool hasCt) const { // Try to get color type via capabilities const nlohmann::json& gamuttype = utils::safeGetMember(lightState, "capabilities", "control", "colorgamuttype"); @@ -150,8 +150,8 @@ ColorType HueLightFactory::getColorType(const nlohmann::json& lightState, bool h { return hasCt ? ColorType::GAMUT_C_TEMPERATURE : ColorType::GAMUT_C; } - std::cerr << "Could not determine HueLight color type:" << modelid << "!\n"; - throw HueException(CURRENT_FILE_INFO, "Could not determine HueLight color type!"); + std::cerr << "Could not determine Light color type:" << modelid << "!\n"; + throw HueException(CURRENT_FILE_INFO, "Could not determine Light color type!"); } } } // namespace hueplusplus diff --git a/src/HueLight.cpp b/src/Light.cpp index 3193cf0..28ecbd5 100644 --- a/src/HueLight.cpp +++ b/src/Light.cpp @@ -1,5 +1,5 @@ /** - \file HueLight.cpp + \file Light.cpp Copyright Notice\n Copyright (C) 2017 Jan Rogall - developer\n Copyright (C) 2017 Moritz Wirger - developer\n @@ -20,7 +20,7 @@ along with hueplusplus. If not, see . **/ -#include "hueplusplus/HueLight.h" +#include "hueplusplus/Light.h" #include #include @@ -32,37 +32,37 @@ namespace hueplusplus { -bool HueLight::On(uint8_t transition) +bool Light::On(uint8_t transition) { return transaction().setOn(true).setTransition(transition).commit(); } -bool HueLight::Off(uint8_t transition) +bool Light::Off(uint8_t transition) { return transaction().setOn(false).setTransition(transition).commit(); } -bool HueLight::isOn() +bool Light::isOn() { return state.getValue().at("state").at("on").get(); } -bool HueLight::isOn() const +bool Light::isOn() const { return state.getValue().at("state").at("on").get(); } -std::string HueLight::getLuminaireUId() const +std::string Light::getLuminaireUId() const { return state.getValue().value("luminaireuniqueid", std::string()); } -ColorType HueLight::getColorType() const +ColorType Light::getColorType() const { return colorType; } -ColorGamut HueLight::getColorGamut() const +ColorGamut Light::getColorGamut() const { switch (colorType) { @@ -91,30 +91,30 @@ ColorGamut HueLight::getColorGamut() const } } -unsigned int HueLight::KelvinToMired(unsigned int kelvin) const +unsigned int Light::KelvinToMired(unsigned int kelvin) const { return int(0.5f + (1000000 / kelvin)); } -unsigned int HueLight::MiredToKelvin(unsigned int mired) const +unsigned int Light::MiredToKelvin(unsigned int mired) const { return int(0.5f + (1000000 / mired)); } -bool HueLight::alert() +bool Light::alert() { return transaction().alert().commit(); } -StateTransaction HueLight::transaction() +StateTransaction Light::transaction() { return StateTransaction( state.getCommandAPI(), "/lights/" + std::to_string(id) + "/state", &state.getValue().at("state")); } -HueLight::HueLight(int id, const HueCommandAPI& commands) : HueLight(id, commands, nullptr, nullptr, nullptr) { } +Light::Light(int id, const HueCommandAPI& commands) : Light(id, commands, nullptr, nullptr, nullptr) { } -HueLight::HueLight(int id, const HueCommandAPI& commands, std::shared_ptr brightnessStrategy, +Light::Light(int id, const HueCommandAPI& commands, std::shared_ptr brightnessStrategy, std::shared_ptr colorTempStrategy, std::shared_ptr colorHueStrategy, std::chrono::steady_clock::duration refreshDuration) : BaseDevice(id, commands, "/lights/", refreshDuration), diff --git a/src/HueSensor.cpp b/src/Sensor.cpp index 567ac71..7f18e5e 100644 --- a/src/HueSensor.cpp +++ b/src/Sensor.cpp @@ -1,5 +1,5 @@ /** - \file HueSensor.cpp + \file Sensor.cpp Copyright Notice\n Copyright (C) 2020 Stefan Herbrechtsmeier - developer\n @@ -19,13 +19,13 @@ along with hueplusplus. If not, see . **/ -#include "hueplusplus/HueSensor.h" +#include "hueplusplus/Sensor.h" #include "json/json.hpp" namespace hueplusplus { -int HueSensor::getButtonEvent() +int Sensor::getButtonEvent() { if (hasButtonEvent()) { @@ -34,7 +34,7 @@ int HueSensor::getButtonEvent() return 0; } -int HueSensor::getButtonEvent() const +int Sensor::getButtonEvent() const { if (hasButtonEvent()) { @@ -43,7 +43,7 @@ int HueSensor::getButtonEvent() const return 0; } -int HueSensor::getStatus() +int Sensor::getStatus() { if (hasStatus()) { @@ -52,7 +52,7 @@ int HueSensor::getStatus() return 0; } -int HueSensor::getStatus() const +int Sensor::getStatus() const { if (hasStatus()) { @@ -61,17 +61,17 @@ int HueSensor::getStatus() const return 0; } -bool HueSensor::hasButtonEvent() const +bool Sensor::hasButtonEvent() const { return state.getValue().at("state").count("buttonevent") != 0; } -bool HueSensor::hasStatus() const +bool Sensor::hasStatus() const { return state.getValue().at("state").count("status") != 0; } -HueSensor::HueSensor(int id, const HueCommandAPI& commands, std::chrono::steady_clock::duration refreshDuration) +Sensor::Sensor(int id, const HueCommandAPI& commands, std::chrono::steady_clock::duration refreshDuration) : BaseDevice(id, commands, "/sensors/", refreshDuration) { } } // namespace hueplusplus diff --git a/src/SimpleBrightnessStrategy.cpp b/src/SimpleBrightnessStrategy.cpp index 457c732..fab3b1f 100644 --- a/src/SimpleBrightnessStrategy.cpp +++ b/src/SimpleBrightnessStrategy.cpp @@ -31,18 +31,18 @@ namespace hueplusplus { -bool SimpleBrightnessStrategy::setBrightness(unsigned int bri, uint8_t transition, HueLight& light) const +bool SimpleBrightnessStrategy::setBrightness(unsigned int bri, uint8_t transition, Light& light) const { // Careful, only use state until any light function might refresh the value and invalidate the reference return light.transaction().setBrightness(bri).setTransition(transition).commit(); } -unsigned int SimpleBrightnessStrategy::getBrightness(HueLight& light) const +unsigned int SimpleBrightnessStrategy::getBrightness(Light& light) const { return light.state.getValue()["state"]["bri"].get(); } -unsigned int SimpleBrightnessStrategy::getBrightness(const HueLight& light) const +unsigned int SimpleBrightnessStrategy::getBrightness(const Light& light) const { return light.state.getValue()["state"]["bri"].get(); } diff --git a/src/SimpleColorHueStrategy.cpp b/src/SimpleColorHueStrategy.cpp index a9c3114..25294f9 100644 --- a/src/SimpleColorHueStrategy.cpp +++ b/src/SimpleColorHueStrategy.cpp @@ -26,45 +26,45 @@ #include #include -#include "hueplusplus/APIConfig.h" +#include "hueplusplus/LibConfig.h" #include "hueplusplus/HueExceptionMacro.h" #include "hueplusplus/Utils.h" namespace hueplusplus { -bool SimpleColorHueStrategy::setColorHue(uint16_t hue, uint8_t transition, HueLight& light) const +bool SimpleColorHueStrategy::setColorHue(uint16_t hue, uint8_t transition, Light& light) const { return light.transaction().setColorHue(hue).setTransition(transition).commit(); } -bool SimpleColorHueStrategy::setColorSaturation(uint8_t sat, uint8_t transition, HueLight& light) const +bool SimpleColorHueStrategy::setColorSaturation(uint8_t sat, uint8_t transition, Light& light) const { return light.transaction().setColorSaturation(sat).setTransition(transition).commit(); } bool SimpleColorHueStrategy::setColorHueSaturation( - const HueSaturation& hueSat, uint8_t transition, HueLight& light) const + const HueSaturation& hueSat, uint8_t transition, Light& light) const { return light.transaction().setColor(hueSat).setTransition(transition).commit(); } -bool SimpleColorHueStrategy::setColorXY(const XYBrightness& xy, uint8_t transition, HueLight& light) const +bool SimpleColorHueStrategy::setColorXY(const XYBrightness& xy, uint8_t transition, Light& light) const { return light.transaction().setColor(xy).setTransition(transition).commit(); } -bool SimpleColorHueStrategy::setColorLoop(bool on, HueLight& light) const +bool SimpleColorHueStrategy::setColorLoop(bool on, Light& light) const { return light.transaction().setColorLoop(true).commit(); } -bool SimpleColorHueStrategy::alertHueSaturation(const HueSaturation& hueSat, HueLight& light) const +bool SimpleColorHueStrategy::alertHueSaturation(const HueSaturation& hueSat, Light& light) const { // Careful, only use state until any light function might refresh the value and invalidate the reference const nlohmann::json& state = light.state.getValue()["state"]; std::string cType = state["colormode"].get(); bool on = state["on"].get(); - const HueLight& cLight = light; + const Light& cLight = light; if (cType == "hs") { HueSaturation oldHueSat = cLight.getColorHueSaturation(); @@ -101,14 +101,14 @@ bool SimpleColorHueStrategy::alertHueSaturation(const HueSaturation& hueSat, Hue } } -bool SimpleColorHueStrategy::alertXY(const XYBrightness& xy, HueLight& light) const +bool SimpleColorHueStrategy::alertXY(const XYBrightness& xy, Light& light) const { // Careful, only use state until any light function might refresh the value and invalidate the reference const nlohmann::json& state = light.state.getValue()["state"]; std::string cType = state["colormode"].get(); bool on = state["on"].get(); // const reference to prevent refreshes - const HueLight& cLight = light; + const Light& cLight = light; if (cType == "hs") { HueSaturation oldHueSat = cLight.getColorHueSaturation(); @@ -146,27 +146,27 @@ bool SimpleColorHueStrategy::alertXY(const XYBrightness& xy, HueLight& light) co } } -HueSaturation SimpleColorHueStrategy::getColorHueSaturation(HueLight& light) const +HueSaturation SimpleColorHueStrategy::getColorHueSaturation(Light& light) const { // Save value, so there are no inconsistent results if it is refreshed between two calls const nlohmann::json& state = light.state.getValue()["state"]; return HueSaturation {state["hue"].get(), state["sat"].get()}; } -HueSaturation SimpleColorHueStrategy::getColorHueSaturation(const HueLight& light) const +HueSaturation SimpleColorHueStrategy::getColorHueSaturation(const Light& light) const { return HueSaturation { light.state.getValue()["state"]["hue"].get(), light.state.getValue()["state"]["sat"].get()}; } -XYBrightness SimpleColorHueStrategy::getColorXY(HueLight& light) const +XYBrightness SimpleColorHueStrategy::getColorXY(Light& light) const { // Save value, so there are no inconsistent results if it is refreshed between two calls const nlohmann::json& state = light.state.getValue()["state"]; return XYBrightness {{state["xy"][0].get(), state["xy"][1].get()}, state["bri"].get() / 254.f}; } -XYBrightness SimpleColorHueStrategy::getColorXY(const HueLight& light) const +XYBrightness SimpleColorHueStrategy::getColorXY(const Light& light) const { const nlohmann::json& state = light.state.getValue()["state"]; return XYBrightness {{state["xy"][0].get(), state["xy"][1].get()}, state["bri"].get() / 254.f}; diff --git a/src/SimpleColorTemperatureStrategy.cpp b/src/SimpleColorTemperatureStrategy.cpp index fa51c7e..3da6a16 100644 --- a/src/SimpleColorTemperatureStrategy.cpp +++ b/src/SimpleColorTemperatureStrategy.cpp @@ -26,18 +26,18 @@ #include #include -#include "hueplusplus/APIConfig.h" +#include "hueplusplus/LibConfig.h" #include "hueplusplus/HueExceptionMacro.h" #include "hueplusplus/Utils.h" namespace hueplusplus { -bool SimpleColorTemperatureStrategy::setColorTemperature(unsigned int mired, uint8_t transition, HueLight& light) const +bool SimpleColorTemperatureStrategy::setColorTemperature(unsigned int mired, uint8_t transition, Light& light) const { return light.transaction().setColorTemperature(mired).setTransition(transition).commit(); } -bool SimpleColorTemperatureStrategy::alertTemperature(unsigned int mired, HueLight& light) const +bool SimpleColorTemperatureStrategy::alertTemperature(unsigned int mired, Light& light) const { // Careful, only use state until any light function might refresh the value and invalidate the reference const nlohmann::json& state = light.state.getValue()["state"]; @@ -64,12 +64,12 @@ bool SimpleColorTemperatureStrategy::alertTemperature(unsigned int mired, HueLig } } -unsigned int SimpleColorTemperatureStrategy::getColorTemperature(HueLight& light) const +unsigned int SimpleColorTemperatureStrategy::getColorTemperature(Light& light) const { return light.state.getValue()["state"]["ct"].get(); } -unsigned int SimpleColorTemperatureStrategy::getColorTemperature(const HueLight& light) const +unsigned int SimpleColorTemperatureStrategy::getColorTemperature(const Light& light) const { return light.state.getValue()["state"]["ct"].get(); } diff --git a/src/UPnP.cpp b/src/UPnP.cpp index 056b5ad..024c881 100644 --- a/src/UPnP.cpp +++ b/src/UPnP.cpp @@ -25,7 +25,7 @@ #include #include -#include "hueplusplus/APIConfig.h" +#include "hueplusplus/LibConfig.h" namespace hueplusplus { diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index cbfe729..f0317a3 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -32,15 +32,15 @@ target_compile_features(gtest PUBLIC cxx_std_14) set(TEST_SOURCES test_APICache.cpp test_BaseHttpHandler.cpp + test_Bridge.cpp test_BridgeConfig.cpp test_ColorUnits.cpp test_ExtendedColorHueStrategy.cpp test_ExtendedColorTemperatureStrategy.cpp test_Group.cpp - test_Hue.cpp - test_HueLight.cpp - test_HueLightFactory.cpp test_HueCommandAPI.cpp + test_Light.cpp + test_LightFactory.cpp test_Main.cpp test_UPnP.cpp test_ResourceList.cpp diff --git a/test/mocks/mock_HueLight.h b/test/mocks/mock_Light.h index d42c2b6..24112bb 100644 --- a/test/mocks/mock_HueLight.h +++ b/test/mocks/mock_Light.h @@ -1,5 +1,5 @@ /** - \file mock_HueLight.h + \file mock_Light.h Copyright Notice\n Copyright (C) 2017 Jan Rogall - developer\n Copyright (C) 2017 Moritz Wirger - developer\n @@ -29,15 +29,15 @@ #include #include "../testhelper.h" -#include "hueplusplus/HueLight.h" +#include "hueplusplus/Light.h" #include "json/json.hpp" //! Mock Class -class MockHueLight : public hueplusplus::HueLight +class MockLight : public hueplusplus::Light { public: - MockHueLight(std::shared_ptr handler) - : HueLight(1, hueplusplus::HueCommandAPI(getBridgeIp(), getBridgePort(), getBridgeUsername(), handler), nullptr, + MockLight(std::shared_ptr handler) + : Light(1, hueplusplus::HueCommandAPI(getBridgeIp(), getBridgePort(), getBridgeUsername(), handler), nullptr, nullptr, nullptr, std::chrono::steady_clock::duration::max()) { // Set refresh duration to max, so random refreshes do not hinder the test setups diff --git a/test/test_Hue.cpp b/test/test_Bridge.cpp index 7f5c86a..c214b8c 100644 --- a/test/test_Hue.cpp +++ b/test/test_Bridge.cpp @@ -1,5 +1,5 @@ /** - \file test_Hue.cpp + \file test_Bridge.cpp Copyright Notice\n Copyright (C) 2017 Jan Rogall - developer\n Copyright (C) 2017 Moritz Wirger - developer\n @@ -28,8 +28,8 @@ #include "testhelper.h" -#include "hueplusplus/APIConfig.h" -#include "hueplusplus/Hue.h" +#include "hueplusplus/Bridge.h" +#include "hueplusplus/LibConfig.h" #include "json/json.hpp" #include "mocks/mock_HttpHandler.h" @@ -64,18 +64,18 @@ protected: TEST_F(HueFinderTest, FindBridges) { - HueFinder finder(handler); - std::vector bridges = finder.FindBridges(); + BridgeFinder finder(handler); + std::vector bridges = finder.FindBridges(); - HueFinder::HueIdentification bridge_to_comp; + BridgeFinder::BridgeIdentification bridge_to_comp; bridge_to_comp.ip = getBridgeIp(); bridge_to_comp.port = getBridgePort(); bridge_to_comp.mac = getBridgeMac(); - EXPECT_EQ(bridges.size(), 1) << "HueFinder found more than one Bridge"; - EXPECT_EQ(bridges[0].ip, bridge_to_comp.ip) << "HueIdentification ip does not match"; - EXPECT_EQ(bridges[0].port, bridge_to_comp.port) << "HueIdentification port does not match"; - EXPECT_EQ(bridges[0].mac, bridge_to_comp.mac) << "HueIdentification mac does not match"; + EXPECT_EQ(bridges.size(), 1) << "BridgeFinder found more than one Bridge"; + EXPECT_EQ(bridges[0].ip, bridge_to_comp.ip) << "BridgeIdentification ip does not match"; + EXPECT_EQ(bridges[0].port, bridge_to_comp.port) << "BridgeIdentification port does not match"; + EXPECT_EQ(bridges[0].mac, bridge_to_comp.mac) << "BridgeIdentification mac does not match"; // Test invalid description EXPECT_CALL(*handler, GETString("/description.xml", "application/xml", "", getBridgeIp(), getBridgePort())) @@ -97,8 +97,8 @@ TEST_F(HueFinderTest, GetBridge) .Times(AtLeast(1)) .WillRepeatedly(Return(errorResponse)); - HueFinder finder(handler); - std::vector bridges = finder.FindBridges(); + BridgeFinder finder(handler); + std::vector bridges = finder.FindBridges(); ASSERT_THROW(finder.GetBridge(bridges[0]), HueException); @@ -108,10 +108,10 @@ TEST_F(HueFinderTest, GetBridge) .Times(1) .WillOnce(Return(successResponse)); - finder = HueFinder(handler); + finder = BridgeFinder(handler); bridges = finder.FindBridges(); - Hue test_bridge = finder.GetBridge(bridges[0]); + Bridge test_bridge = finder.GetBridge(bridges[0]); EXPECT_EQ(test_bridge.getBridgeIP(), getBridgeIp()) << "Bridge IP not matching"; EXPECT_EQ(test_bridge.getBridgePort(), getBridgePort()) << "Bridge Port not matching"; @@ -122,11 +122,11 @@ TEST_F(HueFinderTest, GetBridge) TEST_F(HueFinderTest, AddUsername) { - HueFinder finder(handler); - std::vector bridges = finder.FindBridges(); + BridgeFinder finder(handler); + std::vector bridges = finder.FindBridges(); finder.AddUsername(bridges[0].mac, getBridgeUsername()); - Hue test_bridge = finder.GetBridge(bridges[0]); + Bridge test_bridge = finder.GetBridge(bridges[0]); EXPECT_EQ(test_bridge.getBridgeIP(), getBridgeIp()) << "Bridge IP not matching"; EXPECT_EQ(test_bridge.getBridgePort(), getBridgePort()) << "Bridge Port not matching"; @@ -135,8 +135,8 @@ TEST_F(HueFinderTest, AddUsername) TEST_F(HueFinderTest, GetAllUsernames) { - HueFinder finder(handler); - std::vector bridges = finder.FindBridges(); + BridgeFinder finder(handler); + std::vector bridges = finder.FindBridges(); finder.AddUsername(bridges[0].mac, getBridgeUsername()); @@ -144,17 +144,17 @@ TEST_F(HueFinderTest, GetAllUsernames) EXPECT_EQ(users[getBridgeMac()], getBridgeUsername()) << "Username of MAC:" << getBridgeMac() << "not matching"; } -TEST(Hue, Constructor) +TEST(Bridge, Constructor) { std::shared_ptr handler = std::make_shared(); - Hue test_bridge(getBridgeIp(), getBridgePort(), getBridgeUsername(), handler); + Bridge test_bridge(getBridgeIp(), getBridgePort(), getBridgeUsername(), handler); EXPECT_EQ(test_bridge.getBridgeIP(), getBridgeIp()) << "Bridge IP not matching"; EXPECT_EQ(test_bridge.getBridgePort(), getBridgePort()) << "Bridge Port not matching"; EXPECT_EQ(test_bridge.getUsername(), getBridgeUsername()) << "Bridge username not matching"; } -TEST(Hue, requestUsername) +TEST(Bridge, requestUsername) { using namespace ::testing; std::shared_ptr handler = std::make_shared(); @@ -168,7 +168,7 @@ TEST(Hue, requestUsername) .Times(AtLeast(1)) .WillRepeatedly(Return(errorResponse)); - Hue test_bridge(getBridgeIp(), getBridgePort(), "", handler); + Bridge test_bridge(getBridgeIp(), getBridgePort(), "", handler); std::string username = test_bridge.requestUsername(); EXPECT_EQ(username, "") << "Returned username not matching"; @@ -180,7 +180,7 @@ TEST(Hue, requestUsername) int otherError = 1; nlohmann::json exceptionResponse = {{{"error", {{"type", otherError}, {"address", ""}, {"description", "some error"}}}}}; - Hue testBridge(getBridgeIp(), getBridgePort(), "", handler); + Bridge testBridge(getBridgeIp(), getBridgePort(), "", handler); EXPECT_CALL(*handler, POSTJson("/api", request, getBridgeIp(), getBridgePort())) .WillOnce(Return(exceptionResponse)); @@ -206,9 +206,9 @@ TEST(Hue, requestUsername) .Times(1) .WillRepeatedly(Return(successResponse)); - Hue test_bridge(getBridgeIp(), getBridgePort(), "", handler); + Bridge test_bridge(getBridgeIp(), getBridgePort(), "", handler); - nlohmann::json hue_bridge_state{ {"lights", {}} }; + nlohmann::json hue_bridge_state {{"lights", {}}}; EXPECT_CALL( *handler, GETJson("/api/" + getBridgeUsername(), nlohmann::json::object(), getBridgeIp(), getBridgePort())) .Times(1) @@ -221,25 +221,25 @@ TEST(Hue, requestUsername) } } -TEST(Hue, setIP) +TEST(Bridge, setIP) { std::shared_ptr handler = std::make_shared(); - Hue test_bridge(getBridgeIp(), getBridgePort(), "", handler); + Bridge test_bridge(getBridgeIp(), getBridgePort(), "", handler); EXPECT_EQ(test_bridge.getBridgeIP(), getBridgeIp()) << "Bridge IP not matching after initialization"; test_bridge.setIP("192.168.2.112"); EXPECT_EQ(test_bridge.getBridgeIP(), "192.168.2.112") << "Bridge IP not matching after setting it"; } -TEST(Hue, setPort) +TEST(Bridge, setPort) { std::shared_ptr handler = std::make_shared(); - Hue test_bridge = Hue(getBridgeIp(), getBridgePort(), "", handler); + Bridge test_bridge = Bridge(getBridgeIp(), getBridgePort(), "", handler); EXPECT_EQ(test_bridge.getBridgePort(), getBridgePort()) << "Bridge Port not matching after initialization"; test_bridge.setPort(81); EXPECT_EQ(test_bridge.getBridgePort(), 81) << "Bridge Port not matching after setting it"; } -TEST(Hue, getLight) +TEST(Bridge, getLight) { using namespace ::testing; std::shared_ptr handler = std::make_shared(); @@ -247,7 +247,7 @@ TEST(Hue, getLight) *handler, GETJson("/api/" + getBridgeUsername(), nlohmann::json::object(), getBridgeIp(), getBridgePort())) .Times(1); - Hue test_bridge(getBridgeIp(), getBridgePort(), getBridgeUsername(), handler); + Bridge test_bridge(getBridgeIp(), getBridgePort(), getBridgeUsername(), handler); // Test exception ASSERT_THROW(test_bridge.lights().get(1), HueException); @@ -272,10 +272,10 @@ TEST(Hue, getLight) .WillRepeatedly(Return(hue_bridge_state["lights"]["1"])); // Refresh cache - test_bridge = Hue(getBridgeIp(), getBridgePort(), getBridgeUsername(), handler); + test_bridge = Bridge(getBridgeIp(), getBridgePort(), getBridgeUsername(), handler); // Test when correct data is sent - HueLight test_light_1 = test_bridge.lights().get(1); + Light test_light_1 = test_bridge.lights().get(1); EXPECT_EQ(test_light_1.getName(), "Hue ambiance lamp 1"); EXPECT_EQ(test_light_1.getColorType(), ColorType::TEMPERATURE); @@ -286,7 +286,7 @@ TEST(Hue, getLight) EXPECT_EQ(test_light_1.getColorType(), ColorType::TEMPERATURE); } -TEST(Hue, removeLight) +TEST(Bridge, removeLight) { using namespace ::testing; std::shared_ptr handler = std::make_shared(); @@ -303,7 +303,7 @@ TEST(Hue, removeLight) .Times(1) .WillOnce(Return(hue_bridge_state)); - Hue test_bridge(getBridgeIp(), getBridgePort(), getBridgeUsername(), handler); + Bridge test_bridge(getBridgeIp(), getBridgePort(), getBridgeUsername(), handler); EXPECT_CALL(*handler, GETJson("/api/" + getBridgeUsername() + "/lights/1", nlohmann::json::object(), getBridgeIp(), getBridgePort())) @@ -322,14 +322,14 @@ TEST(Hue, removeLight) .WillOnce(Return(nlohmann::json())); // Test when correct data is sent - HueLight test_light_1 = test_bridge.lights().get(1); + Light test_light_1 = test_bridge.lights().get(1); EXPECT_EQ(test_bridge.lights().remove(1), true); EXPECT_EQ(test_bridge.lights().remove(1), false); } -TEST(Hue, getAllLights) +TEST(Bridge, getAllLights) { using namespace ::testing; std::shared_ptr handler = std::make_shared(); @@ -352,15 +352,15 @@ TEST(Hue, getAllLights) .Times(AtLeast(1)) .WillRepeatedly(Return(hue_bridge_state["lights"]["1"])); - Hue test_bridge(getBridgeIp(), getBridgePort(), getBridgeUsername(), handler); + Bridge test_bridge(getBridgeIp(), getBridgePort(), getBridgeUsername(), handler); - std::vector> test_lights = test_bridge.lights().getAll(); + std::vector> test_lights = test_bridge.lights().getAll(); ASSERT_EQ(1, test_lights.size()); EXPECT_EQ(test_lights[0].get().getName(), "Hue ambiance lamp 1"); EXPECT_EQ(test_lights[0].get().getColorType(), ColorType::TEMPERATURE); } -TEST(Hue, lightExists) +TEST(Bridge, lightExists) { using namespace ::testing; std::shared_ptr handler = std::make_shared(); @@ -377,7 +377,7 @@ TEST(Hue, lightExists) .Times(AtLeast(1)) .WillRepeatedly(Return(hue_bridge_state)); - Hue test_bridge(getBridgeIp(), getBridgePort(), getBridgeUsername(), handler); + Bridge test_bridge(getBridgeIp(), getBridgePort(), getBridgeUsername(), handler); test_bridge.refresh(); @@ -385,7 +385,7 @@ TEST(Hue, lightExists) EXPECT_FALSE(Const(test_bridge).lights().exists(2)); } -TEST(Hue, getGroup) +TEST(Bridge, getGroup) { using namespace ::testing; std::shared_ptr handler = std::make_shared(); @@ -393,7 +393,7 @@ TEST(Hue, getGroup) *handler, GETJson("/api/" + getBridgeUsername(), nlohmann::json::object(), getBridgeIp(), getBridgePort())) .Times(1); - Hue test_bridge(getBridgeIp(), getBridgePort(), getBridgeUsername(), handler); + Bridge test_bridge(getBridgeIp(), getBridgePort(), getBridgeUsername(), handler); // Test exception ASSERT_THROW(test_bridge.groups().get(1), HueException); @@ -417,7 +417,7 @@ TEST(Hue, getGroup) .WillRepeatedly(Return(hue_bridge_state["groups"]["1"])); // Refresh cache - test_bridge = Hue(getBridgeIp(), getBridgePort(), getBridgeUsername(), handler); + test_bridge = Bridge(getBridgeIp(), getBridgePort(), getBridgeUsername(), handler); // Test when correct data is sent Group test_group_1 = test_bridge.groups().get(1); @@ -430,7 +430,7 @@ TEST(Hue, getGroup) EXPECT_EQ(test_group_1.getType(), "LightGroup"); } -TEST(Hue, removeGroup) +TEST(Bridge, removeGroup) { using namespace ::testing; std::shared_ptr handler = std::make_shared(); @@ -446,7 +446,7 @@ TEST(Hue, removeGroup) .Times(1) .WillOnce(Return(hue_bridge_state)); - Hue test_bridge(getBridgeIp(), getBridgePort(), getBridgeUsername(), handler); + Bridge test_bridge(getBridgeIp(), getBridgePort(), getBridgeUsername(), handler); EXPECT_CALL(*handler, GETJson("/api/" + getBridgeUsername() + "/groups/1", nlohmann::json::object(), getBridgeIp(), getBridgePort())) @@ -472,7 +472,7 @@ TEST(Hue, removeGroup) EXPECT_EQ(test_bridge.groups().remove(1), false); } -TEST(Hue, groupExists) +TEST(Bridge, groupExists) { using namespace ::testing; std::shared_ptr handler = std::make_shared(); @@ -488,7 +488,7 @@ TEST(Hue, groupExists) .Times(AtLeast(1)) .WillRepeatedly(Return(hue_bridge_state)); - Hue test_bridge(getBridgeIp(), getBridgePort(), getBridgeUsername(), handler); + Bridge test_bridge(getBridgeIp(), getBridgePort(), getBridgeUsername(), handler); test_bridge.refresh(); @@ -496,7 +496,7 @@ TEST(Hue, groupExists) EXPECT_EQ(false, Const(test_bridge).groups().exists(2)); } -TEST(Hue, getAllGroups) +TEST(Bridge, getAllGroups) { using namespace ::testing; std::shared_ptr handler = std::make_shared(); @@ -518,7 +518,7 @@ TEST(Hue, getAllGroups) .Times(AtLeast(1)) .WillRepeatedly(Return(hue_bridge_state["groups"]["1"])); - Hue test_bridge(getBridgeIp(), getBridgePort(), getBridgeUsername(), handler); + Bridge test_bridge(getBridgeIp(), getBridgePort(), getBridgeUsername(), handler); std::vector> test_groups = test_bridge.groups().getAll(); ASSERT_EQ(1, test_groups.size()); @@ -526,14 +526,14 @@ TEST(Hue, getAllGroups) EXPECT_EQ(test_groups[0].get().getType(), "LightGroup"); } -TEST(Hue, createGroup) +TEST(Bridge, createGroup) { using namespace ::testing; std::shared_ptr handler = std::make_shared(); EXPECT_CALL( *handler, GETJson("/api/" + getBridgeUsername(), nlohmann::json::object(), getBridgeIp(), getBridgePort())) .Times(AtLeast(1)); - Hue test_bridge(getBridgeIp(), getBridgePort(), getBridgeUsername(), handler); + Bridge test_bridge(getBridgeIp(), getBridgePort(), getBridgeUsername(), handler); CreateGroup create = CreateGroup::Room({2, 3}, "Nice room", "LivingRoom"); nlohmann::json request = create.getRequest(); const int id = 4; diff --git a/test/test_ExtendedColorHueStrategy.cpp b/test/test_ExtendedColorHueStrategy.cpp index cc6afad..886e35d 100644 --- a/test/test_ExtendedColorHueStrategy.cpp +++ b/test/test_ExtendedColorHueStrategy.cpp @@ -32,7 +32,7 @@ #include "hueplusplus/ExtendedColorHueStrategy.h" #include "json/json.hpp" #include "mocks/mock_HttpHandler.h" -#include "mocks/mock_HueLight.h" +#include "mocks/mock_Light.h" using namespace hueplusplus; @@ -44,7 +44,7 @@ TEST(ExtendedColorHueStrategy, alertHueSaturation) *handler, GETJson("/api/" + getBridgeUsername() + "/lights/1", nlohmann::json::object(), getBridgeIp(), 80)) .Times(AtLeast(1)) .WillRepeatedly(Return(nlohmann::json::object())); - MockHueLight light(handler); + MockLight light(handler); const HueSaturation hueSat {200, 100}; // Needs to update the state so transactions are correctly trimmed @@ -123,7 +123,7 @@ TEST(ExtendedColorHueStrategy, alertXY) *handler, GETJson("/api/" + getBridgeUsername() + "/lights/1", nlohmann::json::object(), getBridgeIp(), 80)) .Times(AtLeast(1)) .WillRepeatedly(Return(nlohmann::json::object())); - MockHueLight light(handler); + MockLight light(handler); const XYBrightness xy {{0.1f, 0.1f}, 1.f}; // Needs to update the state so transactions are correctly trimmed diff --git a/test/test_ExtendedColorTemperatureStrategy.cpp b/test/test_ExtendedColorTemperatureStrategy.cpp index 65c763a..4ed85d0 100644 --- a/test/test_ExtendedColorTemperatureStrategy.cpp +++ b/test/test_ExtendedColorTemperatureStrategy.cpp @@ -32,7 +32,7 @@ #include "hueplusplus/ExtendedColorTemperatureStrategy.h" #include "json/json.hpp" #include "mocks/mock_HttpHandler.h" -#include "mocks/mock_HueLight.h" +#include "mocks/mock_Light.h" using namespace hueplusplus; @@ -44,7 +44,7 @@ TEST(ExtendedColorTemperatureStrategy, alertTemperature) *handler, GETJson("/api/" + getBridgeUsername() + "/lights/1", nlohmann::json::object(), getBridgeIp(), 80)) .Times(AtLeast(1)) .WillRepeatedly(Return(nlohmann::json::object())); - MockHueLight light(handler); + MockLight light(handler); const auto setCTLambda = [&](unsigned int ct, int transition) { light.getState()["state"]["colormode"] = "ct"; diff --git a/test/test_HueCommandAPI.cpp b/test/test_HueCommandAPI.cpp index e32efb6..450f527 100644 --- a/test/test_HueCommandAPI.cpp +++ b/test/test_HueCommandAPI.cpp @@ -25,7 +25,7 @@ #include "testhelper.h" -#include "hueplusplus/Hue.h" +#include "hueplusplus/Bridge.h" #include "json/json.hpp" #include "mocks/mock_HttpHandler.h" diff --git a/test/test_HueLight.cpp b/test/test_Light.cpp index 3a61275..f344969 100644 --- a/test/test_HueLight.cpp +++ b/test/test_Light.cpp @@ -25,8 +25,8 @@ #include "testhelper.h" -#include "hueplusplus/Hue.h" -#include "hueplusplus/HueLight.h" +#include "hueplusplus/Bridge.h" +#include "hueplusplus/Light.h" #include "json/json.hpp" #include "mocks/mock_HttpHandler.h" @@ -37,7 +37,7 @@ class HueLightTest : public ::testing::Test protected: std::shared_ptr handler; nlohmann::json hue_bridge_state; - Hue test_bridge; + Bridge test_bridge; protected: HueLightTest() @@ -93,12 +93,12 @@ protected: TEST_F(HueLightTest, Constructor) { - const HueLight ctest_light_1 = test_bridge.lights().get(1); - HueLight test_light_1 = test_bridge.lights().get(1); - const HueLight ctest_light_2 = test_bridge.lights().get(2); - HueLight test_light_2 = test_bridge.lights().get(2); - const HueLight ctest_light_3 = test_bridge.lights().get(3); - HueLight test_light_3 = test_bridge.lights().get(3); + const Light ctest_light_1 = test_bridge.lights().get(1); + Light test_light_1 = test_bridge.lights().get(1); + const Light ctest_light_2 = test_bridge.lights().get(2); + Light test_light_2 = test_bridge.lights().get(2); + const Light ctest_light_3 = test_bridge.lights().get(3); + Light test_light_3 = test_bridge.lights().get(3); } TEST_F(HueLightTest, On) @@ -120,9 +120,9 @@ TEST_F(HueLightTest, On) .Times(1) .WillOnce(Return(prep_ret)); - HueLight test_light_1 = test_bridge.lights().get(1); - HueLight test_light_2 = test_bridge.lights().get(2); - HueLight test_light_3 = test_bridge.lights().get(3); + Light test_light_1 = test_bridge.lights().get(1); + Light test_light_2 = test_bridge.lights().get(2); + Light test_light_3 = test_bridge.lights().get(3); EXPECT_EQ(true, test_light_1.On(33)); EXPECT_EQ(false, test_light_2.On()); @@ -144,9 +144,9 @@ TEST_F(HueLightTest, Off) .Times(1) .WillOnce(Return(prep_ret)); - HueLight test_light_1 = test_bridge.lights().get(1); - HueLight test_light_2 = test_bridge.lights().get(2); - HueLight test_light_3 = test_bridge.lights().get(3); + Light test_light_1 = test_bridge.lights().get(1); + Light test_light_2 = test_bridge.lights().get(2); + Light test_light_3 = test_bridge.lights().get(3); EXPECT_EQ(true, test_light_1.Off(33)); EXPECT_EQ(true, test_light_2.Off()); @@ -155,12 +155,12 @@ TEST_F(HueLightTest, Off) TEST_F(HueLightTest, isOn) { - const HueLight ctest_light_1 = test_bridge.lights().get(1); - const HueLight ctest_light_2 = test_bridge.lights().get(2); - const HueLight ctest_light_3 = test_bridge.lights().get(3); - HueLight test_light_1 = test_bridge.lights().get(1); - HueLight test_light_2 = test_bridge.lights().get(2); - HueLight test_light_3 = test_bridge.lights().get(3); + const Light ctest_light_1 = test_bridge.lights().get(1); + const Light ctest_light_2 = test_bridge.lights().get(2); + const Light ctest_light_3 = test_bridge.lights().get(3); + Light test_light_1 = test_bridge.lights().get(1); + Light test_light_2 = test_bridge.lights().get(2); + Light test_light_3 = test_bridge.lights().get(3); EXPECT_EQ(true, ctest_light_1.isOn()); EXPECT_EQ(false, ctest_light_2.isOn()); @@ -172,12 +172,12 @@ TEST_F(HueLightTest, isOn) TEST_F(HueLightTest, getId) { - const HueLight ctest_light_1 = test_bridge.lights().get(1); - const HueLight ctest_light_2 = test_bridge.lights().get(2); - const HueLight ctest_light_3 = test_bridge.lights().get(3); - HueLight test_light_1 = test_bridge.lights().get(1); - HueLight test_light_2 = test_bridge.lights().get(2); - HueLight test_light_3 = test_bridge.lights().get(3); + const Light ctest_light_1 = test_bridge.lights().get(1); + const Light ctest_light_2 = test_bridge.lights().get(2); + const Light ctest_light_3 = test_bridge.lights().get(3); + Light test_light_1 = test_bridge.lights().get(1); + Light test_light_2 = test_bridge.lights().get(2); + Light test_light_3 = test_bridge.lights().get(3); EXPECT_EQ(1, ctest_light_1.getId()); EXPECT_EQ(2, ctest_light_2.getId()); @@ -189,12 +189,12 @@ TEST_F(HueLightTest, getId) TEST_F(HueLightTest, getType) { - const HueLight ctest_light_1 = test_bridge.lights().get(1); - const HueLight ctest_light_2 = test_bridge.lights().get(2); - const HueLight ctest_light_3 = test_bridge.lights().get(3); - HueLight test_light_1 = test_bridge.lights().get(1); - HueLight test_light_2 = test_bridge.lights().get(2); - HueLight test_light_3 = test_bridge.lights().get(3); + const Light ctest_light_1 = test_bridge.lights().get(1); + const Light ctest_light_2 = test_bridge.lights().get(2); + const Light ctest_light_3 = test_bridge.lights().get(3); + Light test_light_1 = test_bridge.lights().get(1); + Light test_light_2 = test_bridge.lights().get(2); + Light test_light_3 = test_bridge.lights().get(3); EXPECT_EQ("Dimmable light", ctest_light_1.getType()); EXPECT_EQ("Color light", ctest_light_2.getType()); @@ -206,12 +206,12 @@ TEST_F(HueLightTest, getType) TEST_F(HueLightTest, getName) { - const HueLight ctest_light_1 = test_bridge.lights().get(1); - const HueLight ctest_light_2 = test_bridge.lights().get(2); - const HueLight ctest_light_3 = test_bridge.lights().get(3); - HueLight test_light_1 = test_bridge.lights().get(1); - HueLight test_light_2 = test_bridge.lights().get(2); - HueLight test_light_3 = test_bridge.lights().get(3); + const Light ctest_light_1 = test_bridge.lights().get(1); + const Light ctest_light_2 = test_bridge.lights().get(2); + const Light ctest_light_3 = test_bridge.lights().get(3); + Light test_light_1 = test_bridge.lights().get(1); + Light test_light_2 = test_bridge.lights().get(2); + Light test_light_3 = test_bridge.lights().get(3); EXPECT_EQ("Hue lamp 1", ctest_light_1.getName()); EXPECT_EQ("Hue lamp 2", ctest_light_2.getName()); @@ -223,12 +223,12 @@ TEST_F(HueLightTest, getName) TEST_F(HueLightTest, getModelId) { - const HueLight ctest_light_1 = test_bridge.lights().get(1); - const HueLight ctest_light_2 = test_bridge.lights().get(2); - const HueLight ctest_light_3 = test_bridge.lights().get(3); - HueLight test_light_1 = test_bridge.lights().get(1); - HueLight test_light_2 = test_bridge.lights().get(2); - HueLight test_light_3 = test_bridge.lights().get(3); + const Light ctest_light_1 = test_bridge.lights().get(1); + const Light ctest_light_2 = test_bridge.lights().get(2); + const Light ctest_light_3 = test_bridge.lights().get(3); + Light test_light_1 = test_bridge.lights().get(1); + Light test_light_2 = test_bridge.lights().get(2); + Light test_light_3 = test_bridge.lights().get(3); EXPECT_EQ("LWB004", ctest_light_1.getModelId()); EXPECT_EQ("LST001", ctest_light_2.getModelId()); @@ -240,12 +240,12 @@ TEST_F(HueLightTest, getModelId) TEST_F(HueLightTest, getUId) { - const HueLight ctest_light_1 = test_bridge.lights().get(1); - const HueLight ctest_light_2 = test_bridge.lights().get(2); - const HueLight ctest_light_3 = test_bridge.lights().get(3); - HueLight test_light_1 = test_bridge.lights().get(1); - HueLight test_light_2 = test_bridge.lights().get(2); - HueLight test_light_3 = test_bridge.lights().get(3); + const Light ctest_light_1 = test_bridge.lights().get(1); + const Light ctest_light_2 = test_bridge.lights().get(2); + const Light ctest_light_3 = test_bridge.lights().get(3); + Light test_light_1 = test_bridge.lights().get(1); + Light test_light_2 = test_bridge.lights().get(2); + Light test_light_3 = test_bridge.lights().get(3); EXPECT_EQ("00:00:00:00:00:00:00:00-00", ctest_light_1.getUId()); EXPECT_EQ("11:11:11:11:11:11:11:11-11", ctest_light_2.getUId()); @@ -257,12 +257,12 @@ TEST_F(HueLightTest, getUId) TEST_F(HueLightTest, getManufacturername) { - const HueLight ctest_light_1 = test_bridge.lights().get(1); - const HueLight ctest_light_2 = test_bridge.lights().get(2); - const HueLight ctest_light_3 = test_bridge.lights().get(3); - HueLight test_light_1 = test_bridge.lights().get(1); - HueLight test_light_2 = test_bridge.lights().get(2); - HueLight test_light_3 = test_bridge.lights().get(3); + const Light ctest_light_1 = test_bridge.lights().get(1); + const Light ctest_light_2 = test_bridge.lights().get(2); + const Light ctest_light_3 = test_bridge.lights().get(3); + Light test_light_1 = test_bridge.lights().get(1); + Light test_light_2 = test_bridge.lights().get(2); + Light test_light_3 = test_bridge.lights().get(3); EXPECT_EQ("Philips", ctest_light_1.getManufacturername()); EXPECT_EQ("", ctest_light_2.getManufacturername()); @@ -274,12 +274,12 @@ TEST_F(HueLightTest, getManufacturername) TEST_F(HueLightTest, getProductname) { - const HueLight ctest_light_1 = test_bridge.lights().get(1); - const HueLight ctest_light_2 = test_bridge.lights().get(2); - const HueLight ctest_light_3 = test_bridge.lights().get(3); - HueLight test_light_1 = test_bridge.lights().get(1); - HueLight test_light_2 = test_bridge.lights().get(2); - HueLight test_light_3 = test_bridge.lights().get(3); + const Light ctest_light_1 = test_bridge.lights().get(1); + const Light ctest_light_2 = test_bridge.lights().get(2); + const Light ctest_light_3 = test_bridge.lights().get(3); + Light test_light_1 = test_bridge.lights().get(1); + Light test_light_2 = test_bridge.lights().get(2); + Light test_light_3 = test_bridge.lights().get(3); EXPECT_EQ("Hue bloom", ctest_light_1.getProductname()); EXPECT_EQ("", ctest_light_2.getProductname()); @@ -291,12 +291,12 @@ TEST_F(HueLightTest, getProductname) TEST_F(HueLightTest, getLuminaireUId) { - const HueLight ctest_light_1 = test_bridge.lights().get(1); - const HueLight ctest_light_2 = test_bridge.lights().get(2); - const HueLight ctest_light_3 = test_bridge.lights().get(3); - HueLight test_light_1 = test_bridge.lights().get(1); - HueLight test_light_2 = test_bridge.lights().get(2); - HueLight test_light_3 = test_bridge.lights().get(3); + const Light ctest_light_1 = test_bridge.lights().get(1); + const Light ctest_light_2 = test_bridge.lights().get(2); + const Light ctest_light_3 = test_bridge.lights().get(3); + Light test_light_1 = test_bridge.lights().get(1); + Light test_light_2 = test_bridge.lights().get(2); + Light test_light_3 = test_bridge.lights().get(3); EXPECT_EQ("0000000", ctest_light_1.getLuminaireUId()); EXPECT_EQ("", ctest_light_2.getLuminaireUId()); @@ -308,12 +308,12 @@ TEST_F(HueLightTest, getLuminaireUId) TEST_F(HueLightTest, getSwVersion) { - const HueLight ctest_light_1 = test_bridge.lights().get(1); - const HueLight ctest_light_2 = test_bridge.lights().get(2); - const HueLight ctest_light_3 = test_bridge.lights().get(3); - HueLight test_light_1 = test_bridge.lights().get(1); - HueLight test_light_2 = test_bridge.lights().get(2); - HueLight test_light_3 = test_bridge.lights().get(3); + const Light ctest_light_1 = test_bridge.lights().get(1); + const Light ctest_light_2 = test_bridge.lights().get(2); + const Light ctest_light_3 = test_bridge.lights().get(3); + Light test_light_1 = test_bridge.lights().get(1); + Light test_light_2 = test_bridge.lights().get(2); + Light test_light_3 = test_bridge.lights().get(3); EXPECT_EQ("5.50.1.19085", ctest_light_1.getSwVersion()); EXPECT_EQ("5.50.1.19085", ctest_light_2.getSwVersion()); @@ -348,9 +348,9 @@ TEST_F(HueLightTest, setName) .Times(1) .WillOnce(Return(prep_ret)); - HueLight test_light_1 = test_bridge.lights().get(1); - HueLight test_light_2 = test_bridge.lights().get(2); - HueLight test_light_3 = test_bridge.lights().get(3); + Light test_light_1 = test_bridge.lights().get(1); + Light test_light_2 = test_bridge.lights().get(2); + Light test_light_3 = test_bridge.lights().get(3); EXPECT_EQ(true, test_light_1.setName(expected_request["name"].get())); EXPECT_EQ(false, test_light_2.setName(expected_request["name"].get())); @@ -359,12 +359,12 @@ TEST_F(HueLightTest, setName) TEST_F(HueLightTest, getColorType) { - const HueLight ctest_light_1 = test_bridge.lights().get(1); - const HueLight ctest_light_2 = test_bridge.lights().get(2); - const HueLight ctest_light_3 = test_bridge.lights().get(3); - HueLight test_light_1 = test_bridge.lights().get(1); - HueLight test_light_2 = test_bridge.lights().get(2); - HueLight test_light_3 = test_bridge.lights().get(3); + const Light ctest_light_1 = test_bridge.lights().get(1); + const Light ctest_light_2 = test_bridge.lights().get(2); + const Light ctest_light_3 = test_bridge.lights().get(3); + Light test_light_1 = test_bridge.lights().get(1); + Light test_light_2 = test_bridge.lights().get(2); + Light test_light_3 = test_bridge.lights().get(3); EXPECT_EQ(ColorType::NONE, ctest_light_1.getColorType()); EXPECT_EQ(ColorType::GAMUT_A, ctest_light_2.getColorType()); @@ -376,12 +376,12 @@ TEST_F(HueLightTest, getColorType) TEST_F(HueLightTest, KelvinToMired) { - const HueLight ctest_light_1 = test_bridge.lights().get(1); - const HueLight ctest_light_2 = test_bridge.lights().get(2); - const HueLight ctest_light_3 = test_bridge.lights().get(3); - HueLight test_light_1 = test_bridge.lights().get(1); - HueLight test_light_2 = test_bridge.lights().get(2); - HueLight test_light_3 = test_bridge.lights().get(3); + const Light ctest_light_1 = test_bridge.lights().get(1); + const Light ctest_light_2 = test_bridge.lights().get(2); + const Light ctest_light_3 = test_bridge.lights().get(3); + Light test_light_1 = test_bridge.lights().get(1); + Light test_light_2 = test_bridge.lights().get(2); + Light test_light_3 = test_bridge.lights().get(3); EXPECT_EQ(10000, ctest_light_1.KelvinToMired(100)); EXPECT_EQ(500, ctest_light_2.KelvinToMired(2000)); @@ -393,12 +393,12 @@ TEST_F(HueLightTest, KelvinToMired) TEST_F(HueLightTest, MiredToKelvin) { - const HueLight ctest_light_1 = test_bridge.lights().get(1); - const HueLight ctest_light_2 = test_bridge.lights().get(2); - const HueLight ctest_light_3 = test_bridge.lights().get(3); - HueLight test_light_1 = test_bridge.lights().get(1); - HueLight test_light_2 = test_bridge.lights().get(2); - HueLight test_light_3 = test_bridge.lights().get(3); + const Light ctest_light_1 = test_bridge.lights().get(1); + const Light ctest_light_2 = test_bridge.lights().get(2); + const Light ctest_light_3 = test_bridge.lights().get(3); + Light test_light_1 = test_bridge.lights().get(1); + Light test_light_2 = test_bridge.lights().get(2); + Light test_light_3 = test_bridge.lights().get(3); EXPECT_EQ(100, ctest_light_1.MiredToKelvin(10000)); EXPECT_EQ(2000, ctest_light_2.MiredToKelvin(500)); @@ -411,12 +411,12 @@ TEST_F(HueLightTest, MiredToKelvin) TEST_F(HueLightTest, hasBrightnessControl) { - const HueLight ctest_light_1 = test_bridge.lights().get(1); - const HueLight ctest_light_2 = test_bridge.lights().get(2); - const HueLight ctest_light_3 = test_bridge.lights().get(3); - HueLight test_light_1 = test_bridge.lights().get(1); - HueLight test_light_2 = test_bridge.lights().get(2); - HueLight test_light_3 = test_bridge.lights().get(3); + const Light ctest_light_1 = test_bridge.lights().get(1); + const Light ctest_light_2 = test_bridge.lights().get(2); + const Light ctest_light_3 = test_bridge.lights().get(3); + Light test_light_1 = test_bridge.lights().get(1); + Light test_light_2 = test_bridge.lights().get(2); + Light test_light_3 = test_bridge.lights().get(3); EXPECT_EQ(true, ctest_light_1.hasBrightnessControl()); EXPECT_EQ(true, ctest_light_2.hasBrightnessControl()); @@ -428,12 +428,12 @@ TEST_F(HueLightTest, hasBrightnessControl) TEST_F(HueLightTest, hasTemperatureControl) { - const HueLight ctest_light_1 = test_bridge.lights().get(1); - const HueLight ctest_light_2 = test_bridge.lights().get(2); - const HueLight ctest_light_3 = test_bridge.lights().get(3); - HueLight test_light_1 = test_bridge.lights().get(1); - HueLight test_light_2 = test_bridge.lights().get(2); - HueLight test_light_3 = test_bridge.lights().get(3); + const Light ctest_light_1 = test_bridge.lights().get(1); + const Light ctest_light_2 = test_bridge.lights().get(2); + const Light ctest_light_3 = test_bridge.lights().get(3); + Light test_light_1 = test_bridge.lights().get(1); + Light test_light_2 = test_bridge.lights().get(2); + Light test_light_3 = test_bridge.lights().get(3); EXPECT_EQ(false, ctest_light_1.hasTemperatureControl()); EXPECT_EQ(false, ctest_light_2.hasTemperatureControl()); @@ -445,12 +445,12 @@ TEST_F(HueLightTest, hasTemperatureControl) TEST_F(HueLightTest, hasColorControl) { - const HueLight ctest_light_1 = test_bridge.lights().get(1); - const HueLight ctest_light_2 = test_bridge.lights().get(2); - const HueLight ctest_light_3 = test_bridge.lights().get(3); - HueLight test_light_1 = test_bridge.lights().get(1); - HueLight test_light_2 = test_bridge.lights().get(2); - HueLight test_light_3 = test_bridge.lights().get(3); + const Light ctest_light_1 = test_bridge.lights().get(1); + const Light ctest_light_2 = test_bridge.lights().get(2); + const Light ctest_light_3 = test_bridge.lights().get(3); + Light test_light_1 = test_bridge.lights().get(1); + Light test_light_2 = test_bridge.lights().get(2); + Light test_light_3 = test_bridge.lights().get(3); EXPECT_EQ(false, ctest_light_1.hasColorControl()); EXPECT_EQ(true, ctest_light_2.hasColorControl()); @@ -481,9 +481,9 @@ TEST_F(HueLightTest, setBrightness) .Times(1) .WillOnce(Return(prep_ret)); - HueLight test_light_1 = test_bridge.lights().get(1); - HueLight test_light_2 = test_bridge.lights().get(2); - HueLight test_light_3 = test_bridge.lights().get(3); + Light test_light_1 = test_bridge.lights().get(1); + Light test_light_2 = test_bridge.lights().get(2); + Light test_light_3 = test_bridge.lights().get(3); EXPECT_EQ(false, test_light_1.setBrightness(200)); EXPECT_EQ(true, test_light_2.setBrightness(0, 2)); @@ -492,12 +492,12 @@ TEST_F(HueLightTest, setBrightness) TEST_F(HueLightTest, getBrightness) { - const HueLight ctest_light_1 = test_bridge.lights().get(1); - const HueLight ctest_light_2 = test_bridge.lights().get(2); - const HueLight ctest_light_3 = test_bridge.lights().get(3); - HueLight test_light_1 = test_bridge.lights().get(1); - HueLight test_light_2 = test_bridge.lights().get(2); - HueLight test_light_3 = test_bridge.lights().get(3); + const Light ctest_light_1 = test_bridge.lights().get(1); + const Light ctest_light_2 = test_bridge.lights().get(2); + const Light ctest_light_3 = test_bridge.lights().get(3); + Light test_light_1 = test_bridge.lights().get(1); + Light test_light_2 = test_bridge.lights().get(2); + Light test_light_3 = test_bridge.lights().get(3); EXPECT_EQ(254, ctest_light_1.getBrightness()); EXPECT_EQ(0, ctest_light_2.getBrightness()); @@ -525,9 +525,9 @@ TEST_F(HueLightTest, setColorTemperature) .Times(1) .WillOnce(Return(prep_ret)); - HueLight test_light_1 = test_bridge.lights().get(1); - HueLight test_light_2 = test_bridge.lights().get(2); - HueLight test_light_3 = test_bridge.lights().get(3); + Light test_light_1 = test_bridge.lights().get(1); + Light test_light_2 = test_bridge.lights().get(2); + Light test_light_3 = test_bridge.lights().get(3); EXPECT_EQ(false, test_light_1.setColorTemperature(153)); EXPECT_EQ(false, test_light_2.setColorTemperature(400, 2)); @@ -536,12 +536,12 @@ TEST_F(HueLightTest, setColorTemperature) TEST_F(HueLightTest, getColorTemperature) { - const HueLight ctest_light_1 = test_bridge.lights().get(1); - const HueLight ctest_light_2 = test_bridge.lights().get(2); - const HueLight ctest_light_3 = test_bridge.lights().get(3); - HueLight test_light_1 = test_bridge.lights().get(1); - HueLight test_light_2 = test_bridge.lights().get(2); - HueLight test_light_3 = test_bridge.lights().get(3); + const Light ctest_light_1 = test_bridge.lights().get(1); + const Light ctest_light_2 = test_bridge.lights().get(2); + const Light ctest_light_3 = test_bridge.lights().get(3); + Light test_light_1 = test_bridge.lights().get(1); + Light test_light_2 = test_bridge.lights().get(2); + Light test_light_3 = test_bridge.lights().get(3); EXPECT_EQ(0, ctest_light_1.getColorTemperature()); EXPECT_EQ(0, ctest_light_2.getColorTemperature()); @@ -572,9 +572,9 @@ TEST_F(HueLightTest, setColorHue) .Times(1) .WillOnce(Return(prep_ret)); - HueLight test_light_1 = test_bridge.lights().get(1); - HueLight test_light_2 = test_bridge.lights().get(2); - HueLight test_light_3 = test_bridge.lights().get(3); + Light test_light_1 = test_bridge.lights().get(1); + Light test_light_2 = test_bridge.lights().get(2); + Light test_light_3 = test_bridge.lights().get(3); EXPECT_EQ(false, test_light_1.setColorHue(153)); EXPECT_EQ(false, test_light_2.setColorHue(30000, 2)); @@ -602,9 +602,9 @@ TEST_F(HueLightTest, setColorSaturation) .Times(1) .WillOnce(Return(prep_ret)); - HueLight test_light_1 = test_bridge.lights().get(1); - HueLight test_light_2 = test_bridge.lights().get(2); - HueLight test_light_3 = test_bridge.lights().get(3); + Light test_light_1 = test_bridge.lights().get(1); + Light test_light_2 = test_bridge.lights().get(2); + Light test_light_3 = test_bridge.lights().get(3); EXPECT_EQ(false, test_light_1.setColorSaturation(0)); EXPECT_EQ(false, test_light_2.setColorSaturation(140, 2)); @@ -635,9 +635,9 @@ TEST_F(HueLightTest, setColorHueSaturation) .Times(1) .WillOnce(Return(prep_ret)); - HueLight test_light_1 = test_bridge.lights().get(1); - HueLight test_light_2 = test_bridge.lights().get(2); - HueLight test_light_3 = test_bridge.lights().get(3); + Light test_light_1 = test_bridge.lights().get(1); + Light test_light_2 = test_bridge.lights().get(2); + Light test_light_3 = test_bridge.lights().get(3); EXPECT_EQ(false, test_light_1.setColorHueSaturation({153, 0})); EXPECT_EQ(false, test_light_2.setColorHueSaturation({30000, 140}, 2)); @@ -646,12 +646,12 @@ TEST_F(HueLightTest, setColorHueSaturation) TEST_F(HueLightTest, getColorHueSaturation) { - const HueLight ctest_light_1 = test_bridge.lights().get(1); - const HueLight ctest_light_2 = test_bridge.lights().get(2); - const HueLight ctest_light_3 = test_bridge.lights().get(3); - HueLight test_light_1 = test_bridge.lights().get(1); - HueLight test_light_2 = test_bridge.lights().get(2); - HueLight test_light_3 = test_bridge.lights().get(3); + const Light ctest_light_1 = test_bridge.lights().get(1); + const Light ctest_light_2 = test_bridge.lights().get(2); + const Light ctest_light_3 = test_bridge.lights().get(3); + Light test_light_1 = test_bridge.lights().get(1); + Light test_light_2 = test_bridge.lights().get(2); + Light test_light_3 = test_bridge.lights().get(3); EXPECT_EQ((HueSaturation {0, 0}), ctest_light_1.getColorHueSaturation()); EXPECT_EQ((HueSaturation {12345, 123}), ctest_light_2.getColorHueSaturation()); @@ -683,9 +683,9 @@ TEST_F(HueLightTest, setColorXY) .Times(1) .WillOnce(Return(prep_ret)); - HueLight test_light_1 = test_bridge.lights().get(1); - HueLight test_light_2 = test_bridge.lights().get(2); - HueLight test_light_3 = test_bridge.lights().get(3); + Light test_light_1 = test_bridge.lights().get(1); + Light test_light_2 = test_bridge.lights().get(2); + Light test_light_3 = test_bridge.lights().get(3); EXPECT_EQ(false, test_light_1.setColorXY({{0.01f, 0.f}, 1.f})); EXPECT_EQ(false, test_light_2.setColorXY({{0.123f, 1.f}, 1.f}, 2)); @@ -694,12 +694,12 @@ TEST_F(HueLightTest, setColorXY) TEST_F(HueLightTest, getColorXY) { - const HueLight ctest_light_1 = test_bridge.lights().get(1); - const HueLight ctest_light_2 = test_bridge.lights().get(2); - const HueLight ctest_light_3 = test_bridge.lights().get(3); - HueLight test_light_1 = test_bridge.lights().get(1); - HueLight test_light_2 = test_bridge.lights().get(2); - HueLight test_light_3 = test_bridge.lights().get(3); + const Light ctest_light_1 = test_bridge.lights().get(1); + const Light ctest_light_2 = test_bridge.lights().get(2); + const Light ctest_light_3 = test_bridge.lights().get(3); + Light test_light_1 = test_bridge.lights().get(1); + Light test_light_2 = test_bridge.lights().get(2); + Light test_light_3 = test_bridge.lights().get(3); EXPECT_EQ((XYBrightness {{0.f, 0.f}, 0.f}), ctest_light_1.getColorXY()); EXPECT_EQ((XYBrightness {{0.102f, 0.102f}, 0.f}), ctest_light_2.getColorXY()); EXPECT_EQ((XYBrightness {{0.102f, 0.102f}, 1.f}), ctest_light_3.getColorXY()); @@ -730,9 +730,9 @@ TEST_F(HueLightTest, setColorRGB) .Times(1) .WillOnce(Return(prep_ret)); - HueLight test_light_1 = test_bridge.lights().get(1); - HueLight test_light_2 = test_bridge.lights().get(2); - HueLight test_light_3 = test_bridge.lights().get(3); + Light test_light_1 = test_bridge.lights().get(1); + Light test_light_2 = test_bridge.lights().get(2); + Light test_light_3 = test_bridge.lights().get(3); EXPECT_EQ(false, test_light_1.setColorRGB({0, 0, 0}, 0)); EXPECT_EQ(false, test_light_2.setColorRGB({32, 64, 128}, 2)); @@ -757,9 +757,9 @@ TEST_F(HueLightTest, alert) .Times(1) .WillOnce(Return(prep_ret)); - HueLight test_light_1 = test_bridge.lights().get(1); - HueLight test_light_2 = test_bridge.lights().get(2); - HueLight test_light_3 = test_bridge.lights().get(3); + Light test_light_1 = test_bridge.lights().get(1); + Light test_light_2 = test_bridge.lights().get(2); + Light test_light_3 = test_bridge.lights().get(3); EXPECT_EQ(false, test_light_1.alert()); EXPECT_EQ(false, test_light_2.alert()); @@ -773,9 +773,9 @@ TEST_F(HueLightTest, alertTemperature) .Times(1) .WillOnce(Return(nlohmann::json::array())); - HueLight test_light_1 = test_bridge.lights().get(1); - HueLight test_light_2 = test_bridge.lights().get(2); - HueLight test_light_3 = test_bridge.lights().get(3); + Light test_light_1 = test_bridge.lights().get(1); + Light test_light_2 = test_bridge.lights().get(2); + Light test_light_3 = test_bridge.lights().get(3); EXPECT_EQ(false, test_light_1.alertTemperature(400)); EXPECT_EQ(false, test_light_2.alertTemperature(100)); @@ -789,9 +789,9 @@ TEST_F(HueLightTest, alertHueSaturation) .Times(1) .WillOnce(Return(nlohmann::json::array())); - HueLight test_light_1 = test_bridge.lights().get(1); - HueLight test_light_2 = test_bridge.lights().get(2); - HueLight test_light_3 = test_bridge.lights().get(3); + Light test_light_1 = test_bridge.lights().get(1); + Light test_light_2 = test_bridge.lights().get(2); + Light test_light_3 = test_bridge.lights().get(3); EXPECT_EQ(false, test_light_1.alertHueSaturation({0, 255})); EXPECT_EQ(false, test_light_2.alertHueSaturation({3000, 100})); @@ -805,9 +805,9 @@ TEST_F(HueLightTest, alertXY) .Times(1) .WillOnce(Return(nlohmann::json::array())); - HueLight test_light_1 = test_bridge.lights().get(1); - HueLight test_light_2 = test_bridge.lights().get(2); - HueLight test_light_3 = test_bridge.lights().get(3); + Light test_light_1 = test_bridge.lights().get(1); + Light test_light_2 = test_bridge.lights().get(2); + Light test_light_3 = test_bridge.lights().get(3); EXPECT_EQ(false, test_light_1.alertXY({{0.1f, 0.1f}, 1.f})); EXPECT_EQ(false, test_light_2.alertXY({{0.2434f, 0.2344f}, 1.f})); @@ -824,9 +824,9 @@ TEST_F(HueLightTest, setColorLoop) .Times(1) .WillOnce(Return(nlohmann::json::array())); - HueLight test_light_1 = test_bridge.lights().get(1); - HueLight test_light_2 = test_bridge.lights().get(2); - HueLight test_light_3 = test_bridge.lights().get(3); + Light test_light_1 = test_bridge.lights().get(1); + Light test_light_2 = test_bridge.lights().get(2); + Light test_light_3 = test_bridge.lights().get(3); EXPECT_EQ(false, test_light_1.setColorLoop(true)); EXPECT_EQ(false, test_light_2.setColorLoop(false)); diff --git a/test/test_HueLightFactory.cpp b/test/test_LightFactory.cpp index 96ad74e..22fc00f 100644 --- a/test/test_HueLightFactory.cpp +++ b/test/test_LightFactory.cpp @@ -29,12 +29,12 @@ using namespace hueplusplus; -TEST(HueLightFactory, createLight_noGamut) +TEST(LightFactory, createLight_noGamut) { using namespace ::testing; std::shared_ptr handler = std::make_shared(); - HueLightFactory factory(HueCommandAPI(getBridgeIp(), getBridgePort(), getBridgeUsername(), handler), + LightFactory factory(HueCommandAPI(getBridgeIp(), getBridgePort(), getBridgeUsername(), handler), std::chrono::steady_clock::duration::max()); nlohmann::json lightState @@ -49,7 +49,7 @@ TEST(HueLightFactory, createLight_noGamut) .Times(AtLeast(1)) .WillRepeatedly(Return(lightState)); - HueLight test_light_1 = factory.createLight(lightState, 1); + Light test_light_1 = factory.createLight(lightState, 1); EXPECT_EQ(test_light_1.getColorType(), ColorType::TEMPERATURE); lightState["type"] = "Dimmable light"; @@ -76,12 +76,12 @@ TEST(HueLightFactory, createLight_noGamut) ASSERT_THROW(factory.createLight(lightState, 1), HueException); } -TEST(HueLightFactory, createLight_gamutCapabilities) +TEST(LightFactory, createLight_gamutCapabilities) { using namespace ::testing; std::shared_ptr handler = std::make_shared(); - HueLightFactory factory(HueCommandAPI(getBridgeIp(), getBridgePort(), getBridgeUsername(), handler), + LightFactory factory(HueCommandAPI(getBridgeIp(), getBridgePort(), getBridgeUsername(), handler), std::chrono::steady_clock::duration::max()); nlohmann::json lightState @@ -97,7 +97,7 @@ TEST(HueLightFactory, createLight_gamutCapabilities) .Times(AtLeast(1)) .WillRepeatedly(Return(lightState)); - HueLight test_light_1 = factory.createLight(lightState, 1); + Light test_light_1 = factory.createLight(lightState, 1); EXPECT_EQ(test_light_1.getColorType(), ColorType::GAMUT_A); lightState["capabilities"]["control"]["colorgamuttype"] = "B"; @@ -160,12 +160,12 @@ TEST(HueLightFactory, createLight_gamutCapabilities) EXPECT_EQ(test_light_1.getColorType(), ColorType::GAMUT_C_TEMPERATURE); } -TEST(HueLightFactory, createLight_gamutModelid) +TEST(LightFactory, createLight_gamutModelid) { using namespace ::testing; std::shared_ptr handler = std::make_shared(); - HueLightFactory factory(HueCommandAPI(getBridgeIp(), getBridgePort(), getBridgeUsername(), handler), + LightFactory factory(HueCommandAPI(getBridgeIp(), getBridgePort(), getBridgeUsername(), handler), std::chrono::steady_clock::duration::max()); const std::string gamutAModel = "LST001"; @@ -184,7 +184,7 @@ TEST(HueLightFactory, createLight_gamutModelid) .Times(AtLeast(1)) .WillRepeatedly(Return(lightState)); - HueLight test_light_1 = factory.createLight(lightState, 1); + Light test_light_1 = factory.createLight(lightState, 1); EXPECT_EQ(test_light_1.getColorType(), ColorType::GAMUT_A); lightState["modelid"] = gamutBModel; diff --git a/test/test_Main.cpp b/test/test_Main.cpp index 896d1d2..1acba9b 100644 --- a/test/test_Main.cpp +++ b/test/test_Main.cpp @@ -21,7 +21,7 @@ **/ #include -#include +#include namespace { diff --git a/test/test_SimpleBrightnessStrategy.cpp b/test/test_SimpleBrightnessStrategy.cpp index cfe01b4..ad29b7a 100644 --- a/test/test_SimpleBrightnessStrategy.cpp +++ b/test/test_SimpleBrightnessStrategy.cpp @@ -32,7 +32,7 @@ #include "hueplusplus/SimpleBrightnessStrategy.h" #include "json/json.hpp" #include "mocks/mock_HttpHandler.h" -#include "mocks/mock_HueLight.h" +#include "mocks/mock_Light.h" using namespace hueplusplus; @@ -44,7 +44,7 @@ TEST(SimpleBrightnessStrategy, setBrightness) *handler, GETJson("/api/" + getBridgeUsername() + "/lights/1", nlohmann::json::object(), getBridgeIp(), 80)) .Times(AtLeast(1)) .WillRepeatedly(Return(nlohmann::json::object())); - MockHueLight test_light(handler); + MockLight test_light(handler); const std::string statePath = "/api/" + getBridgeUsername() + "/lights/1/state"; @@ -84,10 +84,10 @@ TEST(SimpleBrightnessStrategy, getBrightness) *handler, GETJson("/api/" + getBridgeUsername() + "/lights/1", nlohmann::json::object(), getBridgeIp(), 80)) .Times(AtLeast(1)) .WillRepeatedly(Return(nlohmann::json::object())); - MockHueLight test_light(handler); + MockLight test_light(handler); test_light.getState()["state"]["bri"] = 200; EXPECT_EQ(200, SimpleBrightnessStrategy().getBrightness(test_light)); test_light.getState()["state"]["bri"] = 0; - EXPECT_EQ(0, SimpleBrightnessStrategy().getBrightness(static_cast(test_light))); + EXPECT_EQ(0, SimpleBrightnessStrategy().getBrightness(static_cast(test_light))); } diff --git a/test/test_SimpleColorHueStrategy.cpp b/test/test_SimpleColorHueStrategy.cpp index a7de057..0b4f0d6 100644 --- a/test/test_SimpleColorHueStrategy.cpp +++ b/test/test_SimpleColorHueStrategy.cpp @@ -32,7 +32,7 @@ #include "hueplusplus/SimpleColorHueStrategy.h" #include "json/json.hpp" #include "mocks/mock_HttpHandler.h" -#include "mocks/mock_HueLight.h" +#include "mocks/mock_Light.h" using namespace hueplusplus; @@ -44,7 +44,7 @@ TEST(SimpleColorHueStrategy, setColorHue) *handler, GETJson("/api/" + getBridgeUsername() + "/lights/1", nlohmann::json::object(), getBridgeIp(), 80)) .Times(AtLeast(1)) .WillRepeatedly(Return(nlohmann::json::object())); - MockHueLight test_light(handler); + MockLight test_light(handler); const std::string statePath = "/api/" + getBridgeUsername() + "/lights/1/state"; @@ -78,7 +78,7 @@ TEST(SimpleColorHueStrategy, setColorSaturation) *handler, GETJson("/api/" + getBridgeUsername() + "/lights/1", nlohmann::json::object(), getBridgeIp(), 80)) .Times(AtLeast(1)) .WillRepeatedly(Return(nlohmann::json::object())); - MockHueLight test_light(handler); + MockLight test_light(handler); const std::string statePath = "/api/" + getBridgeUsername() + "/lights/1/state"; @@ -112,7 +112,7 @@ TEST(SimpleColorHueStrategy, setColorHueSaturation) *handler, GETJson("/api/" + getBridgeUsername() + "/lights/1", nlohmann::json::object(), getBridgeIp(), 80)) .Times(AtLeast(1)) .WillRepeatedly(Return(nlohmann::json::object())); - MockHueLight test_light(handler); + MockLight test_light(handler); const std::string statePath = "/api/" + getBridgeUsername() + "/lights/1/state"; @@ -150,7 +150,7 @@ TEST(SimpleColorHueStrategy, setColorXY) *handler, GETJson("/api/" + getBridgeUsername() + "/lights/1", nlohmann::json::object(), getBridgeIp(), 80)) .Times(AtLeast(1)) .WillRepeatedly(Return(nlohmann::json::object())); - MockHueLight test_light(handler); + MockLight test_light(handler); const std::string statePath = "/api/" + getBridgeUsername() + "/lights/1/state"; @@ -179,7 +179,7 @@ TEST(SimpleColorHueStrategy, setColorLoop) *handler, GETJson("/api/" + getBridgeUsername() + "/lights/1", nlohmann::json::object(), getBridgeIp(), 80)) .Times(AtLeast(1)) .WillRepeatedly(Return(nlohmann::json::object())); - MockHueLight test_light(handler); + MockLight test_light(handler); const std::string statePath = "/api/" + getBridgeUsername() + "/lights/1/state"; @@ -210,7 +210,7 @@ TEST(SimpleColorHueStrategy, alertHueSaturation) *handler, GETJson("/api/" + getBridgeUsername() + "/lights/1", nlohmann::json::object(), getBridgeIp(), 80)) .Times(AtLeast(1)) .WillRepeatedly(Return(nlohmann::json::object())); - MockHueLight light(handler); + MockLight light(handler); // Invalid colormode { @@ -335,7 +335,7 @@ TEST(SimpleColorHueStrategy, alertXY) *handler, GETJson("/api/" + getBridgeUsername() + "/lights/1", nlohmann::json::object(), getBridgeIp(), 80)) .Times(AtLeast(1)) .WillRepeatedly(Return(nlohmann::json::object())); - MockHueLight light(handler); + MockLight light(handler); // Invalid colormode { @@ -455,7 +455,7 @@ TEST(SimpleColorHueStrategy, getColorHueSaturation) *handler, GETJson("/api/" + getBridgeUsername() + "/lights/1", nlohmann::json::object(), getBridgeIp(), 80)) .Times(AtLeast(1)) .WillRepeatedly(Return(nlohmann::json::object())); - MockHueLight test_light(handler); + MockLight test_light(handler); test_light.getState()["state"]["hue"] = 5000; test_light.getState()["state"]["sat"] = 128; @@ -463,7 +463,7 @@ TEST(SimpleColorHueStrategy, getColorHueSaturation) test_light.getState()["state"]["hue"] = 50000; test_light.getState()["state"]["sat"] = 158; EXPECT_EQ((HueSaturation {50000, 158}), - SimpleColorHueStrategy().getColorHueSaturation(static_cast(test_light))); + SimpleColorHueStrategy().getColorHueSaturation(static_cast(test_light))); } TEST(SimpleColorHueStrategy, getColorXY) @@ -474,7 +474,7 @@ TEST(SimpleColorHueStrategy, getColorXY) *handler, GETJson("/api/" + getBridgeUsername() + "/lights/1", nlohmann::json::object(), getBridgeIp(), 80)) .Times(AtLeast(1)) .WillRepeatedly(Return(nlohmann::json::object())); - MockHueLight test_light(handler); + MockLight test_light(handler); test_light.getState()["state"]["xy"][0] = 0.1234; test_light.getState()["state"]["xy"][1] = 0.1234; diff --git a/test/test_SimpleColorTemperatureStrategy.cpp b/test/test_SimpleColorTemperatureStrategy.cpp index bf909c4..770dd28 100644 --- a/test/test_SimpleColorTemperatureStrategy.cpp +++ b/test/test_SimpleColorTemperatureStrategy.cpp @@ -33,7 +33,7 @@ #include "hueplusplus/SimpleColorTemperatureStrategy.h" #include "json/json.hpp" #include "mocks/mock_HttpHandler.h" -#include "mocks/mock_HueLight.h" +#include "mocks/mock_Light.h" using namespace hueplusplus; @@ -45,7 +45,7 @@ TEST(SimpleColorTemperatureStrategy, setColorTemperature) *handler, GETJson("/api/" + getBridgeUsername() + "/lights/1", nlohmann::json::object(), getBridgeIp(), 80)) .Times(AtLeast(1)) .WillRepeatedly(Return(nlohmann::json::object())); - MockHueLight test_light(handler); + MockLight test_light(handler); const std::string statePath = "/api/" + getBridgeUsername() + "/lights/1/state"; @@ -87,7 +87,7 @@ TEST(SimpleColorTemperatureStrategy, alertTemperature) *handler, GETJson("/api/" + getBridgeUsername() + "/lights/1", nlohmann::json::object(), getBridgeIp(), 80)) .Times(AtLeast(1)) .WillRepeatedly(Return(nlohmann::json::object())); - MockHueLight light(handler); + MockLight light(handler); const auto setCTLambda = [&](unsigned int ct, int transition) { light.getState()["state"]["colormode"] = "ct"; @@ -146,10 +146,10 @@ TEST(SimpleColorTemperatureStrategy, getColorTemperature) *handler, GETJson("/api/" + getBridgeUsername() + "/lights/1", nlohmann::json::object(), getBridgeIp(), 80)) .Times(AtLeast(1)) .WillRepeatedly(Return(nlohmann::json::object())); - MockHueLight test_light(handler); + MockLight test_light(handler); test_light.getState()["state"]["ct"] = 200; EXPECT_EQ(200, SimpleColorTemperatureStrategy().getColorTemperature(test_light)); test_light.getState()["state"]["ct"] = 500; - EXPECT_EQ(500, SimpleColorTemperatureStrategy().getColorTemperature(static_cast(test_light))); + EXPECT_EQ(500, SimpleColorTemperatureStrategy().getColorTemperature(static_cast(test_light))); } diff --git a/test/test_UPnP.cpp b/test/test_UPnP.cpp index 5faba5a..f17be6c 100644 --- a/test/test_UPnP.cpp +++ b/test/test_UPnP.cpp @@ -26,7 +26,7 @@ #include "iostream" #include "testhelper.h" -#include "hueplusplus/APIConfig.h" +#include "hueplusplus/LibConfig.h" #include "hueplusplus/UPnP.h" #include "json/json.hpp" #include "mocks/mock_HttpHandler.h"