1 /*
2 * Copyright (c) 2024 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 #ifdef NOTIFICATION_SMART_REMINDER_SUPPORTED
16 #include "gtest/gtest.h"
17 #include "reminder_swing_decision_center.h"
18 #include "mock_swing_callback_stub.h"
19
20 using namespace testing::ext;
21 namespace OHOS {
22 namespace Notification {
23
24 class ReminderSwingDecisionCenterTest : public testing::Test {
25 public:
ReminderSwingDecisionCenterTest()26 ReminderSwingDecisionCenterTest()
27 {}
~ReminderSwingDecisionCenterTest()28 ~ReminderSwingDecisionCenterTest()
29 {}
SetUpTestCas(void)30 static void SetUpTestCas(void) {};
TearDownTestCase(void)31 static void TearDownTestCase(void) {};
32 void SetUp();
TearDown()33 void TearDown() {};
34 public:
35 ReminderSwingDecisionCenter reminderSwingDecisionCenter_;
36 };
37
SetUp(void)38 void ReminderSwingDecisionCenterTest::SetUp(void)
39 {
40 reminderSwingDecisionCenter_ = ReminderSwingDecisionCenter::GetInstance();
41 }
42
43 /**
44 * @tc.name: RegisterSwingCallback_00001
45 * @tc.desc: Test RegisterSwingCallback
46 * @tc.type: FUNC
47 */
48 HWTEST_F(ReminderSwingDecisionCenterTest, RegisterSwingCallback_00001, Function | SmallTest | Level1)
49 {
50 sptr<IRemoteObject> swingCallback = nullptr;
51 auto ret = reminderSwingDecisionCenter_.RegisterSwingCallback(swingCallback);
52 ASSERT_EQ(ret, (int)ERR_INVALID_VALUE);
53 }
54
55 /**
56 * @tc.name: RegisterSwingCallback_00002
57 * @tc.desc: Test RegisterSwingCallback
58 * @tc.type: FUNC
59 */
60 HWTEST_F(ReminderSwingDecisionCenterTest, RegisterSwingCallback_00002, Function | SmallTest | Level1)
61 {
62 auto swingCallbackProxy = new (std::nothrow)MockSwingCallBackStub();
63 EXPECT_NE(swingCallbackProxy, nullptr);
64 sptr<IRemoteObject> swingCallback = swingCallbackProxy->AsObject();
65 int ret = reminderSwingDecisionCenter_.RegisterSwingCallback(swingCallback);
66 ASSERT_EQ(ret, (int)ERR_OK);
67 }
68 } //namespace Notification
69 } //namespace OHOS
70 #endif