2 * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 #include <gmock/gmock.h>
21 #include <gtest/gtest.h>
24 #include <sys/types.h>
25 #include <sys/syscall.h>
27 #include <glib-object.h>
31 #include "mtpResponder.h"
33 using ::testing::InitGoogleTest;
34 using ::testing::Test;
35 using ::testing::TestCase;
37 #ifdef TIZEN_TEST_GCOV
38 extern "C" void __gcov_flush(void);
41 TEST(MtpResponder_t, mtp_init_p0)
45 add_rem_store_t sel = MTP_ADDREM_AUTO;
47 ret = mtp.mtp_init(sel);
49 EXPECT_EQ(ERROR_NONE, ret);
52 TEST(MtpResponder_t, mtp_init_p1)
56 add_rem_store_t sel = MTP_ADDREM_INTERNAL;
58 ret = mtp.mtp_init(sel);
60 EXPECT_EQ(ERROR_NONE, ret);
63 TEST(MtpResponder_t, mtp_init_p2)
67 add_rem_store_t sel = MTP_ADDREM_EXTERNAL;
69 ret = mtp.mtp_init(sel);
71 EXPECT_EQ(ERROR_NONE, ret);
74 TEST(MtpResponder_t, mtp_init_p3)
78 add_rem_store_t sel = MTP_ADDREM_ALL;
80 ret = mtp.mtp_init(sel);
82 EXPECT_EQ(ERROR_NONE, ret);
85 TEST(MtpResponder_t, mtp_deinit_p0)
90 ret = mtp.mtp_deinit();
92 EXPECT_EQ(ERROR_NONE, ret);
95 TEST(MtpResponder_t, hutil_get_storage_entry_n)
100 ret = mtp.hutil_get_storage_entry();
102 EXPECT_NE(ERROR_NONE, ret);
105 TEST(MtpResponder_t, hutil_get_storage_ids_p)
110 ret = mtp.hutil_get_storage_ids();
112 EXPECT_EQ(ERROR_NONE, ret);
115 TEST(MtpResponder_t, hutil_get_device_property_n)
120 ret = mtp.hutil_get_device_property();
122 EXPECT_NE(ERROR_NONE, ret);
125 TEST(MtpResponder_t, hutil_set_device_property_n)
130 ret = mtp.hutil_set_device_property();
132 EXPECT_NE(ERROR_NONE, ret);
135 TEST(MtpResponder_t, hutil_reset_device_entry_n)
140 ret = mtp.hutil_reset_device_entry();
142 EXPECT_NE(ERROR_NONE, ret);
145 TEST(MtpResponder_t, hutil_add_object_entry_n)
150 ret = mtp.hutil_add_object_entry();
152 EXPECT_NE(ERROR_NONE, ret);
155 TEST(MtpResponder_t, hutil_remove_object_entry_n)
160 ret = mtp.hutil_remove_object_entry();
162 EXPECT_NE(ERROR_NONE, ret);
165 TEST(MtpResponder_t, hutil_get_object_entry_n)
170 ret = mtp.hutil_get_object_entry();
172 EXPECT_NE(ERROR_NONE, ret);
175 TEST(MtpResponder_t, hutil_copy_object_entries_n)
180 ret = mtp.hutil_copy_object_entries();
182 EXPECT_NE(ERROR_NONE, ret);
185 TEST(MtpResponder_t, hutil_move_object_entry_n)
190 ret = mtp.hutil_move_object_entry();
192 EXPECT_NE(ERROR_NONE, ret);
195 TEST(MtpResponder_t, hutil_duplicate_object_entry_n)
200 ret = mtp.hutil_duplicate_object_entry();
202 EXPECT_NE(ERROR_NONE, ret);
205 TEST(MtpResponder_t, hutil_read_file_data_from_offset_n)
210 ret = mtp.hutil_read_file_data_from_offset();
212 EXPECT_NE(ERROR_NONE, ret);
215 TEST(MtpResponder_t, hutil_write_file_data_n)
220 ret = mtp.hutil_write_file_data();
222 EXPECT_NE(ERROR_NONE, ret);
225 TEST(MtpResponder_t, hutil_get_object_entry_size_n)
230 ret = mtp.hutil_get_object_entry_size();
232 EXPECT_NE(ERROR_NONE, ret);
235 #ifdef MTP_SUPPORT_SET_PROTECTION
236 TEST(MtpResponder_t, hutil_set_protection_n)
241 ret = mtp.hutil_set_protection();
243 EXPECT_NE(ERROR_NONE, ret);
245 #endif /* MTP_SUPPORT_SET_PROTECTION */
247 TEST(MtpResponder_t, hutil_get_num_objects_n)
252 ret = mtp.hutil_get_num_objects();
254 EXPECT_NE(ERROR_NONE, ret);
257 TEST(MtpResponder_t, hutil_get_object_handles_n)
262 ret = mtp.hutil_get_object_handles();
264 EXPECT_NE(ERROR_NONE, ret);
267 TEST(MtpResponder_t, hutil_construct_object_entry_p)
272 ret = mtp.hutil_construct_object_entry();
274 EXPECT_EQ(ERROR_NONE, ret);
277 //========================================
279 TEST(MtpResponder_t, hutil_construct_object_entry_prop_list_n)
284 ret = mtp.hutil_construct_object_entry_prop_list();
286 EXPECT_NE(ERROR_NONE, ret);
289 TEST(MtpResponder_t, hutil_get_object_prop_value_n)
294 ret = mtp.hutil_get_object_prop_value();
296 EXPECT_NE(ERROR_NONE, ret);
299 TEST(MtpResponder_t, hutil_update_object_property_n)
304 ret = mtp.hutil_update_object_property();
306 EXPECT_NE(ERROR_NONE, ret);
309 TEST(MtpResponder_t, hutil_get_prop_desc_n)
314 ret = mtp.hutil_get_prop_desc();
316 EXPECT_NE(ERROR_NONE, ret);
319 TEST(MtpResponder_t, hutil_get_object_prop_supported_p)
324 ret = mtp.hutil_get_object_prop_supported();
326 EXPECT_EQ(ERROR_NONE, ret);
329 TEST(MtpResponder_t, hutil_get_object_prop_list_n)
334 ret = mtp.hutil_get_object_prop_list();
336 EXPECT_NE(ERROR_NONE, ret);
339 TEST(MtpResponder_t, hutil_add_object_references_enhanced_p)
344 ret = mtp.hutil_add_object_references_enhanced();
346 EXPECT_EQ(ERROR_NONE, ret);
349 TEST(MtpResponder_t, hutil_remove_object_reference_p)
354 ret = mtp.hutil_remove_object_reference();
356 EXPECT_EQ(ERROR_NONE, ret);
359 TEST(MtpResponder_t, hutil_get_object_references_n)
364 ret = mtp.hutil_get_object_references();
366 EXPECT_NE(ERROR_NONE, ret);
369 TEST(MtpResponder_t, hutil_get_number_of_objects_p)
374 ret = mtp.hutil_get_number_of_objects();
376 EXPECT_EQ(ERROR_NONE, ret);
379 TEST(MtpResponder_t, hutil_get_interdep_prop_config_list_size_p)
384 ret = mtp.hutil_get_interdep_prop_config_list_size();
386 EXPECT_EQ(ERROR_NONE, ret);
389 TEST(MtpResponder_t, hutil_get_interdep_prop_config_list_data_p)
394 ret = mtp.hutil_get_interdep_prop_config_list_data();
396 EXPECT_EQ(ERROR_NONE, ret);
399 TEST(MtpResponder_t, hutil_get_playback_skip_n)
404 ret = mtp.hutil_get_playback_skip();
406 EXPECT_NE(ERROR_NONE, ret);
409 TEST(MtpResponder_t, hutil_format_storage_n)
414 ret = mtp.hutil_format_storage();
416 EXPECT_NE(ERROR_NONE, ret);
419 TEST(MtpResponder_t, hutil_get_storage_info_size_p)
424 ret = mtp.hutil_get_storage_info_size();
426 EXPECT_EQ(ERROR_NONE, ret);
429 //================== _MTP_CMD_HANDLER_H_ ======================
431 TEST(MtpResponder_t, cmd_hdlr_send_response_n)
436 ret = mtp.cmd_hdlr_send_response();
438 EXPECT_EQ(ERROR_NONE, ret);
441 TEST(MtpResponder_t, cmd_hdlr_send_response_code_n)
446 ret = mtp.cmd_hdlr_send_response_code();
448 EXPECT_EQ(ERROR_NONE, ret);
451 //================== _MTP_EVENT_HANDLER_H_ ======================
453 TEST(MtpResponder_t, hdlr_get_param_cmd_container_p)
458 ret = mtp.hdlr_get_param_cmd_container();
460 EXPECT_EQ(ERROR_NONE, ret);
463 TEST(MtpResponder_t, hdlr_add_param_resp_container_p)
468 ret = mtp.hdlr_add_param_resp_container();
470 EXPECT_EQ(ERROR_NONE, ret);
473 TEST(MtpResponder_t, hdlr_validate_cmd_container_p)
478 ret = mtp.hdlr_validate_cmd_container();
480 EXPECT_NE(ERROR_NONE, ret);
483 TEST(MtpResponder_t, hdlr_alloc_buf_data_container_p)
488 ret = mtp.hdlr_alloc_buf_data_container();
490 EXPECT_EQ(ERROR_NONE, ret);
494 TEST(MtpResponder_t, hdlr_send_data_container_n)
499 ret = mtp.hdlr_send_data_container();
501 EXPECT_EQ(ERROR_NONE, ret);
504 TEST(MtpResponder_t, hdlr_send_bulk_data_n)
509 ret = mtp.hdlr_send_bulk_data();
511 EXPECT_EQ(ERROR_NONE, ret);
514 TEST(MtpResponder_t, hdlr_rcv_data_container_p)
519 ret = mtp.hdlr_rcv_data_container();
521 EXPECT_EQ(ERROR_NONE, ret);
524 TEST(MtpResponder_t, hdlr_get_payload_size_p)
529 ret = mtp.hdlr_get_payload_size();
531 EXPECT_EQ(ERROR_NONE, ret);
534 TEST(MtpResponder_t, hdlr_get_payload_data_p)
539 ret = mtp.hdlr_get_payload_data();
541 EXPECT_EQ(ERROR_NONE, ret);
544 TEST(MtpResponder_t, hdlr_resp_container_init_p)
549 ret = mtp.hdlr_resp_container_init();
551 EXPECT_EQ(ERROR_NONE, ret);
554 TEST(MtpResponder_t, hdlr_init_event_container_p)
559 ret = mtp.hdlr_init_event_container();
561 EXPECT_EQ(ERROR_NONE, ret);
564 TEST(MtpResponder_t, hdlr_init_event_container_with_param_p)
569 ret = mtp.hdlr_init_event_container_with_param();
571 EXPECT_EQ(ERROR_NONE, ret);
574 TEST(MtpResponder_t, hdlr_conv_cmd_container_byte_order_p)
579 ret = mtp.hdlr_conv_cmd_container_byte_order();
581 EXPECT_EQ(ERROR_NONE, ret);
584 TEST(MtpResponder_t, hdlr_conv_data_container_byte_order_p)
589 ret = mtp.hdlr_conv_data_container_byte_order();
591 EXPECT_EQ(ERROR_NONE, ret);
594 //mtp_bool _hdlr_rcv_file_in_data_container(data_container_t *dst, mtp_char *filepath, mtp_uint32 path_len);
598 //========================================
600 int main(int argc, char **argv)
602 #ifdef TIZEN_TEST_GCOV
603 setenv("GCOV_PREFIX", "/tmp", 1);
606 InitGoogleTest(&argc, argv);
607 int ret = RUN_ALL_TESTS();
609 #ifdef TIZEN_TEST_GCOV