assert_int_equal(conf, expected);
}
+static void test_open_device_vid_pid(void **state)
+{
+ libhusb_device_handle *handle;
+ libhusb_context *ctx;
+ libusb_device_handle *lusb_dev_handle;
+ libusb_device *lusb_device;
+ uint16_t vid, pid;
+
+ vid = (uint16_t)rand();
+ pid = (uint16_t)rand();
+ lusb_dev_handle = (libusb_device_handle *)rand();
+ lusb_device = (libusb_device *)rand();
+
+ ctx = (libhusb_context *)(*state);
+ assert_non_null(ctx);
+
+ expect_value(libusb_open_device_with_vid_pid, ctx, ctx->lusb_ctx);
+ expect_value(libusb_open_device_with_vid_pid, vendor_id, vid);
+ expect_value(libusb_open_device_with_vid_pid, product_id, pid);
+ will_return(libusb_open_device_with_vid_pid, lusb_dev_handle);
+ will_return(libusb_get_device, lusb_device);
+
+ handle = libhusb_device_open_with_vid_pid(ctx, vid, pid);
+
+ assert_non_null(handle);
+ assert_ptr_equal(handle->lusb_dev_handle, lusb_dev_handle);
+ assert_non_null(handle->device);
+ assert_ptr_equal(handle->device->lusb_dev, lusb_device);
+}
+
/* Custom macro for defining test with given name and fixed teardown function */
#define HUSB_TEST(func, setup, teardown) \
cmocka_unit_test_setup_teardown(func, setup, teardown)
HUSB_TEST_DEVICE(test_get_address),
HUSB_TEST_DEVICE(test_get_device_descriptor),
HUSB_TEST_DEV_HANDLE(test_get_active_config),
+ HUSB_TEST_CTX(test_open_device_vid_pid),
};