• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 #include <gmock/gmock.h>
19 #include "parameters.h"
20 #include "floating_ball_option.h"
21 #include "wm_common.h"
22 
23 using namespace testing;
24 using namespace testing::ext;
25 
26 namespace OHOS {
27 namespace Rosen {
28 
29 class FloatingBallOptionTest : public testing::Test {
30 public:
31     static void SetUpTestCase();
32     static void TearDownTestCase();
33     void SetUp() override;
34     void TearDown() override;
35 };
36 
SetUpTestCase()37 void FloatingBallOptionTest::SetUpTestCase()
38 {
39 }
40 
TearDownTestCase()41 void FloatingBallOptionTest::TearDownTestCase()
42 {
43 }
44 
SetUp()45 void FloatingBallOptionTest::SetUp()
46 {
47 }
48 
TearDown()49 void FloatingBallOptionTest::TearDown()
50 {
51 }
52 
53 namespace {
54 /**
55  * @tc.name: TestParamSetAndGet
56  * @tc.desc: TestParamSetAndGet
57  * @tc.type: FUNC
58  */
59 HWTEST_F(FloatingBallOptionTest, TestParamSetAndGet, TestSize.Level1)
60 {
61     auto option = sptr<FbOption>::MakeSptr();
62     uint32_t templateType = 1;
63     std::string title = "title";
64     std::string content = "content";
65     std::string color = "#RRGGBB";
66     std::shared_ptr<Media::PixelMap> icon = nullptr;
67     option->SetTemplate(templateType);
68     option->SetTitle(title);
69     option->SetContent(content);
70     option->SetBackgroundColor(color);
71     option->SetIcon(icon);
72     EXPECT_EQ(templateType, option->GetTemplate());
73     EXPECT_EQ(title, option->GetTitle());
74     EXPECT_EQ(content, option->GetContent());
75     EXPECT_EQ(nullptr, option->GetIcon());
76     EXPECT_EQ(color, option->GetBackgroundColor());
77 
78     FloatingBallTemplateBaseInfo fbTemplateBaseInfo;
79     option->GetFbTemplateBaseInfo(fbTemplateBaseInfo);
80     EXPECT_EQ(title, fbTemplateBaseInfo.title_);
81     EXPECT_EQ(templateType, fbTemplateBaseInfo.template_);
82     EXPECT_EQ(content, fbTemplateBaseInfo.content_);
83     EXPECT_EQ(color, fbTemplateBaseInfo.backgroundColor_);
84 }
85 }
86 }
87 }