• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024-2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "usbfn_mtp_test.h"
17 
18 #include <cinttypes>
19 #include <cstdio>
20 #include <iostream>
21 #include <sstream>
22 #include <vector>
23 #include <fcntl.h>
24 
25 #include "directory_ex.h"
26 #include "file_ex.h"
27 #include "hdf_log.h"
28 #include "securec.h"
29 #include "v1_0/iusb_interface.h"
30 #include "v1_0/iusbfn_mtp_interface.h"
31 #include "v1_0/usb_types.h"
32 #include "v1_0/usbfn_mtp_types.h"
33 
34 #define HDF_LOG_TAG usbfn_mtp_ut
35 
36 using namespace testing::ext;
37 using namespace OHOS;
38 using namespace OHOS::HDI::Usb::V1_0;
39 using namespace std;
40 using namespace OHOS::HDI::Usb::Gadget::Mtp::V1_0;
41 
42 namespace {
43 constexpr int32_t SLEEP_TIME = 3;
44 constexpr int32_t MTP_EVENT_PACKET_MAX_BYTES = 28;
45 constexpr int32_t MTP_EVENT_PACKET_VALID_LEN = 20;
46 constexpr int32_t MTP_EVENT_PACKET_INVALID_LEN = 29;
47 constexpr uint16_t CMD_CODE_GET_DEVICE_INFO = 0x1001;
48 constexpr uint32_t MTP_PACKET_HEADER_SIZE = 12;
49 constexpr uint32_t BULK_IN_ONCE_MAX_SIZE = 1024;
50 constexpr uint32_t BULK_IN_LESS_THEN_ONCE = 45;
51 constexpr uint32_t BULK_IN_MORE_THEN_ONCE = 2023;
52 constexpr int64_t MTP_MAX_FILE_SIZE = 0xFFFFFFFFLL;
53 constexpr int64_t GEN_FILE_BUF_SIZE = 1024;
54 constexpr int64_t GEN_FILE_LIMIT_512MB = 512 * 1024 * 1024;
55 constexpr int32_t PRINT_VECTOR_MAX_LENGTH = 30;
56 const std::string WORKED_UT_PATH = "/data/local/tmp/";
57 const std::string MTP_TEST_SEND_FILE = "/data/local/tmp/sampleFile.mtp";
58 const std::string MTP_TEST_RECV_FILE = "/data/local/tmp/sampleFile.mtp";
59 
60 sptr<IUsbfnMtpInterface> g_usbfnMtpInterface = nullptr;
61 sptr<IUsbInterface> g_usbInterface = nullptr;
62 int32_t g_currentFunc = USB_FUNCTION_NONE;
63 int32_t g_fileTestCount = 0;
64 
65 struct UsbFnMtpFileSlice g_mfs = {
66     .offset = 0,
67     .length = 0,
68     .command = 0,
69     .transactionId = 0,
70 };
71 
PrintVector(const std::string & msg,std::vector<uint8_t> & data,bool hexFormat)72 void PrintVector(const std::string &msg, std::vector<uint8_t> &data, bool hexFormat)
73 {
74     size_t printLen = data.size();
75     bool ignore = false;
76     if (printLen > static_cast<size_t>(PRINT_VECTOR_MAX_LENGTH)) {
77         printLen = static_cast<size_t>(PRINT_VECTOR_MAX_LENGTH);
78         ignore = true;
79     }
80     std::stringstream ss;
81     for (size_t i = 0; i < printLen; i++) {
82         if (hexFormat) {
83             ss << std::hex << "0x" << (0xFF & data.at(i)) << " ";
84         } else {
85             ss << data.at(i);
86         }
87     }
88     std::string output = msg + std::string("(") + std::to_string(printLen) + std::string("):") + ss.str();
89     if (ignore) {
90         output += "......";
91     }
92     HDF_LOGV("UsbfnMtpTestAdditional::PrintVector %{public}s", output.c_str());
93 }
94 
GetFileSize(const std::string & pathName)95 uint64_t GetFileSize(const std::string &pathName)
96 {
97     struct stat statbuf;
98     uint64_t ret = stat(pathName.c_str(), &statbuf);
99     if (ret != 0) {
100         return 0;
101     }
102     return static_cast<uint64_t>(statbuf.st_size);
103 }
104 
WriteRandomDataToFile(const std::string & pathName,uint64_t fileSize)105 bool WriteRandomDataToFile(const std::string &pathName, uint64_t fileSize)
106 {
107     int32_t random = open("/dev/urandom", O_RDONLY);
108     if (random < 0) {
109         HDF_LOGE("UsbfnMtpTestAdditional::WriteRandomDataToFile get random data failed");
110         return false;
111     }
112     FILE *opFile = std::fopen(pathName.c_str(), "w");
113     if (opFile == nullptr) {
114         HDF_LOGE("UsbfnMtpTestAdditional::WriteRandomDataToFile create file failed: %{public}s", pathName.c_str());
115         return false;
116     }
117     char buffer[GEN_FILE_BUF_SIZE];
118     int64_t count = static_cast<int64_t>(fileSize);
119     while (count > 0) {
120         (void)memset_s(buffer, sizeof(buffer), 0, sizeof(buffer));
121         int64_t readSize = count > GEN_FILE_BUF_SIZE ? GEN_FILE_BUF_SIZE : count;
122         ssize_t readActual = read(random, static_cast<void *>(buffer), static_cast<size_t>(readSize));
123         if (readActual != static_cast<ssize_t>(readSize)) {
124             HDF_LOGW("UsbfnMtpTestAdditional::WriteRandomDataToFile read random failed");
125             break;
126         }
127         size_t writeActual = std::fwrite(static_cast<void *>(buffer), 1, static_cast<size_t>(readSize), opFile);
128         if (writeActual != static_cast<size_t>(readSize)) {
129             HDF_LOGW("UsbfnMtpTestAdditional::WriteRandomDataToFile write failed");
130             break;
131         }
132         count -= readSize;
133     }
134     std::fflush(opFile);
135     std::fclose(opFile);
136     close(random);
137     HDF_LOGV("UsbfnMtpTestAdditional::WriteRandomDataToFile file %{public}s: %{public}" PRIu64 "/%{public}" PRIu64 "",
138              pathName.c_str(), GetFileSize(pathName), fileSize);
139     return count > 0 ? false : true;
140 }
141 
GenerateFile(const std::string & pathName,int64_t fileSize)142 bool GenerateFile(const std::string &pathName, int64_t fileSize)
143 {
144     if (GetFileSize(pathName) == static_cast<uint64_t>(fileSize)) {
145         HDF_LOGW("UsbfnMtpTestAdditional::GenerateFile file already exist");
146         return true;
147     }
148     if (fileSize > GEN_FILE_LIMIT_512MB) {
149         int32_t ret = truncate(pathName.c_str(), static_cast<off_t>(fileSize));
150         if (ret != 0) {
151             HDF_LOGE("UsbfnMtpTestAdditional::GenerateFile fail to truncate file to size: %{public}" PRId64 "",
152                      fileSize);
153             return false;
154         }
155         HDF_LOGV("UsbfnMtpTestAdditional::GenerateFile truncate %{public}s %{public}" PRId64 "", pathName.c_str(),
156                  fileSize);
157         return true;
158     }
159     return WriteRandomDataToFile(pathName, static_cast<uint64_t>(fileSize));
160 }
161 
SetUpTestCase(void)162 void UsbfnMtpTestAdditional::SetUpTestCase(void)
163 {
164     ASSERT_TRUE(GetCurrentProcPath() == WORKED_UT_PATH);
165     std::cout << "===>please connect to PC use USB 3.0 interface, press enter to continue set function to mtp"
166               << std::endl;
167     int32_t c;
168     while ((c = getchar()) != '\n' && c != EOF) {
169     }
170 
171     g_usbInterface = IUsbInterface::Get();
172     ASSERT_TRUE(g_usbInterface != nullptr);
173     auto ret = g_usbInterface->SetPortRole(DEFAULT_PORT_ID, POWER_ROLE_SINK, DATA_ROLE_DEVICE);
174     sleep(SLEEP_TIME);
175     if (ret != 0) {
176         ASSERT_EQ(HDF_ERR_NOT_SUPPORT, ret);
177     } else {
178         ASSERT_EQ(0, ret);
179     }
180     ret = g_usbInterface->GetCurrentFunctions(g_currentFunc);
181     ASSERT_EQ(0, ret);
182     std::cout << "===>current function=" << g_currentFunc << ", set function to mtp, please wait" << std::endl;
183     ret = g_usbInterface->SetCurrentFunctions(USB_FUNCTION_MTP);
184     ASSERT_EQ(0, ret);
185 
186     g_usbfnMtpInterface = IUsbfnMtpInterface::Get();
187     ASSERT_TRUE(g_usbfnMtpInterface != nullptr);
188     ret = g_usbfnMtpInterface->Start();
189     ASSERT_EQ(0, ret);
190 }
191 
TearDownTestCase(void)192 void UsbfnMtpTestAdditional::TearDownTestCase(void)
193 {
194     HDF_LOGV("UsbfnMtpTestAdditional::TearDownTestCase");
195     ASSERT_TRUE(g_usbfnMtpInterface != nullptr);
196     auto ret = g_usbfnMtpInterface->Stop();
197     ASSERT_EQ(0, ret);
198     ASSERT_TRUE(g_usbInterface != nullptr);
199     ret = g_usbInterface->SetCurrentFunctions(g_currentFunc);
200     ASSERT_EQ(0, ret);
201     if (g_fileTestCount == 0) {
202         return;
203     }
204     /* 1 means single test, run with '--gtest_filter=' option */
205     if (g_fileTestCount == 1) {
206         std::cout << "===>please delete temporary test file if needed: sendfile=" << MTP_TEST_SEND_FILE
207                   << " recvfile=" << MTP_TEST_RECV_FILE << std::endl;
208         return;
209     }
210     if (FileExists(std::string(MTP_TEST_SEND_FILE))) {
211         if (remove(MTP_TEST_SEND_FILE.c_str()) != 0) {
212             std::cout << "[-] remove send file failed: " << MTP_TEST_SEND_FILE << std::endl;
213         }
214     }
215     if (FileExists(std::string(MTP_TEST_RECV_FILE))) {
216         if (remove(MTP_TEST_RECV_FILE.c_str()) != 0) {
217             std::cout << "[-] remove recv file failed: " << MTP_TEST_RECV_FILE << std::endl;
218         }
219     }
220 }
221 
SetUp(void)222 void UsbfnMtpTestAdditional::SetUp(void) {}
223 
TearDown(void)224 void UsbfnMtpTestAdditional::TearDown(void) {}
225 /**
226  * @tc.number: SUB_USB_DeviceManager_HDI_MTPPTPTest_0100
227  * @tc.name: testHdiUsbMtpTestReceiveFile001
228  * @tc.desc: mfs Indicates the mtp file slice info. mfs.length = 1.
229  */
230 HWTEST_F(UsbfnMtpTestAdditional, testHdiUsbMtpTestReceiveFile001, Function | MediumTest | Level1)
231 {
232     ASSERT_TRUE(g_usbfnMtpInterface != nullptr);
233     ASSERT_TRUE(GetCurrentProcPath() == WORKED_UT_PATH);
234     g_fileTestCount++;
235     struct UsbFnMtpFileSlice mfs = g_mfs;
236     mfs.length = 1;
237     std::cout << "testHdiUsbMtpTestReceiveFile001===>use libusb in PC launch bulk-out transfer(size = " << mfs.length
238               << "), press enter to continue" << std::endl;
239     int32_t c;
240     while ((c = getchar()) != '\n' && c != EOF) {
241     }
242 
243     std::string filePathName = MTP_TEST_RECV_FILE;
244     mfs.fd = open(filePathName.c_str(), O_CREAT | O_RDWR | O_TRUNC, 0777);
245     ASSERT_GT(mfs.fd, 0);
246     auto ret = g_usbfnMtpInterface->ReceiveFile(mfs);
247     close(mfs.fd);
248     ASSERT_EQ(ret, 0);
249     ASSERT_EQ(GetFileSize(filePathName), static_cast<uint64_t>(mfs.length));
250 }
251 
252 /**
253  * @tc.number: SUB_USB_DeviceManager_HDI_MTPPTPTest_0200
254  * @tc.name: testHdiUsbMtpTestReceiveFile002
255  * @tc.desc: mfs Indicates the mtp file slice info. mfs.length = 100.
256  */
257 HWTEST_F(UsbfnMtpTestAdditional, testHdiUsbMtpTestReceiveFile002, Function | MediumTest | Level1)
258 {
259     ASSERT_TRUE(g_usbfnMtpInterface != nullptr);
260     ASSERT_TRUE(GetCurrentProcPath() == WORKED_UT_PATH);
261     g_fileTestCount++;
262     struct UsbFnMtpFileSlice mfs = g_mfs;
263     mfs.length = 100;
264     std::cout << "testHdiUsbMtpTestReceiveFile002===>use libusb in PC launch bulk-out transfer(size = " << mfs.length
265               << "), press enter to continue" << std::endl;
266     int32_t c;
267     while ((c = getchar()) != '\n' && c != EOF) {
268     }
269 
270     std::string filePathName = MTP_TEST_RECV_FILE;
271     mfs.fd = open(filePathName.c_str(), O_CREAT | O_RDWR | O_TRUNC, 0777);
272     ASSERT_GT(mfs.fd, 0);
273     auto ret = g_usbfnMtpInterface->ReceiveFile(mfs);
274     close(mfs.fd);
275     ASSERT_EQ(ret, 0);
276     ASSERT_EQ(GetFileSize(filePathName), static_cast<uint64_t>(mfs.length));
277 }
278 
279 /**
280  * @tc.number: SUB_USB_DeviceManager_HDI_MTPPTPTest_0300
281  * @tc.name: testHdiUsbMtpTestReceiveFile003
282  * @tc.desc: mfs Indicates the mtp file slice info. mfs.length = 255.
283  */
284 HWTEST_F(UsbfnMtpTestAdditional, testHdiUsbMtpTestReceiveFile003, Function | MediumTest | Level1)
285 {
286     ASSERT_TRUE(g_usbfnMtpInterface != nullptr);
287     ASSERT_TRUE(GetCurrentProcPath() == WORKED_UT_PATH);
288     g_fileTestCount++;
289     struct UsbFnMtpFileSlice mfs = g_mfs;
290     mfs.length = 255;
291     std::cout << "testHdiUsbMtpTestReceiveFile003===>use libusb in PC launch bulk-out transfer(size = " << mfs.length
292               << "), press enter to continue" << std::endl;
293     int32_t c;
294     while ((c = getchar()) != '\n' && c != EOF) {
295     }
296 
297     std::string filePathName = MTP_TEST_RECV_FILE;
298     mfs.fd = open(filePathName.c_str(), O_CREAT | O_RDWR | O_TRUNC, 0777);
299     ASSERT_GT(mfs.fd, 0);
300     auto ret = g_usbfnMtpInterface->ReceiveFile(mfs);
301     close(mfs.fd);
302     ASSERT_EQ(ret, 0);
303     ASSERT_EQ(GetFileSize(filePathName), static_cast<uint64_t>(mfs.length));
304 }
305 
306 /**
307  * @tc.number: SUB_USB_DeviceManager_HDI_MTPPTPTest_0400
308  * @tc.name: testHdiUsbMtpTestReceiveFile004
309  * @tc.desc: mfs Indicates the mtp file slice info. mfs.length = 1000.
310  */
311 HWTEST_F(UsbfnMtpTestAdditional, testHdiUsbMtpTestReceiveFile004, Function | MediumTest | Level1)
312 {
313     ASSERT_TRUE(g_usbfnMtpInterface != nullptr);
314     ASSERT_TRUE(GetCurrentProcPath() == WORKED_UT_PATH);
315     g_fileTestCount++;
316     struct UsbFnMtpFileSlice mfs = g_mfs;
317     mfs.length = 1000;
318     std::cout << "testHdiUsbMtpTestReceiveFile004===>use libusb in PC launch bulk-out transfer(size = " << mfs.length
319               << "), press enter to continue" << std::endl;
320     int32_t c;
321     while ((c = getchar()) != '\n' && c != EOF) {
322     }
323 
324     std::string filePathName = MTP_TEST_RECV_FILE;
325     mfs.fd = open(filePathName.c_str(), O_CREAT | O_RDWR | O_TRUNC, 0777);
326     ASSERT_GT(mfs.fd, 0);
327     auto ret = g_usbfnMtpInterface->ReceiveFile(mfs);
328     close(mfs.fd);
329     ASSERT_EQ(ret, 0);
330     ASSERT_EQ(GetFileSize(filePathName), static_cast<uint64_t>(mfs.length));
331 }
332 
333 /**
334  * @tc.number: SUB_USB_DeviceManager_HDI_MTPPTPTest_0500
335  * @tc.name: testHdiUsbMtpTestReceiveFile005
336  * @tc.desc: mfs Indicates the mtp file slice info. mfs.length = MTP_MAX_FILE_SIZE - 2.
337  */
338 HWTEST_F(UsbfnMtpTestAdditional, testHdiUsbMtpTestReceiveFile005, Function | MediumTest | Level1)
339 {
340     ASSERT_TRUE(g_usbfnMtpInterface != nullptr);
341     ASSERT_TRUE(GetCurrentProcPath() == WORKED_UT_PATH);
342     g_fileTestCount++;
343     struct UsbFnMtpFileSlice mfs = g_mfs;
344     mfs.length = MTP_MAX_FILE_SIZE - 2;
345     std::cout << "testHdiUsbMtpTestReceiveFile005===>use libusb in PC launch bulk-out transfer(size = " << mfs.length
346               << "), press enter to continue" << std::endl;
347     int32_t c;
348     while ((c = getchar()) != '\n' && c != EOF) {
349     }
350 
351     std::string filePathName = MTP_TEST_RECV_FILE;
352     mfs.fd = open(filePathName.c_str(), O_CREAT | O_RDWR | O_TRUNC, 0777);
353     ASSERT_GT(mfs.fd, 0);
354     auto ret = g_usbfnMtpInterface->ReceiveFile(mfs);
355     close(mfs.fd);
356     ASSERT_EQ(ret, 0);
357     ASSERT_EQ(GetFileSize(filePathName), static_cast<uint64_t>(mfs.length));
358 }
359 
360 /**
361  * @tc.number: SUB_USB_DeviceManager_HDI_MTPPTPTest_0600
362  * @tc.name: testHdiUsbMtpTestReceiveFile006
363  * @tc.desc: mfs Indicates the mtp file slice info. mfs.length = MTP_MAX_FILE_SIZE - 1024.
364  */
365 HWTEST_F(UsbfnMtpTestAdditional, testHdiUsbMtpTestReceiveFile006, Function | MediumTest | Level1)
366 {
367     ASSERT_TRUE(g_usbfnMtpInterface != nullptr);
368     ASSERT_TRUE(GetCurrentProcPath() == WORKED_UT_PATH);
369     g_fileTestCount++;
370     struct UsbFnMtpFileSlice mfs = g_mfs;
371     mfs.length = MTP_MAX_FILE_SIZE - 1024;
372     std::cout << "testHdiUsbMtpTestReceiveFile006===>use libusb in PC launch bulk-out transfer(size = " << mfs.length
373               << "), press enter to continue" << std::endl;
374     int32_t c;
375     while ((c = getchar()) != '\n' && c != EOF) {
376     }
377 
378     std::string filePathName = MTP_TEST_RECV_FILE;
379     mfs.fd = open(filePathName.c_str(), O_CREAT | O_RDWR | O_TRUNC, 0777);
380     ASSERT_GT(mfs.fd, 0);
381     auto ret = g_usbfnMtpInterface->ReceiveFile(mfs);
382     close(mfs.fd);
383     ASSERT_EQ(ret, 0);
384     ASSERT_EQ(GetFileSize(filePathName), static_cast<uint64_t>(mfs.length));
385 }
386 
387 /**
388  * @tc.number: SUB_USB_DeviceManager_HDI_MTPPTPTest_0700
389  * @tc.name: testHdiUsbMtpTestReceiveFile007
390  * @tc.desc: mfs Indicates the mtp file slice info.mfs.length = 1 mfs.command = 1 mfs.transactionId = 1.
391  */
392 HWTEST_F(UsbfnMtpTestAdditional, testHdiUsbMtpTestReceiveFile007, Function | MediumTest | Level1)
393 {
394     ASSERT_TRUE(g_usbfnMtpInterface != nullptr);
395     ASSERT_TRUE(GetCurrentProcPath() == WORKED_UT_PATH);
396     g_fileTestCount++;
397     struct UsbFnMtpFileSlice mfs = g_mfs;
398     mfs.length = 1;
399     mfs.command = 1;
400     mfs.transactionId = 1;
401     std::cout << "testHdiUsbMtpTestReceiveFile007===>use libusb in PC launch bulk-out transfer(size = " << mfs.length
402               << "), press enter to continue" << std::endl;
403     int32_t c;
404     while ((c = getchar()) != '\n' && c != EOF) {
405     }
406 
407     std::string filePathName = MTP_TEST_RECV_FILE;
408     mfs.fd = open(filePathName.c_str(), O_CREAT | O_RDWR | O_TRUNC, 0777);
409     ASSERT_GT(mfs.fd, 0);
410     auto ret = g_usbfnMtpInterface->ReceiveFile(mfs);
411     close(mfs.fd);
412     ASSERT_EQ(ret, 0);
413     ASSERT_EQ(GetFileSize(filePathName), static_cast<uint64_t>(mfs.length));
414 }
415 
416 /**
417  * @tc.number: SUB_USB_DeviceManager_HDI_MTPPTPTest_0800
418  * @tc.name: testHdiUsbMtpTestReceiveFile008
419  * @tc.desc: mfs Indicates the mtp file slice info. mfs.length = 100 mfs.command = 100 mfs.transactionId = 100.
420  */
421 HWTEST_F(UsbfnMtpTestAdditional, testHdiUsbMtpTestReceiveFile008, Function | MediumTest | Level1)
422 {
423     ASSERT_TRUE(g_usbfnMtpInterface != nullptr);
424     ASSERT_TRUE(GetCurrentProcPath() == WORKED_UT_PATH);
425     g_fileTestCount++;
426     struct UsbFnMtpFileSlice mfs = g_mfs;
427     mfs.length = 100;
428     mfs.command = 100;
429     mfs.transactionId = 100;
430     std::cout << "testHdiUsbMtpTestReceiveFile008===>use libusb in PC launch bulk-out transfer(size = " << mfs.length
431               << "), press enter to continue" << std::endl;
432     int32_t c;
433     while ((c = getchar()) != '\n' && c != EOF) {
434     }
435 
436     std::string filePathName = MTP_TEST_RECV_FILE;
437     mfs.fd = open(filePathName.c_str(), O_CREAT | O_RDWR | O_TRUNC, 0777);
438     ASSERT_GT(mfs.fd, 0);
439     auto ret = g_usbfnMtpInterface->ReceiveFile(mfs);
440     close(mfs.fd);
441     ASSERT_EQ(ret, 0);
442     ASSERT_EQ(GetFileSize(filePathName), static_cast<uint64_t>(mfs.length));
443 }
444 
445 /**
446  * @tc.number: SUB_USB_DeviceManager_HDI_MTPPTPTest_0900
447  * @tc.name: testHdiUsbMtpTestReceiveFile009
448  * @tc.desc: mfs Indicates the mtp file slice info. mfs.length = 1000 mfs.command = 1000 mfs.transactionId = 1000.
449  */
450 HWTEST_F(UsbfnMtpTestAdditional, testHdiUsbMtpTestReceiveFile009, Function | MediumTest | Level1)
451 {
452     ASSERT_TRUE(g_usbfnMtpInterface != nullptr);
453     ASSERT_TRUE(GetCurrentProcPath() == WORKED_UT_PATH);
454     g_fileTestCount++;
455     struct UsbFnMtpFileSlice mfs = g_mfs;
456     mfs.length = 1000;
457     mfs.command = 1000;
458     mfs.transactionId = 1000;
459     std::cout << "testHdiUsbMtpTestReceiveFile009===>use libusb in PC launch bulk-out transfer(size = " << mfs.length
460               << "), press enter to continue" << std::endl;
461     int32_t c;
462     while ((c = getchar()) != '\n' && c != EOF) {
463     }
464 
465     std::string filePathName = MTP_TEST_RECV_FILE;
466     mfs.fd = open(filePathName.c_str(), O_CREAT | O_RDWR | O_TRUNC, 0777);
467     ASSERT_GT(mfs.fd, 0);
468     auto ret = g_usbfnMtpInterface->ReceiveFile(mfs);
469     close(mfs.fd);
470     ASSERT_EQ(ret, 0);
471     ASSERT_EQ(GetFileSize(filePathName), static_cast<uint64_t>(mfs.length));
472 }
473 
474 /**
475  * @tc.number: SUB_USB_DeviceManager_HDI_MTPPTPTest_1000
476  * @tc.name: testHdiUsbMtpTestReceiveFile010
477  * @tc.desc: mfs Indicates the mtp file slice info. mfs.length = 25 mfs.command = 100 mfs.transactionId = 100.
478  */
479 HWTEST_F(UsbfnMtpTestAdditional, testHdiUsbMtpTestReceiveFile010, Function | MediumTest | Level1)
480 {
481     ASSERT_TRUE(g_usbfnMtpInterface != nullptr);
482     ASSERT_TRUE(GetCurrentProcPath() == WORKED_UT_PATH);
483     g_fileTestCount++;
484     struct UsbFnMtpFileSlice mfs = g_mfs;
485     mfs.length = 25;
486     mfs.command = 100;
487     mfs.transactionId = 100;
488     std::cout << "testHdiUsbMtpTestReceiveFile010===>use libusb in PC launch bulk-out transfer(size = " << mfs.length
489               << "), press enter to continue" << std::endl;
490     int32_t c;
491     while ((c = getchar()) != '\n' && c != EOF) {
492     }
493 
494     std::string filePathName = MTP_TEST_RECV_FILE;
495     mfs.fd = open(filePathName.c_str(), O_CREAT | O_RDWR | O_TRUNC, 0777);
496     ASSERT_GT(mfs.fd, 0);
497     auto ret = g_usbfnMtpInterface->ReceiveFile(mfs);
498     close(mfs.fd);
499     ASSERT_EQ(ret, 0);
500     ASSERT_EQ(GetFileSize(filePathName), static_cast<uint64_t>(mfs.length));
501 }
502 
503 /**
504  * @tc.number: SUB_USB_DeviceManager_HDI_MTPPTPTest_1100
505  * @tc.name: testHdiUsbMtpTestReceiveFile011
506  * @tc.desc: mfs Indicates the mtp file slice info. mfs.length = 100 mfs.command = 200 mfs.transactionId = 300.
507  */
508 HWTEST_F(UsbfnMtpTestAdditional, testHdiUsbMtpTestReceiveFile011, Function | MediumTest | Level1)
509 {
510     ASSERT_TRUE(g_usbfnMtpInterface != nullptr);
511     ASSERT_TRUE(GetCurrentProcPath() == WORKED_UT_PATH);
512     g_fileTestCount++;
513     struct UsbFnMtpFileSlice mfs = g_mfs;
514     mfs.length = 100;
515     mfs.command = 200;
516     mfs.transactionId = 300;
517     std::cout << "testHdiUsbMtpTestReceiveFile011===>use libusb in PC launch bulk-out transfer(size = " << mfs.length
518               << "), press enter to continue" << std::endl;
519     int32_t c;
520     while ((c = getchar()) != '\n' && c != EOF) {
521     }
522 
523     std::string filePathName = MTP_TEST_RECV_FILE;
524     mfs.fd = open(filePathName.c_str(), O_CREAT | O_RDWR | O_TRUNC, 0777);
525     ASSERT_GT(mfs.fd, 0);
526     auto ret = g_usbfnMtpInterface->ReceiveFile(mfs);
527     close(mfs.fd);
528     ASSERT_EQ(ret, 0);
529     ASSERT_EQ(GetFileSize(filePathName), static_cast<uint64_t>(mfs.length));
530 }
531 
532 /**
533  * @tc.number: SUB_USB_DeviceManager_HDI_MTPPTPTest_1200
534  * @tc.name: testHdiUsbMtpTestReceiveFile012
535  * @tc.desc: mfs Indicates the mtp file slice info. mfs.length = 1000 mfs.command = 2000 mfs.transactionId = 3000.
536  */
537 HWTEST_F(UsbfnMtpTestAdditional, testHdiUsbMtpTestReceiveFile012, Function | MediumTest | Level1)
538 {
539     ASSERT_TRUE(g_usbfnMtpInterface != nullptr);
540     ASSERT_TRUE(GetCurrentProcPath() == WORKED_UT_PATH);
541     g_fileTestCount++;
542     struct UsbFnMtpFileSlice mfs = g_mfs;
543     mfs.length = 1000;
544     mfs.command = 2000;
545     mfs.transactionId = 3000;
546     std::cout << "testHdiUsbMtpTestReceiveFile012===>use libusb in PC launch bulk-out transfer(size = " << mfs.length
547               << "), press enter to continue" << std::endl;
548     int32_t c;
549     while ((c = getchar()) != '\n' && c != EOF) {
550     }
551 
552     std::string filePathName = MTP_TEST_RECV_FILE;
553     mfs.fd = open(filePathName.c_str(), O_CREAT | O_RDWR | O_TRUNC, 0777);
554     ASSERT_GT(mfs.fd, 0);
555     auto ret = g_usbfnMtpInterface->ReceiveFile(mfs);
556     close(mfs.fd);
557     ASSERT_EQ(ret, 0);
558     ASSERT_EQ(GetFileSize(filePathName), static_cast<uint64_t>(mfs.length));
559 }
560 
561 /**
562  * @tc.number: SUB_USB_DeviceManager_HDI_MTPPTPTest_1300
563  * @tc.name: testHdiUsbMtpTestReceiveFile013
564  * @tc.desc: mfs Indicates the mtp file slice info. mfs.length = 1 mfs.command = 1 mfs.transactionId = 100.
565  */
566 HWTEST_F(UsbfnMtpTestAdditional, testHdiUsbMtpTestReceiveFile013, Function | MediumTest | Level1)
567 {
568     ASSERT_TRUE(g_usbfnMtpInterface != nullptr);
569     ASSERT_TRUE(GetCurrentProcPath() == WORKED_UT_PATH);
570     g_fileTestCount++;
571     struct UsbFnMtpFileSlice mfs = g_mfs;
572     mfs.length = 1;
573     mfs.command = 1;
574     mfs.transactionId = 100;
575     std::cout << "testHdiUsbMtpTestReceiveFile013===>use libusb in PC launch bulk-out transfer(size = " << mfs.length
576               << "), press enter to continue" << std::endl;
577     int32_t c;
578     while ((c = getchar()) != '\n' && c != EOF) {
579     }
580 
581     std::string filePathName = MTP_TEST_RECV_FILE;
582     mfs.fd = open(filePathName.c_str(), O_CREAT | O_RDWR | O_TRUNC, 0777);
583     ASSERT_GT(mfs.fd, 0);
584     auto ret = g_usbfnMtpInterface->ReceiveFile(mfs);
585     close(mfs.fd);
586     ASSERT_EQ(ret, 0);
587     ASSERT_EQ(GetFileSize(filePathName), static_cast<uint64_t>(mfs.length));
588 }
589 
590 /**
591  * @tc.number: SUB_USB_DeviceManager_HDI_MTPPTPTest_1400
592  * @tc.name: testHdiUsbMtpTestSendEvent001
593  * @tc.desc: Send event data by USB MTP/PTP driver. devData.assign(MTP_EVENT_PACKET_VALID_LEN, 'S').
594  */
595 HWTEST_F(UsbfnMtpTestAdditional, testHdiUsbMtpTestSendEvent001, Function | MediumTest | Level1)
596 {
597     ASSERT_TRUE(g_usbfnMtpInterface != nullptr);
598     std::vector<uint8_t> devData;
599     devData.assign(MTP_EVENT_PACKET_VALID_LEN, 'S');
600     std::cout << "testHdiUsbMtpTestSendEvent001===>use libusb in PC launch intr-in transfer(expect=" << devData.size()
601               << "), press enter to continue" << std::endl;
602     int32_t c;
603     while ((c = getchar()) != '\n' && c != EOF) {
604     }
605 
606     auto ret = g_usbfnMtpInterface->SendEvent(devData);
607     ASSERT_EQ(0, ret);
608 }
609 
610 /**
611  * @tc.number: SUB_USB_DeviceManager_HDI_MTPPTPTest_1500
612  * @tc.name: testHdiUsbMtpTestSendEvent002
613  * @tc.desc: Send event data by USB MTP/PTP driver. devData.assign(MTP_EVENT_PACKET_MAX_BYTES, 'S').
614  */
615 HWTEST_F(UsbfnMtpTestAdditional, testHdiUsbMtpTestSendEvent002, Function | MediumTest | Level1)
616 {
617     ASSERT_TRUE(g_usbfnMtpInterface != nullptr);
618     std::vector<uint8_t> devData;
619     devData.assign(MTP_EVENT_PACKET_MAX_BYTES, 'S');
620     std::cout << "testHdiUsbMtpTestSendEvent002===>use libusb in PC launch intr-in transfer(expect=" << devData.size()
621               << "), press enter to continue" << std::endl;
622     int32_t c;
623     while ((c = getchar()) != '\n' && c != EOF) {
624     }
625     auto ret = g_usbfnMtpInterface->SendEvent(devData);
626     ASSERT_EQ(0, ret);
627 }
628 
629 /**
630  * @tc.number: SUB_USB_DeviceManager_HDI_MTPPTPTest_1600
631  * @tc.name: testHdiUsbMtpTestSendEvent003
632  * @tc.desc: Send event data by USB MTP/PTP driver. devData.assign(MTP_EVENT_PACKET_INVALID_LEN, 'S').
633  */
634 HWTEST_F(UsbfnMtpTestAdditional, testHdiUsbMtpTestSendEvent003, Function | MediumTest | Level2)
635 {
636     ASSERT_TRUE(g_usbfnMtpInterface != nullptr);
637     std::vector<uint8_t> devData;
638     devData.assign(MTP_EVENT_PACKET_INVALID_LEN, 'S');
639     std::cout << "testHdiUsbMtpTestSendEvent003===>use libusb in PC launch intr-in transfer(expect=no data, "
640               << "or error), press enter to continue" << std::endl;
641     int32_t c;
642     while ((c = getchar()) != '\n' && c != EOF) {
643     }
644 
645     auto ret = g_usbfnMtpInterface->SendEvent(devData);
646     ASSERT_NE(0, ret);
647     std::cout << "testHdiUsbMtpTestSendEvent003===>make sure transfer timeout in PC, then start next test "
648               << std::endl;
649 }
650 
651 /**
652  * @tc.number: SUB_USB_DeviceManager_HDI_MTPPTPTest_1700
653  * @tc.name: testHdiUsbMtpTestSendEvent004
654  * @tc.desc: Send event data by USB MTP/PTP driver. Cycle 10 times.
655  */
656 HWTEST_F(UsbfnMtpTestAdditional, testHdiUsbMtpTestSendEvent004, Function | MediumTest | Level1)
657 {
658     ASSERT_TRUE(g_usbfnMtpInterface != nullptr);
659     std::vector<uint8_t> devData = {0x65, 0x76, 0x65, 0x6E, 0x74, 0x30, 0x30, 0x34};
660     int32_t ret;
661     int32_t c;
662     for (int i = 0; i < 5; i++) {
663         std::cout
664             << "testHdiUsbMtpTestSendEvent004===>use libusb in PC launch intr-in transfer(expect string=event004), "
665             << "press enter to continue" << std::endl;
666 
667         while ((c = getchar()) != '\n' && c != EOF) {
668         }
669 
670         ret = g_usbfnMtpInterface->SendEvent(devData);
671         ASSERT_EQ(0, ret);
672 
673         PrintVector("event004", devData, true);
674     }
675 }
676 
677 /**
678  * @tc.number: SUB_USB_DeviceManager_HDI_MTPPTPTest_1800
679  * @tc.name: testHdiUsbMtpTestRead001
680  * @tc.desc: Read data by USB MTP/PTP driver.
681  */
682 HWTEST_F(UsbfnMtpTestAdditional, testHdiUsbMtpTestRead001, Function | MediumTest | Level1)
683 {
684     ASSERT_TRUE(g_usbfnMtpInterface != nullptr);
685     std::vector<uint8_t> devData;
686 
687     std::cout << "testHdiUsbMtpTestRead001===>use libusb in PC launch bulk-out transfer(size=" << 5
688               << "), press enter to continue" << std::endl;
689     int32_t c;
690     while ((c = getchar()) != '\n' && c != EOF) {
691     }
692 
693     int32_t ret = g_usbfnMtpInterface->Read(devData);
694     ASSERT_EQ(ret, 0);
695     ASSERT_EQ(devData.size(), static_cast<size_t>(5));
696 }
697 
698 /**
699  * @tc.number: SUB_USB_DeviceManager_HDI_MTPPTPTest_1900
700  * @tc.name: testHdiUsbMtpTestWrite001
701  * @tc.desc: Write data by USB MTP/PTP driver.devData.assign(BULK_IN_LESS_THEN_ONCE, 'r').
702  */
703 HWTEST_F(UsbfnMtpTestAdditional, testHdiUsbMtpTestWrite001, Function | MediumTest | Level1)
704 {
705     ASSERT_TRUE(g_usbfnMtpInterface != nullptr);
706     uint32_t length = BULK_IN_LESS_THEN_ONCE;
707     std::vector<uint8_t> devData;
708     devData.assign(length, 'r');
709 
710     std::cout << "testHdiUsbMtpTestWrite001===>use libusb in PC launch bulk-in transfer(expect=" << length
711               << "), press enter to continue" << std::endl;
712     int32_t c;
713     while ((c = getchar()) != '\n' && c != EOF) {
714     }
715 
716     auto ret = g_usbfnMtpInterface->Write(devData);
717     ASSERT_EQ(ret, 0);
718 }
719 
720 /**
721  * @tc.number: SUB_USB_DeviceManager_HDI_MTPPTPTest_2000
722  * @tc.name: testHdiUsbMtpTestWrite002
723  * @tc.desc: Write data by USB MTP/PTP driver.devData.assign(BULK_IN_ONCE_MAX_SIZE, 'r').
724  */
725 HWTEST_F(UsbfnMtpTestAdditional, testHdiUsbMtpTestWrite002, Function | MediumTest | Level1)
726 {
727     ASSERT_TRUE(g_usbfnMtpInterface != nullptr);
728     uint32_t length = BULK_IN_ONCE_MAX_SIZE;
729     std::vector<uint8_t> devData;
730     devData.assign(length, 'r');
731     std::cout << "testHdiUsbMtpTestWrite002===>use libusb in PC launch bulk-in transfer(expect=" << length
732               << "), press enter to continue" << std::endl;
733     int32_t c;
734     while ((c = getchar()) != '\n' && c != EOF) {
735     }
736 
737     auto ret = g_usbfnMtpInterface->Write(devData);
738     ASSERT_EQ(ret, 0);
739 }
740 
741 /**
742  * @tc.number: SUB_USB_DeviceManager_HDI_MTPPTPTest_2100
743  * @tc.name: testHdiUsbMtpTestWrite003
744  * @tc.desc: Write data by USB MTP/PTP driver.devData.assign(BULK_IN_MORE_THEN_ONCE, 'r').
745  */
746 HWTEST_F(UsbfnMtpTestAdditional, testHdiUsbMtpTestWrite003, Function | MediumTest | Level1)
747 {
748     ASSERT_TRUE(g_usbfnMtpInterface != nullptr);
749     uint32_t length = BULK_IN_MORE_THEN_ONCE;
750     std::vector<uint8_t> devData;
751     devData.assign(length, 'r');
752     std::cout << "testHdiUsbMtpTestWrite003===>use libusb in PC launch bulk-in transfer(expect=" << length
753               << "), press enter to continue" << std::endl;
754     int32_t c;
755     while ((c = getchar()) != '\n' && c != EOF) {
756     }
757 
758     auto ret = g_usbfnMtpInterface->Write(devData);
759     ASSERT_EQ(ret, 0);
760 }
761 
762 /**
763  * @tc.number: SUB_USB_DeviceManager_HDI_MTPPTPTest_2200
764  * @tc.name: testHdiUsbMtpTestWrite004
765  * @tc.desc: Write data by USB MTP/PTP driver.devData.assign(BULK_IN_MORE_THEN_ONCE, 'i').
766  */
767 HWTEST_F(UsbfnMtpTestAdditional, testHdiUsbMtpTestWrite004, Function | MediumTest | Level1)
768 {
769     ASSERT_TRUE(g_usbfnMtpInterface != nullptr);
770     uint32_t length = BULK_IN_MORE_THEN_ONCE;
771     std::vector<uint8_t> devData;
772     devData.assign(length, 'i');
773     std::cout << "testHdiUsbMtpTestWrite004===>use libusb in PC launch bulk-in transfer(expect=" << length
774               << "), press enter to continue" << std::endl;
775     int32_t c;
776     while ((c = getchar()) != '\n' && c != EOF) {
777     }
778 
779     auto ret = g_usbfnMtpInterface->Write(devData);
780     ASSERT_EQ(ret, 0);
781 }
782 /**
783  * @tc.number: SUB_USB_DeviceManager_HDI_MTPPTPTest_2300
784  * @tc.name: testHdiUsbMtpTestWrite005
785  * @tc.desc: Write data by USB MTP/PTP driver.Cycle 10 times.
786  */
787 HWTEST_F(UsbfnMtpTestAdditional, testHdiUsbMtpTestWrite005, Function | MediumTest | Level1)
788 {
789     ASSERT_TRUE(g_usbfnMtpInterface != nullptr);
790     int32_t ret;
791     int i;
792     int32_t c;
793     std::vector<uint8_t> devData = {0x77, 0x72, 0x69, 0x74, 0x65, 0x30, 0x30, 0x35};
794     for (i = 0; i < 5; i++) {
795         std::cout << "testHdiUsbMtpTestWrite005===>use libusb in PC launch bulk-in transfer(expect string=write005), "
796                   << "press enter to continue" << std::endl;
797 
798         while ((c = getchar()) != '\n' && c != EOF) {
799         }
800 
801         ret = g_usbfnMtpInterface->Write(devData);
802         ASSERT_EQ(ret, 0);
803 
804         PrintVector("write005", devData, true);
805     }
806 }
807 
808 /**
809  * @tc.number: SUB_USB_DeviceManager_HDI_MTPPTPTest_2400
810  * @tc.name: testHdiUsbMtpTestSendFile001
811  * @tc.desc: Send file by USB MTP/PTP driver.mfs.length = 1.
812  */
813 HWTEST_F(UsbfnMtpTestAdditional, testHdiUsbMtpTestSendFile001, Function | MediumTest | Level1)
814 {
815     ASSERT_TRUE(g_usbfnMtpInterface != nullptr);
816     ASSERT_TRUE(GetCurrentProcPath() == WORKED_UT_PATH);
817     g_fileTestCount++;
818     struct UsbFnMtpFileSlice mfs = g_mfs;
819     mfs.length = 1;
820     std::string filePathName = MTP_TEST_SEND_FILE;
821     EXPECT_TRUE(GenerateFile(filePathName, mfs.length));
822     std::cout << "testHdiUsbMtpTestSendFile001===>use libusb in PC launch bulk-in transfer(expect " << mfs.length
823               << "), press enter to continue" << std::endl;
824     int32_t c;
825     while ((c = getchar()) != '\n' && c != EOF) {
826     }
827 
828     mfs.fd = open(filePathName.c_str(), O_CREAT | O_RDONLY);
829     ASSERT_GT(mfs.fd, 0);
830     auto ret = g_usbfnMtpInterface->SendFile(mfs);
831     close(mfs.fd);
832     ASSERT_EQ(ret, 0);
833 }
834 
835 /**
836  * @tc.number: SUB_USB_DeviceManager_HDI_MTPPTPTest_2500
837  * @tc.name: testHdiUsbMtpTestSendFile002
838  * @tc.desc: Send file by USB MTP/PTP driver.mfs.length = 100.
839  */
840 HWTEST_F(UsbfnMtpTestAdditional, testHdiUsbMtpTestSendFile002, Function | MediumTest | Level1)
841 {
842     ASSERT_TRUE(g_usbfnMtpInterface != nullptr);
843     ASSERT_TRUE(GetCurrentProcPath() == WORKED_UT_PATH);
844     g_fileTestCount++;
845     struct UsbFnMtpFileSlice mfs = g_mfs;
846     mfs.length = 100;
847     std::string filePathName = MTP_TEST_SEND_FILE;
848     EXPECT_TRUE(GenerateFile(filePathName, mfs.length));
849     std::cout << "testHdiUsbMtpTestSendFile002===>use libusb in PC launch bulk-in transfer(expect " << mfs.length
850               << "), press enter to continue" << std::endl;
851     int32_t c;
852     while ((c = getchar()) != '\n' && c != EOF) {
853     }
854 
855     mfs.fd = open(filePathName.c_str(), O_CREAT | O_RDONLY);
856     ASSERT_GT(mfs.fd, 0);
857     auto ret = g_usbfnMtpInterface->SendFile(mfs);
858     close(mfs.fd);
859     ASSERT_EQ(ret, 0);
860 }
861 
862 /**
863  * @tc.number: SUB_USB_DeviceManager_HDI_MTPPTPTest_2600
864  * @tc.name: testHdiUsbMtpTestSendFile003
865  * @tc.desc: Send file by USB MTP/PTP driver.mfs.length = 1000.
866  */
867 HWTEST_F(UsbfnMtpTestAdditional, testHdiUsbMtpTestSendFile003, Function | MediumTest | Level1)
868 {
869     ASSERT_TRUE(g_usbfnMtpInterface != nullptr);
870     ASSERT_TRUE(GetCurrentProcPath() == WORKED_UT_PATH);
871     g_fileTestCount++;
872     struct UsbFnMtpFileSlice mfs = g_mfs;
873     mfs.length = 1000;
874     std::string filePathName = MTP_TEST_SEND_FILE;
875     EXPECT_TRUE(GenerateFile(filePathName, mfs.length));
876     std::cout << "testHdiUsbMtpTestSendFile003===>use libusb in PC launch bulk-in transfer(expect " << mfs.length
877               << "), press enter to continue" << std::endl;
878     int32_t c;
879     while ((c = getchar()) != '\n' && c != EOF) {
880     }
881 
882     mfs.fd = open(filePathName.c_str(), O_CREAT | O_RDONLY);
883     ASSERT_GT(mfs.fd, 0);
884     auto ret = g_usbfnMtpInterface->SendFile(mfs);
885     close(mfs.fd);
886     ASSERT_EQ(ret, 0);
887 }
888 
889 /**
890  * @tc.number: SUB_USB_DeviceManager_HDI_MTPPTPTest_2700
891  * @tc.name: testHdiUsbMtpTestSendFile004
892  * @tc.desc: Send file by USB MTP/PTP driver.mfs.length = 1024.
893  */
894 HWTEST_F(UsbfnMtpTestAdditional, testHdiUsbMtpTestSendFile004, Function | MediumTest | Level1)
895 {
896     ASSERT_TRUE(g_usbfnMtpInterface != nullptr);
897     ASSERT_TRUE(GetCurrentProcPath() == WORKED_UT_PATH);
898     g_fileTestCount++;
899     struct UsbFnMtpFileSlice mfs = g_mfs;
900     mfs.length = 1024;
901     std::string filePathName = MTP_TEST_SEND_FILE;
902     EXPECT_TRUE(GenerateFile(filePathName, mfs.length));
903     std::cout << "testHdiUsbMtpTestSendFile004===>use libusb in PC launch bulk-in transfer(expect " << mfs.length
904               << "), press enter to continue" << std::endl;
905     int32_t c;
906     while ((c = getchar()) != '\n' && c != EOF) {
907     }
908 
909     mfs.fd = open(filePathName.c_str(), O_CREAT | O_RDONLY);
910     ASSERT_GT(mfs.fd, 0);
911     auto ret = g_usbfnMtpInterface->SendFile(mfs);
912     close(mfs.fd);
913     ASSERT_EQ(ret, 0);
914 }
915 
916 /**
917  * @tc.number: SUB_USB_DeviceManager_HDI_MTPPTPTest_2800
918  * @tc.name: testHdiUsbMtpTestSendFile005
919  * @tc.desc: Send file by USB MTP/PTP driver.mfs.length = 255.
920  */
921 HWTEST_F(UsbfnMtpTestAdditional, testHdiUsbMtpTestSendFile005, Function | MediumTest | Level1)
922 {
923     ASSERT_TRUE(g_usbfnMtpInterface != nullptr);
924     ASSERT_TRUE(GetCurrentProcPath() == WORKED_UT_PATH);
925     g_fileTestCount++;
926     struct UsbFnMtpFileSlice mfs = g_mfs;
927     mfs.length = 255;
928     std::string filePathName = MTP_TEST_SEND_FILE;
929     EXPECT_TRUE(GenerateFile(filePathName, mfs.length));
930     std::cout << "testHdiUsbMtpTestSendFile005===>use libusb in PC launch bulk-in transfer(expect " << mfs.length
931               << "), press enter to continue" << std::endl;
932     int32_t c;
933     while ((c = getchar()) != '\n' && c != EOF) {
934     }
935 
936     mfs.fd = open(filePathName.c_str(), O_CREAT | O_RDONLY);
937     ASSERT_GT(mfs.fd, 0);
938     auto ret = g_usbfnMtpInterface->SendFile(mfs);
939     close(mfs.fd);
940     ASSERT_EQ(ret, 0);
941 }
942 
943 /**
944  * @tc.number: SUB_USB_DeviceManager_HDI_MTPPTPTest_2900
945  * @tc.name: testHdiUsbMtpTestSendFile006
946  * @tc.desc: Send file by USB MTP/PTP driver.mfs.length = 1 mfs.command = CMD_CODE_GET_DEVICE_INFO.
947  */
948 HWTEST_F(UsbfnMtpTestAdditional, testHdiUsbMtpTestSendFile006, Function | MediumTest | Level1)
949 {
950     ASSERT_TRUE(g_usbfnMtpInterface != nullptr);
951     ASSERT_TRUE(GetCurrentProcPath() == WORKED_UT_PATH);
952     g_fileTestCount++;
953     struct UsbFnMtpFileSlice mfs = g_mfs;
954     mfs.length = 1;
955     mfs.command = CMD_CODE_GET_DEVICE_INFO;
956     std::string filePathName = MTP_TEST_SEND_FILE;
957     EXPECT_TRUE(GenerateFile(filePathName, mfs.length));
958     std::cout << "testHdiUsbMtpTestSendFile006===>use libusb in PC launch bulk-in transfer(expect " << mfs.length
959               << "), press enter to continue" << std::endl;
960     int32_t c;
961     while ((c = getchar()) != '\n' && c != EOF) {
962     }
963 
964     mfs.fd = open(filePathName.c_str(), O_CREAT | O_RDONLY);
965     ASSERT_GT(mfs.fd, 0);
966     auto ret = g_usbfnMtpInterface->SendFile(mfs);
967     close(mfs.fd);
968     ASSERT_EQ(ret, 0);
969 }
970 
971 /**
972  * @tc.number: SUB_USB_DeviceManager_HDI_MTPPTPTest_3000
973  * @tc.name: testHdiUsbMtpTestSendFile007
974  * @tc.desc: Send file by USB MTP/PTP driver.mfs.length = 100 command = CMD_CODE_GET_DEVICE_INFO.
975  */
976 HWTEST_F(UsbfnMtpTestAdditional, testHdiUsbMtpTestSendFile007, Function | MediumTest | Level1)
977 {
978     ASSERT_TRUE(g_usbfnMtpInterface != nullptr);
979     ASSERT_TRUE(GetCurrentProcPath() == WORKED_UT_PATH);
980     g_fileTestCount++;
981     struct UsbFnMtpFileSlice mfs = g_mfs;
982     mfs.length = 100;
983     mfs.command = CMD_CODE_GET_DEVICE_INFO;
984     std::string filePathName = MTP_TEST_SEND_FILE;
985     EXPECT_TRUE(GenerateFile(filePathName, mfs.length));
986     std::cout << "testHdiUsbMtpTestSendFile007===>use libusb in PC launch bulk-in transfer(expect " << mfs.length
987               << "), press enter to continue" << std::endl;
988     int32_t c;
989     while ((c = getchar()) != '\n' && c != EOF) {
990     }
991 
992     mfs.fd = open(filePathName.c_str(), O_CREAT | O_RDONLY);
993     ASSERT_GT(mfs.fd, 0);
994     auto ret = g_usbfnMtpInterface->SendFile(mfs);
995     close(mfs.fd);
996     ASSERT_EQ(ret, 0);
997 }
998 
999 /**
1000  * @tc.number: SUB_USB_DeviceManager_HDI_MTPPTPTest_3100
1001  * @tc.name: testHdiUsbMtpTestSendFile008
1002  * @tc.desc: Send file by USB MTP/PTP driver.mfs.length = 1000 command = CMD_CODE_GET_DEVICE_INFO.
1003  */
1004 HWTEST_F(UsbfnMtpTestAdditional, testHdiUsbMtpTestSendFile008, Function | MediumTest | Level1)
1005 {
1006     ASSERT_TRUE(g_usbfnMtpInterface != nullptr);
1007     ASSERT_TRUE(GetCurrentProcPath() == WORKED_UT_PATH);
1008     g_fileTestCount++;
1009     struct UsbFnMtpFileSlice mfs = g_mfs;
1010     mfs.length = 1000;
1011     mfs.command = CMD_CODE_GET_DEVICE_INFO;
1012     std::string filePathName = MTP_TEST_SEND_FILE;
1013     EXPECT_TRUE(GenerateFile(filePathName, mfs.length));
1014     std::cout << "testHdiUsbMtpTestSendFile008===>use libusb in PC launch bulk-in transfer(expect " << mfs.length
1015               << "), press enter to continue" << std::endl;
1016     int32_t c;
1017     while ((c = getchar()) != '\n' && c != EOF) {
1018     }
1019 
1020     mfs.fd = open(filePathName.c_str(), O_CREAT | O_RDONLY);
1021     ASSERT_GT(mfs.fd, 0);
1022     auto ret = g_usbfnMtpInterface->SendFile(mfs);
1023     close(mfs.fd);
1024     ASSERT_EQ(ret, 0);
1025 }
1026 
1027 /**
1028  * @tc.number: SUB_USB_DeviceManager_HDI_MTPPTPTest_3200
1029  * @tc.name: testHdiUsbMtpTestSendFile009
1030  * @tc.desc: Send file by USB MTP/PTP driver.mfs.length = 1024 command = CMD_CODE_GET_DEVICE_INFO.
1031  */
1032 HWTEST_F(UsbfnMtpTestAdditional, testHdiUsbMtpTestSendFile009, Function | MediumTest | Level1)
1033 {
1034     ASSERT_TRUE(g_usbfnMtpInterface != nullptr);
1035     ASSERT_TRUE(GetCurrentProcPath() == WORKED_UT_PATH);
1036     g_fileTestCount++;
1037     struct UsbFnMtpFileSlice mfs = g_mfs;
1038     mfs.length = 1024;
1039     mfs.command = CMD_CODE_GET_DEVICE_INFO;
1040     std::string filePathName = MTP_TEST_SEND_FILE;
1041     EXPECT_TRUE(GenerateFile(filePathName, mfs.length));
1042     std::cout << "testHdiUsbMtpTestSendFile009===>use libusb in PC launch bulk-in transfer(expect " << mfs.length
1043               << "), press enter to continue" << std::endl;
1044     int32_t c;
1045     while ((c = getchar()) != '\n' && c != EOF) {
1046     }
1047 
1048     mfs.fd = open(filePathName.c_str(), O_CREAT | O_RDONLY);
1049     ASSERT_GT(mfs.fd, 0);
1050     auto ret = g_usbfnMtpInterface->SendFile(mfs);
1051     close(mfs.fd);
1052     ASSERT_EQ(ret, 0);
1053 }
1054 
1055 /**
1056  * @tc.number: SUB_USB_DeviceManager_HDI_MTPPTPTest_3300
1057  * @tc.name: testHdiUsbMtpTestSendFile010
1058  * @tc.desc: Send file by USB MTP/PTP driver.mfs.length = 255 command = CMD_CODE_GET_DEVICE_INFO.
1059  */
1060 HWTEST_F(UsbfnMtpTestAdditional, testHdiUsbMtpTestSendFile010, Function | MediumTest | Level1)
1061 {
1062     ASSERT_TRUE(g_usbfnMtpInterface != nullptr);
1063     ASSERT_TRUE(GetCurrentProcPath() == WORKED_UT_PATH);
1064     g_fileTestCount++;
1065     struct UsbFnMtpFileSlice mfs = g_mfs;
1066     mfs.length = 255;
1067     mfs.command = CMD_CODE_GET_DEVICE_INFO;
1068     std::string filePathName = MTP_TEST_SEND_FILE;
1069     EXPECT_TRUE(GenerateFile(filePathName, mfs.length));
1070     std::cout << "testHdiUsbMtpTestSendFile010===>use libusb in PC launch bulk-in transfer(expect " << mfs.length
1071               << "), press enter to continue" << std::endl;
1072     int32_t c;
1073     while ((c = getchar()) != '\n' && c != EOF) {
1074     }
1075 
1076     mfs.fd = open(filePathName.c_str(), O_CREAT | O_RDONLY);
1077     ASSERT_GT(mfs.fd, 0);
1078     auto ret = g_usbfnMtpInterface->SendFile(mfs);
1079     close(mfs.fd);
1080     ASSERT_EQ(ret, 0);
1081 }
1082 
1083 /**
1084  * @tc.number: SUB_USB_DeviceManager_HDI_MTPPTPTest_3400
1085  * @tc.name: testHdiUsbMtpTestSendFile011
1086  * @tc.desc: Send file by USB MTP/PTP driver.mfs.length = MTP_MAX_FILE_SIZE - 1.
1087  */
1088 HWTEST_F(UsbfnMtpTestAdditional, testHdiUsbMtpTestSendFile011, Function | MediumTest | Level1)
1089 {
1090     ASSERT_TRUE(g_usbfnMtpInterface != nullptr);
1091     ASSERT_TRUE(GetCurrentProcPath() == WORKED_UT_PATH);
1092     g_fileTestCount++;
1093     struct UsbFnMtpFileSlice mfs = g_mfs;
1094     mfs.length = MTP_MAX_FILE_SIZE - 1;
1095     std::string filePathName = MTP_TEST_SEND_FILE;
1096     EXPECT_TRUE(GenerateFile(filePathName, mfs.length));
1097     std::cout << "testHdiUsbMtpTestSendFile011===>use libusb in PC launch bulk-in transfer(speed, expect " << mfs.length
1098               << "), press enter to continue" << std::endl;
1099     int32_t c;
1100     while ((c = getchar()) != '\n' && c != EOF) {
1101     }
1102 
1103     mfs.fd = open(filePathName.c_str(), O_CREAT | O_RDONLY);
1104     ASSERT_GT(mfs.fd, 0);
1105     auto ret = g_usbfnMtpInterface->SendFile(mfs);
1106     close(mfs.fd);
1107     ASSERT_EQ(0, ret);
1108 }
1109 
1110 /**
1111  * @tc.number: SUB_USB_DeviceManager_HDI_MTPPTPTest_3500
1112  * @tc.name: testHdiUsbMtpTestSendFile012
1113  * @tc.desc: Send file by USB MTP/PTP driver.mfs.length = MTP_MAX_FILE_SIZE - 2.
1114  */
1115 HWTEST_F(UsbfnMtpTestAdditional, testHdiUsbMtpTestSendFile012, Function | MediumTest | Level1)
1116 {
1117     ASSERT_TRUE(g_usbfnMtpInterface != nullptr);
1118     ASSERT_TRUE(GetCurrentProcPath() == WORKED_UT_PATH);
1119     g_fileTestCount++;
1120     struct UsbFnMtpFileSlice mfs = g_mfs;
1121     mfs.length = MTP_MAX_FILE_SIZE - 2;
1122     std::string filePathName = MTP_TEST_SEND_FILE;
1123     EXPECT_TRUE(GenerateFile(filePathName, mfs.length));
1124     std::cout << "testHdiUsbMtpTestSendFile012===>use libusb in PC launch bulk-in transfer(speed, expect " << mfs.length
1125               << "), press enter to continue" << std::endl;
1126     int32_t c;
1127     while ((c = getchar()) != '\n' && c != EOF) {
1128     }
1129 
1130     mfs.fd = open(filePathName.c_str(), O_CREAT | O_RDONLY);
1131     ASSERT_GT(mfs.fd, 0);
1132     auto ret = g_usbfnMtpInterface->SendFile(mfs);
1133     close(mfs.fd);
1134     ASSERT_EQ(0, ret);
1135 }
1136 
1137 /**
1138  * @tc.number: SUB_USB_DeviceManager_HDI_MTPPTPTest_3600
1139  * @tc.name: testHdiUsbMtpTestSendFile013
1140  * @tc.desc: Send file by USB MTP/PTP driver.mfs.mfs.length = BULK_IN_LESS_THEN_ONCE mfs.command =
1141  * CMD_CODE_GET_DEVICE_INFO Cycle 10 times.
1142  */
1143 HWTEST_F(UsbfnMtpTestAdditional, testHdiUsbMtpTestSendFile013, Function | MediumTest | Level1)
1144 {
1145     ASSERT_TRUE(g_usbfnMtpInterface != nullptr);
1146     ASSERT_TRUE(GetCurrentProcPath() == WORKED_UT_PATH);
1147     g_fileTestCount++;
1148     struct UsbFnMtpFileSlice mfs = g_mfs;
1149     mfs.length = BULK_IN_LESS_THEN_ONCE;
1150     mfs.command = CMD_CODE_GET_DEVICE_INFO;
1151     std::string filePathName = MTP_TEST_SEND_FILE;
1152     EXPECT_TRUE(GenerateFile(filePathName, mfs.length));
1153     int32_t ret;
1154     int i;
1155     int32_t c;
1156     for (i = 0; i < 10; i++) {
1157         std::cout << "testHdiUsbMtpTestSendFile013===>use libusb in PC launch bulk-in transfer(expect "
1158                   << mfs.length + MTP_PACKET_HEADER_SIZE << "), press enter to continue" << std::endl;
1159 
1160         while ((c = getchar()) != '\n' && c != EOF) {
1161         }
1162         mfs.fd = open(filePathName.c_str(), O_CREAT | O_RDONLY);
1163         ASSERT_GT(mfs.fd, 0);
1164 
1165         ret = g_usbfnMtpInterface->SendFile(mfs);
1166         close(mfs.fd);
1167         ASSERT_EQ(0, ret);
1168     }
1169 }
1170 
1171 /**
1172  * @tc.number: SUB_USB_DeviceManager_HDI_MTPPTPTest_3700
1173  * @tc.name: testHdiUsbMtpTestSendFile014
1174  * @tc.desc: Send file by USB MTP/PTP driver.mfs.length = 1 mfs.command = 1.
1175  */
1176 HWTEST_F(UsbfnMtpTestAdditional, testHdiUsbMtpTestSendFile014, Function | MediumTest | Level1)
1177 {
1178     ASSERT_TRUE(g_usbfnMtpInterface != nullptr);
1179     ASSERT_TRUE(GetCurrentProcPath() == WORKED_UT_PATH);
1180     g_fileTestCount++;
1181     struct UsbFnMtpFileSlice mfs = g_mfs;
1182     mfs.length = 1;
1183     mfs.command = 1;
1184     std::string filePathName = MTP_TEST_SEND_FILE;
1185     EXPECT_TRUE(GenerateFile(filePathName, mfs.length));
1186     std::cout << "testHdiUsbMtpTestSendFile014===>use libusb in PC launch bulk-in transfer(expect " << mfs.length
1187               << "), press enter to continue" << std::endl;
1188     int32_t c;
1189     while ((c = getchar()) != '\n' && c != EOF) {
1190     }
1191 
1192     mfs.fd = open(filePathName.c_str(), O_CREAT | O_RDONLY);
1193     ASSERT_GT(mfs.fd, 0);
1194     auto ret = g_usbfnMtpInterface->SendFile(mfs);
1195     close(mfs.fd);
1196     ASSERT_EQ(ret, 0);
1197 }
1198 
1199 /**
1200  * @tc.number: SUB_USB_DeviceManager_HDI_MTPPTPTest_3800
1201  * @tc.name: testHdiUsbMtpTestSendFile015
1202  * @tc.desc: Send file by USB MTP/PTP driver.mfs.length = 100 mfs.command = 100.
1203  */
1204 HWTEST_F(UsbfnMtpTestAdditional, testHdiUsbMtpTestSendFile015, Function | MediumTest | Level1)
1205 {
1206     ASSERT_TRUE(g_usbfnMtpInterface != nullptr);
1207     ASSERT_TRUE(GetCurrentProcPath() == WORKED_UT_PATH);
1208     g_fileTestCount++;
1209     struct UsbFnMtpFileSlice mfs = g_mfs;
1210     mfs.length = 100;
1211     mfs.command = 100;
1212     std::string filePathName = MTP_TEST_SEND_FILE;
1213     EXPECT_TRUE(GenerateFile(filePathName, mfs.length));
1214     std::cout << "testHdiUsbMtpTestSendFile015===>use libusb in PC launch bulk-in transfer(expect " << mfs.length
1215               << "), press enter to continue" << std::endl;
1216     int32_t c;
1217     while ((c = getchar()) != '\n' && c != EOF) {
1218     }
1219 
1220     mfs.fd = open(filePathName.c_str(), O_CREAT | O_RDONLY);
1221     ASSERT_GT(mfs.fd, 0);
1222     auto ret = g_usbfnMtpInterface->SendFile(mfs);
1223     close(mfs.fd);
1224     ASSERT_EQ(ret, 0);
1225 }
1226 
1227 /**
1228  * @tc.number: SUB_USB_DeviceManager_HDI_MTPPTPTest_3900
1229  * @tc.name: testHdiUsbMtpTestSendFile016
1230  * @tc.desc: Send file by USB MTP/PTP driver.mfs.length = 1000 mfs.command = 1000.
1231  */
1232 HWTEST_F(UsbfnMtpTestAdditional, testHdiUsbMtpTestSendFile016, Function | MediumTest | Level1)
1233 {
1234     ASSERT_TRUE(g_usbfnMtpInterface != nullptr);
1235     ASSERT_TRUE(GetCurrentProcPath() == WORKED_UT_PATH);
1236     g_fileTestCount++;
1237     struct UsbFnMtpFileSlice mfs = g_mfs;
1238     mfs.length = 1000;
1239     mfs.command = 1000;
1240     std::string filePathName = MTP_TEST_SEND_FILE;
1241     EXPECT_TRUE(GenerateFile(filePathName, mfs.length));
1242     std::cout << "testHdiUsbMtpTestSendFile016===>use libusb in PC launch bulk-in transfer(expect " << mfs.length
1243               << "), press enter to continue" << std::endl;
1244     int32_t c;
1245     while ((c = getchar()) != '\n' && c != EOF) {
1246     }
1247 
1248     mfs.fd = open(filePathName.c_str(), O_CREAT | O_RDONLY);
1249     ASSERT_GT(mfs.fd, 0);
1250     auto ret = g_usbfnMtpInterface->SendFile(mfs);
1251     close(mfs.fd);
1252     ASSERT_EQ(ret, 0);
1253 }
1254 
1255 /**
1256  * @tc.number: SUB_USB_DeviceManager_HDI_MTPPTPTest_4000
1257  * @tc.name: testHdiUsbMtpTestSendFile017
1258  * @tc.desc: Send file by USB MTP/PTP driver.mfs.length = 1024 mfs.command = 1024.
1259  */
1260 HWTEST_F(UsbfnMtpTestAdditional, testHdiUsbMtpTestSendFile017, Function | MediumTest | Level1)
1261 {
1262     ASSERT_TRUE(g_usbfnMtpInterface != nullptr);
1263     ASSERT_TRUE(GetCurrentProcPath() == WORKED_UT_PATH);
1264     g_fileTestCount++;
1265     struct UsbFnMtpFileSlice mfs = g_mfs;
1266     mfs.length = 1024;
1267     mfs.command = 1024;
1268     std::string filePathName = MTP_TEST_SEND_FILE;
1269     EXPECT_TRUE(GenerateFile(filePathName, mfs.length));
1270     std::cout << "testHdiUsbMtpTestSendFile017===>use libusb in PC launch bulk-in transfer(expect " << mfs.length
1271               << "), press enter to continue" << std::endl;
1272     int32_t c;
1273     while ((c = getchar()) != '\n' && c != EOF) {
1274     }
1275 
1276     mfs.fd = open(filePathName.c_str(), O_CREAT | O_RDONLY);
1277     ASSERT_GT(mfs.fd, 0);
1278     auto ret = g_usbfnMtpInterface->SendFile(mfs);
1279     close(mfs.fd);
1280     ASSERT_EQ(ret, 0);
1281 }
1282 
1283 /**
1284  * @tc.number: SUB_USB_DeviceManager_HDI_MTPPTPTest_4100
1285  * @tc.name: testHdiUsbMtpTestSendFile018
1286  * @tc.desc: Send file by USB MTP/PTP driver.mfs.length = 255 mfs.command = 255.
1287  */
1288 HWTEST_F(UsbfnMtpTestAdditional, testHdiUsbMtpTestSendFile018, Function | MediumTest | Level1)
1289 {
1290     ASSERT_TRUE(g_usbfnMtpInterface != nullptr);
1291     ASSERT_TRUE(GetCurrentProcPath() == WORKED_UT_PATH);
1292     g_fileTestCount++;
1293     struct UsbFnMtpFileSlice mfs = g_mfs;
1294     mfs.length = 255;
1295     mfs.command = 255;
1296     std::string filePathName = MTP_TEST_SEND_FILE;
1297     EXPECT_TRUE(GenerateFile(filePathName, mfs.length));
1298     std::cout << "testHdiUsbMtpTestSendFile018===>use libusb in PC launch bulk-in transfer(expect " << mfs.length
1299               << "), press enter to continue" << std::endl;
1300     int32_t c;
1301     while ((c = getchar()) != '\n' && c != EOF) {
1302     }
1303 
1304     mfs.fd = open(filePathName.c_str(), O_CREAT | O_RDONLY);
1305     ASSERT_GT(mfs.fd, 0);
1306     auto ret = g_usbfnMtpInterface->SendFile(mfs);
1307     close(mfs.fd);
1308     ASSERT_EQ(ret, 0);
1309 }
1310 
1311 /**
1312  * @tc.number: SUB_USB_DeviceManager_HDI_MTPPTPTest_4200
1313  * @tc.name: testHdiUsbMtpTestSendFile019
1314  * @tc.desc: Send file by USB MTP/PTP driver.mfs.length = 200.mfs.command = 200.
1315  */
1316 HWTEST_F(UsbfnMtpTestAdditional, testHdiUsbMtpTestSendFile019, Function | MediumTest | Level1)
1317 {
1318     ASSERT_TRUE(g_usbfnMtpInterface != nullptr);
1319     ASSERT_TRUE(GetCurrentProcPath() == WORKED_UT_PATH);
1320     g_fileTestCount++;
1321     struct UsbFnMtpFileSlice mfs = g_mfs;
1322     mfs.length = 200;
1323     mfs.command = 200;
1324     std::string filePathName = MTP_TEST_SEND_FILE;
1325     EXPECT_TRUE(GenerateFile(filePathName, mfs.length));
1326     std::cout << "testHdiUsbMtpTestSendFile019===>use libusb in PC launch bulk-in transfer(expect " << mfs.length
1327               << "), press enter to continue" << std::endl;
1328     int32_t c;
1329     while ((c = getchar()) != '\n' && c != EOF) {
1330     }
1331 
1332     mfs.fd = open(filePathName.c_str(), O_CREAT | O_RDONLY);
1333     ASSERT_GT(mfs.fd, 0);
1334     auto ret = g_usbfnMtpInterface->SendFile(mfs);
1335     close(mfs.fd);
1336     ASSERT_EQ(ret, 0);
1337 }
1338 
1339 /**
1340  * @tc.number: SUB_USB_DeviceManager_HDI_MTPPTPTest_4300
1341  * @tc.name: testHdiUsbMtpTestStart001
1342  * @tc.desc: Opens a USB MTP/PTP driver.
1343  */
1344 HWTEST_F(UsbfnMtpTestAdditional, testHdiUsbMtpTestStart001, Function | MediumTest | Level1)
1345 {
1346     ASSERT_TRUE(g_usbfnMtpInterface != nullptr);
1347     auto ret = g_usbfnMtpInterface->Start();
1348     ASSERT_EQ(0, ret);
1349     ret = g_usbfnMtpInterface->Stop();
1350     ASSERT_EQ(0, ret);
1351 }
1352 
1353 /**
1354  * @tc.number: SUB_USB_DeviceManager_HDI_MTPPTPTest_4400
1355  * @tc.name: testHdiUsbMtpTestStop001
1356  * @tc.desc: Closes a USB MTP/PTP driver.
1357  */
1358 HWTEST_F(UsbfnMtpTestAdditional, testHdiUsbMtpTestStop001, Function | MediumTest | Level1)
1359 {
1360     ASSERT_TRUE(g_usbfnMtpInterface != nullptr);
1361     int32_t ret;
1362     int i;
1363     for (i = 0; i < 10; i++) {
1364         ret = g_usbfnMtpInterface->Start();
1365         ASSERT_EQ(0, ret);
1366         ret = g_usbfnMtpInterface->Stop();
1367         ASSERT_EQ(0, ret);
1368     }
1369 }
1370 } // namespace
1371