• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "asset_query_sync_result_test.h"
17 
18 #include <string>
19 #include <gtest/gtest.h>
20 
21 #include "asset_api.h"
22 #include "asset_test_common.h"
23 
24 using namespace testing::ext;
25 namespace UnitTest::AssetQuerySyncResultTest {
26 class AssetQuerySyncResultTest : public testing::Test {
27 public:
28     static void SetUpTestCase(void);
29 
30     static void TearDownTestCase(void);
31 
32     void SetUp(void);
33 
34     void TearDown(void);
35 };
36 
SetUpTestCase(void)37 void AssetQuerySyncResultTest::SetUpTestCase(void)
38 {
39 }
40 
TearDownTestCase(void)41 void AssetQuerySyncResultTest::TearDownTestCase(void)
42 {
43 }
44 
SetUp(void)45 void AssetQuerySyncResultTest::SetUp(void)
46 {
47 }
48 
TearDown(void)49 void AssetQuerySyncResultTest::TearDown(void)
50 {
51 }
52 
53 /**
54  * @tc.name: AssetQuerySyncResultTest.AssetQuerySyncResultTest001
55  * @tc.desc: query sync result, expect ASSET_SUCCESS.
56  * @tc.type: FUNC
57  * @tc.result:0
58  */
59 HWTEST_F(AssetQuerySyncResultTest, AssetQuerySyncResultTest001, TestSize.Level0)
60 {
61     Asset_Attr attr[] = {};
62     Asset_SyncResult result = { 0 };
63     ASSERT_EQ(ASSET_SUCCESS, OH_Asset_QuerySyncResult(attr, ARRAY_SIZE(attr), &result));
64 }
65 
66 /**
67  * @tc.name: AssetQuerySyncResultTest.AssetQuerySyncResultTest002
68  * @tc.desc: query sync result of attr, expect ASSET_SUCCESS.
69  * @tc.type: FUNC
70  * @tc.result:0
71  */
72 HWTEST_F(AssetQuerySyncResultTest, AssetQuerySyncResultTest002, TestSize.Level0)
73 {
74     Asset_Attr attr[] = {
75         { .tag = ASSET_TAG_REQUIRE_ATTR_ENCRYPTED, .value.boolean = true },
76     };
77     Asset_SyncResult result = { 0 };
78     ASSERT_EQ(ASSET_SUCCESS, OH_Asset_QuerySyncResult(attr, ARRAY_SIZE(attr), &result));
79 }
80 
81 /**
82  * @tc.name: AssetQuerySyncResultTest.AssetQuerySyncResultTest003
83  * @tc.desc: query sync result of group, expect ASSET_UNSUPPORTED.
84  * @tc.type: FUNC
85  * @tc.result:0
86  */
87 HWTEST_F(AssetQuerySyncResultTest, AssetQuerySyncResultTest003, TestSize.Level0)
88 {
89     Asset_Blob funcName = { .size = strlen(__func__), .data = reinterpret_cast<uint8_t*>(const_cast<char*>(__func__)) };
90     Asset_Attr attr[] = {
91         { .tag = ASSET_TAG_GROUP_ID, .value.blob = funcName },
92     };
93     Asset_SyncResult result = { 0 };
94     ASSERT_EQ(ASSET_UNSUPPORTED, OH_Asset_QuerySyncResult(attr, ARRAY_SIZE(attr), &result));
95 }
96 }