1 /*
2 * Copyright (c) 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 #include "dtk_test_register.h"
16
17 namespace OHOS {
18 namespace Rosen {
Instance()19 DtkTestRegister* DtkTestRegister::Instance()
20 {
21 static DtkTestRegister* instance = nullptr;
22 if (instance == nullptr) {
23 instance = new DtkTestRegister();
24 }
25 return instance;
26 }
27
regist(const std::string testName,const std::function<std::shared_ptr<TestBase> ()> testCase,TestLevel testLevel,int testCaseIndex)28 bool DtkTestRegister::regist(const std::string testName,
29 const std::function<std::shared_ptr<TestBase>()> testCase,
30 TestLevel testLevel, int testCaseIndex)
31 {
32 int iTestLevel = testLevel;
33 std::string key = testName + "_L" + std::to_string(iTestLevel) + "_" + std::to_string(testCaseIndex);
34 testCaseMap.emplace(key, testCase);
35 return true;
36 }
37
getTestCaseMap()38 std::unordered_map<std::string, std::function<std::shared_ptr<TestBase>()>> DtkTestRegister::getTestCaseMap()
39 {
40 return testCaseMap;
41 }
42 } // namespace Rosen
43 } // namespace OHOS