1 /* 2 * Copyright (c) 2022 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 <gtest/gtest.h> 17 #include <singleton.h> 18 #include <cassert> 19 #include <sys/types.h> 20 #include <sys/stat.h> 21 #include <fcntl.h> 22 #include <string> 23 #include <vector> 24 #include <unordered_map> 25 26 #include "remote_file_share.h" 27 28 namespace { 29 using namespace std; 30 using namespace OHOS::AppFileService::ModuleRemoteFileShare; 31 32 const int E_INVALID_ARGUMENT = 22; 33 const int E_OK = 0; 34 35 class RemoteFileShareTest : public testing::Test { 36 public: SetUpTestCase(void)37 static void SetUpTestCase(void) {}; TearDownTestCase()38 static void TearDownTestCase() {}; SetUp()39 void SetUp() {}; TearDown()40 void TearDown() {}; 41 }; 42 43 /** 44 * @tc.name: remote_file_share_test_0000 45 * @tc.desc: Test function of RemoteFileShare() interface for SUCCESS. 46 * @tc.size: MEDIUM 47 * @tc.type: FUNC 48 * @tc.level Level 1 49 * @tc.require: SR000H63TL 50 */ 51 HWTEST_F(RemoteFileShareTest, Remote_file_share_RemoteFileShare_0000, testing::ext::TestSize.Level1) 52 { 53 GTEST_LOG_(INFO) << "RemoteFileShareTest-begin Remote_file_share_RemoteFileShare_0000"; 54 RemoteFileShare* test = new RemoteFileShare; 55 ASSERT_TRUE(test != nullptr) << "RemoteFileShare Construct Failed!"; 56 delete test; 57 GTEST_LOG_(INFO) << "RemoteFileShareTest-end Remote_file_share_RemoteFileShare_0000"; 58 } 59 60 /** 61 * @tc.name: remote_file_share_test_0001 62 * @tc.desc: Test function of CreateSharePath() interface for SUCCESS. 63 * @tc.size: MEDIUM 64 * @tc.type: FUNC 65 * @tc.level Level 1 66 * @tc.require: SR000H63TL 67 */ 68 HWTEST_F(RemoteFileShareTest, Remote_file_share_CreateSharePath_0001, testing::ext::TestSize.Level1) 69 { 70 GTEST_LOG_(INFO) << "RemoteFileShareTest-begin Remote_file_share_CreateSharePath_0001"; 71 const int fd = -1; 72 const int userId = 100; 73 const string deviceId = "0"; 74 string sharePath = ""; 75 int ret = RemoteFileShare::CreateSharePath(fd, sharePath, userId, deviceId); 76 EXPECT_EQ(ret, E_INVALID_ARGUMENT); 77 GTEST_LOG_(INFO) << "RemoteFileShareTest-end Remote_file_share_CreateSharePath_0001"; 78 } 79 80 /** 81 * @tc.name: remote_file_share_test_0002 82 * @tc.desc: Test function of CreateSharePath() interface for SUCCESS. 83 * @tc.size: MEDIUM 84 * @tc.type: FUNC 85 * @tc.level Level 1 86 * @tc.require: SR000H63TL 87 */ 88 HWTEST_F(RemoteFileShareTest, Remote_file_share_CreateSharePath_0002, testing::ext::TestSize.Level1) 89 { 90 GTEST_LOG_(INFO) << "RemoteFileShareTest-begin Remote_file_share_CreateSharePath_0002"; 91 const int fd = 10; 92 const int userId = 90; 93 const string deviceId = "0"; 94 string sharePath = ""; 95 int ret = RemoteFileShare::CreateSharePath(fd, sharePath, userId, deviceId); 96 EXPECT_EQ(ret, E_INVALID_ARGUMENT); 97 GTEST_LOG_(INFO) << "RemoteFileShareTest-end Remote_file_share_CreateSharePath_0002"; 98 } 99 100 /** 101 * @tc.name: remote_file_share_test_0003 102 * @tc.desc: Test function of CreateSharePath() interface for SUCCESS. 103 * @tc.size: MEDIUM 104 * @tc.type: FUNC 105 * @tc.level Level 1 106 * @tc.require: SR000H63TL 107 */ 108 HWTEST_F(RemoteFileShareTest, Remote_file_share_CreateSharePath_0003, testing::ext::TestSize.Level1) 109 { 110 GTEST_LOG_(INFO) << "RemoteFileShareTest-begin Remote_file_share_CreateSharePath_0003"; 111 const int fd = 10; 112 const int userId = 100; 113 const string deviceId = "00"; 114 string sharePath = ""; 115 int ret = RemoteFileShare::CreateSharePath(fd, sharePath, userId, deviceId); 116 EXPECT_EQ(ret, E_INVALID_ARGUMENT); 117 GTEST_LOG_(INFO) << "RemoteFileShareTest-end Remote_file_share_CreateSharePath_0003"; 118 } 119 120 /** 121 * @tc.name: remote_file_share_test_0004 122 * @tc.desc: Test function of CreateSharePath() interface for SUCCESS. 123 * @tc.size: MEDIUM 124 * @tc.type: FUNC 125 * @tc.level Level 1 126 * @tc.require: SR000H63TL 127 */ 128 HWTEST_F(RemoteFileShareTest, Remote_file_share_CreateSharePath_0004, testing::ext::TestSize.Level1) 129 { 130 GTEST_LOG_(INFO) << "RemoteFileShareTest-begin Remote_file_share_CreateSharePath_0004"; 131 const string fileStr = "/data/test/remote_file_share_test.txt"; 132 int fd = open(fileStr.c_str(), O_RDWR); 133 ASSERT_TRUE(fd != -1) << "RemoteFileShareTest Create File Failed!"; 134 const int userId = 100; 135 const string deviceId = "0"; 136 string sharePath = ""; 137 int ret = RemoteFileShare::CreateSharePath(fd, sharePath, userId, deviceId); 138 close(fd); 139 EXPECT_EQ(ret, E_OK); 140 GTEST_LOG_(INFO) << "RemoteFileShareTest Create Share Path " << sharePath; 141 GTEST_LOG_(INFO) << "RemoteFileShareTest-end Remote_file_share_CreateSharePath_0004"; 142 } 143 144 /** 145 * @tc.name: remote_file_share_test_0005 146 * @tc.desc: Test function of CreateSharePath() interface for SUCCESS. 147 * @tc.size: MEDIUM 148 * @tc.type: FUNC 149 * @tc.level Level 1 150 * @tc.require: SR000H63TL 151 */ 152 HWTEST_F(RemoteFileShareTest, Remote_file_share_CreateSharePath_0005, testing::ext::TestSize.Level1) 153 { 154 GTEST_LOG_(INFO) << "RemoteFileShareTest-begin Remote_file_share_CreateSharePath_0005"; 155 const string fileStr = "/data/test/remote_file_share_test.txt"; 156 int fd = open(fileStr.c_str(), O_RDWR); 157 ASSERT_TRUE(fd != -1) << "RemoteFileShareTest Create File Failed!"; 158 const int userId = 100; 159 const string deviceId = "0"; 160 string sharePath = ""; 161 char pthreadName[PATH_MAX]; 162 int ret = pthread_getname_np(pthread_self(), pthreadName, sizeof(pthreadName)); 163 EXPECT_EQ(ret, E_OK); 164 string pthreadNameStr = pthreadName; 165 string errPthreadName = "../test"; 166 ret = pthread_setname_np(pthread_self(), errPthreadName.c_str()); 167 EXPECT_EQ(ret, E_OK); 168 ret = RemoteFileShare::CreateSharePath(fd, sharePath, userId, deviceId); 169 close(fd); 170 EXPECT_NE(ret, E_OK); 171 ret = pthread_setname_np(pthread_self(), pthreadNameStr.c_str()); 172 EXPECT_EQ(ret, E_OK); 173 GTEST_LOG_(INFO) << "RemoteFileShareTest Create Share Path " << sharePath; 174 GTEST_LOG_(INFO) << "RemoteFileShareTest-end Remote_file_share_CreateSharePath_0005"; 175 } 176 177 /** 178 * @tc.name: remote_file_share_test_0005 179 * @tc.desc: Test function of GetDfsUriFromLocal() interface for SUCCESS. 180 * @tc.size: MEDIUM 181 * @tc.type: FUNC 182 * @tc.level Level 1 183 * @tc.require: I7KDF7 184 */ 185 HWTEST_F(RemoteFileShareTest, Remote_file_share_GetDfsUriFromLocal_0005, testing::ext::TestSize.Level1) 186 { 187 GTEST_LOG_(INFO) << "RemoteFileShareTest-begin Remote_file_share_GetDfsUriFromLocal_0005"; 188 const string dirPath = "/data/app/el2/100/base/com.demo.a/"; 189 const string uriStr = "file://com.demo.a/data/storage/el2/base/remote_file_share_test.txt"; 190 const string fileStr = "/data/app/el2/100/base/com.demo.a/remote_file_share_test.txt"; 191 const int userId = 100; 192 193 int ret = mkdir(dirPath.c_str(), S_IRWXU | S_IRWXG | S_IXOTH); 194 ASSERT_TRUE((ret != -1) || (ret == -1 && errno == EEXIST)) << "RemoteFileShareTest mkdir failed! " << errno; 195 196 int fd = open(fileStr.c_str(), O_RDWR | O_CREAT); 197 ASSERT_TRUE(fd != -1) << "Failed to open file in RemoteFileShareTest! " << errno; 198 close(fd); 199 200 HmdfsUriInfo hui; 201 ret = RemoteFileShare::GetDfsUriFromLocal(uriStr, userId, hui); 202 EXPECT_EQ(ret, E_OK); 203 204 ret = unlink(fileStr.c_str()); 205 ASSERT_TRUE(ret != -1) << "Failed to delete file in RemoteFileShareTest! " << errno; 206 207 ret = rmdir(dirPath.c_str()); 208 ASSERT_TRUE(ret != -1) << "RemoteFileShareTest rmdir failed! " << errno; 209 GTEST_LOG_(INFO) << "RemoteFileShareTest uri is " << hui.uriStr; 210 GTEST_LOG_(INFO) << "RemoteFileShareTest file size is " << hui.fileSize; 211 GTEST_LOG_(INFO) << "RemoteFileShareTest-end Remote_file_share_GetDfsUriFromLocal_0005"; 212 } 213 214 /** 215 * @tc.name: remote_file_share_test_0006 216 * @tc.desc: Test function of GetDfsUriFromLocal() interface for FAILURE. 217 * @tc.size: MEDIUM 218 * @tc.type: FUNC 219 * @tc.level Level 1 220 * @tc.require: I7KDF7 221 */ 222 HWTEST_F(RemoteFileShareTest, Remote_file_share_GetDfsUriFromLocal_0006, testing::ext::TestSize.Level1) 223 { 224 GTEST_LOG_(INFO) << "RemoteFileShareTest-begin Remote_file_share_GetDfsUriFromLocal_0006"; 225 const string uriStr = ""; 226 const int userId = 100; 227 HmdfsUriInfo hui; 228 int ret = RemoteFileShare::GetDfsUriFromLocal(uriStr, userId, hui); 229 EXPECT_EQ(ret, -EINVAL); 230 231 vector<string> uriList; 232 unordered_map<string, HmdfsUriInfo> uriToDfsUriMaps; 233 uriList.push_back(uriStr); 234 ret = RemoteFileShare::GetDfsUrisFromLocal(uriList, userId, uriToDfsUriMaps); 235 EXPECT_EQ(ret, -EINVAL); 236 237 GTEST_LOG_(INFO) << "RemoteFileShareTest uri is " << hui.uriStr; 238 GTEST_LOG_(INFO) << "RemoteFileShareTest file size is " << hui.fileSize; 239 GTEST_LOG_(INFO) << "RemoteFileShareTest-end Remote_file_share_GetDfsUriFromLocal_0006"; 240 } 241 242 /** 243 * @tc.name: remote_file_share_test_0007 244 * @tc.desc: Test function of GetDfsUriFromLocal() interface for FAILURE. 245 * @tc.size: MEDIUM 246 * @tc.type: FUNC 247 * @tc.level Level 1 248 * @tc.require: I7KDF7 249 */ 250 HWTEST_F(RemoteFileShareTest, Remote_file_share_GetDfsUriFromLocal_0007, testing::ext::TestSize.Level1) 251 { 252 GTEST_LOG_(INFO) << "RemoteFileShareTest-begin Remote_file_share_GetDfsUriFromLocal_0007"; 253 const string uriStr = "file://com.demo.a/./data/storage/el2/base/remote_file_share_test.txt"; 254 const int userId = 100; 255 HmdfsUriInfo hui; 256 int ret = RemoteFileShare::GetDfsUriFromLocal(uriStr, userId, hui); 257 EXPECT_EQ(ret, -EINVAL); 258 259 vector<string> uriList; 260 unordered_map<string, HmdfsUriInfo> uriToDfsUriMaps; 261 uriList.push_back(uriStr); 262 ret = RemoteFileShare::GetDfsUrisFromLocal(uriList, userId, uriToDfsUriMaps); 263 EXPECT_EQ(ret, -EINVAL); 264 265 GTEST_LOG_(INFO) << "RemoteFileShareTest uri is " << hui.uriStr; 266 GTEST_LOG_(INFO) << "RemoteFileShareTest file size is " << hui.fileSize; 267 GTEST_LOG_(INFO) << "RemoteFileShareTest-end Remote_file_share_GetDfsUriFromLocal_0007"; 268 } 269 270 /** 271 * @tc.name: remote_file_share_test_0008 272 * @tc.desc: Test function of GetDfsUriFromLocal() interface for FAILURE. 273 * @tc.size: MEDIUM 274 * @tc.type: FUNC 275 * @tc.level Level 1 276 * @tc.require: I7KDF7 277 */ 278 HWTEST_F(RemoteFileShareTest, Remote_file_share_GetDfsUriFromLocal_0008, testing::ext::TestSize.Level1) 279 { 280 GTEST_LOG_(INFO) << "RemoteFileShareTest-begin Remote_file_share_GetDfsUriFromLocal_0008"; 281 const string uriStr = "file://com.demo.a/../data/storage/el2/base/remote_file_share_test.txt"; 282 const int userId = 100; 283 HmdfsUriInfo hui; 284 int ret = RemoteFileShare::GetDfsUriFromLocal(uriStr, userId, hui); 285 EXPECT_EQ(ret, -EINVAL); 286 287 vector<string> uriList; 288 unordered_map<string, HmdfsUriInfo> uriToDfsUriMaps; 289 uriList.push_back(uriStr); 290 ret = RemoteFileShare::GetDfsUrisFromLocal(uriList, userId, uriToDfsUriMaps); 291 EXPECT_EQ(ret, -EINVAL); 292 293 GTEST_LOG_(INFO) << "RemoteFileShareTest uri is " << hui.uriStr; 294 GTEST_LOG_(INFO) << "RemoteFileShareTest file size is " << hui.fileSize; 295 GTEST_LOG_(INFO) << "RemoteFileShareTest-end Remote_file_share_GetDfsUriFromLocal_0008"; 296 } 297 298 /** 299 * @tc.name: remote_file_share_test_0009 300 * @tc.desc: Test function of GetDfsUriFromLocal() interface for FAILURE. 301 * @tc.size: MEDIUM 302 * @tc.type: FUNC 303 * @tc.level Level 1 304 * @tc.require: I7KDF7 305 */ 306 HWTEST_F(RemoteFileShareTest, Remote_file_share_GetDfsUriFromLocal_0009, testing::ext::TestSize.Level1) 307 { 308 GTEST_LOG_(INFO) << "RemoteFileShareTest-begin Remote_file_share_GetDfsUriFromLocal_0009"; 309 const string uriStr = "file://com.demo.a/data/storage/el3/base/remote_file_share_test.txt"; 310 const int userId = 100; 311 HmdfsUriInfo hui; 312 int ret = RemoteFileShare::GetDfsUriFromLocal(uriStr, userId, hui); 313 EXPECT_EQ(ret, -EINVAL); 314 315 vector<string> uriList; 316 unordered_map<string, HmdfsUriInfo> uriToDfsUriMaps; 317 uriList.push_back(uriStr); 318 ret = RemoteFileShare::GetDfsUrisFromLocal(uriList, userId, uriToDfsUriMaps); 319 EXPECT_EQ(ret, -EINVAL); 320 321 GTEST_LOG_(INFO) << "RemoteFileShareTest uri is " << hui.uriStr; 322 GTEST_LOG_(INFO) << "RemoteFileShareTest file size is " << hui.fileSize; 323 GTEST_LOG_(INFO) << "RemoteFileShareTest-end Remote_file_share_GetDfsUriFromLocal_0009"; 324 } 325 326 /** 327 * @tc.name: remote_file_share_test_0010 328 * @tc.desc: Test function of GetDfsUriFromLocal() interface for FAILURE. 329 * @tc.size: MEDIUM 330 * @tc.type: FUNC 331 * @tc.level Level 1 332 * @tc.require: I7KDF7 333 */ 334 HWTEST_F(RemoteFileShareTest, Remote_file_share_GetDfsUriFromLocal_0010, testing::ext::TestSize.Level1) 335 { 336 GTEST_LOG_(INFO) << "RemoteFileShareTest-begin Remote_file_share_GetDfsUriFromLocal_0010"; 337 const string uriStr = "file://com.demo.a/data/storage/el2/base/notExistFile.txt"; 338 const int userId = 100; 339 HmdfsUriInfo hui; 340 int ret = RemoteFileShare::GetDfsUriFromLocal(uriStr, userId, hui); 341 EXPECT_NE(ret, E_OK); 342 343 vector<string> uriList; 344 unordered_map<string, HmdfsUriInfo> uriToDfsUriMaps; 345 uriList.push_back(uriStr); 346 ret = RemoteFileShare::GetDfsUrisFromLocal(uriList, userId, uriToDfsUriMaps); 347 EXPECT_NE(ret, E_OK); 348 349 GTEST_LOG_(INFO) << "RemoteFileShareTest uri is " << hui.uriStr; 350 GTEST_LOG_(INFO) << "RemoteFileShareTest file size is " << hui.fileSize; 351 GTEST_LOG_(INFO) << "RemoteFileShareTest-end Remote_file_share_GetDfsUriFromLocal_0010"; 352 } 353 354 /** 355 * @tc.name: remote_file_share_test_0011 356 * @tc.desc: Test function of GetDfsUriFromLocal() interface for SUCCESS. 357 * the file name is chinese which has been encoded 358 * @tc.size: MEDIUM 359 * @tc.type: FUNC 360 * @tc.level Level 1 361 * @tc.require: I7KDF7 362 */ 363 HWTEST_F(RemoteFileShareTest, Remote_file_share_GetDfsUriFromLocal_0011, testing::ext::TestSize.Level1) 364 { 365 GTEST_LOG_(INFO) << "RemoteFileShareTest-begin Remote_file_share_GetDfsUriFromLocal_0011"; 366 const string dirPath = "/data/app/el2/100/base/com.demo.a/"; 367 const string uriStr = "file://com.demo.a/data/storage/el2/base/" 368 "%E5%85%B1%20%E4%BA%AB%20%E6%96%87%20%E4%BB%B6%20%E6%B5%8B%20%E8%AF%95.txt"; 369 const string fileStr = "/data/app/el2/100/base/com.demo.a/共 享 文 件 测 试.txt"; 370 const int userId = 100; 371 372 int ret = mkdir(dirPath.c_str(), S_IRWXU | S_IRWXG | S_IXOTH); 373 ASSERT_TRUE((ret != -1) || (ret == -1 && errno == EEXIST)) << "RemoteFileShareTest mkdir failed! " << errno; 374 375 int fd = open(fileStr.c_str(), O_RDWR | O_CREAT); 376 ASSERT_TRUE(fd != -1) << "RemoteFileShareTest open file failed! " << errno; 377 close(fd); 378 379 HmdfsUriInfo hui; 380 ret = RemoteFileShare::GetDfsUriFromLocal(uriStr, userId, hui); 381 EXPECT_EQ(ret, E_OK); 382 ret = unlink(fileStr.c_str()); 383 ASSERT_TRUE(ret != -1) << "RemoteFileShareTest delete file failed! " << errno; 384 385 ret = rmdir(dirPath.c_str()); 386 ASSERT_TRUE(ret != -1) << "RemoteFileShareTest rmdir failed! " << errno; 387 388 vector<string> uriList; 389 unordered_map<string, HmdfsUriInfo> uriToDfsUriMaps; 390 uriList.push_back(uriStr); 391 ret = RemoteFileShare::GetDfsUrisFromLocal(uriList, userId, uriToDfsUriMaps); 392 EXPECT_NE(ret, E_OK); 393 394 GTEST_LOG_(INFO) << "RemoteFileShareTest uri is " << hui.uriStr; 395 GTEST_LOG_(INFO) << "RemoteFileShareTest file size is " << hui.fileSize; 396 GTEST_LOG_(INFO) << "RemoteFileShareTest-end Remote_file_share_GetDfsUriFromLocal_0011"; 397 } 398 399 /** 400 * @tc.name: remote_file_share_test_0012 401 * @tc.desc: Test function of TransRemoteUriToLocal() interface for SUCCESS. 402 * @tc.size: MEDIUM 403 * @tc.type: FUNC 404 * @tc.level Level 1 405 * @tc.require: I7KDF7 406 */ 407 HWTEST_F(RemoteFileShareTest, Remote_file_share_TransRemoteUriToLocal_0012, testing::ext::TestSize.Level1) 408 { 409 GTEST_LOG_(INFO) << "RemoteFileShareTest-begin Remote_file_share_TransRemoteUriToLocal_0012"; 410 const vector<string> uriList = {"file://docs/storage/Users/currentUser/Document/1.txt", 411 "file://docs/storage/Users/currentUser/Download/Subject/2.jpg", 412 "file://docs/storage/Users/currentUser/Document/Subject1/Subject2/1.txt", 413 "file://docs/storage/100/account/Document/Subject1/Subject2/1.txt"}; 414 const vector<string> expectedList = {"file://docs/storage/hmdfs/001/Document/1.txt", 415 "file://docs/storage/hmdfs/001/Download/Subject/2.jpg", 416 "file://docs/storage/hmdfs/001/Document/Subject1/Subject2/1.txt", 417 "file://docs/storage/hmdfs/001/Document/Subject1/Subject2/1.txt"}; 418 const string networkId = "100"; 419 const string deviceId = "001"; 420 vector<string> resultList; 421 int ret = RemoteFileShare::TransRemoteUriToLocal(uriList, networkId, deviceId, resultList); 422 EXPECT_EQ(ret, E_OK); 423 EXPECT_EQ(resultList, expectedList); 424 425 GTEST_LOG_(INFO) << "RemoteFileShareTest-end Remote_file_share_TransRemoteUriToLocal_0012"; 426 } 427 428 /** 429 * @tc.name: remote_file_share_test_0013 430 * @tc.desc: Test function of TransRemoteUriToLocal() interface for FAILURE. 431 * the sandboxPath of uri does not equal to "storage" 432 * @tc.size: MEDIUM 433 * @tc.type: FUNC 434 * @tc.level Level 1 435 * @tc.require: I7KDF7 436 */ 437 HWTEST_F(RemoteFileShareTest, Remote_file_share_TransRemoteUriToLocal_0013, testing::ext::TestSize.Level1) 438 { 439 GTEST_LOG_(INFO) << "RemoteFileShareTest-begin Remote_file_share_TransRemoteUriToLocal_0013"; 440 const vector<string> uriList = {"file://docs/storage/Users/currentUser/Document/1.txt", 441 "file://docs/hmdfs/Users/currentUser/Download/Subject/2.jpg", 442 "file://docs/tmp/Users/currentUser/Document/Subject1/Subject2/1.txt", 443 "file://docs/storage/100/account/Document/Subject1/Subject2/1.txt"}; 444 const string networkId = "100"; 445 const string deviceId = "001"; 446 vector<string> resultList; 447 int ret = RemoteFileShare::TransRemoteUriToLocal(uriList, networkId, deviceId, resultList); 448 EXPECT_NE(ret, E_OK); 449 EXPECT_EQ(resultList, uriList); 450 451 GTEST_LOG_(INFO) << "RemoteFileShareTest-end Remote_file_share_TransRemoteUriToLocal_0013"; 452 } 453 454 /** 455 * @tc.name: remote_file_share_test_0014 456 * @tc.desc: Test function of TransRemoteUriToLocal() interface for FAILURE. 457 * the bundlename of uri does not equal to "docs" 458 * @tc.size: MEDIUM 459 * @tc.type: FUNC 460 * @tc.level Level 1 461 * @tc.require: I7KDF7 462 */ 463 HWTEST_F(RemoteFileShareTest, Remote_file_share_TransRemoteUriToLocal_0014, testing::ext::TestSize.Level1) 464 { 465 GTEST_LOG_(INFO) << "RemoteFileShareTest-begin Remote_file_share_TransRemoteUriToLocal_0014"; 466 const vector<string> uriList = {"file://docs/storage/Users/currentUser/Document/1.txt", 467 "file://doc/storage/Users/currentUser/Download/Subject/2.jpg", 468 "file://docs/storage/Users/currentUser/Document/Subject1/Subject2/1.txt", 469 "file://doc/storage/100/account/Document/Subject1/Subject2/1.txt"}; 470 const string networkId = "100"; 471 const string deviceId = "001"; 472 vector<string> resultList; 473 int ret = RemoteFileShare::TransRemoteUriToLocal(uriList, networkId, deviceId, resultList); 474 EXPECT_NE(ret, E_OK); 475 EXPECT_EQ(resultList, uriList); 476 477 GTEST_LOG_(INFO) << "RemoteFileShareTest-end Remote_file_share_TransRemoteUriToLocal_0014"; 478 } 479 480 /** 481 * @tc.name: remote_file_share_test_0015 482 * @tc.desc: Test function of TransRemoteUriToLocal() interface for FAILURE. 483 * the scheme of uri does not equal to "file" 484 * @tc.size: MEDIUM 485 * @tc.type: FUNC 486 * @tc.level Level 1 487 * @tc.require: I7KDF7 488 */ 489 HWTEST_F(RemoteFileShareTest, Remote_file_share_TransRemoteUriToLocal_0015, testing::ext::TestSize.Level1) 490 { 491 GTEST_LOG_(INFO) << "RemoteFileShareTest-begin Remote_file_share_TransRemoteUriToLocal_0015"; 492 const vector<string> uriList = {"FILE://docs/storage/Users/currentUser/Document/1.txt", 493 "file://docs/storage/Users/currentUser/Download/Subject/2.jpg", 494 "file://docs/storage/Users/currentUser/Document/Subject1/Subject2/1.txt", 495 "file://docs/storage/100/account/Document/Subject1/Subject2/1.txt"}; 496 const string networkId = "100"; 497 const string deviceId = "001"; 498 vector<string> resultList; 499 int ret = RemoteFileShare::TransRemoteUriToLocal(uriList, networkId, deviceId, resultList); 500 EXPECT_NE(ret, E_OK); 501 EXPECT_EQ(resultList, uriList); 502 503 GTEST_LOG_(INFO) << "RemoteFileShareTest-end Remote_file_share_TransRemoteUriToLocal_0015"; 504 } 505 } 506