1 /*
2 * Copyright (c) 2021-2022 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 <gtest/gtest.h>
17
18 #define private public
19 #include "os_account_subscribe_info.h"
20 #undef private
21
22 using namespace testing::ext;
23 using namespace OHOS;
24 using namespace OHOS::AccountSA;
25
26 namespace {
27 const std::string STRING_NAME = "account";
28 } // namespace
29 class OsAccountSubscribeInfoTest : public testing::Test {
30 public:
31 static void SetUpTestCase(void);
32 static void TearDownTestCase(void);
33 void SetUp(void) override;
34 void TearDown(void) override;
35 };
36
SetUpTestCase(void)37 void OsAccountSubscribeInfoTest::SetUpTestCase(void)
38 {}
39
TearDownTestCase(void)40 void OsAccountSubscribeInfoTest::TearDownTestCase(void)
41 {}
42
SetUp(void)43 void OsAccountSubscribeInfoTest::SetUp(void)
44 {}
45
TearDown(void)46 void OsAccountSubscribeInfoTest::TearDown(void)
47 {}
48
49 /**
50 * @tc.name: OsAccountSubscribeInfoTestTest01
51 * @tc.desc: Test osaccount subscribe info marshalling/unmarshalling
52 * @tc.type: FUNC
53 * @tc.require:
54 */
55 HWTEST_F(OsAccountSubscribeInfoTest, OsAccountSubscribeInfoTestTest01, TestSize.Level0)
56 {
57 OsAccountSubscribeInfo osAccountSubscribeInfo(ACTIVED, STRING_NAME);
58
59 Parcel parcel;
60 EXPECT_EQ(true, osAccountSubscribeInfo.Marshalling(parcel));
61
62 std::shared_ptr<OsAccountSubscribeInfo> readedData(OsAccountSubscribeInfo::Unmarshalling(parcel));
63 EXPECT_NE(nullptr, readedData);
64
65 EXPECT_EQ(osAccountSubscribeInfo.osAccountSubscribeType_, readedData->osAccountSubscribeType_);
66 EXPECT_EQ(osAccountSubscribeInfo.name_, readedData->name_);
67 }