Home | History | Annotate | Download | only in src
      1 /*
      2 Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.
      3 
      4 Redistribution and use in source and binary forms, with or without
      5 modification, are permitted provided that the following conditions are
      6 met:
      7     * Redistributions of source code must retain the above copyright
      8       notice, this list of conditions and the following disclaimer.
      9     * Redistributions in binary form must reproduce the above
     10       copyright notice, this list of conditions and the following
     11       disclaimer in the documentation and/or other materials provided
     12       with the distribution.
     13     * Neither the name of The Linux Foundation nor the names of its
     14       contributors may be used to endorse or promote products derived
     15       from this software without specific prior written permission.
     16 
     17 THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
     18 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
     19 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
     20 ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
     21 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     22 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     23 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
     24 BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     25 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
     26 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
     27 IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     28 */
     29 
     30 #include <pthread.h>
     31 #include "mm_camera_dbg.h"
     32 #include <errno.h>
     33 #include <sys/ioctl.h>
     34 #include <sys/types.h>
     35 #include <sys/stat.h>
     36 #include <fcntl.h>
     37 #include <poll.h>
     38 #include "mm_qcamera_unit_test.h"
     39 
     40 #define MM_QCAMERA_APP_UTEST_MAX_MAIN_LOOP 4
     41 #define MM_QCAM_APP_TEST_NUM 128
     42 
     43 static mm_app_tc_t mm_app_tc[MM_QCAM_APP_TEST_NUM];
     44 static int num_test_cases = 0;
     45 static mm_jpeg_ops_t jpeg_ops;
     46 
     47 extern int system_dimension_set(int cam_id);
     48 extern int stopPreview(int cam_id);
     49 extern int takePicture_yuv(int cam_id);
     50 extern int startRdi(int cam_id);
     51 extern int stopRdi(int cam_id);
     52 extern int startStats(int cam_id);
     53 extern int stopStats(int cam_id);
     54 extern int takePicture_zsl(int cam_id);
     55 extern int takePicture_rdi(int cam_id);
     56 extern int mm_app_tc_reprocess_preview_only(mm_camera_app_t *cam_apps);
     57 extern int takePicture_raw(int cam_id);
     58 
     59 int mm_app_tc_0(mm_camera_app_t *cam_apps)
     60 {
     61     int rc = MM_CAMERA_OK;
     62     int i,j;
     63     int result = 0;
     64 
     65     printf("\n Verifying Preview on front and back camera...\n");
     66     if (cam_apps->num_cameras == 0) {
     67         CDBG_ERROR("%s:Query Failed: Num of cameras = %d\n",__func__, cam_apps->num_cameras);
     68         rc = -1;
     69         goto end;
     70     }
     71     for (i = 0; i < cam_apps->num_cameras; i++) {
     72         if ( mm_app_open(i) != MM_CAMERA_OK) {
     73             CDBG_ERROR("%s:mm_app_open() err=%d\n",__func__, rc);
     74             rc = -1;
     75             goto end;
     76         }
     77         if (system_dimension_set(my_cam_app.cam_open) != MM_CAMERA_OK) {
     78             CDBG_ERROR("%s:system_dimension_set() err=%d\n",__func__, rc);
     79             rc = -1;
     80             goto end;
     81         }
     82         for (j = 0; j < MM_QCAMERA_APP_INTERATION; j++) {
     83             if ( MM_CAMERA_OK != (rc = startPreview(my_cam_app.cam_open))) {
     84                 CDBG_ERROR("%s: startPreview() err=%d\n", __func__, rc);
     85                 break;
     86             }
     87             /*if(mm_camera_app_timedwait() == ETIMEDOUT) {
     88                     CDBG_ERROR("%s: Preview Callback not received in time or qbuf failed\n", __func__);
     89                     break;
     90             }*/
     91             mm_camera_app_wait();
     92             if ( MM_CAMERA_OK != (rc = stopPreview(my_cam_app.cam_open))) {
     93                 CDBG("%s: startPreview() err=%d\n", __func__, rc);
     94                 break;
     95             }
     96             result++;
     97         }
     98         if ( mm_app_close(my_cam_app.cam_open) != MM_CAMERA_OK) {
     99             CDBG_ERROR("%s:mm_app_close() err=%d\n",__func__, rc);
    100             rc = -1;
    101             goto end;
    102         }
    103 
    104         if (result != MM_QCAMERA_APP_INTERATION) {
    105             printf("%s: Preview Start/Stop Fails for Camera %d in %d iteration", __func__, i,j);
    106             rc = -1;
    107             break;
    108         }
    109 
    110         result = 0;
    111     }
    112     end:
    113     if (rc == 0) {
    114         printf("\nPassed\n");
    115     } else {
    116         printf("\nFailed\n");
    117     }
    118     CDBG("%s:END, rc = %d\n", __func__, rc);
    119     return rc;
    120 }
    121 
    122 int mm_app_tc_1(mm_camera_app_t *cam_apps)
    123 {
    124     int rc = MM_CAMERA_OK;
    125     int i,j;
    126     int result = 0;
    127 
    128     printf("\n Verifying Snapshot on front and back camera...\n");
    129     for (i = 0; i < cam_apps->num_cameras; i++) {
    130         if ( mm_app_open(i) != MM_CAMERA_OK) {
    131             CDBG_ERROR("%s:mm_app_open() err=%d\n",__func__, rc);
    132             rc = -1;
    133             goto end;
    134         }
    135         if (system_dimension_set(my_cam_app.cam_open) != MM_CAMERA_OK) {
    136             CDBG_ERROR("%s:system_dimension_set() err=%d\n",__func__, rc);
    137             rc = -1;
    138             goto end;
    139         }
    140 
    141         if ( MM_CAMERA_OK != (rc = startPreview(my_cam_app.cam_open))) {
    142             CDBG_ERROR("%s: startPreview() err=%d\n", __func__, rc);
    143             break;
    144         }
    145         for (j = 0; j < MM_QCAMERA_APP_INTERATION; j++) {
    146             if ( MM_CAMERA_OK != (rc = takePicture_yuv(my_cam_app.cam_open))) {
    147                 CDBG_ERROR("%s: TakePicture() err=%d\n", __func__, rc);
    148                 break;
    149             }
    150             /*if(mm_camera_app_timedwait() == ETIMEDOUT) {
    151                     CDBG_ERROR("%s: Snapshot/Preview Callback not received in time or qbuf Faile\n", __func__);
    152                     break;
    153             }*/
    154             mm_camera_app_wait();
    155             result++;
    156         }
    157         if ( MM_CAMERA_OK != (rc = stopPreview(my_cam_app.cam_open))) {
    158             CDBG("%s: startPreview() err=%d\n", __func__, rc);
    159             break;
    160         }
    161         if ( mm_app_close(my_cam_app.cam_open) != MM_CAMERA_OK) {
    162             CDBG_ERROR("%s:mm_app_close() err=%d\n",__func__, rc);
    163             rc = -1;
    164             goto end;
    165         }
    166         if (result != MM_QCAMERA_APP_INTERATION) {
    167             printf("%s: Snapshot Start/Stop Fails for Camera %d in %d iteration", __func__, i,j);
    168             rc = -1;
    169             break;
    170         }
    171 
    172         result = 0;
    173     }
    174     end:
    175     if (rc == 0) {
    176         printf("\t***Passed***\n");
    177     } else {
    178         printf("\t***Failed***\n");
    179     }
    180     CDBG("%s:END, rc = %d\n", __func__, rc);
    181     return rc;
    182 }
    183 
    184 int mm_app_tc_2(mm_camera_app_t *cam_apps)
    185 {
    186     int rc = MM_CAMERA_OK;
    187     int i,j;
    188     int result = 0;
    189 
    190     printf("\n Verifying Video on front and back camera...\n");
    191     for (i = 0; i < cam_apps->num_cameras; i++) {
    192         if ( mm_app_open(i) != MM_CAMERA_OK) {
    193             CDBG_ERROR("%s:mm_app_open() err=%d\n",__func__, rc);
    194             rc = -1;
    195             goto end;
    196         }
    197         if (system_dimension_set(my_cam_app.cam_open) != MM_CAMERA_OK) {
    198             CDBG_ERROR("%s:system_dimension_set() err=%d\n",__func__, rc);
    199             rc = -1;
    200             goto end;
    201         }
    202 
    203         if ( MM_CAMERA_OK != (rc = startPreview(my_cam_app.cam_open))) {
    204             CDBG_ERROR("%s: startPreview() err=%d\n", __func__, rc);
    205             break;
    206         }
    207         for (j = 0; j < MM_QCAMERA_APP_INTERATION; j++) {
    208             if ( MM_CAMERA_OK != (rc = startRecording(my_cam_app.cam_open))) {
    209                 CDBG_ERROR("%s: StartVideorecording() err=%d\n", __func__, rc);
    210                 break;
    211             }
    212 
    213             /*if(mm_camera_app_timedwait() == ETIMEDOUT) {
    214                     CDBG_ERROR("%s: Video Callback not received in time\n", __func__);
    215                     break;
    216             }*/
    217             mm_camera_app_wait();
    218             usleep(10*1000);
    219             if ( MM_CAMERA_OK != (rc = stopRecording(my_cam_app.cam_open))) {
    220                 CDBG_ERROR("%s: Stopvideorecording() err=%d\n", __func__, rc);
    221                 break;
    222             }
    223             result++;
    224         }
    225         if ( MM_CAMERA_OK != (rc = stopPreview(my_cam_app.cam_open))) {
    226             CDBG("%s: startPreview() err=%d\n", __func__, rc);
    227             break;
    228         }
    229         if ( mm_app_close(my_cam_app.cam_open) != MM_CAMERA_OK) {
    230             CDBG_ERROR("%s:mm_app_close() err=%d\n",__func__, rc);
    231             rc = -1;
    232             goto end;
    233         }
    234         if (result != MM_QCAMERA_APP_INTERATION) {
    235             printf("%s: Video Start/Stop Fails for Camera %d in %d iteration", __func__, i,j);
    236             rc = -1;
    237             break;
    238         }
    239 
    240         result = 0;
    241     }
    242     end:
    243     if (rc == 0) {
    244         printf("\nPassed\n");
    245     } else {
    246         printf("\nFailed\n");
    247     }
    248     CDBG("%s:END, rc = %d\n", __func__, rc);
    249     return rc;
    250 }
    251 
    252 int mm_app_tc_3(mm_camera_app_t *cam_apps)
    253 {
    254     int rc = MM_CAMERA_OK;
    255     int i,j;
    256     int result = 0;
    257 
    258     printf("\n Verifying RDI Stream on front and back camera...\n");
    259     if (cam_apps->num_cameras == 0) {
    260         CDBG_ERROR("%s:Query Failed: Num of cameras = %d\n",__func__, cam_apps->num_cameras);
    261         rc = -1;
    262         goto end;
    263     }
    264     CDBG_ERROR("SINGLE open RDI ");
    265     for (i = 1; i < cam_apps->num_cameras; i++) {
    266         if ( mm_app_open(i) != MM_CAMERA_OK) {
    267             CDBG_ERROR("%s:mm_app_open() err=%d\n",__func__, rc);
    268             rc = -1;
    269             goto end;
    270         }
    271         if (system_dimension_set(my_cam_app.cam_open) != MM_CAMERA_OK) {
    272             CDBG_ERROR("%s:system_dimension_set() err=%d\n",__func__, rc);
    273             rc = -1;
    274             goto end;
    275         }
    276         CDBG_ERROR("SINGLE start RDI case");
    277         for (j = 0; j < MM_QCAMERA_APP_INTERATION; j++) {
    278             if ( MM_CAMERA_OK != (rc = startRdi(my_cam_app.cam_open))) {
    279                 CDBG_ERROR("%s: StartVideorecording() err=%d\n", __func__, rc);
    280                 break;
    281             }
    282 
    283             /*if(mm_camera_app_timedwait() == ETIMEDOUT) {
    284                     CDBG_ERROR("%s: Video Callback not received in time\n", __func__);
    285                     break;
    286             }*/
    287             mm_camera_app_wait();
    288             usleep(10*1000);
    289             CDBG_ERROR("SINGLE stop RDI");
    290             if ( MM_CAMERA_OK != (rc = stopRdi(my_cam_app.cam_open))) {
    291                 CDBG_ERROR("%s: Stopvideorecording() err=%d\n", __func__, rc);
    292                 break;
    293             }
    294             result++;
    295         }
    296         CDBG_ERROR("SINGLE close RDI");
    297         if ( mm_app_close(my_cam_app.cam_open) != MM_CAMERA_OK) {
    298             CDBG_ERROR("%s:mm_app_close() err=%d\n",__func__, rc);
    299             rc = -1;
    300             goto end;
    301         }
    302         if (result != MM_QCAMERA_APP_INTERATION) {
    303             printf("%s: Video Start/Stop Fails for Camera %d in %d iteration", __func__, i,j);
    304             rc = -1;
    305             break;
    306         }
    307 
    308         result = 0;
    309     }
    310     end:
    311     if (rc == 0) {
    312         printf("\nPassed\n");
    313     } else {
    314         printf("\nFailed\n");
    315     }
    316     CDBG("%s:END, rc = %d\n", __func__, rc);
    317     return rc;
    318 }
    319 
    320 int mm_app_tc_4(mm_camera_app_t *cam_apps)
    321 {
    322     int rc = MM_CAMERA_OK;
    323     int i,j;
    324     int result = 0;
    325 
    326     printf("\n Verifying ZSL Snapshot on front and back camera...\n");
    327     for (i = 0; i < cam_apps->num_cameras; i++) {
    328         if ( mm_app_open(i) != MM_CAMERA_OK) {
    329             CDBG_ERROR("%s:mm_app_open() err=%d\n",__func__, rc);
    330             rc = -1;
    331             goto end;
    332         }
    333         if (system_dimension_set(my_cam_app.cam_open) != MM_CAMERA_OK) {
    334             CDBG_ERROR("%s:system_dimension_set() err=%d\n",__func__, rc);
    335             rc = -1;
    336             goto end;
    337         }
    338 
    339         if ( MM_CAMERA_OK != (rc = startPreview(my_cam_app.cam_open))) {
    340             CDBG_ERROR("%s: startPreview() err=%d\n", __func__, rc);
    341             break;
    342         }
    343         for (j = 0; j < MM_QCAMERA_APP_INTERATION; j++) {
    344             if ( MM_CAMERA_OK != (rc = takePicture_zsl(my_cam_app.cam_open))) {
    345                 CDBG_ERROR("%s: TakePicture() ZSL err=%d\n", __func__, rc);
    346                 break;
    347             }
    348             /*if(mm_camera_app_timedwait() == ETIMEDOUT) {
    349                     CDBG_ERROR("%s: Snapshot/Preview Callback not received in time or qbuf Faile\n", __func__);
    350                     break;
    351             }*/
    352             mm_camera_app_wait();
    353             result++;
    354         }
    355         if ( MM_CAMERA_OK != (rc = stopPreview(my_cam_app.cam_open))) {
    356             CDBG("%s: startPreview() err=%d\n", __func__, rc);
    357             break;
    358         }
    359         if ( mm_app_close(my_cam_app.cam_open) != MM_CAMERA_OK) {
    360             CDBG_ERROR("%s:mm_app_close() err=%d\n",__func__, rc);
    361             rc = -1;
    362             goto end;
    363         }
    364         if (result != MM_QCAMERA_APP_INTERATION) {
    365             printf("%s: Snapshot ZSL Start/Stop Fails for Camera %d in %d iteration", __func__, i,j);
    366             rc = -1;
    367             break;
    368         }
    369 
    370         result = 0;
    371     }
    372     end:
    373     if (rc == 0) {
    374         printf("\t***Passed***\n");
    375     } else {
    376         printf("\t***Failed***\n");
    377     }
    378     CDBG("%s:END, rc = %d\n", __func__, rc);
    379     return rc;
    380 }
    381 
    382 
    383 
    384 int mm_app_tc_5(mm_camera_app_t *cam_apps)
    385 {
    386     int rc = MM_CAMERA_OK;
    387     int i;
    388     printf("Running %s - open/close ,video0, open/close snapshot channel only\n", __func__);
    389 #if 0
    390     for (i = 0; i < MM_QCAMERA_APP_UTEST_MAX_MAIN_LOOP; i++) {
    391         if ( 0 != (rc = mm_app_open(cam_id, MM_CAMERA_OP_MODE_NOTUSED))) {
    392             CDBG("%s: open cam %d at opmode = %d err, loop=%d, rc=%d\n",
    393                  __func__, cam_id, MM_CAMERA_OP_MODE_NOTUSED, i, rc);
    394             goto end;
    395         }
    396         if (0 != (rc = mm_app_open_snapshot(cam_id))) {
    397             goto end;
    398         }
    399         if (0 != (rc = mm_app_close_snapshot(cam_id))) {
    400             goto end;
    401         }
    402         if ( 0 != (rc = mm_app_close(cam_id))) {
    403             CDBG("%s: close cam %d at opmode = %d err,loop=%d, rc=%d\n",
    404                  __func__, cam_id, MM_CAMERA_OP_MODE_NOTUSED, i, rc);
    405             goto end;
    406         }
    407     }
    408     end:
    409 #endif
    410     CDBG("%s:END, rc=%d\n", __func__, rc);
    411     return rc;
    412 }
    413 
    414 int mm_app_tc_6(mm_camera_app_t *cam_apps)
    415 {
    416     int rc = MM_CAMERA_OK;
    417     int i;
    418     printf("Running %s - simple preview \n", __func__);
    419 #if 0
    420     if ( 0 != (rc = mm_app_open(cam_id, MM_CAMERA_OP_MODE_NOTUSED))) {
    421         CDBG("%s: open cam %d at opmode = %d err, loop=%d, rc=%d\n",
    422              __func__, cam_id, MM_CAMERA_OP_MODE_NOTUSED, i, rc);
    423         goto end;
    424     }
    425 
    426     for (i = 0; i < MM_QCAMERA_APP_UTEST_MAX_MAIN_LOOP; i++) {
    427         if (0 != (rc = mm_app_init_preview(cam_id))) {
    428             goto end;
    429         }
    430         if (0 != (rc = mm_app_start_preview(cam_id))) {
    431             goto end;
    432         }
    433         /* sleep 8 seconds */
    434         usleep(8000000);
    435         if (0 != (rc = mm_app_stop_preview(cam_id))) {
    436             goto end;
    437         }
    438         if (0 != (rc=mm_app_deinit_preview(cam_id))) {
    439             goto end;
    440         }
    441         if (0 != (rc = mm_app_close_preview(cam_id))) {
    442             goto end;
    443         }
    444     }
    445     if ( 0 != (rc = mm_app_close(cam_id))) {
    446         CDBG("%s: close cam %d at opmode = %d err,loop=%d, rc=%d\n",
    447              __func__, cam_id, MM_CAMERA_OP_MODE_NOTUSED, i, rc);
    448         goto end;
    449     }
    450 end:
    451 #endif
    452     CDBG("%s:END, rc=%d\n", __func__, rc);
    453     return rc;
    454 }
    455 
    456 int mm_app_tc_7(mm_camera_app_t *cam_apps)
    457 {
    458     int rc = MM_CAMERA_OK;
    459     int i;
    460     printf("Running %s - simple preview and recording \n", __func__);
    461 #if 0
    462     if ( 0 != (rc = mm_app_open(cam_id, MM_CAMERA_OP_MODE_NOTUSED))) {
    463         CDBG("%s: open cam %d at opmode = %d err, loop=%d, rc=%d\n",
    464              __func__, cam_id, MM_CAMERA_OP_MODE_NOTUSED, i, rc);
    465         goto end;
    466     }
    467 
    468     for (i = 0; i < MM_QCAMERA_APP_UTEST_MAX_MAIN_LOOP; i++) {
    469         if (0 != (rc = mm_app_init_preview(cam_id))) {
    470             goto end;
    471         }
    472         if (0 != (rc = mm_app_start_preview(cam_id))) {
    473             goto end;
    474         }
    475         /* sleep 8 seconds */
    476         usleep(8000000);
    477         if (0 != (rc = mm_app_start_recording(cam_id))) {
    478             goto end;
    479         }
    480         usleep(1000000);
    481         if (0 != (rc = mm_app_stop_recording(cam_id))) {
    482             goto end;
    483         }
    484         usleep(8000000);
    485         if (0 != (rc = mm_app_stop_preview(cam_id))) {
    486             goto end;
    487         }
    488         if (0 != (rc=mm_app_deinit_preview(cam_id))) {
    489             goto end;
    490         }
    491         if (0 != (rc = mm_app_close_preview(cam_id))) {
    492             goto end;
    493         }
    494     }
    495     if ( 0 != (rc = mm_app_close(cam_id))) {
    496         CDBG("%s: close cam %d at opmode = %d err,loop=%d, rc=%d\n",
    497              __func__, cam_id, MM_CAMERA_OP_MODE_NOTUSED, i, rc);
    498         goto end;
    499     }
    500 end:
    501 #endif
    502     CDBG("%s:END, rc=%d\n", __func__, rc);
    503     return rc;
    504 }
    505 
    506 int mm_app_tc_8(mm_camera_app_t *cam_apps)
    507 {
    508     int rc = MM_CAMERA_OK;
    509     int i;
    510     printf("Running %s - preview, recording, and snapshot, then preview again \n", __func__);
    511 #if 0
    512     if ( 0 != (rc = mm_app_open(cam_id, MM_CAMERA_OP_MODE_NOTUSED))) {
    513         CDBG("%s: open cam %d at opmode = %d err, loop=%d, rc=%d\n",
    514              __func__, cam_id, MM_CAMERA_OP_MODE_NOTUSED, i, rc);
    515         goto end;
    516     }
    517 
    518     for (i = 0; i < MM_QCAMERA_APP_UTEST_MAX_MAIN_LOOP; i++) {
    519         if (0 != (rc = mm_app_init_preview(cam_id))) {
    520             goto end;
    521         }
    522         if (0 != (rc = mm_app_start_preview(cam_id))) {
    523             goto end;
    524         }
    525         /* sleep 8 seconds */
    526         usleep(8000000);
    527         if (0 != (rc = mm_app_start_recording(cam_id))) {
    528             goto end;
    529         }
    530         usleep(1000000);
    531         if (0 != (rc = mm_app_stop_recording(cam_id))) {
    532             goto end;
    533         }
    534         if (0 != (rc = mm_app_stop_preview(cam_id))) {
    535             goto end;
    536         }
    537         if (0!=(rc=mm_app_init_snapshot(cam_id))) {
    538             goto end;
    539         }
    540         if (0 != (rc=mm_app_take_picture(cam_id))) {
    541             goto end;
    542         }
    543         if ( 0 != (rc = mm_app_deinit_snahspot(cam_id))) {
    544             goto end;
    545         }
    546         if (0 != (rc = mm_app_start_preview(cam_id))) {
    547             goto end;
    548         }
    549         usleep(8000000);
    550         if (0 != (rc=mm_app_deinit_preview(cam_id))) {
    551             goto end;
    552         }
    553         if (0 != (rc = mm_app_close_preview(cam_id))) {
    554             goto end;
    555         }
    556     }
    557     if ( 0 != (rc = mm_app_close(cam_id))) {
    558         CDBG("%s: close cam %d at opmode = %d err,loop=%d, rc=%d\n",
    559              __func__, cam_id, MM_CAMERA_OP_MODE_NOTUSED, i, rc);
    560         goto end;
    561     }
    562 end:
    563 #endif
    564     CDBG("%s:END, rc=%d\n", __func__, rc);
    565     return rc;
    566 }
    567 
    568 int mm_app_tc_9(mm_camera_app_t *cam_apps) /*RDI snapshot*/
    569 {
    570     int rc = MM_CAMERA_OK;
    571     int i,j,k;
    572     int result = 0;
    573 
    574     printf("\n Verifying RDI Stream on front and back camera...\n");
    575     if (cam_apps->num_cameras == 0) {
    576         CDBG_ERROR("%s:Query Failed: Num of cameras = %d\n",__func__, cam_apps->num_cameras);
    577         rc = -1;
    578         goto end;
    579     }
    580     CDBG_ERROR("SINGLE open RDI snapshot test case");
    581     for (i = 1; i < cam_apps->num_cameras; i++) {
    582         if ( mm_app_open(i) != MM_CAMERA_OK) {
    583             CDBG_ERROR("%s:mm_app_open() err=%d\n",__func__, rc);
    584             rc = -1;
    585             goto end;
    586         }
    587         if (system_dimension_set(my_cam_app.cam_open) != MM_CAMERA_OK) {
    588             CDBG_ERROR("%s:system_dimension_set() err=%d\n",__func__, rc);
    589             rc = -1;
    590             goto end;
    591         }
    592         CDBG_ERROR("SINGLE start RDI case");
    593         for (j = 0; j < MM_QCAMERA_APP_INTERATION; j++) {
    594             if ( MM_CAMERA_OK != (rc = startRdi(my_cam_app.cam_open))) {
    595                 CDBG_ERROR("%s: StartVideorecording() err=%d\n", __func__, rc);
    596                 break;
    597             }
    598             usleep(10*1000);
    599             CDBG_ERROR("SINGLE start RDI snapshot");
    600             for (k = 0; k < MM_QCAMERA_APP_INTERATION; k++) {
    601               if ( MM_CAMERA_OK != (rc = takePicture_rdi(my_cam_app.cam_open))) {
    602                 CDBG_ERROR("%s: TakePicture() err=%d\n", __func__, rc);
    603                 break;
    604               }
    605               usleep(10*1000);
    606               mm_camera_app_wait();
    607               result++;
    608             }
    609             CDBG_ERROR("SINGLE stop RDI");
    610             if ( MM_CAMERA_OK != (rc = stopRdi(my_cam_app.cam_open))) {
    611                 CDBG_ERROR("%s: Stopvideorecording() err=%d\n", __func__, rc);
    612                 break;
    613             }
    614         }
    615         CDBG_ERROR("SINGLE close RDI");
    616         if ( mm_app_close(my_cam_app.cam_open) != MM_CAMERA_OK) {
    617             CDBG_ERROR("%s:mm_app_close() err=%d\n",__func__, rc);
    618             rc = -1;
    619             goto end;
    620         }
    621         if (result != (MM_QCAMERA_APP_INTERATION * MM_QCAMERA_APP_INTERATION)) {
    622             printf("%s: Video Start/Stop Fails for Camera %d in %d iteration", __func__, i,j);
    623             rc = -1;
    624             break;
    625         }
    626 
    627         result = 0;
    628     }
    629     end:
    630     if (rc == 0) {
    631         printf("\nPassed\n");
    632     } else {
    633         printf("\nFailed\n");
    634     }
    635     CDBG("%s:END, rc = %d\n", __func__, rc);
    636     return rc;
    637 }
    638 
    639 int mm_app_tc_10(mm_camera_app_t *cam_apps)
    640 {
    641     int rc = MM_CAMERA_OK;
    642     int i,j;
    643     int result = 0;
    644 
    645     printf("\n Verifying RAW Snapshot on front and back camera...\n");
    646     for (i = 0; i < cam_apps->num_cameras; i++) {
    647         if ( mm_app_open(i) != MM_CAMERA_OK) {
    648             CDBG_ERROR("%s:mm_app_open() err=%d\n",__func__, rc);
    649             rc = -1;
    650             goto end;
    651         }
    652         if (system_dimension_set(my_cam_app.cam_open) != MM_CAMERA_OK) {
    653             CDBG_ERROR("%s:system_dimension_set() err=%d\n",__func__, rc);
    654             rc = -1;
    655             goto end;
    656         }
    657 
    658         if ( MM_CAMERA_OK != (rc = startPreview(my_cam_app.cam_open))) {
    659             CDBG_ERROR("%s: startPreview() err=%d\n", __func__, rc);
    660             break;
    661         }
    662         for (j = 0; j < MM_QCAMERA_APP_INTERATION; j++) {
    663             if ( MM_CAMERA_OK != (rc = takePicture_raw(my_cam_app.cam_open))) {
    664                 CDBG_ERROR("%s: TakePicture() err=%d\n", __func__, rc);
    665                 break;
    666             }
    667             /*if(mm_camera_app_timedwait() == ETIMEDOUT) {
    668                     CDBG_ERROR("%s: Snapshot/Preview Callback not received in time or qbuf Faile\n", __func__);
    669                     break;
    670             }*/
    671             mm_camera_app_wait();
    672             result++;
    673         }
    674         if ( MM_CAMERA_OK != (rc = stopPreview(my_cam_app.cam_open))) {
    675             CDBG("%s: startPreview() err=%d\n", __func__, rc);
    676             break;
    677         }
    678         if ( mm_app_close(my_cam_app.cam_open) != MM_CAMERA_OK) {
    679             CDBG_ERROR("%s:mm_app_close() err=%d\n",__func__, rc);
    680             rc = -1;
    681             goto end;
    682         }
    683         if (result != MM_QCAMERA_APP_INTERATION) {
    684             printf("%s: Snapshot Start/Stop Fails for Camera %d in %d iteration", __func__, i,j);
    685             rc = -1;
    686             break;
    687         }
    688 
    689         result = 0;
    690     }
    691     end:
    692     if (rc == 0) {
    693         printf("\t***Passed***\n");
    694     } else {
    695         printf("\t***Failed***\n");
    696     }
    697     CDBG("%s:END, rc = %d\n", __func__, rc);
    698     return rc;
    699 }
    700 
    701 int mm_app_gen_test_cases()
    702 {
    703     int tc = 0;
    704     memset(mm_app_tc, 0, sizeof(mm_app_tc));
    705     if (tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_tc_0;
    706     if (tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_tc_1;
    707     if (tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_tc_2;
    708     //if (tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_tc_3; /*Enable only when RDI enabled for front camera*/
    709     //if(tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_tc_4;
    710     /*if(tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_tc_5;
    711       if(tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_tc_6;
    712       if(tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_tc_7;
    713       if(tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_tc_8;*/
    714     //if(tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_tc_9;  /*Enable only when rdi enabled for front camera*/
    715     if (tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_tc_10;
    716 
    717     /* test case for reprocess with preview only */
    718     /*
    719     if (tc < MM_QCAM_APP_TEST_NUM) {
    720         mm_app_tc[tc++].f = mm_app_tc_reprocess_preview_only;
    721     }
    722     */
    723     /* test case for reprocess with preview and recording */
    724     /*
    725     if (tc < MM_QCAM_APP_TEST_NUM) {
    726         mm_app_tc[tc++].f = mm_app_tc_reprocess_preview_and_recording;
    727     }
    728     */
    729 
    730     return tc;
    731 }
    732 
    733 int mm_app_unit_test_entry(mm_camera_app_t *cam_app)
    734 {
    735     int rc = MM_CAMERA_OK;
    736     int i, tc = 0;
    737     int cam_id = 0;
    738 
    739     tc = mm_app_gen_test_cases();
    740     CDBG("Running %d test cases\n",tc);
    741     for (i = 0; i < tc; i++) {
    742         mm_app_tc[i].r = mm_app_tc[i].f(cam_app);
    743         if (mm_app_tc[i].r != MM_CAMERA_OK) {
    744             printf("%s: test case %d error = %d, abort unit testing engine!!!!\n",
    745                    __func__, i, mm_app_tc[i].r);
    746             rc = mm_app_tc[i].r;
    747             goto end;
    748         }
    749     }
    750     end:
    751     printf("nTOTAL_TSET_CASE = %d, NUM_TEST_RAN = %d, rc=%d\n", tc, i, rc);
    752     return rc;
    753 }
    754 
    755 
    756 
    757 
    758