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 ****************************************************************************/
21 #include <gtest/gtest.h>
31 #include "ilm_client.h"
32 #include "ilm_control.h"
37 /* Tests with callbacks
38 * For each test first set the global variables to point to where parameters of the callbacks are supposed to be placed.
40 static pthread_mutex_t notificationMutex = PTHREAD_MUTEX_INITIALIZER;
41 static pthread_cond_t waiterVariable = PTHREAD_COND_INITIALIZER;
42 static int timesCalled=0;
44 class NotificationTest: public TestBase, public ::testing::Test {
47 static void SetUpTestCase() {
50 static void TearDownTestCase() {
58 LayerProperties = ilmLayerProperties();
59 mask = ILM_NOTIFICATION_ALL;
61 SurfaceProperties = ilmSurfaceProperties();
64 ilm_layerRemove(layer);
66 ilm_layerCreateWithDimension(&layer, 800, 480);
70 ilm_surfaceRemove(surface);
72 ilm_surfaceCreate((t_ilm_nativehandle)wlSurface,10,10,ILM_PIXELFORMAT_RGBA_8888,&surface);
83 // Pointers where to put received values for current Test
84 static t_ilm_layer callbackLayerId;
85 static t_ilm_layer callbackSurfaceId;
86 static struct ilmLayerProperties LayerProperties;
87 static t_ilm_notification_mask mask;
88 static t_ilm_surface surface;
89 static ilmSurfaceProperties SurfaceProperties;
92 static void assertCallbackcalled(int numberOfExpectedCalls=1){
93 static struct timespec theTime;
94 clock_gettime(CLOCK_REALTIME, &theTime);
96 pthread_mutex_lock( ¬ificationMutex );
99 if (numberOfExpectedCalls!=timesCalled){
100 status = pthread_cond_timedwait( &waiterVariable, ¬ificationMutex, &theTime);
102 } while (status!=ETIMEDOUT && numberOfExpectedCalls!=timesCalled);
103 ASSERT_NE(ETIMEDOUT, status);
104 pthread_mutex_unlock( ¬ificationMutex );
108 static void assertNoCallbackIsCalled(){
109 struct timespec theTime;
110 clock_gettime(CLOCK_REALTIME, &theTime);
112 pthread_mutex_lock( ¬ificationMutex );
113 // assert that we have not been notified
114 ASSERT_EQ(ETIMEDOUT, pthread_cond_timedwait( &waiterVariable, ¬ificationMutex, &theTime));
115 pthread_mutex_unlock( ¬ificationMutex );
119 static void LayerCallbackFunction(t_ilm_layer layer, struct ilmLayerProperties* LayerProperties, t_ilm_notification_mask mask)
121 pthread_mutex_lock( ¬ificationMutex );
123 NotificationTest::callbackLayerId = layer;
124 NotificationTest::LayerProperties = *LayerProperties;
125 NotificationTest::mask = mask;
127 pthread_cond_signal( &waiterVariable );
128 pthread_mutex_unlock( ¬ificationMutex );
131 static void SurfaceCallbackFunction(t_ilm_surface surface, struct ilmSurfaceProperties* surfaceProperties, t_ilm_notification_mask mask)
133 pthread_mutex_lock( ¬ificationMutex );
135 NotificationTest::callbackSurfaceId = surface;
136 NotificationTest::SurfaceProperties = *surfaceProperties;
137 NotificationTest::mask = mask;
139 pthread_cond_signal( &waiterVariable );
140 pthread_mutex_unlock( ¬ificationMutex );
144 // Pointers where to put received values for current Test
145 t_ilm_layer NotificationTest::callbackLayerId;
146 t_ilm_layer NotificationTest::callbackSurfaceId;
147 struct ilmLayerProperties NotificationTest::LayerProperties;
148 t_ilm_notification_mask NotificationTest::mask;
149 t_ilm_surface NotificationTest::surface;
150 ilmSurfaceProperties NotificationTest::SurfaceProperties;
155 TEST_F(NotificationTest, ilm_layerAddNotificationWithoutCallback)
158 t_ilm_uint layer = 89;
160 ASSERT_EQ(ILM_SUCCESS,ilm_layerCreateWithDimension(&layer, 800, 480));
161 ASSERT_EQ(ILM_SUCCESS,ilm_commitChanges());
164 printf("test calling ilm_layerAddNotification\n");
165 //ASSERT_EQ(ILM_SUCCESS,ilm_commitChanges());
166 ASSERT_EQ(ILM_SUCCESS, ilm_layerAddNotification(layer,NULL));
168 ASSERT_EQ(ILM_SUCCESS,ilm_layerRemove(layer));
169 ASSERT_EQ(ILM_SUCCESS,ilm_commitChanges());
173 TEST_F(NotificationTest, ilm_surfaceAddNotificationWithoutCallback)
176 t_ilm_uint surface = 67;
178 ilm_surfaceCreate((t_ilm_nativehandle)wlSurface,10,10,ILM_PIXELFORMAT_RGBA_8888,&surface);
182 ilmErrorTypes status = ilm_surfaceAddNotification(surface,NULL);
183 ASSERT_EQ(ILM_SUCCESS, status);
185 ilm_surfaceRemove(surface);
190 TEST_F(NotificationTest, NotifyOnLayerSetPosition)
192 ASSERT_EQ(ILM_SUCCESS,ilm_layerAddNotification(layer,&LayerCallbackFunction));
194 t_ilm_uint* pos = new t_ilm_uint[2];
197 ilm_layerSetPosition(layer,pos);
200 // expect callback to have been called
201 assertCallbackcalled();
203 EXPECT_EQ(layer,callbackLayerId);
204 EXPECT_EQ(7u,LayerProperties.destX);
205 EXPECT_EQ(2u,LayerProperties.destY);
206 EXPECT_EQ(ILM_NOTIFICATION_DEST_RECT,mask);
208 ASSERT_EQ(ILM_SUCCESS,ilm_layerRemoveNotification(layer));
211 TEST_F(NotificationTest, NotifyOnLayerSetDimension)
213 ASSERT_EQ(ILM_SUCCESS,ilm_layerAddNotification(layer,&LayerCallbackFunction));
215 t_ilm_uint* pos = new t_ilm_uint[2];
218 ilm_layerSetDimension(layer,pos);
221 // expect callback to have been called
222 assertCallbackcalled();
224 EXPECT_EQ(layer,callbackLayerId);
225 EXPECT_EQ(70u,LayerProperties.destWidth);
226 EXPECT_EQ(22u,LayerProperties.destHeight);
227 EXPECT_EQ(ILM_NOTIFICATION_DEST_RECT,mask);
229 ASSERT_EQ(ILM_SUCCESS,ilm_layerRemoveNotification(layer));
232 TEST_F(NotificationTest, NotifyOnLayerSetDestinationRectangle)
234 ASSERT_EQ(ILM_SUCCESS,ilm_layerAddNotification(layer,&LayerCallbackFunction));
236 ilm_layerSetDestinationRectangle(layer,33,567,55,99);
239 // expect callback to have been called
240 assertCallbackcalled();
242 EXPECT_EQ(layer,callbackLayerId);
243 EXPECT_EQ(33u,LayerProperties.destX);
244 EXPECT_EQ(567u,LayerProperties.destY);
245 EXPECT_EQ(55u,LayerProperties.destWidth);
246 EXPECT_EQ(99u,LayerProperties.destHeight);
247 EXPECT_EQ(ILM_NOTIFICATION_DEST_RECT,mask);
249 ASSERT_EQ(ILM_SUCCESS,ilm_layerRemoveNotification(layer));
252 TEST_F(NotificationTest, NotifyOnLayerSetOpacity)
254 ASSERT_EQ(ILM_SUCCESS,ilm_layerAddNotification(layer,&LayerCallbackFunction));
256 t_ilm_float opacity = 0.789;
257 ilm_layerSetOpacity(layer,opacity);
260 // expect callback to have been called
261 assertCallbackcalled();
263 EXPECT_EQ(layer,callbackLayerId);
264 EXPECT_FLOAT_EQ(0.789,LayerProperties.opacity);
265 EXPECT_EQ(ILM_NOTIFICATION_OPACITY,mask);
267 ASSERT_EQ(ILM_SUCCESS,ilm_layerRemoveNotification(layer));
270 TEST_F(NotificationTest, NotifyOnLayerSetOrientation)
272 ASSERT_EQ(ILM_SUCCESS,ilm_layerAddNotification(layer,&LayerCallbackFunction));
274 e_ilmOrientation orientation = ILM_ONEHUNDREDEIGHTY;
275 ilm_layerSetOrientation(layer,orientation);
278 // expect callback to have been called
279 assertCallbackcalled();
281 EXPECT_EQ(layer,callbackLayerId);
282 EXPECT_EQ(ILM_ONEHUNDREDEIGHTY,LayerProperties.orientation);
283 EXPECT_EQ(ILM_NOTIFICATION_ORIENTATION,mask);
285 ASSERT_EQ(ILM_SUCCESS,ilm_layerRemoveNotification(layer));
288 TEST_F(NotificationTest, NotifyOnLayerSetSourceRectangle)
290 ASSERT_EQ(ILM_SUCCESS,ilm_layerAddNotification(layer,&LayerCallbackFunction));
292 ilm_layerSetSourceRectangle(layer,33,567,55,99);
295 // expect callback to have been called
296 assertCallbackcalled();
298 EXPECT_EQ(layer,callbackLayerId);
299 EXPECT_EQ(33u,LayerProperties.sourceX);
300 EXPECT_EQ(567u,LayerProperties.sourceY);
301 EXPECT_EQ(55u,LayerProperties.sourceWidth);
302 EXPECT_EQ(99u,LayerProperties.sourceHeight);
303 EXPECT_EQ(ILM_NOTIFICATION_SOURCE_RECT,mask);
305 ASSERT_EQ(ILM_SUCCESS,ilm_layerRemoveNotification(layer));
308 TEST_F(NotificationTest, NotifyOnLayerSetVisibility)
310 ASSERT_EQ(ILM_SUCCESS,ilm_layerAddNotification(layer,&LayerCallbackFunction));
312 t_ilm_bool value = ILM_TRUE;
313 ilm_layerSetVisibility(layer,value);
316 // expect callback to have been called
317 assertCallbackcalled();
319 EXPECT_EQ(layer,callbackLayerId);
320 EXPECT_TRUE(LayerProperties.visibility);
321 EXPECT_EQ(ILM_NOTIFICATION_VISIBILITY,mask);
323 ASSERT_EQ(ILM_SUCCESS,ilm_layerRemoveNotification(layer));
326 TEST_F(NotificationTest, NotifyOnLayerMultipleValues1)
328 ASSERT_EQ(ILM_SUCCESS,ilm_layerAddNotification(layer,&LayerCallbackFunction));
330 ilm_layerSetSourceRectangle(layer,33,567,55,99);
331 ilm_layerSetOrientation(layer,ILM_ONEHUNDREDEIGHTY);
334 // expect callback to have been called
335 assertCallbackcalled();
337 EXPECT_EQ(layer,callbackLayerId);
338 EXPECT_EQ(33u,LayerProperties.sourceX);
339 EXPECT_EQ(567u,LayerProperties.sourceY);
340 EXPECT_EQ(55u,LayerProperties.sourceWidth);
341 EXPECT_EQ(99u,LayerProperties.sourceHeight);
342 EXPECT_EQ(ILM_ONEHUNDREDEIGHTY,LayerProperties.orientation);
343 EXPECT_EQ(ILM_NOTIFICATION_SOURCE_RECT|ILM_NOTIFICATION_ORIENTATION,mask);
345 ASSERT_EQ(ILM_SUCCESS,ilm_layerRemoveNotification(layer));
348 TEST_F(NotificationTest, NotifyOnLayerMultipleValues2)
350 ASSERT_EQ(ILM_SUCCESS,ilm_layerAddNotification(layer,&LayerCallbackFunction));
352 t_ilm_float opacity = 0.789;
353 ilm_layerSetOpacity(layer,opacity);
354 ilm_layerSetVisibility(layer,true);
355 ilm_layerSetDestinationRectangle(layer,33,567,55,99);
358 // expect callback to have been called
359 assertCallbackcalled();
361 EXPECT_EQ(layer,callbackLayerId);
362 EXPECT_TRUE(LayerProperties.visibility);
363 EXPECT_FLOAT_EQ(0.789,LayerProperties.opacity);
364 EXPECT_EQ(33u,LayerProperties.destX);
365 EXPECT_EQ(567u,LayerProperties.destY);
366 EXPECT_EQ(55u,LayerProperties.destWidth);
367 EXPECT_EQ(99u,LayerProperties.destHeight);
368 EXPECT_EQ(ILM_NOTIFICATION_DEST_RECT|ILM_NOTIFICATION_VISIBILITY|ILM_NOTIFICATION_OPACITY,mask);
370 ASSERT_EQ(ILM_SUCCESS,ilm_layerRemoveNotification(layer));
373 TEST_F(NotificationTest, NotifyOnLayerAllValues)
375 ASSERT_EQ(ILM_SUCCESS,ilm_layerAddNotification(layer,&LayerCallbackFunction));
377 t_ilm_float opacity = 0.789;
378 ilm_layerSetOpacity(layer,opacity);
379 ilm_layerSetVisibility(layer,true);
380 ilm_layerSetDestinationRectangle(layer,133,1567,155,199);
381 ilm_layerSetSourceRectangle(layer,33,567,55,99);
382 ilm_layerSetOrientation(layer,ILM_ONEHUNDREDEIGHTY);
385 // expect callback to have been called
386 assertCallbackcalled();
388 EXPECT_EQ(layer,callbackLayerId);
389 EXPECT_EQ(33u,LayerProperties.sourceX);
390 EXPECT_EQ(567u,LayerProperties.sourceY);
391 EXPECT_EQ(55u,LayerProperties.sourceWidth);
392 EXPECT_EQ(99u,LayerProperties.sourceHeight);
393 EXPECT_EQ(ILM_ONEHUNDREDEIGHTY,LayerProperties.orientation);
395 EXPECT_TRUE(LayerProperties.visibility);
396 EXPECT_FLOAT_EQ(opacity,LayerProperties.opacity);
397 EXPECT_EQ(133u,LayerProperties.destX);
398 EXPECT_EQ(1567u,LayerProperties.destY);
399 EXPECT_EQ(155u,LayerProperties.destWidth);
400 EXPECT_EQ(199u,LayerProperties.destHeight);
401 EXPECT_EQ(ILM_NOTIFICATION_DEST_RECT|ILM_NOTIFICATION_VISIBILITY|ILM_NOTIFICATION_OPACITY|ILM_NOTIFICATION_SOURCE_RECT|ILM_NOTIFICATION_ORIENTATION,mask);
403 ASSERT_EQ(ILM_SUCCESS,ilm_layerRemoveNotification(layer));
406 TEST_F(NotificationTest, DoNotSendNotificationsAfterRemoveLayer)
408 ASSERT_EQ(ILM_SUCCESS,ilm_layerAddNotification(layer,&LayerCallbackFunction));
410 ilm_layerSetOrientation(layer,ILM_ONEHUNDREDEIGHTY);
412 assertCallbackcalled();
414 ASSERT_EQ(ILM_SUCCESS,ilm_layerRemoveNotification(layer));
416 // change a lot of things
417 t_ilm_float opacity = 0.789;
418 ilm_layerSetOpacity(layer,opacity);
419 ilm_layerSetVisibility(layer,true);
420 ilm_layerSetDestinationRectangle(layer,133,1567,155,199);
421 ilm_layerSetSourceRectangle(layer,33,567,55,99);
422 ilm_layerSetOrientation(layer,ILM_ONEHUNDREDEIGHTY);
425 // assert that we have not been notified
426 assertNoCallbackIsCalled();
430 TEST_F(NotificationTest, MultipleRegistrationsLayer)
432 ASSERT_EQ(ILM_SUCCESS,ilm_layerAddNotification(layer,&LayerCallbackFunction));
434 ilm_layerSetOrientation(layer,ILM_ONEHUNDREDEIGHTY);
436 assertCallbackcalled();
438 ASSERT_EQ(ILM_SUCCESS,ilm_layerRemoveNotification(layer));
440 // change a lot of things
441 t_ilm_float opacity = 0.789;
442 ilm_layerSetOpacity(layer,opacity);
443 ilm_layerSetVisibility(layer,true);
444 ilm_layerSetDestinationRectangle(layer,133,1567,155,199);
445 ilm_layerSetSourceRectangle(layer,33,567,55,99);
446 ilm_layerSetOrientation(layer,ILM_ONEHUNDREDEIGHTY);
449 // assert that we have not been notified
450 assertNoCallbackIsCalled();
452 // register for notifications again
453 ASSERT_EQ(ILM_SUCCESS,ilm_layerAddNotification(layer,&LayerCallbackFunction));
455 ilm_layerSetOrientation(layer,ILM_ZERO);
457 assertCallbackcalled();
459 ASSERT_EQ(ILM_SUCCESS,ilm_layerRemoveNotification(layer));
462 TEST_F(NotificationTest, DefaultIsNotToReceiveNotificationsLayer)
465 ilm_layerSetOrientation(layer,ILM_ONEHUNDREDEIGHTY);
468 // change a lot of things
469 t_ilm_float opacity = 0.789;
470 ilm_layerSetOpacity(layer,opacity);
471 ilm_layerSetVisibility(layer,true);
472 ilm_layerSetDestinationRectangle(layer,133,1567,155,199);
473 ilm_layerSetSourceRectangle(layer,33,567,55,99);
474 ilm_layerSetOrientation(layer,ILM_ONEHUNDREDEIGHTY);
477 // assert that we have not been notified
478 assertNoCallbackIsCalled();
482 TEST_F(NotificationTest, NotifyOnSurfaceSetPosition)
484 ASSERT_EQ(ILM_SUCCESS,ilm_surfaceAddNotification(surface,&SurfaceCallbackFunction));
486 t_ilm_uint* pos = new t_ilm_uint[2];
489 ilm_surfaceSetPosition(surface,pos);
492 // expect callback to have been called
493 assertCallbackcalled();
495 EXPECT_EQ(surface,callbackSurfaceId);
496 EXPECT_EQ(7u,SurfaceProperties.destX);
497 EXPECT_EQ(2u,SurfaceProperties.destY);
498 EXPECT_EQ(ILM_NOTIFICATION_DEST_RECT,mask);
500 ASSERT_EQ(ILM_SUCCESS,ilm_surfaceRemoveNotification(surface));
503 TEST_F(NotificationTest, NotifyOnSurfaceSetDimension)
505 ASSERT_EQ(ILM_SUCCESS,ilm_surfaceAddNotification(surface,&SurfaceCallbackFunction));
507 t_ilm_uint* pos = new t_ilm_uint[2];
510 ilm_surfaceSetDimension(surface,pos);
513 // expect callback to have been called
514 assertCallbackcalled();
516 EXPECT_EQ(surface,callbackSurfaceId);
517 EXPECT_EQ(70u,SurfaceProperties.destWidth);
518 EXPECT_EQ(22u,SurfaceProperties.destHeight);
519 EXPECT_EQ(ILM_NOTIFICATION_DEST_RECT,mask);
521 ASSERT_EQ(ILM_SUCCESS,ilm_surfaceRemoveNotification(surface));
524 TEST_F(NotificationTest, NotifyOnSurfaceSetDestinationRectangle)
526 ASSERT_EQ(ILM_SUCCESS,ilm_surfaceAddNotification(surface,&SurfaceCallbackFunction));
528 ilm_surfaceSetDestinationRectangle(surface,33,567,55,99);
531 // expect callback to have been called
532 assertCallbackcalled();
534 EXPECT_EQ(surface,callbackSurfaceId);
535 EXPECT_EQ(33u,SurfaceProperties.destX);
536 EXPECT_EQ(567u,SurfaceProperties.destY);
537 EXPECT_EQ(55u,SurfaceProperties.destWidth);
538 EXPECT_EQ(99u,SurfaceProperties.destHeight);
539 EXPECT_EQ(ILM_NOTIFICATION_DEST_RECT,mask);
541 ASSERT_EQ(ILM_SUCCESS,ilm_surfaceRemoveNotification(surface));
544 TEST_F(NotificationTest, NotifyOnSurfaceSetOpacity)
546 ASSERT_EQ(ILM_SUCCESS,ilm_surfaceAddNotification(surface,&SurfaceCallbackFunction));
548 t_ilm_float opacity = 0.789;
549 ilm_surfaceSetOpacity(surface,opacity);
552 // expect callback to have been called
553 assertCallbackcalled();
555 EXPECT_EQ(surface,callbackSurfaceId);
556 EXPECT_FLOAT_EQ(0.789,SurfaceProperties.opacity);
557 EXPECT_EQ(ILM_NOTIFICATION_OPACITY,mask);
559 ASSERT_EQ(ILM_SUCCESS,ilm_surfaceRemoveNotification(surface));
562 TEST_F(NotificationTest, NotifyOnSurfaceSetOrientation)
564 ASSERT_EQ(ILM_SUCCESS,ilm_surfaceAddNotification(surface,&SurfaceCallbackFunction));
566 e_ilmOrientation orientation = ILM_ONEHUNDREDEIGHTY;
567 ilm_surfaceSetOrientation(surface,orientation);
570 // expect callback to have been called
571 assertCallbackcalled();
573 EXPECT_EQ(surface,callbackSurfaceId);
574 EXPECT_EQ(ILM_ONEHUNDREDEIGHTY,SurfaceProperties.orientation);
575 EXPECT_EQ(ILM_NOTIFICATION_ORIENTATION,mask);
577 ASSERT_EQ(ILM_SUCCESS,ilm_surfaceRemoveNotification(surface));
580 TEST_F(NotificationTest, NotifyOnSurfaceSetSourceRectangle)
582 ASSERT_EQ(ILM_SUCCESS,ilm_surfaceAddNotification(surface,&SurfaceCallbackFunction));
584 ilm_surfaceSetSourceRectangle(surface,33,567,55,99);
587 // expect callback to have been called
588 assertCallbackcalled();
590 EXPECT_EQ(surface,callbackSurfaceId);
591 EXPECT_EQ(33u,SurfaceProperties.sourceX);
592 EXPECT_EQ(567u,SurfaceProperties.sourceY);
593 EXPECT_EQ(55u,SurfaceProperties.sourceWidth);
594 EXPECT_EQ(99u,SurfaceProperties.sourceHeight);
595 EXPECT_EQ(ILM_NOTIFICATION_SOURCE_RECT,mask);
597 ASSERT_EQ(ILM_SUCCESS,ilm_surfaceRemoveNotification(surface));
600 TEST_F(NotificationTest, NotifyOnSurfaceSetVisibility)
602 ASSERT_EQ(ILM_SUCCESS,ilm_surfaceAddNotification(surface,&SurfaceCallbackFunction));
604 t_ilm_bool value = ILM_TRUE;
605 ilm_surfaceSetVisibility(surface,value);
608 // expect callback to have been called
609 assertCallbackcalled();
611 EXPECT_EQ(surface,callbackSurfaceId);
612 EXPECT_TRUE(SurfaceProperties.visibility);
613 EXPECT_EQ(ILM_NOTIFICATION_VISIBILITY,mask);
615 ASSERT_EQ(ILM_SUCCESS,ilm_surfaceRemoveNotification(surface));
618 TEST_F(NotificationTest, NotifyOnSurfaceMultipleValues1)
620 ASSERT_EQ(ILM_SUCCESS,ilm_surfaceAddNotification(surface,&SurfaceCallbackFunction));
622 ilm_surfaceSetSourceRectangle(surface,33,567,55,99);
623 ilm_surfaceSetOrientation(surface,ILM_ONEHUNDREDEIGHTY);
626 // expect callback to have been called
627 assertCallbackcalled();
629 EXPECT_EQ(surface,callbackSurfaceId);
630 EXPECT_EQ(33u,SurfaceProperties.sourceX);
631 EXPECT_EQ(567u,SurfaceProperties.sourceY);
632 EXPECT_EQ(55u,SurfaceProperties.sourceWidth);
633 EXPECT_EQ(99u,SurfaceProperties.sourceHeight);
634 EXPECT_EQ(ILM_ONEHUNDREDEIGHTY,SurfaceProperties.orientation);
635 EXPECT_EQ(ILM_NOTIFICATION_SOURCE_RECT|ILM_NOTIFICATION_ORIENTATION,mask);
637 ASSERT_EQ(ILM_SUCCESS,ilm_surfaceRemoveNotification(surface));
640 TEST_F(NotificationTest, NotifyOnSurfaceMultipleValues2)
642 ASSERT_EQ(ILM_SUCCESS,ilm_surfaceAddNotification(surface,&SurfaceCallbackFunction));
644 t_ilm_float opacity = 0.789;
645 ilm_surfaceSetOpacity(surface,opacity);
646 ilm_surfaceSetVisibility(surface,true);
647 ilm_surfaceSetDestinationRectangle(surface,33,567,55,99);
650 // expect callback to have been called
651 assertCallbackcalled();
653 EXPECT_EQ(surface,callbackSurfaceId);
654 EXPECT_TRUE(SurfaceProperties.visibility);
655 EXPECT_FLOAT_EQ(0.789,SurfaceProperties.opacity);
656 EXPECT_EQ(33u,SurfaceProperties.destX);
657 EXPECT_EQ(567u,SurfaceProperties.destY);
658 EXPECT_EQ(55u,SurfaceProperties.destWidth);
659 EXPECT_EQ(99u,SurfaceProperties.destHeight);
660 EXPECT_EQ(ILM_NOTIFICATION_DEST_RECT|ILM_NOTIFICATION_VISIBILITY|ILM_NOTIFICATION_OPACITY,mask);
662 ASSERT_EQ(ILM_SUCCESS,ilm_surfaceRemoveNotification(surface));
665 TEST_F(NotificationTest, NotifyOnSurfaceAllValues)
667 ASSERT_EQ(ILM_SUCCESS,ilm_surfaceAddNotification(surface,&SurfaceCallbackFunction));
669 t_ilm_float opacity = 0.789;
670 ilm_surfaceSetOpacity(surface,opacity);
671 ilm_surfaceSetVisibility(surface,true);
672 ilm_surfaceSetDestinationRectangle(surface,133,1567,155,199);
673 ilm_surfaceSetSourceRectangle(surface,33,567,55,99);
674 ilm_surfaceSetOrientation(surface,ILM_ONEHUNDREDEIGHTY);
677 // expect callback to have been called
678 assertCallbackcalled();
680 EXPECT_EQ(surface,callbackSurfaceId);
681 EXPECT_EQ(33u,SurfaceProperties.sourceX);
682 EXPECT_EQ(567u,SurfaceProperties.sourceY);
683 EXPECT_EQ(55u,SurfaceProperties.sourceWidth);
684 EXPECT_EQ(99u,SurfaceProperties.sourceHeight);
685 EXPECT_EQ(ILM_ONEHUNDREDEIGHTY,SurfaceProperties.orientation);
687 EXPECT_TRUE(SurfaceProperties.visibility);
688 EXPECT_FLOAT_EQ(opacity,SurfaceProperties.opacity);
689 EXPECT_EQ(133u,SurfaceProperties.destX);
690 EXPECT_EQ(1567u,SurfaceProperties.destY);
691 EXPECT_EQ(155u,SurfaceProperties.destWidth);
692 EXPECT_EQ(199u,SurfaceProperties.destHeight);
693 EXPECT_EQ(ILM_NOTIFICATION_DEST_RECT|ILM_NOTIFICATION_VISIBILITY|ILM_NOTIFICATION_OPACITY|ILM_NOTIFICATION_SOURCE_RECT|ILM_NOTIFICATION_ORIENTATION,mask);
695 ASSERT_EQ(ILM_SUCCESS,ilm_surfaceRemoveNotification(surface));
698 TEST_F(NotificationTest, DoNotSendNotificationsAfterRemoveSurface)
700 ASSERT_EQ(ILM_SUCCESS,ilm_surfaceAddNotification(surface,&SurfaceCallbackFunction));
702 ilm_surfaceSetOrientation(surface,ILM_ONEHUNDREDEIGHTY);
704 assertCallbackcalled();
706 ASSERT_EQ(ILM_SUCCESS,ilm_surfaceRemoveNotification(surface));
708 // change a lot of things
709 t_ilm_float opacity = 0.789;
710 ilm_surfaceSetOpacity(surface,opacity);
711 ilm_surfaceSetVisibility(surface,true);
712 ilm_surfaceSetDestinationRectangle(surface,133,1567,155,199);
713 ilm_surfaceSetSourceRectangle(surface,33,567,55,99);
714 ilm_surfaceSetOrientation(surface,ILM_ONEHUNDREDEIGHTY);
717 // assert that we have not been notified
718 assertNoCallbackIsCalled();
722 TEST_F(NotificationTest, MultipleRegistrationsSurface)
724 ASSERT_EQ(ILM_SUCCESS,ilm_surfaceAddNotification(surface,&SurfaceCallbackFunction));
726 ilm_surfaceSetOrientation(surface,ILM_ONEHUNDREDEIGHTY);
728 assertCallbackcalled();
730 ASSERT_EQ(ILM_SUCCESS,ilm_surfaceRemoveNotification(surface));
732 // change a lot of things
733 t_ilm_float opacity = 0.789;
734 ilm_surfaceSetOpacity(surface,opacity);
735 ilm_surfaceSetVisibility(surface,true);
736 ilm_surfaceSetDestinationRectangle(surface,133,1567,155,199);
737 ilm_surfaceSetSourceRectangle(surface,33,567,55,99);
738 ilm_surfaceSetOrientation(surface,ILM_ONEHUNDREDEIGHTY);
741 // assert that we have not been notified
742 assertNoCallbackIsCalled();
744 // register for notifications again
745 ASSERT_EQ(ILM_SUCCESS,ilm_surfaceAddNotification(surface,&SurfaceCallbackFunction));
747 ilm_surfaceSetOrientation(surface,ILM_ZERO);
749 assertCallbackcalled();
751 ASSERT_EQ(ILM_SUCCESS,ilm_surfaceRemoveNotification(surface));
754 TEST_F(NotificationTest, DefaultIsNotToReceiveNotificationsSurface)
757 ilm_surfaceSetOrientation(surface,ILM_ONEHUNDREDEIGHTY);
760 // change a lot of things
761 t_ilm_float opacity = 0.789;
762 ilm_surfaceSetOpacity(surface,opacity);
763 ilm_surfaceSetVisibility(surface,true);
764 ilm_surfaceSetDestinationRectangle(surface,133,1567,155,199);
765 ilm_surfaceSetSourceRectangle(surface,33,567,55,99);
766 ilm_surfaceSetOrientation(surface,ILM_ONEHUNDREDEIGHTY);
769 // assert that we have not been notified
770 assertNoCallbackIsCalled();