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
16 #include "UTTest_app_manager_two.h"
17
18 #include "dm_error_type.h"
19
20 using namespace OHOS::AppExecFwk;
21 using namespace testing;
22
23 namespace OHOS {
24 namespace DistributedHardware {
SetUp()25 void AppManagerTwoTest::SetUp()
26 {
27 }
28
TearDown()29 void AppManagerTwoTest::TearDown()
30 {
31 }
32
SetUpTestCase()33 void AppManagerTwoTest::SetUpTestCase()
34 {
35 }
36
TearDownTestCase()37 void AppManagerTwoTest::TearDownTestCase()
38 {
39 }
40
41 HWTEST_F(AppManagerTwoTest, GetTokenIdByBundleName_001, testing::ext::TestSize.Level1)
42 {
43 int32_t userId = 0;
44 std::string bundleName = "";
45 int64_t tokenId = 0;
46 int32_t ret = AppManager::GetInstance().GetTokenIdByBundleName(userId, bundleName, tokenId);
47 EXPECT_NE(ret, 0);
48 }
49
50 HWTEST_F(AppManagerTwoTest, GetTokenIdByBundleName_002, testing::ext::TestSize.Level1)
51 {
52 int32_t userId = 0;
53 std::string bundleName = "bundleName";
54 int64_t tokenId = 0;
55 int32_t ret = AppManager::GetInstance().GetTokenIdByBundleName(userId, bundleName, tokenId);
56 EXPECT_NE(ret, 0);
57 }
58
59 HWTEST_F(AppManagerTwoTest, GetBundleNameByTokenId_001, testing::ext::TestSize.Level1)
60 {
61 int64_t tokenId = -1;
62 std::string bundleName = "bundleName";
63 int32_t ret = AppManager::GetInstance().GetBundleNameByTokenId(tokenId, bundleName);
64 EXPECT_EQ(ret, ERR_DM_FAILED);
65 }
66
67 HWTEST_F(AppManagerTwoTest, GetBundleNameByTokenId_002, testing::ext::TestSize.Level1)
68 {
69 int64_t tokenId = 0;
70 std::string bundleName = "bundleName";
71 int32_t ret = AppManager::GetInstance().GetBundleNameByTokenId(tokenId, bundleName);
72 EXPECT_EQ(ret, ERR_DM_FAILED);
73 }
74 } // namespace DistributedHardware
75 } // namespace OHOS