• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 "test_common.h"
17 
18 #include <climits>
19 #include <cstdio>
20 #include <cstdlib>
21 #include <unistd.h>
22 
23 #include "hilog_wrapper.h"
24 #include "utils/errors.h"
25 
26 #if defined(__linux__)
27 #include <malloc.h>
28 #endif
29 
30 namespace OHOS {
31 namespace Global {
32 namespace Resource {
FormatFullPath(const char * fileRelativePath)33 std::string FormatFullPath(const char *fileRelativePath)
34 {
35     const char *value = "/user/data";
36     std::string result(value);
37     result.append("/");
38     result.append(fileRelativePath);
39     return result;
40 }
41 
PrintIdValues(const HapResource::IdValues * idValues)42 void PrintIdValues(const HapResource::IdValues *idValues)
43 {
44     HILOG_DEBUG("idvalues size: %u", idValues->GetLimitPathsConst().size());
45     for (size_t i = 0; i < idValues->GetLimitPathsConst().size(); ++i) {
46         auto limitPath = idValues->GetLimitPathsConst()[i];
47         HILOG_DEBUG("%zu: folder is: %s, value: %s", i, limitPath->GetFolder().c_str(),
48             limitPath->GetIdItem()->ToString().c_str());
49     }
50 }
51 
PrintMapString(const std::map<std::string,std::string> & value)52 void PrintMapString(const std::map<std::string, std::string> &value)
53 {
54     auto iter = value.begin();
55     for (; iter != value.end(); ++iter) {
56         std::string key = iter->first;
57         std::string val = iter->second;
58         HILOG_DEBUG("%s : %s", key.c_str(), val.c_str());
59     }
60 }
61 
PrintVectorString(const std::vector<std::string> & value)62 void PrintVectorString(const std::vector<std::string> &value)
63 {
64     for (size_t i = 0; i < value.size(); ++i) {
65         std::string val = value[i];
66         HILOG_DEBUG("%zu : %s", i, val.c_str());
67     }
68 }
69 
CreateResConfig(const char * language,const char * script,const char * region)70 ResConfig *CreateResConfig(const char *language, const char *script, const char *region)
71 {
72     ResConfig *resConfig = CreateResConfig();
73     if (resConfig == nullptr) {
74         return nullptr;
75     }
76     resConfig->SetLocaleInfo(language, script, region);
77     return resConfig;
78 }
79 } // namespace Resource
80 } // namespace Global
81 } // namespace OHOS
82