• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "ability_context.h"
18 #include "completed_callback.h"
19 #include "context_container.h"
20 #include "element_name.h"
21 #include "event_handler.h"
22 #include "base_types.h"
23 #include "pending_want.h"
24 #include "pending_want_record.h"
25 #include "want.h"
26 #define private public
27 #define protected public
28 #include "want_agent.h"
29 #undef private
30 #undef protected
31 #include "want_agent_constant.h"
32 #include "want_agent_helper.h"
33 #include "want_agent_info.h"
34 #include "want_params.h"
35 #include "want_receiver_stub.h"
36 #include "want_sender_stub.h"
37 
38 using namespace testing::ext;
39 using namespace OHOS::AAFwk;
40 using namespace OHOS;
41 using OHOS::AppExecFwk::ElementName;
42 using namespace OHOS::AppExecFwk;
43 using namespace OHOS::AbilityRuntime::WantAgent;
44 using vector_str = std::vector<std::string>;
45 
46 namespace OHOS::AbilityRuntime::WantAgent {
47 class WantAgentTest : public testing::Test {
48 public:
WantAgentTest()49     WantAgentTest()
50     {}
~WantAgentTest()51     ~WantAgentTest()
52     {}
53     static void SetUpTestCase(void);
54     static void TearDownTestCase(void);
55     void SetUp();
56     void TearDown();
57 };
58 
SetUpTestCase(void)59 void WantAgentTest::SetUpTestCase(void)
60 {}
61 
TearDownTestCase(void)62 void WantAgentTest::TearDownTestCase(void)
63 {}
64 
SetUp(void)65 void WantAgentTest::SetUp(void)
66 {}
67 
TearDown(void)68 void WantAgentTest::TearDown(void)
69 {}
70 
71 /*
72  * @tc.number    : WantAgent_0100
73  * @tc.name      : WantAgentInfo Constructors
74  * @tc.desc      : 1.Constructors and GetPendingWant
75  */
76 HWTEST_F(WantAgentTest, WantAgent_0100, Function | MediumTest | Level1)
77 {
78     std::shared_ptr<WantAgent> wantAgent = std::make_shared<WantAgent>(nullptr);
79     EXPECT_EQ(wantAgent->GetPendingWant(), nullptr);
80 }
81 
82 /*
83  * @tc.number    : WantAgent_0200
84  * @tc.name      : WantAgentInfo Constructors
85  * @tc.desc      : 1.Constructors and GetPendingWant
86  */
87 HWTEST_F(WantAgentTest, WantAgent_0200, Function | MediumTest | Level1)
88 {
89     sptr<IWantSender> target(new (std::nothrow) PendingWantRecord());
90     std::shared_ptr<PendingWant> pendingWant = std::make_shared<PendingWant>(target);
91     std::shared_ptr<WantAgent> wantAgent = std::make_shared<WantAgent>(pendingWant);
92     EXPECT_EQ(wantAgent->GetPendingWant(), pendingWant);
93 }
94 }  // namespace OHOS::AbilityRuntime::WantAgent
95