• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 "distributed_data_mgr.h"
17 #include <gtest/gtest.h>
18 #include <vector>
19 #include "types.h"
20 #include "accesstoken_kit.h"
21 #include "nativetoken_kit.h"
22 #include "ipc_skeleton.h"
23 #include "token_setproc.h"
24 
25 using namespace testing::ext;
26 using namespace OHOS::DistributedKv;
27 using namespace OHOS::Security::AccessToken;
28 std::string BUNDLE_NAME = "ohos.distributeddatamgrtest.demo";
29 namespace OHOS::Test {
30 class DistributedDataMgrTest : public testing::Test {
31 public:
32     static DistributedDataMgr manager;
SetUpTestCase(void)33     static void SetUpTestCase(void){};
TearDownTestCase(void)34     static void TearDownTestCase(void){};
SetUp()35     void SetUp(){};
TearDown()36     void TearDown(){};
37     static constexpr int32_t TEST_USERID = 100;
38     static constexpr int32_t APP_INDEX = 0;
39 };
40 DistributedDataMgr DistributedDataMgrTest::manager;
41 
42 /**
43 * @tc.name: ClearAppStorage
44 * @tc.desc:
45 * @tc.type: FUNC
46 * @tc.require:
47 * @tc.author: SQL
48 */
49 HWTEST_F(DistributedDataMgrTest, ClearAppStorage001, TestSize.Level1)
50 {
51     auto tokenId = AccessTokenKit::GetNativeTokenId("foundation");
52     SetSelfTokenID(tokenId);
53     auto ret = manager.ClearAppStorage(BUNDLE_NAME, TEST_USERID, APP_INDEX, tokenId);
54     EXPECT_EQ(ret, Status::SUCCESS);
55 }
56 } // namespace OHOS::Test