• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 #include "print_resolution.h"
18 #include "printer_capability.h"
19 #include "print_margin.h"
20 
21 using namespace testing::ext;
22 
23 namespace OHOS {
24 namespace Print {
25 class PrintResolutionTest : public testing::Test {
26 public:
27     static void SetUpTestCase(void);
28     static void TearDownTestCase(void);
29     void SetUp();
30     void TearDown();
31 };
32 
SetUpTestCase(void)33 void PrintResolutionTest::SetUpTestCase(void) {}
34 
TearDownTestCase(void)35 void PrintResolutionTest::TearDownTestCase(void) {}
36 
SetUp(void)37 void PrintResolutionTest::SetUp(void) {}
38 
TearDown(void)39 void PrintResolutionTest::TearDown(void) {}
40 
41 /**
42  * @tc.name: PrintResolutionTest_001
43  * @tc.desc: Verify the constructor function.
44  * @tc.type: FUNC
45  * @tc.require:
46  */
47 HWTEST_F(PrintResolutionTest, PrintResolutionTest_001_NeedRename, TestSize.Level1)
48 {
49     OHOS::Print::PrintResolution resolution;
50     OHOS::Print::PrintResolution res;
51     res = resolution;
52     resolution.Dump();
53     EXPECT_EQ(res.GetId(), resolution.GetId());
54     EXPECT_EQ(res.GetHorizontalDpi(), resolution.GetHorizontalDpi());
55     EXPECT_EQ(res.GetVerticalDpi(), resolution.GetVerticalDpi());
56 }
57 
58 /**
59  * @tc.name: PrintResolutionTest_002
60  * @tc.desc: Verify the constructor function.
61  * @tc.type: FUNC
62  * @tc.require:
63  */
64 HWTEST_F(PrintResolutionTest, PrintResolutionTest_002_NeedRename, TestSize.Level1)
65 {
66     OHOS::Print::PrintResolution resolution;
67     resolution.Reset();
68     EXPECT_EQ("", resolution.GetId());
69 }
70 
71 /**
72  * @tc.name: PrintResolutionTest_003
73  * @tc.desc: Verify the getId function.
74  * @tc.type: FUNC
75  * @tc.require:
76  */
77 HWTEST_F(PrintResolutionTest, PrintResolutionTest_003_NeedRename, TestSize.Level1)
78 {
79     OHOS::Print::PrintResolution resolution;
80     resolution.SetId("test");
81     EXPECT_EQ("test", resolution.GetId());
82 }
83 
84 /**
85  * @tc.name: PrintResolutionTest_004
86  * @tc.desc: Verify the getHorizontalDpi function.
87  * @tc.type: FUNC
88  * @tc.require:
89  */
90 HWTEST_F(PrintResolutionTest, PrintResolutionTest_004_NeedRename, TestSize.Level1)
91 {
92     OHOS::Print::PrintResolution resolution;
93     resolution.SetHorizontalDpi(32);
94     EXPECT_EQ((uint32_t)32, resolution.GetHorizontalDpi());
95 }
96 
97 /**
98  * @tc.name: PrintResolutionTest_005
99  * @tc.desc: Verify the getVerticalDpi function.
100  * @tc.type: FUNC
101  * @tc.require:
102  */
103 HWTEST_F(PrintResolutionTest, PrintResolutionTest_005_NeedRename, TestSize.Level1)
104 {
105     OHOS::Print::PrintResolution resolution;
106     resolution.SetVerticalDpi(32);
107     EXPECT_EQ((uint32_t)32, resolution.GetVerticalDpi());
108 }
109 
110 /**
111  * @tc.name: PrintResolutionTest_006
112  * @tc.desc: Verify the marshalling function.
113  * @tc.type: FUNC
114  * @tc.require:
115  */
116 HWTEST_F(PrintResolutionTest, PrintResolutionTest_006_NeedRename, TestSize.Level1)
117 {
118     OHOS::Print::PrintResolution resolution;
119     resolution.SetId("test");
120     resolution.SetHorizontalDpi(32);
121     resolution.SetVerticalDpi(32);
122     Parcel parcel;
123     EXPECT_EQ(resolution.Marshalling(parcel), true);
124 }
125 
126 /**
127  * @tc.name: PrintResolutionTest_007
128  * @tc.desc: Verify the unmarshalling function.
129  * @tc.type: FUNC
130  * @tc.require:
131  */
132 HWTEST_F(PrintResolutionTest, PrintResolutionTest_007_NeedRename, TestSize.Level1)
133 {
134     OHOS::Print::PrintResolution resolution;
135     resolution.SetId("test");
136     resolution.SetHorizontalDpi(32);
137     resolution.SetVerticalDpi(32);
138     Parcel parcel;
139     resolution.Marshalling(parcel);
140     auto result = OHOS::Print::PrintResolution::Unmarshalling(parcel);
141     EXPECT_NE(nullptr, result);
142 }
143 
144 /**
145  * @tc.name: PrintResolutionTest_008
146  * @tc.desc: Verify the copy constructor function.
147  * @tc.type: FUNC
148  * @tc.require:
149  */
150 HWTEST_F(PrintResolutionTest, PrintResolutionTest_008_NeedRename, TestSize.Level1)
151 {
152     OHOS::Print::PrintResolution resolution;
153     resolution.SetId("test");
154     OHOS::Print::PrintResolution copyResolution(resolution);
155     EXPECT_EQ(copyResolution.GetId(), resolution.GetId());
156 }
157 
158 /**
159  * @tc.name: PrintResolutionTest_009
160  * @tc.desc: Verify the assignment construction function.
161  * @tc.type: FUNC
162  * @tc.require:
163  */
164 HWTEST_F(PrintResolutionTest, PrintResolutionTest_009_NeedRename, TestSize.Level1)
165 {
166     OHOS::Print::PrintResolution resolution;
167     resolution.SetId("test");
168     OHOS::Print::PrintResolution copyResolution = resolution;
169     EXPECT_EQ(copyResolution.GetId(), resolution.GetId());
170 }
171 }  // namespace Print
172 }  // namespace OHOS
173