Commit 4056d09080a7f2ece9d5544da2cb085d85f700a9

Authored by Moritz Wirger
1 parent 23937b4c

Add mock class for HueLight

- make functions of HueLight virtual so they can be mocked
hueplusplus/include/HueLight.h
@@ -105,94 +105,94 @@ public: @@ -105,94 +105,94 @@ public:
105 //! 105 //!
106 //! \param transition Optional parameter to set the transition from current state to new, standard is 4 = 400ms 106 //! \param transition Optional parameter to set the transition from current state to new, standard is 4 = 400ms
107 //! \return Bool that is true on success 107 //! \return Bool that is true on success
108 - bool On(uint8_t transition = 4); 108 + virtual bool On(uint8_t transition = 4);
109 109
110 //! \brief Function that turns the light off. 110 //! \brief Function that turns the light off.
111 //! 111 //!
112 //! \param transition Optional parameter to set the transition from current state to new, standard is 4 = 400ms 112 //! \param transition Optional parameter to set the transition from current state to new, standard is 4 = 400ms
113 //! \return Bool that is true on success 113 //! \return Bool that is true on success
114 - bool Off(uint8_t transition = 4); 114 + virtual bool Off(uint8_t transition = 4);
115 115
116 //! \brief Function to check whether a light is on or off 116 //! \brief Function to check whether a light is on or off
117 //! 117 //!
118 //! \return Bool that is true, when the light is on and false, when off 118 //! \return Bool that is true, when the light is on and false, when off
119 - bool isOn(); 119 + virtual bool isOn();
120 120
121 //! \brief Const function to check whether a light is on or off 121 //! \brief Const function to check whether a light is on or off
122 //! 122 //!
123 //! \note This will not refresh the light state 123 //! \note This will not refresh the light state
124 //! \return Bool that is true, when the light is on and false, when off 124 //! \return Bool that is true, when the light is on and false, when off
125 - bool isOn() const; 125 + virtual bool isOn() const;
126 126
127 //! \brief Const function that returns the id of this light 127 //! \brief Const function that returns the id of this light
128 //! 128 //!
129 //! \return integer representing the light id 129 //! \return integer representing the light id
130 - int getId() const; 130 + virtual int getId() const;
131 131
132 //! \brief Const function that returns the light type 132 //! \brief Const function that returns the light type
133 //! 133 //!
134 //! \return String containing the type 134 //! \return String containing the type
135 - std::string getType() const; 135 + virtual std::string getType() const;
136 136
137 //! \brief Function that returns the name of the light. 137 //! \brief Function that returns the name of the light.
138 //! 138 //!
139 //! \return String containig the name of the light 139 //! \return String containig the name of the light
140 - std::string getName(); 140 + virtual std::string getName();
141 141
142 //! \brief Const function that returns the name of the light. 142 //! \brief Const function that returns the name of the light.
143 //! 143 //!
144 //! \note This will not refresh the light state 144 //! \note This will not refresh the light state
145 //! \return String containig the name of the light 145 //! \return String containig the name of the light
146 - std::string getName() const; 146 + virtual std::string getName() const;
147 147
148 //! \brief Const function that returns the modelid of the light 148 //! \brief Const function that returns the modelid of the light
149 //! 149 //!
150 //! \return String conatining the modelid 150 //! \return String conatining the modelid
151 - std::string getModelId() const; 151 + virtual std::string getModelId() const;
152 152
153 //! \brief Const function that returns the uniqueid of the light 153 //! \brief Const function that returns the uniqueid of the light
154 //! 154 //!
155 //! \note Only working on bridges with versions starting at 1.4 155 //! \note Only working on bridges with versions starting at 1.4
156 //! \return String containing the uniqueid or an empty string when the function is not supported 156 //! \return String containing the uniqueid or an empty string when the function is not supported
157 - std::string getUId() const; 157 + virtual std::string getUId() const;
158 158
159 //! \brief Const function that returns the manufacturername of the light 159 //! \brief Const function that returns the manufacturername of the light
160 //! 160 //!
161 //! \note Only working on bridges with versions starting at 1.7 161 //! \note Only working on bridges with versions starting at 1.7
162 //! \return String containing the manufacturername or an empty string when the function is not supported 162 //! \return String containing the manufacturername or an empty string when the function is not supported
163 - std::string getManufacturername() const; 163 + virtual std::string getManufacturername() const;
164 164
165 //! \brief Const function that returns the luminaireuniqueid of the light 165 //! \brief Const function that returns the luminaireuniqueid of the light
166 //! 166 //!
167 //! \note Only working on bridges with versions starting at 1.9 167 //! \note Only working on bridges with versions starting at 1.9
168 //! \return String containing the luminaireuniqueid or an empty string when the function is not supported 168 //! \return String containing the luminaireuniqueid or an empty string when the function is not supported
169 - std::string getLuminaireUId() const; 169 + virtual std::string getLuminaireUId() const;
170 170
171 //! \brief Function that returns the software version of the light 171 //! \brief Function that returns the software version of the light
172 //! 172 //!
173 //! \return String containing the software version 173 //! \return String containing the software version
174 - std::string getSwVersion(); 174 + virtual std::string getSwVersion();
175 175
176 //! \brief Const function that returns the software version of the light 176 //! \brief Const function that returns the software version of the light
177 //! 177 //!
178 //! \note This will not refresh the light state 178 //! \note This will not refresh the light state
179 //! \return String containing the software version 179 //! \return String containing the software version
180 - std::string getSwVersion() const; 180 + virtual std::string getSwVersion() const;
181 181
182 //! \brief Function that sets the name of the light 182 //! \brief Function that sets the name of the light
183 //! 183 //!
184 //! \return Bool that is true on success 184 //! \return Bool that is true on success
185 - bool setName(const std::string& name); 185 + virtual bool setName(const std::string& name);
186 186
187 //! \brief Const function that returns the color type of the light. 187 //! \brief Const function that returns the color type of the light.
188 //! 188 //!
189 //! \return ColorType containig the color type of the light 189 //! \return ColorType containig the color type of the light
190 - ColorType getColorType() const; 190 + virtual ColorType getColorType() const;
191 191
192 //! \brief Const function to check whether this light has brightness control 192 //! \brief Const function to check whether this light has brightness control
193 //! 193 //!
194 //! \return Bool that is true when the light has specified abilities and false when not 194 //! \return Bool that is true when the light has specified abilities and false when not
195 - bool hasBrightnessControl() const 195 + virtual bool hasBrightnessControl() const
196 { 196 {
197 return brightnessStrategy != nullptr; 197 return brightnessStrategy != nullptr;
198 }; 198 };
@@ -200,7 +200,7 @@ public: @@ -200,7 +200,7 @@ public:
200 //! \brief Const function to check whether this light has color temperature control 200 //! \brief Const function to check whether this light has color temperature control
201 //! 201 //!
202 //! \return Bool that is true when the light has specified abilities and false when not 202 //! \return Bool that is true when the light has specified abilities and false when not
203 - bool hasTemperatureControl() const 203 + virtual bool hasTemperatureControl() const
204 { 204 {
205 return colorTemperatureStrategy != nullptr; 205 return colorTemperatureStrategy != nullptr;
206 }; 206 };
@@ -208,7 +208,7 @@ public: @@ -208,7 +208,7 @@ public:
208 //! \brief Connst function to check whether this light has full color control 208 //! \brief Connst function to check whether this light has full color control
209 //! 209 //!
210 //! \return Bool that is true when the light has specified abilities and false when not 210 //! \return Bool that is true when the light has specified abilities and false when not
211 - bool hasColorControl() const 211 + virtual bool hasColorControl() const
212 { 212 {
213 return colorHueStrategy != nullptr; 213 return colorHueStrategy != nullptr;
214 }; 214 };
@@ -232,7 +232,7 @@ public: @@ -232,7 +232,7 @@ public:
232 //! \param bri Unsigned int that specifies the brightness 232 //! \param bri Unsigned int that specifies the brightness
233 //! \param transition Optional parameter to set the transition from current state to new, standard is 4 = 400ms 233 //! \param transition Optional parameter to set the transition from current state to new, standard is 4 = 400ms
234 //! \return Bool that is true on success 234 //! \return Bool that is true on success
235 - bool setBrightness(unsigned int bri, uint8_t transition = 4) 235 + virtual bool setBrightness(unsigned int bri, uint8_t transition = 4)
236 { 236 {
237 if (brightnessStrategy) 237 if (brightnessStrategy)
238 { 238 {
@@ -247,7 +247,7 @@ public: @@ -247,7 +247,7 @@ public:
247 //! \note This will not refresh the light state 247 //! \note This will not refresh the light state
248 //! The brightness can range from 0 = off to 254 = fully lit. 248 //! The brightness can range from 0 = off to 254 = fully lit.
249 //! \return Unsigned int that is 0 when function failed 249 //! \return Unsigned int that is 0 when function failed
250 - unsigned int getBrightness() const 250 + virtual unsigned int getBrightness() const
251 { 251 {
252 if (brightnessStrategy) 252 if (brightnessStrategy)
253 { 253 {
@@ -261,7 +261,7 @@ public: @@ -261,7 +261,7 @@ public:
261 //! \note The brightness will only be returned if the light has a reference to a specific \ref BrightnessStrategy. 261 //! \note The brightness will only be returned if the light has a reference to a specific \ref BrightnessStrategy.
262 //! The brightness can range from 0 = off to 254 = fully lit. 262 //! The brightness can range from 0 = off to 254 = fully lit.
263 //! \return Unsigned int that is 0 when function failed 263 //! \return Unsigned int that is 0 when function failed
264 - unsigned int getBrightness() 264 + virtual unsigned int getBrightness()
265 { 265 {
266 if (brightnessStrategy) 266 if (brightnessStrategy)
267 { 267 {
@@ -277,7 +277,7 @@ public: @@ -277,7 +277,7 @@ public:
277 //! \param mired Unsigned int that specifies the color temperature in Mired 277 //! \param mired Unsigned int that specifies the color temperature in Mired
278 //! \param transition Optional parameter to set the transition from current state to new, standard is 4 = 400ms 278 //! \param transition Optional parameter to set the transition from current state to new, standard is 4 = 400ms
279 //! \return Bool that is true on success 279 //! \return Bool that is true on success
280 - bool setColorTemperature(unsigned int mired, uint8_t transition = 4) 280 + virtual bool setColorTemperature(unsigned int mired, uint8_t transition = 4)
281 { 281 {
282 if (colorTemperatureStrategy) 282 if (colorTemperatureStrategy)
283 { 283 {
@@ -293,7 +293,7 @@ public: @@ -293,7 +293,7 @@ public:
293 //! The color temperature in mired ranges from 153 to 500 whereas 153 is cold and 500 is warm. 293 //! The color temperature in mired ranges from 153 to 500 whereas 153 is cold and 500 is warm.
294 //! \param light A reference of the light 294 //! \param light A reference of the light
295 //! \return Unsigned int representing the color temperature in mired or 0 when failed 295 //! \return Unsigned int representing the color temperature in mired or 0 when failed
296 - unsigned int getColorTemperature() const 296 + virtual unsigned int getColorTemperature() const
297 { 297 {
298 if (colorTemperatureStrategy) 298 if (colorTemperatureStrategy)
299 { 299 {
@@ -309,7 +309,7 @@ public: @@ -309,7 +309,7 @@ public:
309 //! The color temperature in mired ranges from 153 to 500 whereas 153 is cold and 500 is warm. 309 //! The color temperature in mired ranges from 153 to 500 whereas 153 is cold and 500 is warm.
310 //! \param light A reference of the light 310 //! \param light A reference of the light
311 //! \return Unsigned int representing the color temperature in mired or 0 when failed 311 //! \return Unsigned int representing the color temperature in mired or 0 when failed
312 - unsigned int getColorTemperature() 312 + virtual unsigned int getColorTemperature()
313 { 313 {
314 if (colorTemperatureStrategy) 314 if (colorTemperatureStrategy)
315 { 315 {
@@ -325,7 +325,7 @@ public: @@ -325,7 +325,7 @@ public:
325 //! \param hue uint16_t that specifies the hue 325 //! \param hue uint16_t that specifies the hue
326 //! \param transition Optional parameter to set the transition from current state to new, standard is 4 = 400ms 326 //! \param transition Optional parameter to set the transition from current state to new, standard is 4 = 400ms
327 //! \return Bool that is true on success 327 //! \return Bool that is true on success
328 - bool setColorHue(uint16_t hue, uint8_t transition = 4) 328 + virtual bool setColorHue(uint16_t hue, uint8_t transition = 4)
329 { 329 {
330 if(colorHueStrategy) 330 if(colorHueStrategy)
331 { 331 {
@@ -341,7 +341,7 @@ public: @@ -341,7 +341,7 @@ public:
341 //! \param sat uint8_t that specifies the saturation 341 //! \param sat uint8_t that specifies the saturation
342 //! \param transition Optional parameter to set the transition from current state to new, standard is 4 = 400ms 342 //! \param transition Optional parameter to set the transition from current state to new, standard is 4 = 400ms
343 //! \return Bool that is true on success 343 //! \return Bool that is true on success
344 - bool setColorSaturation(uint8_t sat, uint8_t transition = 4) 344 + virtual bool setColorSaturation(uint8_t sat, uint8_t transition = 4)
345 { 345 {
346 if(colorHueStrategy) 346 if(colorHueStrategy)
347 { 347 {
@@ -357,7 +357,7 @@ public: @@ -357,7 +357,7 @@ public:
357 //! \param sat uint8_t that specifies the saturation 357 //! \param sat uint8_t that specifies the saturation
358 //! \param transition Optional parameter to set the transition from current state to new, standard is 4 = 400ms. 358 //! \param transition Optional parameter to set the transition from current state to new, standard is 4 = 400ms.
359 //! \return Bool that is true on success 359 //! \return Bool that is true on success
360 - bool setColorHueSaturation(uint16_t hue, uint8_t sat, uint8_t transition = 4) 360 + virtual bool setColorHueSaturation(uint16_t hue, uint8_t sat, uint8_t transition = 4)
361 { 361 {
362 if(colorHueStrategy) 362 if(colorHueStrategy)
363 { 363 {
@@ -372,7 +372,7 @@ public: @@ -372,7 +372,7 @@ public:
372 //! \note This will not refresh the light state 372 //! \note This will not refresh the light state
373 //! \param light A reference of the light 373 //! \param light A reference of the light
374 //! \return Pair containing the hue as first value and saturation as second value or an empty one when failed 374 //! \return Pair containing the hue as first value and saturation as second value or an empty one when failed
375 - std::pair<uint16_t, uint8_t> getColorHueSaturation() const 375 + virtual std::pair<uint16_t, uint8_t> getColorHueSaturation() const
376 { 376 {
377 if(colorHueStrategy) 377 if(colorHueStrategy)
378 { 378 {
@@ -387,7 +387,7 @@ public: @@ -387,7 +387,7 @@ public:
387 //! Updates the lights state by calling refreshState() 387 //! Updates the lights state by calling refreshState()
388 //! \param light A const reference of the light 388 //! \param light A const reference of the light
389 //! \return Pair containing the hue as first value and saturation as second value or an empty one when failed 389 //! \return Pair containing the hue as first value and saturation as second value or an empty one when failed
390 - std::pair<uint16_t, uint8_t> getColorHueSaturation() 390 + virtual std::pair<uint16_t, uint8_t> getColorHueSaturation()
391 { 391 {
392 if(colorHueStrategy) 392 if(colorHueStrategy)
393 { 393 {
@@ -404,7 +404,7 @@ public: @@ -404,7 +404,7 @@ public:
404 //! \param y float that specifies the y coordinate in CIE 404 //! \param y float that specifies the y coordinate in CIE
405 //! \param transition Optional parameter to set the transition from current state to new, standard is 4 = 400ms 405 //! \param transition Optional parameter to set the transition from current state to new, standard is 4 = 400ms
406 //! \return Bool that is true on success 406 //! \return Bool that is true on success
407 - bool setColorXY(float x, float y, uint8_t transition = 4) 407 + virtual bool setColorXY(float x, float y, uint8_t transition = 4)
408 { 408 {
409 if(colorHueStrategy) 409 if(colorHueStrategy)
410 { 410 {
@@ -419,7 +419,7 @@ public: @@ -419,7 +419,7 @@ public:
419 //! \note This does not update the lights state 419 //! \note This does not update the lights state
420 //! \param light A const reference of the light 420 //! \param light A const reference of the light
421 //! \return Pair containing the x as first value and y as second value or an empty one when failed 421 //! \return Pair containing the x as first value and y as second value or an empty one when failed
422 - std::pair<float, float> getColorXY() const 422 + virtual std::pair<float, float> getColorXY() const
423 { 423 {
424 if(colorHueStrategy) 424 if(colorHueStrategy)
425 { 425 {
@@ -434,7 +434,7 @@ public: @@ -434,7 +434,7 @@ public:
434 //! Updates the lights state by calling refreshState() 434 //! Updates the lights state by calling refreshState()
435 //! \param light A reference of the light 435 //! \param light A reference of the light
436 //! \return Pair containing the x as first value and y as second value or an empty one when failed 436 //! \return Pair containing the x as first value and y as second value or an empty one when failed
437 - std::pair<float, float> getColorXY() 437 + virtual std::pair<float, float> getColorXY()
438 { 438 {
439 if(colorHueStrategy) 439 if(colorHueStrategy)
440 { 440 {
@@ -452,7 +452,7 @@ public: @@ -452,7 +452,7 @@ public:
452 //! \param b uint8_t that specifies the blue color value 452 //! \param b uint8_t that specifies the blue color value
453 //! \param transition Optional parameter to set the transition from current state to new, standard is 4 = 400ms 453 //! \param transition Optional parameter to set the transition from current state to new, standard is 4 = 400ms
454 //! \return Bool that is true on success 454 //! \return Bool that is true on success
455 - bool setColorRGB(uint8_t r, uint8_t g, uint8_t b, uint8_t transition = 4) 455 + virtual bool setColorRGB(uint8_t r, uint8_t g, uint8_t b, uint8_t transition = 4)
456 { 456 {
457 if(colorHueStrategy) 457 if(colorHueStrategy)
458 { 458 {
@@ -472,7 +472,7 @@ public: @@ -472,7 +472,7 @@ public:
472 //! \note The breath cylce will only be performed if the light has a reference to a specific \ref ColorTemperatureStrategy. 472 //! \note The breath cylce will only be performed if the light has a reference to a specific \ref ColorTemperatureStrategy.
473 //! \param mired Color temperature in mired 473 //! \param mired Color temperature in mired
474 //! \return Bool that is true on success 474 //! \return Bool that is true on success
475 - bool alertTemperature(unsigned int mired) 475 + virtual bool alertTemperature(unsigned int mired)
476 { 476 {
477 if(colorTemperatureStrategy) 477 if(colorTemperatureStrategy)
478 { 478 {
@@ -487,7 +487,7 @@ public: @@ -487,7 +487,7 @@ public:
487 //! \param hue uint16_t that specifies the hue 487 //! \param hue uint16_t that specifies the hue
488 //! \param sat uint8_t that specifies the saturation 488 //! \param sat uint8_t that specifies the saturation
489 //! \return Bool that is true on success 489 //! \return Bool that is true on success
490 - bool alertHueSaturation(uint16_t hue, uint8_t sat) 490 + virtual bool alertHueSaturation(uint16_t hue, uint8_t sat)
491 { 491 {
492 if(colorHueStrategy) 492 if(colorHueStrategy)
493 { 493 {
@@ -503,7 +503,7 @@ public: @@ -503,7 +503,7 @@ public:
503 //! \param x float that specifies the x coordinate in CIE 503 //! \param x float that specifies the x coordinate in CIE
504 //! \param y float that specifies the y coordinate in CIE 504 //! \param y float that specifies the y coordinate in CIE
505 //! \return Bool that is true on success 505 //! \return Bool that is true on success
506 - bool alertXY(float x, float y) 506 + virtual bool alertXY(float x, float y)
507 { 507 {
508 if(colorHueStrategy) 508 if(colorHueStrategy)
509 { 509 {
@@ -520,7 +520,7 @@ public: @@ -520,7 +520,7 @@ public:
520 //! \param g uint8_t that specifies the green color value 520 //! \param g uint8_t that specifies the green color value
521 //! \param b uint8_t that specifies the blue color value 521 //! \param b uint8_t that specifies the blue color value
522 //! \return Bool that is true on success 522 //! \return Bool that is true on success
523 - bool alertRGB(uint8_t r, uint8_t g, uint8_t b) 523 + virtual bool alertRGB(uint8_t r, uint8_t g, uint8_t b)
524 { 524 {
525 if(colorHueStrategy) 525 if(colorHueStrategy)
526 { 526 {
@@ -539,7 +539,7 @@ public: @@ -539,7 +539,7 @@ public:
539 //! then use any of the setter functions. 539 //! then use any of the setter functions.
540 //! \param on bool that enables this feature when true and disables it when false 540 //! \param on bool that enables this feature when true and disables it when false
541 //! \return Bool that is true on success 541 //! \return Bool that is true on success
542 - bool setColorLoop(bool on) 542 + virtual bool setColorLoop(bool on)
543 { 543 {
544 if(colorHueStrategy) 544 if(colorHueStrategy)
545 { 545 {
@@ -574,37 +574,37 @@ protected: @@ -574,37 +574,37 @@ protected:
574 //! 574 //!
575 //! The strategy defines how specific commands that deal with brightness control are executed 575 //! The strategy defines how specific commands that deal with brightness control are executed
576 //! \param strat a strategy of type \ref BrightnessStrategy 576 //! \param strat a strategy of type \ref BrightnessStrategy
577 - void setBrightnessStrategy(std::shared_ptr<const BrightnessStrategy> strat) { brightnessStrategy = std::move(strat); }; 577 + virtual void setBrightnessStrategy(std::shared_ptr<const BrightnessStrategy> strat) { brightnessStrategy = std::move(strat); };
578 578
579 //! \brief Protected function that sets the colorTemperature strategy. 579 //! \brief Protected function that sets the colorTemperature strategy.
580 //! 580 //!
581 //! The strategy defines how specific commands that deal with colortemperature control are executed 581 //! The strategy defines how specific commands that deal with colortemperature control are executed
582 //! \param strat a strategy of type \ref ColorTemperatureStrategy 582 //! \param strat a strategy of type \ref ColorTemperatureStrategy
583 - void setColorTemperatureStrategy(std::shared_ptr<const ColorTemperatureStrategy> strat) { colorTemperatureStrategy = std::move(strat); }; 583 + virtual void setColorTemperatureStrategy(std::shared_ptr<const ColorTemperatureStrategy> strat) { colorTemperatureStrategy = std::move(strat); };
584 584
585 //! \brief Protected function that sets the colorHue strategy. 585 //! \brief Protected function that sets the colorHue strategy.
586 //! 586 //!
587 //! The strategy defines how specific commands that deal with color control are executed 587 //! The strategy defines how specific commands that deal with color control are executed
588 //! \param strat a strategy of type \ref ColorHueStrategy 588 //! \param strat a strategy of type \ref ColorHueStrategy
589 - void setColorHueStrategy(std::shared_ptr<const ColorHueStrategy> strat) { colorHueStrategy = std::move(strat); }; 589 + virtual void setColorHueStrategy(std::shared_ptr<const ColorHueStrategy> strat) { colorHueStrategy = std::move(strat); };
590 590
591 //! \brief Protected function that sets the HttpHandler. 591 //! \brief Protected function that sets the HttpHandler.
592 //! 592 //!
593 //! The HttpHandler defines how specific commands that deal with bridge communication are executed 593 //! The HttpHandler defines how specific commands that deal with bridge communication are executed
594 //! \param handler a HttpHandler of type \ref IHttpHandler 594 //! \param handler a HttpHandler of type \ref IHttpHandler
595 - void setHttpHandler(std::shared_ptr<const IHttpHandler> handler) { http_handler = std::move(handler); }; 595 + virtual void setHttpHandler(std::shared_ptr<const IHttpHandler> handler) { http_handler = std::move(handler); };
596 596
597 //! \brief Function that turns the light on without refreshing its state. 597 //! \brief Function that turns the light on without refreshing its state.
598 //! 598 //!
599 //! \param transition Optional parameter to set the transition from current state to new standard is 4 = 400ms 599 //! \param transition Optional parameter to set the transition from current state to new standard is 4 = 400ms
600 //! \return Bool that is true on success 600 //! \return Bool that is true on success
601 - bool OnNoRefresh(uint8_t transition = 4); 601 + virtual bool OnNoRefresh(uint8_t transition = 4);
602 602
603 //! \brief Function that turns the light off without refreshing its state. 603 //! \brief Function that turns the light off without refreshing its state.
604 //! 604 //!
605 //! \param transition Optional parameter to set the transition from current state to new standard is 4 = 400ms 605 //! \param transition Optional parameter to set the transition from current state to new standard is 4 = 400ms
606 //! \return Bool that is true on success 606 //! \return Bool that is true on success
607 - bool OffNoRefresh(uint8_t transition = 4); 607 + virtual bool OffNoRefresh(uint8_t transition = 4);
608 608
609 //! \brief Utility function to send a put request to the light. 609 //! \brief Utility function to send a put request to the light.
610 //! 610 //!
@@ -612,7 +612,7 @@ protected: @@ -612,7 +612,7 @@ protected:
612 //! \param request A Json::Value aka the request to send 612 //! \param request A Json::Value aka the request to send
613 //! \param subPath A path that is appended to the uri, note it should always start with a slash ("/") 613 //! \param subPath A path that is appended to the uri, note it should always start with a slash ("/")
614 //! \return The parsed reply 614 //! \return The parsed reply
615 - Json::Value SendPutRequest(const Json::Value& request, const std::string& subPath); 615 + virtual Json::Value SendPutRequest(const Json::Value& request, const std::string& subPath);
616 616
617 //! \brief Virtual function that refreshes the \ref state of the light. 617 //! \brief Virtual function that refreshes the \ref state of the light.
618 virtual void refreshState(); 618 virtual void refreshState();
hueplusplus/test/mocks/mock_HueLight.h 0 โ†’ 100755
  1 +/**
  2 + \file mock_HueLight.h
  3 + Copyright Notice\n
  4 + Copyright (C) 2017 Jan Rogall - developer\n
  5 + Copyright (C) 2017 Moritz Wirger - developer\n
  6 +
  7 + This program is free software; you can redistribute it and/or modify
  8 + it under the terms of the GNU General Public License as published by
  9 + the Free Software Foundation; either version 3 of the License, or
  10 + (at your option) any later version.
  11 + This program is distributed in the hope that it will be useful,
  12 + but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14 + GNU General Public License for more details.
  15 + You should have received a copy of the GNU General Public License
  16 + along with this program; if not, write to the Free Software Foundation,
  17 + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  18 +**/
  19 +
  20 +#ifndef _MOCK_HUE_LIGHT_H
  21 +#define _MOCK_HUE_LIGHT_H
  22 +
  23 +#include <string>
  24 +#include <vector>
  25 +
  26 +#include <gmock/gmock.h>
  27 +
  28 +#include "../hueplusplus/include/HueLight.h"
  29 +#include "../hueplusplus/include/json/json.h"
  30 +#include "../testhelper.h"
  31 +
  32 +//! Mock Class
  33 +class MockHueLight : public HueLight
  34 +{
  35 +public:
  36 + MockHueLight(std::shared_ptr<const IHttpHandler> handler) : HueLight(bridge_ip, bridge_username, 1, handler){};
  37 +
  38 + Json::Value& getState() {return state;};
  39 +
  40 + MOCK_METHOD1( On, bool(uint8_t transition) );
  41 +
  42 + MOCK_METHOD1( Off, bool(uint8_t transition) );
  43 +
  44 + MOCK_METHOD0( isOn, bool() );
  45 +
  46 + MOCK_CONST_METHOD0( isOn, bool() );
  47 +
  48 + MOCK_CONST_METHOD0( getId, int() );
  49 +
  50 + MOCK_CONST_METHOD0( getType, std::string() );
  51 +
  52 + MOCK_METHOD0( getName, std::string() );
  53 +
  54 + MOCK_CONST_METHOD0( getName, std::string() );
  55 +
  56 + MOCK_CONST_METHOD0( getModelId, std::string() );
  57 +
  58 + MOCK_CONST_METHOD0( getUId, std::string() );
  59 +
  60 + MOCK_CONST_METHOD0( getManufacturername, std::string() );
  61 +
  62 + MOCK_CONST_METHOD0( getLuminaireUId, std::string() );
  63 +
  64 + MOCK_METHOD0( getSwVersion, std::string() );
  65 +
  66 + MOCK_CONST_METHOD0( getSwVersion, std::string() );
  67 +
  68 + MOCK_METHOD1( setName, bool(std::string& name));
  69 +
  70 + MOCK_CONST_METHOD0( getColorType, ColorType() );
  71 +
  72 + MOCK_CONST_METHOD0( hasBrightnessControl, bool() );
  73 +
  74 + MOCK_CONST_METHOD0( hasTemperatureControl, bool() );
  75 +
  76 + MOCK_CONST_METHOD0( hasColorControl, bool() );
  77 +
  78 + MOCK_METHOD2( setBrightness, bool(unsigned int bri, uint8_t transition) );
  79 +
  80 + MOCK_CONST_METHOD0( getBrightness, unsigned int() );
  81 +
  82 + MOCK_METHOD0( getBrightness, unsigned int() );
  83 +
  84 + MOCK_METHOD2( setColorTemperature, bool(unsigned int mired, uint8_t transition) );
  85 +
  86 + MOCK_CONST_METHOD0( getColorTemperature, unsigned int() );
  87 +
  88 + MOCK_METHOD0( getColorTemperature, unsigned int() );
  89 +
  90 + MOCK_METHOD2( setColorHue, bool(uint16_t hue, uint8_t transition) );
  91 +
  92 + MOCK_METHOD2( setColorSaturation, bool(uint8_t sat, uint8_t transition) );
  93 +
  94 + MOCK_METHOD3( setColorHueSaturation, bool(uint16_t hue, uint8_t sat, uint8_t transition) );
  95 +
  96 + MOCK_CONST_METHOD0( getColorHueSaturation, std::pair<uint16_t, uint8_t>() );
  97 +
  98 + MOCK_METHOD0( getColorHueSaturation, std::pair<uint16_t, uint8_t>() );
  99 +
  100 + MOCK_METHOD3( setColorXY, bool(float x, float y, uint8_t transition) );
  101 +
  102 + MOCK_CONST_METHOD0( getColorXY, std::pair<float, float>() );
  103 +
  104 + MOCK_METHOD0( getColorXY, std::pair<float, float>() );
  105 +
  106 + MOCK_METHOD4( setColorRGB, bool(uint8_t r, uint8_t g, uint8_t b, uint8_t transition) );
  107 +
  108 + MOCK_METHOD0( alert, bool() );
  109 +
  110 + MOCK_METHOD1( alertTemperature, bool(unsigned int mired) );
  111 +
  112 + MOCK_METHOD2( alertHueSaturation, bool(uint16_t hue, uint8_t sat) );
  113 +
  114 + MOCK_METHOD2( alertXY, bool(float x, float y) );
  115 +
  116 + MOCK_METHOD3( alertRGB, bool(uint8_t r, uint8_t g, uint8_t b) );
  117 +
  118 + MOCK_METHOD1( setColorLoop, bool(bool on) );
  119 +
  120 + MOCK_METHOD1( OnNoRefresh, bool(uint8_t transition) );
  121 +
  122 + MOCK_METHOD1( OffNoRefresh, bool(uint8_t transition) );
  123 +
  124 + MOCK_METHOD2( SendPutRequest, Json::Value(const Json::Value& request, const std::string& subPath) );
  125 +
  126 + MOCK_METHOD0( refreshState, void() );
  127 +};
  128 +
  129 +#endif