• 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 "ability_manager_errors.h"
19 #define private public
20 #define protected public
21 #include "ability_record.h"
22 #include "ability_start_setting.h"
23 #include "app_scheduler.h"
24 #include "app_utils.h"
25 #include "scene_board/ui_ability_lifecycle_manager.h"
26 #include "scene_board/status_bar_delegate_manager.h"
27 
28 #undef protected
29 #undef private
30 #include "app_mgr_client.h"
31 #include "process_options.h"
32 #include "session/host/include/session.h"
33 #include "session_info.h"
34 #include "startup_util.h"
35 #include "ability_manager_service.h"
36 
37 using namespace testing;
38 using namespace testing::ext;
39 
40 namespace OHOS {
41 namespace AAFwk {
42 
43 class StatusBarDelegateManagerTest : public testing::Test {
44 public:
45     static void SetUpTestCase();
46     static void TearDownTestCase();
47     void SetUp() override;
48     void TearDown() override;
49 };
50 
SetUpTestCase()51 void StatusBarDelegateManagerTest::SetUpTestCase() {}
52 
TearDownTestCase()53 void StatusBarDelegateManagerTest::TearDownTestCase() {}
54 
SetUp()55 void StatusBarDelegateManagerTest::SetUp() {}
56 
TearDown()57 void StatusBarDelegateManagerTest::TearDown() {}
58 
59 
60 /**
61  * @tc.name: StatusBarDelegateManager_IsCallerInStatusBar_0100
62  * @tc.desc: IsCallerInStatusBar
63  * @tc.type: FUNC
64  */
65 HWTEST_F(StatusBarDelegateManagerTest, IsCallerInStatusBar_0100, TestSize.Level1)
66 {
67     std::shared_ptr<StatusBarDelegateManager> statusBarDelegate = std::make_shared<StatusBarDelegateManager>();
68     EXPECT_NE(statusBarDelegate, nullptr);
69     statusBarDelegate->RegisterStatusBarDelegate(nullptr);
70     statusBarDelegate->GetStatusBarDelegate();
71     bool ret = statusBarDelegate->IsCallerInStatusBar("");
72     EXPECT_EQ(ret, false);
73 }
74 
75 /**
76  * @tc.name: StatusBarDelegateManager_DoProcessAttachment_0100
77  * @tc.desc: DoProcessAttachment
78  * @tc.type: FUNC
79  */
80 HWTEST_F(StatusBarDelegateManagerTest, DoProcessAttachment_0100, TestSize.Level1)
81 {
82     std::shared_ptr<StatusBarDelegateManager> statusBarDelegate = std::make_shared<StatusBarDelegateManager>();
83     EXPECT_NE(statusBarDelegate, nullptr);
84     statusBarDelegate->RegisterStatusBarDelegate(nullptr);
85     statusBarDelegate->GetStatusBarDelegate();
86     bool ret = statusBarDelegate->IsCallerInStatusBar("");
87     EXPECT_EQ(ret, false);
88     std::shared_ptr<AbilityRecord> abilityRecord;
89     int32_t attach_ret = statusBarDelegate->DoProcessAttachment(abilityRecord);
90     EXPECT_NE(attach_ret, ERR_OK);
91 }
92 
93 /**
94  * @tc.name: StatusBarDelegateManager_DoCallerProcessAttachment_0100
95  * @tc.desc: DoCallerProcessAttachment
96  * @tc.type: FUNC
97  */
98 HWTEST_F(StatusBarDelegateManagerTest, DoCallerProcessAttachment_0100, TestSize.Level1)
99 {
100     std::shared_ptr<StatusBarDelegateManager> statusBarDelegate = std::make_shared<StatusBarDelegateManager>();
101     EXPECT_NE(statusBarDelegate, nullptr);
102     statusBarDelegate->RegisterStatusBarDelegate(nullptr);
103     statusBarDelegate->GetStatusBarDelegate();
104     bool ret = statusBarDelegate->IsCallerInStatusBar("");
105     EXPECT_EQ(ret, false);
106     std::shared_ptr<AbilityRecord> abilityRecord;
107     int32_t attach_ret = statusBarDelegate->DoProcessAttachment(abilityRecord);
108     EXPECT_NE(attach_ret, ERR_OK);
109 }
110 
111 }  // namespace AAFwk
112 }  // namespace OHOS
113