1 /***************************************************************************
3 * Copyright 2012 BMW Car IT GmbH
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 ****************************************************************************/
20 #include <gtest/gtest.h>
30 #include "ilm_client.h"
31 #include "ilm_control.h"
36 /* Tests with callbacks
37 * For each test first set the global variables to point to where parameters of the callbacks are supposed to be placed.
39 static pthread_mutex_t notificationMutex = PTHREAD_MUTEX_INITIALIZER;
40 static pthread_cond_t waiterVariable = PTHREAD_COND_INITIALIZER;
41 static int timesCalled=0;
43 class NotificationTest: public ::testing::Test {
46 static void SetUpTestCase() {
49 static void TearDownTestCase() {
57 LayerProperties = ilmLayerProperties();
58 mask = ILM_NOTIFICATION_ALL;
60 SurfaceProperties = ilmSurfaceProperties();
63 ilm_layerRemove(layer);
65 ilm_layerCreateWithDimension(&layer, 800, 480);
69 ilm_surfaceRemove(surface);
71 ilm_surfaceCreate(0,10,10,ILM_PIXELFORMAT_RGBA_8888,&surface);
82 // Pointers where to put received values for current Test
83 static t_ilm_layer callbackLayerId;
84 static t_ilm_layer callbackSurfaceId;
85 static struct ilmLayerProperties LayerProperties;
86 static t_ilm_notification_mask mask;
87 static t_ilm_surface surface;
88 static ilmSurfaceProperties SurfaceProperties;
91 static void assertCallbackcalled(int numberOfExpectedCalls=1){
92 static struct timespec theTime;
93 clock_gettime(CLOCK_REALTIME, &theTime);
95 pthread_mutex_lock( ¬ificationMutex );
98 if (numberOfExpectedCalls!=timesCalled){
99 status = pthread_cond_timedwait( &waiterVariable, ¬ificationMutex, &theTime);
101 } while (status!=ETIMEDOUT && numberOfExpectedCalls!=timesCalled);
102 ASSERT_NE(ETIMEDOUT, status);
103 pthread_mutex_unlock( ¬ificationMutex );
107 static void assertNoCallbackIsCalled(){
108 struct timespec theTime;
109 clock_gettime(CLOCK_REALTIME, &theTime);
111 pthread_mutex_lock( ¬ificationMutex );
112 // assert that we have not been notified
113 ASSERT_EQ(ETIMEDOUT, pthread_cond_timedwait( &waiterVariable, ¬ificationMutex, &theTime));
114 pthread_mutex_unlock( ¬ificationMutex );
118 static void LayerCallbackFunction(t_ilm_layer layer, struct ilmLayerProperties* LayerProperties, t_ilm_notification_mask mask)
120 pthread_mutex_lock( ¬ificationMutex );
122 NotificationTest::callbackLayerId = layer;
123 NotificationTest::LayerProperties = *LayerProperties;
124 NotificationTest::mask = mask;
126 pthread_cond_signal( &waiterVariable );
127 pthread_mutex_unlock( ¬ificationMutex );
130 static void SurfaceCallbackFunction(t_ilm_surface surface, struct ilmSurfaceProperties* surfaceProperties, t_ilm_notification_mask mask)
132 pthread_mutex_lock( ¬ificationMutex );
134 NotificationTest::callbackSurfaceId = surface;
135 NotificationTest::SurfaceProperties = *surfaceProperties;
136 NotificationTest::mask = mask;
138 pthread_cond_signal( &waiterVariable );
139 pthread_mutex_unlock( ¬ificationMutex );
143 // Pointers where to put received values for current Test
144 t_ilm_layer NotificationTest::callbackLayerId;
145 t_ilm_layer NotificationTest::callbackSurfaceId;
146 struct ilmLayerProperties NotificationTest::LayerProperties;
147 t_ilm_notification_mask NotificationTest::mask;
148 t_ilm_surface NotificationTest::surface;
149 ilmSurfaceProperties NotificationTest::SurfaceProperties;
154 TEST_F(NotificationTest, ilm_layerAddNotificationWithoutCallback)
157 t_ilm_uint layer = 89;
159 ASSERT_EQ(ILM_SUCCESS,ilm_layerCreateWithDimension(&layer, 800, 480));
160 ASSERT_EQ(ILM_SUCCESS,ilm_commitChanges());
163 printf("test calling ilm_layerAddNotification\n");
164 //ASSERT_EQ(ILM_SUCCESS,ilm_commitChanges());
165 ASSERT_EQ(ILM_SUCCESS, ilm_layerAddNotification(layer,NULL));
167 ASSERT_EQ(ILM_SUCCESS,ilm_layerRemove(layer));
168 ASSERT_EQ(ILM_SUCCESS,ilm_commitChanges());
172 TEST_F(NotificationTest, ilm_surfaceAddNotificationWithoutCallback)
175 t_ilm_uint surface = 67;
177 ilm_surfaceCreate(0,10,10,ILM_PIXELFORMAT_RGBA_8888,&surface);
181 ilmErrorTypes status = ilm_surfaceAddNotification(surface,NULL);
182 ASSERT_EQ(ILM_SUCCESS, status);
184 ilm_surfaceRemove(surface);
189 TEST_F(NotificationTest, NotifyOnLayerSetPosition)
191 ASSERT_EQ(ILM_SUCCESS,ilm_layerAddNotification(layer,&LayerCallbackFunction));
193 t_ilm_uint* pos = new t_ilm_uint[2];
196 ilm_layerSetPosition(layer,pos);
199 // expect callback to have been called
200 assertCallbackcalled();
202 EXPECT_EQ(layer,callbackLayerId);
203 EXPECT_EQ(7u,LayerProperties.destX);
204 EXPECT_EQ(2u,LayerProperties.destY);
205 EXPECT_EQ(ILM_NOTIFICATION_DEST_RECT,mask);
207 ASSERT_EQ(ILM_SUCCESS,ilm_layerRemoveNotification(layer));
210 TEST_F(NotificationTest, NotifyOnLayerSetDimension)
212 ASSERT_EQ(ILM_SUCCESS,ilm_layerAddNotification(layer,&LayerCallbackFunction));
214 t_ilm_uint* pos = new t_ilm_uint[2];
217 ilm_layerSetDimension(layer,pos);
220 // expect callback to have been called
221 assertCallbackcalled();
223 EXPECT_EQ(layer,callbackLayerId);
224 EXPECT_EQ(70u,LayerProperties.destWidth);
225 EXPECT_EQ(22u,LayerProperties.destHeight);
226 EXPECT_EQ(ILM_NOTIFICATION_DEST_RECT,mask);
228 ASSERT_EQ(ILM_SUCCESS,ilm_layerRemoveNotification(layer));
231 TEST_F(NotificationTest, NotifyOnLayerSetDestinationRectangle)
233 ASSERT_EQ(ILM_SUCCESS,ilm_layerAddNotification(layer,&LayerCallbackFunction));
235 ilm_layerSetDestinationRectangle(layer,33,567,55,99);
238 // expect callback to have been called
239 assertCallbackcalled();
241 EXPECT_EQ(layer,callbackLayerId);
242 EXPECT_EQ(33u,LayerProperties.destX);
243 EXPECT_EQ(567u,LayerProperties.destY);
244 EXPECT_EQ(55u,LayerProperties.destWidth);
245 EXPECT_EQ(99u,LayerProperties.destHeight);
246 EXPECT_EQ(ILM_NOTIFICATION_DEST_RECT,mask);
248 ASSERT_EQ(ILM_SUCCESS,ilm_layerRemoveNotification(layer));
251 TEST_F(NotificationTest, NotifyOnLayerSetOpacity)
253 ASSERT_EQ(ILM_SUCCESS,ilm_layerAddNotification(layer,&LayerCallbackFunction));
255 t_ilm_float opacity = 0.789;
256 ilm_layerSetOpacity(layer,opacity);
259 // expect callback to have been called
260 assertCallbackcalled();
262 EXPECT_EQ(layer,callbackLayerId);
263 EXPECT_FLOAT_EQ(0.789,LayerProperties.opacity);
264 EXPECT_EQ(ILM_NOTIFICATION_OPACITY,mask);
266 ASSERT_EQ(ILM_SUCCESS,ilm_layerRemoveNotification(layer));
269 TEST_F(NotificationTest, NotifyOnLayerSetOrientation)
271 ASSERT_EQ(ILM_SUCCESS,ilm_layerAddNotification(layer,&LayerCallbackFunction));
273 e_ilmOrientation orientation = ILM_ONEHUNDREDEIGHTY;
274 ilm_layerSetOrientation(layer,orientation);
277 // expect callback to have been called
278 assertCallbackcalled();
280 EXPECT_EQ(layer,callbackLayerId);
281 EXPECT_EQ(ILM_ONEHUNDREDEIGHTY,LayerProperties.orientation);
282 EXPECT_EQ(ILM_NOTIFICATION_ORIENTATION,mask);
284 ASSERT_EQ(ILM_SUCCESS,ilm_layerRemoveNotification(layer));
287 TEST_F(NotificationTest, NotifyOnLayerSetSourceRectangle)
289 ASSERT_EQ(ILM_SUCCESS,ilm_layerAddNotification(layer,&LayerCallbackFunction));
291 ilm_layerSetSourceRectangle(layer,33,567,55,99);
294 // expect callback to have been called
295 assertCallbackcalled();
297 EXPECT_EQ(layer,callbackLayerId);
298 EXPECT_EQ(33u,LayerProperties.sourceX);
299 EXPECT_EQ(567u,LayerProperties.sourceY);
300 EXPECT_EQ(55u,LayerProperties.sourceWidth);
301 EXPECT_EQ(99u,LayerProperties.sourceHeight);
302 EXPECT_EQ(ILM_NOTIFICATION_SOURCE_RECT,mask);
304 ASSERT_EQ(ILM_SUCCESS,ilm_layerRemoveNotification(layer));
307 TEST_F(NotificationTest, NotifyOnLayerSetVisibility)
309 ASSERT_EQ(ILM_SUCCESS,ilm_layerAddNotification(layer,&LayerCallbackFunction));
311 t_ilm_bool value = ILM_TRUE;
312 ilm_layerSetVisibility(layer,value);
315 // expect callback to have been called
316 assertCallbackcalled();
318 EXPECT_EQ(layer,callbackLayerId);
319 EXPECT_TRUE(LayerProperties.visibility);
320 EXPECT_EQ(ILM_NOTIFICATION_VISIBILITY,mask);
322 ASSERT_EQ(ILM_SUCCESS,ilm_layerRemoveNotification(layer));
325 TEST_F(NotificationTest, NotifyOnLayerMultipleValues1)
327 ASSERT_EQ(ILM_SUCCESS,ilm_layerAddNotification(layer,&LayerCallbackFunction));
329 ilm_layerSetSourceRectangle(layer,33,567,55,99);
330 ilm_layerSetOrientation(layer,ILM_ONEHUNDREDEIGHTY);
333 // expect callback to have been called
334 assertCallbackcalled();
336 EXPECT_EQ(layer,callbackLayerId);
337 EXPECT_EQ(33u,LayerProperties.sourceX);
338 EXPECT_EQ(567u,LayerProperties.sourceY);
339 EXPECT_EQ(55u,LayerProperties.sourceWidth);
340 EXPECT_EQ(99u,LayerProperties.sourceHeight);
341 EXPECT_EQ(ILM_ONEHUNDREDEIGHTY,LayerProperties.orientation);
342 EXPECT_EQ(ILM_NOTIFICATION_SOURCE_RECT|ILM_NOTIFICATION_ORIENTATION,mask);
344 ASSERT_EQ(ILM_SUCCESS,ilm_layerRemoveNotification(layer));
347 TEST_F(NotificationTest, NotifyOnLayerMultipleValues2)
349 ASSERT_EQ(ILM_SUCCESS,ilm_layerAddNotification(layer,&LayerCallbackFunction));
351 t_ilm_float opacity = 0.789;
352 ilm_layerSetOpacity(layer,opacity);
353 ilm_layerSetVisibility(layer,true);
354 ilm_layerSetDestinationRectangle(layer,33,567,55,99);
357 // expect callback to have been called
358 assertCallbackcalled();
360 EXPECT_EQ(layer,callbackLayerId);
361 EXPECT_TRUE(LayerProperties.visibility);
362 EXPECT_FLOAT_EQ(0.789,LayerProperties.opacity);
363 EXPECT_EQ(33u,LayerProperties.destX);
364 EXPECT_EQ(567u,LayerProperties.destY);
365 EXPECT_EQ(55u,LayerProperties.destWidth);
366 EXPECT_EQ(99u,LayerProperties.destHeight);
367 EXPECT_EQ(ILM_NOTIFICATION_DEST_RECT|ILM_NOTIFICATION_VISIBILITY|ILM_NOTIFICATION_OPACITY,mask);
369 ASSERT_EQ(ILM_SUCCESS,ilm_layerRemoveNotification(layer));
372 TEST_F(NotificationTest, NotifyOnLayerAllValues)
374 ASSERT_EQ(ILM_SUCCESS,ilm_layerAddNotification(layer,&LayerCallbackFunction));
376 t_ilm_float opacity = 0.789;
377 ilm_layerSetOpacity(layer,opacity);
378 ilm_layerSetVisibility(layer,true);
379 ilm_layerSetDestinationRectangle(layer,133,1567,155,199);
380 ilm_layerSetSourceRectangle(layer,33,567,55,99);
381 ilm_layerSetOrientation(layer,ILM_ONEHUNDREDEIGHTY);
384 // expect callback to have been called
385 assertCallbackcalled();
387 EXPECT_EQ(layer,callbackLayerId);
388 EXPECT_EQ(33u,LayerProperties.sourceX);
389 EXPECT_EQ(567u,LayerProperties.sourceY);
390 EXPECT_EQ(55u,LayerProperties.sourceWidth);
391 EXPECT_EQ(99u,LayerProperties.sourceHeight);
392 EXPECT_EQ(ILM_ONEHUNDREDEIGHTY,LayerProperties.orientation);
394 EXPECT_TRUE(LayerProperties.visibility);
395 EXPECT_FLOAT_EQ(opacity,LayerProperties.opacity);
396 EXPECT_EQ(133u,LayerProperties.destX);
397 EXPECT_EQ(1567u,LayerProperties.destY);
398 EXPECT_EQ(155u,LayerProperties.destWidth);
399 EXPECT_EQ(199u,LayerProperties.destHeight);
400 EXPECT_EQ(ILM_NOTIFICATION_DEST_RECT|ILM_NOTIFICATION_VISIBILITY|ILM_NOTIFICATION_OPACITY|ILM_NOTIFICATION_SOURCE_RECT|ILM_NOTIFICATION_ORIENTATION,mask);
402 ASSERT_EQ(ILM_SUCCESS,ilm_layerRemoveNotification(layer));
405 TEST_F(NotificationTest, DoNotSendNotificationsAfterRemoveLayer)
407 ASSERT_EQ(ILM_SUCCESS,ilm_layerAddNotification(layer,&LayerCallbackFunction));
409 ilm_layerSetOrientation(layer,ILM_ONEHUNDREDEIGHTY);
411 assertCallbackcalled();
413 ASSERT_EQ(ILM_SUCCESS,ilm_layerRemoveNotification(layer));
415 // change a lot of things
416 t_ilm_float opacity = 0.789;
417 ilm_layerSetOpacity(layer,opacity);
418 ilm_layerSetVisibility(layer,true);
419 ilm_layerSetDestinationRectangle(layer,133,1567,155,199);
420 ilm_layerSetSourceRectangle(layer,33,567,55,99);
421 ilm_layerSetOrientation(layer,ILM_ONEHUNDREDEIGHTY);
424 // assert that we have not been notified
425 assertNoCallbackIsCalled();
429 TEST_F(NotificationTest, MultipleRegistrationsLayer)
431 ASSERT_EQ(ILM_SUCCESS,ilm_layerAddNotification(layer,&LayerCallbackFunction));
433 ilm_layerSetOrientation(layer,ILM_ONEHUNDREDEIGHTY);
435 assertCallbackcalled();
437 ASSERT_EQ(ILM_SUCCESS,ilm_layerRemoveNotification(layer));
439 // change a lot of things
440 t_ilm_float opacity = 0.789;
441 ilm_layerSetOpacity(layer,opacity);
442 ilm_layerSetVisibility(layer,true);
443 ilm_layerSetDestinationRectangle(layer,133,1567,155,199);
444 ilm_layerSetSourceRectangle(layer,33,567,55,99);
445 ilm_layerSetOrientation(layer,ILM_ONEHUNDREDEIGHTY);
448 // assert that we have not been notified
449 assertNoCallbackIsCalled();
451 // register for notifications again
452 ASSERT_EQ(ILM_SUCCESS,ilm_layerAddNotification(layer,&LayerCallbackFunction));
454 ilm_layerSetOrientation(layer,ILM_ZERO);
456 assertCallbackcalled();
458 ASSERT_EQ(ILM_SUCCESS,ilm_layerRemoveNotification(layer));
461 TEST_F(NotificationTest, DefaultIsNotToReceiveNotificationsLayer)
464 ilm_layerSetOrientation(layer,ILM_ONEHUNDREDEIGHTY);
467 // change a lot of things
468 t_ilm_float opacity = 0.789;
469 ilm_layerSetOpacity(layer,opacity);
470 ilm_layerSetVisibility(layer,true);
471 ilm_layerSetDestinationRectangle(layer,133,1567,155,199);
472 ilm_layerSetSourceRectangle(layer,33,567,55,99);
473 ilm_layerSetOrientation(layer,ILM_ONEHUNDREDEIGHTY);
476 // assert that we have not been notified
477 assertNoCallbackIsCalled();
481 TEST_F(NotificationTest, NotifyOnSurfaceSetPosition)
483 ASSERT_EQ(ILM_SUCCESS,ilm_surfaceAddNotification(surface,&SurfaceCallbackFunction));
485 t_ilm_uint* pos = new t_ilm_uint[2];
488 ilm_surfaceSetPosition(surface,pos);
491 // expect callback to have been called
492 assertCallbackcalled();
494 EXPECT_EQ(surface,callbackSurfaceId);
495 EXPECT_EQ(7u,SurfaceProperties.destX);
496 EXPECT_EQ(2u,SurfaceProperties.destY);
497 EXPECT_EQ(ILM_NOTIFICATION_DEST_RECT,mask);
499 ASSERT_EQ(ILM_SUCCESS,ilm_surfaceRemoveNotification(surface));
502 TEST_F(NotificationTest, NotifyOnSurfaceSetDimension)
504 ASSERT_EQ(ILM_SUCCESS,ilm_surfaceAddNotification(surface,&SurfaceCallbackFunction));
506 t_ilm_uint* pos = new t_ilm_uint[2];
509 ilm_surfaceSetDimension(surface,pos);
512 // expect callback to have been called
513 assertCallbackcalled();
515 EXPECT_EQ(surface,callbackSurfaceId);
516 EXPECT_EQ(70u,SurfaceProperties.destWidth);
517 EXPECT_EQ(22u,SurfaceProperties.destHeight);
518 EXPECT_EQ(ILM_NOTIFICATION_DEST_RECT,mask);
520 ASSERT_EQ(ILM_SUCCESS,ilm_surfaceRemoveNotification(surface));
523 TEST_F(NotificationTest, NotifyOnSurfaceSetDestinationRectangle)
525 ASSERT_EQ(ILM_SUCCESS,ilm_surfaceAddNotification(surface,&SurfaceCallbackFunction));
527 ilm_surfaceSetDestinationRectangle(surface,33,567,55,99);
530 // expect callback to have been called
531 assertCallbackcalled();
533 EXPECT_EQ(surface,callbackSurfaceId);
534 EXPECT_EQ(33u,SurfaceProperties.destX);
535 EXPECT_EQ(567u,SurfaceProperties.destY);
536 EXPECT_EQ(55u,SurfaceProperties.destWidth);
537 EXPECT_EQ(99u,SurfaceProperties.destHeight);
538 EXPECT_EQ(ILM_NOTIFICATION_DEST_RECT,mask);
540 ASSERT_EQ(ILM_SUCCESS,ilm_surfaceRemoveNotification(surface));
543 TEST_F(NotificationTest, NotifyOnSurfaceSetOpacity)
545 ASSERT_EQ(ILM_SUCCESS,ilm_surfaceAddNotification(surface,&SurfaceCallbackFunction));
547 t_ilm_float opacity = 0.789;
548 ilm_surfaceSetOpacity(surface,opacity);
551 // expect callback to have been called
552 assertCallbackcalled();
554 EXPECT_EQ(surface,callbackSurfaceId);
555 EXPECT_FLOAT_EQ(0.789,SurfaceProperties.opacity);
556 EXPECT_EQ(ILM_NOTIFICATION_OPACITY,mask);
558 ASSERT_EQ(ILM_SUCCESS,ilm_surfaceRemoveNotification(surface));
561 TEST_F(NotificationTest, NotifyOnSurfaceSetOrientation)
563 ASSERT_EQ(ILM_SUCCESS,ilm_surfaceAddNotification(surface,&SurfaceCallbackFunction));
565 e_ilmOrientation orientation = ILM_ONEHUNDREDEIGHTY;
566 ilm_surfaceSetOrientation(surface,orientation);
569 // expect callback to have been called
570 assertCallbackcalled();
572 EXPECT_EQ(surface,callbackSurfaceId);
573 EXPECT_EQ(ILM_ONEHUNDREDEIGHTY,SurfaceProperties.orientation);
574 EXPECT_EQ(ILM_NOTIFICATION_ORIENTATION,mask);
576 ASSERT_EQ(ILM_SUCCESS,ilm_surfaceRemoveNotification(surface));
579 TEST_F(NotificationTest, NotifyOnSurfaceSetSourceRectangle)
581 ASSERT_EQ(ILM_SUCCESS,ilm_surfaceAddNotification(surface,&SurfaceCallbackFunction));
583 ilm_surfaceSetSourceRectangle(surface,33,567,55,99);
586 // expect callback to have been called
587 assertCallbackcalled();
589 EXPECT_EQ(surface,callbackSurfaceId);
590 EXPECT_EQ(33u,SurfaceProperties.sourceX);
591 EXPECT_EQ(567u,SurfaceProperties.sourceY);
592 EXPECT_EQ(55u,SurfaceProperties.sourceWidth);
593 EXPECT_EQ(99u,SurfaceProperties.sourceHeight);
594 EXPECT_EQ(ILM_NOTIFICATION_SOURCE_RECT,mask);
596 ASSERT_EQ(ILM_SUCCESS,ilm_surfaceRemoveNotification(surface));
599 TEST_F(NotificationTest, NotifyOnSurfaceSetVisibility)
601 ASSERT_EQ(ILM_SUCCESS,ilm_surfaceAddNotification(surface,&SurfaceCallbackFunction));
603 t_ilm_bool value = ILM_TRUE;
604 ilm_surfaceSetVisibility(surface,value);
607 // expect callback to have been called
608 assertCallbackcalled();
610 EXPECT_EQ(surface,callbackSurfaceId);
611 EXPECT_TRUE(SurfaceProperties.visibility);
612 EXPECT_EQ(ILM_NOTIFICATION_VISIBILITY,mask);
614 ASSERT_EQ(ILM_SUCCESS,ilm_surfaceRemoveNotification(surface));
617 TEST_F(NotificationTest, NotifyOnSurfaceMultipleValues1)
619 ASSERT_EQ(ILM_SUCCESS,ilm_surfaceAddNotification(surface,&SurfaceCallbackFunction));
621 ilm_surfaceSetSourceRectangle(surface,33,567,55,99);
622 ilm_surfaceSetOrientation(surface,ILM_ONEHUNDREDEIGHTY);
625 // expect callback to have been called
626 assertCallbackcalled();
628 EXPECT_EQ(surface,callbackSurfaceId);
629 EXPECT_EQ(33u,SurfaceProperties.sourceX);
630 EXPECT_EQ(567u,SurfaceProperties.sourceY);
631 EXPECT_EQ(55u,SurfaceProperties.sourceWidth);
632 EXPECT_EQ(99u,SurfaceProperties.sourceHeight);
633 EXPECT_EQ(ILM_ONEHUNDREDEIGHTY,SurfaceProperties.orientation);
634 EXPECT_EQ(ILM_NOTIFICATION_SOURCE_RECT|ILM_NOTIFICATION_ORIENTATION,mask);
636 ASSERT_EQ(ILM_SUCCESS,ilm_surfaceRemoveNotification(surface));
639 TEST_F(NotificationTest, NotifyOnSurfaceMultipleValues2)
641 ASSERT_EQ(ILM_SUCCESS,ilm_surfaceAddNotification(surface,&SurfaceCallbackFunction));
643 t_ilm_float opacity = 0.789;
644 ilm_surfaceSetOpacity(surface,opacity);
645 ilm_surfaceSetVisibility(surface,true);
646 ilm_surfaceSetDestinationRectangle(surface,33,567,55,99);
649 // expect callback to have been called
650 assertCallbackcalled();
652 EXPECT_EQ(surface,callbackSurfaceId);
653 EXPECT_TRUE(SurfaceProperties.visibility);
654 EXPECT_FLOAT_EQ(0.789,SurfaceProperties.opacity);
655 EXPECT_EQ(33u,SurfaceProperties.destX);
656 EXPECT_EQ(567u,SurfaceProperties.destY);
657 EXPECT_EQ(55u,SurfaceProperties.destWidth);
658 EXPECT_EQ(99u,SurfaceProperties.destHeight);
659 EXPECT_EQ(ILM_NOTIFICATION_DEST_RECT|ILM_NOTIFICATION_VISIBILITY|ILM_NOTIFICATION_OPACITY,mask);
661 ASSERT_EQ(ILM_SUCCESS,ilm_surfaceRemoveNotification(surface));
664 TEST_F(NotificationTest, NotifyOnSurfaceAllValues)
666 ASSERT_EQ(ILM_SUCCESS,ilm_surfaceAddNotification(surface,&SurfaceCallbackFunction));
668 t_ilm_float opacity = 0.789;
669 ilm_surfaceSetOpacity(surface,opacity);
670 ilm_surfaceSetVisibility(surface,true);
671 ilm_surfaceSetDestinationRectangle(surface,133,1567,155,199);
672 ilm_surfaceSetSourceRectangle(surface,33,567,55,99);
673 ilm_surfaceSetOrientation(surface,ILM_ONEHUNDREDEIGHTY);
676 // expect callback to have been called
677 assertCallbackcalled();
679 EXPECT_EQ(surface,callbackSurfaceId);
680 EXPECT_EQ(33u,SurfaceProperties.sourceX);
681 EXPECT_EQ(567u,SurfaceProperties.sourceY);
682 EXPECT_EQ(55u,SurfaceProperties.sourceWidth);
683 EXPECT_EQ(99u,SurfaceProperties.sourceHeight);
684 EXPECT_EQ(ILM_ONEHUNDREDEIGHTY,SurfaceProperties.orientation);
686 EXPECT_TRUE(SurfaceProperties.visibility);
687 EXPECT_FLOAT_EQ(opacity,SurfaceProperties.opacity);
688 EXPECT_EQ(133u,SurfaceProperties.destX);
689 EXPECT_EQ(1567u,SurfaceProperties.destY);
690 EXPECT_EQ(155u,SurfaceProperties.destWidth);
691 EXPECT_EQ(199u,SurfaceProperties.destHeight);
692 EXPECT_EQ(ILM_NOTIFICATION_DEST_RECT|ILM_NOTIFICATION_VISIBILITY|ILM_NOTIFICATION_OPACITY|ILM_NOTIFICATION_SOURCE_RECT|ILM_NOTIFICATION_ORIENTATION,mask);
694 ASSERT_EQ(ILM_SUCCESS,ilm_surfaceRemoveNotification(surface));
697 TEST_F(NotificationTest, DoNotSendNotificationsAfterRemoveSurface)
699 ASSERT_EQ(ILM_SUCCESS,ilm_surfaceAddNotification(surface,&SurfaceCallbackFunction));
701 ilm_surfaceSetOrientation(surface,ILM_ONEHUNDREDEIGHTY);
703 assertCallbackcalled();
705 ASSERT_EQ(ILM_SUCCESS,ilm_surfaceRemoveNotification(surface));
707 // change a lot of things
708 t_ilm_float opacity = 0.789;
709 ilm_surfaceSetOpacity(surface,opacity);
710 ilm_surfaceSetVisibility(surface,true);
711 ilm_surfaceSetDestinationRectangle(surface,133,1567,155,199);
712 ilm_surfaceSetSourceRectangle(surface,33,567,55,99);
713 ilm_surfaceSetOrientation(surface,ILM_ONEHUNDREDEIGHTY);
716 // assert that we have not been notified
717 assertNoCallbackIsCalled();
721 TEST_F(NotificationTest, MultipleRegistrationsSurface)
723 ASSERT_EQ(ILM_SUCCESS,ilm_surfaceAddNotification(surface,&SurfaceCallbackFunction));
725 ilm_surfaceSetOrientation(surface,ILM_ONEHUNDREDEIGHTY);
727 assertCallbackcalled();
729 ASSERT_EQ(ILM_SUCCESS,ilm_surfaceRemoveNotification(surface));
731 // change a lot of things
732 t_ilm_float opacity = 0.789;
733 ilm_surfaceSetOpacity(surface,opacity);
734 ilm_surfaceSetVisibility(surface,true);
735 ilm_surfaceSetDestinationRectangle(surface,133,1567,155,199);
736 ilm_surfaceSetSourceRectangle(surface,33,567,55,99);
737 ilm_surfaceSetOrientation(surface,ILM_ONEHUNDREDEIGHTY);
740 // assert that we have not been notified
741 assertNoCallbackIsCalled();
743 // register for notifications again
744 ASSERT_EQ(ILM_SUCCESS,ilm_surfaceAddNotification(surface,&SurfaceCallbackFunction));
746 ilm_surfaceSetOrientation(surface,ILM_ZERO);
748 assertCallbackcalled();
750 ASSERT_EQ(ILM_SUCCESS,ilm_surfaceRemoveNotification(surface));
753 TEST_F(NotificationTest, DefaultIsNotToReceiveNotificationsSurface)
756 ilm_surfaceSetOrientation(surface,ILM_ONEHUNDREDEIGHTY);
759 // change a lot of things
760 t_ilm_float opacity = 0.789;
761 ilm_surfaceSetOpacity(surface,opacity);
762 ilm_surfaceSetVisibility(surface,true);
763 ilm_surfaceSetDestinationRectangle(surface,133,1567,155,199);
764 ilm_surfaceSetSourceRectangle(surface,33,567,55,99);
765 ilm_surfaceSetOrientation(surface,ILM_ONEHUNDREDEIGHTY);
768 // assert that we have not been notified
769 assertNoCallbackIsCalled();