Eet_Image: Improve test with adding different lossy enums in eet_data_image_header_de...
authorArtem Popov <artem.popov@samsung.com>
Tue, 18 Apr 2017 08:07:07 +0000 (11:07 +0300)
committerArtem Popov <artem.popov@samsung.com>
Tue, 18 Apr 2017 08:07:15 +0000 (11:07 +0300)
Change-Id: If379be7585cafec97269a532bb6f04b1d2ba4d29
Signed-off-by: Artem Popov <artem.popov@samsung.com>
TC/eet/eet_image/utc_eet_data_image_header_decode_cipher.c

index 06f39988c058d1138cdf131347df9aa0182dd4f9..787c70be09c5bd6f64722f5afbc17c681c5224b3 100644 (file)
@@ -31,33 +31,87 @@ teardown(void)
 /**
  * @addtogroup eet_data_image_header_decode_cipher
  * @{
- * @objective Positive test case checks if the function is invoked successfully.
+ * @objective Positive test case checks if the function is invoked successfully.
  * @n Input Data:
  * @li pointer to encoded image pixel data;
  * @li "This is crypto key" - cipher to decode data;
  * @li size of encoded data;
  * @li pointer to variable to write image's width;
  * @li pointer to variable to write image's height;
- * @li pointer to variable to write image's alpha channel flag;
+ * @li pointer to variable to write image's alpha channel;
  * @li pointer to variable to write image's compression level;
  * @li pointer to variable to write image's quality encoding amount;
- * @li pointer to variable to write image's lossiness flag.
+ * @li pointer to variable to write image's lossiness enum.
  *
  * @procedure
- * @step 1 Encode image data.
+ * @step 1 Encode image data with EET_IMAGE_LOSSLESS.
  * @step 2 Decode image data header.
  * @step 3 Check returned value.
  *
- * @passcondition Function executes successfully and returns non-zero value.
+ * @passcondition Function executes successfully and returns values that were set by encode.
  * @}
  */
 START_TEST(utc_eet_data_image_header_decode_cipher_p)
 {
    int size = 0;
    unsigned int w = 0, h = 0;
-   int alpha = 0, compress = 0, quality = 0, lossy = 0;
+   int alpha = 0, compress = 0, quality = 0;
+   Eet_Image_Encoding lossy;
+
    void *encoded_data = eet_data_image_encode_cipher(test_noalpha.color, utc_eet_cipher,
-                                                     test_noalpha.w, test_noalpha.h, test_noalpha.alpha, 9, 100, 0, &size);
+                                                     test_noalpha.w, test_noalpha.h, test_noalpha.alpha, 9, 100, EET_IMAGE_LOSSLESS, &size);
+   if (!encoded_data)
+     {
+        ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Image is not encoded..", __FILE__, __LINE__);
+     }
+   int ret = eet_data_image_header_decode_cipher(encoded_data, utc_eet_cipher, size, &w, &h, &alpha, &compress, &quality, &lossy);
+
+   free(encoded_data);
+
+   if (!ret)
+     {
+        ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Function has returned 0", __FILE__, __LINE__);
+     }
+   else if (w != test_noalpha.w || h != test_noalpha.h || alpha != test_noalpha.alpha || compress != 9 || quality != 100 || lossy != EET_IMAGE_LOSSLESS)
+     {
+        ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. w=%d, h=%d, alpha=%d, compress=%d, quality=%d, lossy=%d", __FILE__, __LINE__, w, h, alpha, compress, quality, lossy);
+     }
+   printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
+}
+END_TEST
+
+/**
+ * @addtogroup eet_data_image_header_decode_cipher
+ * @{
+ * @objective Positive test case 2 checks if the function is invoked successfully.
+ * @n Input Data:
+ * @li pointer to encoded image pixel data;
+ * @li "This is crypto key" - cipher to decode data;
+ * @li size of encoded data;
+ * @li pointer to variable to write image's width;
+ * @li pointer to variable to write image's height;
+ * @li pointer to variable to write image's alpha channel;
+ * @li pointer to variable to write image's compression level;
+ * @li pointer to variable to write image's quality encoding amount;
+ * @li pointer to variable to write image's lossiness enum.
+ *
+ * @procedure
+ * @step 1 Encode image data with EET_IMAGE_JPEG.
+ * @step 2 Decode image data header.
+ * @step 3 Check returned value.
+ *
+ * @passcondition Function executes successfully and returns values that were set by encode
+ * except quality & compress.
+ * @}
+ */
+START_TEST(utc_eet_data_image_header_decode_cipher_p2)
+{
+   int size = 0;
+   unsigned int w = 0, h = 0;
+   int alpha = 0, compress = 0, quality = 0;
+   Eet_Image_Encoding lossy;
+   void *encoded_data = eet_data_image_encode_cipher(test_noalpha.color, utc_eet_cipher,
+                                                     test_noalpha.w, test_noalpha.h, test_noalpha.alpha, 9, 100, EET_IMAGE_JPEG, &size);
    if (!encoded_data)
      {
         ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Image is not encoded..", __FILE__, __LINE__);
@@ -70,7 +124,7 @@ START_TEST(utc_eet_data_image_header_decode_cipher_p)
      {
         ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Function has returned 0", __FILE__, __LINE__);
      }
-   else if (w != test_noalpha.w || h != test_noalpha.h || alpha != test_noalpha.alpha || compress != 9 || quality != 100 || lossy != 0)
+   else if (w != test_noalpha.w || h != test_noalpha.h || alpha != test_noalpha.alpha || lossy != EET_IMAGE_JPEG)
      {
         ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. w=%d, h=%d, alpha=%d, compress=%d, quality=%d, lossy=%d", __FILE__, __LINE__, w, h, alpha, compress, quality, lossy);
      }
@@ -89,24 +143,25 @@ END_TEST
  * @li size of encoded data;
  * @li pointer to variable to write image's width;
  * @li pointer to variable to write image's height;
- * @li pointer to variable to write image's alpha channel flag;
+ * @li pointer to variable to write image's alpha channel;
  * @li pointer to variable to write image's compression level;
  * @li pointer to variable to write image's quality encoding amount;
- * @li pointer to variable to write image's lossiness flag.
+ * @li pointer to variable to write image's lossiness enum.
  *
  * @procedure
  * @step 1 Encode image data.
  * @step 2 Call function 6 times and pass (in turn) NULL instead of all pointers to write properties
  * of the image (parameters 4-9).
  *
- * @passcondition Function doesn't cause segmentation fault.
+ * @passcondition Function returns 0 and doesn't cause segmentation fault.
  * @}
  */
 START_TEST(utc_eet_data_image_header_decode_cipher_n)
 {
    int size = 0;
    unsigned int w = 0, h = 0;
-   int alpha = 0, compress = 0, quality = 0, lossy = 0;
+   int alpha = 0, compress = 0, quality = 0;
+   Eet_Image_Encoding lossy = EET_IMAGE_LOSSLESS;
    void *encoded_data = eet_data_image_encode_cipher(test_noalpha.color, utc_eet_cipher,
                                                      test_noalpha.w, test_noalpha.h, test_noalpha.alpha, 9, 100, 0, &size);
    if (!encoded_data)
@@ -133,10 +188,10 @@ END_TEST
  * @li size of encoded data;
  * @li pointer to variable to write image's width;
  * @li pointer to variable to write image's height;
- * @li pointer to variable to write image's alpha channel flag;
+ * @li pointer to variable to write image's alpha channel;
  * @li pointer to variable to write image's compression level;
  * @li pointer to variable to write image's quality encoding amount;
- * @li pointer to variable to write image's lossiness flag.
+ * @li pointer to variable to write image's lossiness enum.
  *
  * @procedure
  * @step 1 Encode image data.
@@ -150,7 +205,8 @@ START_TEST(utc_eet_data_image_header_decode_cipher_n2)
 {
    int size = 0;
    unsigned int w = 0, h = 0;
-   int alpha = 0, compress = 0, quality = 0, lossy = 0;
+   int alpha = 0, compress = 0, quality = 0;
+   Eet_Image_Encoding lossy = EET_IMAGE_LOSSLESS;
    void *encoded_data = eet_data_image_encode_cipher(test_noalpha.color, utc_eet_cipher,
                                                      test_noalpha.w, test_noalpha.h, test_noalpha.alpha, 9, 100, 0, &size);
 
@@ -190,6 +246,7 @@ test_suite(void)
    tcase_set_timeout(tcase, 30);
    tcase_add_checked_fixture(tcase, setup, teardown);
    tcase_add_test(tcase, utc_eet_data_image_header_decode_cipher_p);
+   tcase_add_test(tcase, utc_eet_data_image_header_decode_cipher_p2);
    tcase_add_test(tcase, utc_eet_data_image_header_decode_cipher_n);
    tcase_add_test(tcase, utc_eet_data_image_header_decode_cipher_n2);
    suite_add_tcase(suite, tcase);