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
16 #include <gtest/gtest.h>
17
18 #include "iremote_object_mocker.h"
19 #include "pattern_detach_callback_proxy.h"
20
21 using namespace testing;
22 using namespace testing::ext;
23
24 namespace OHOS {
25 namespace Rosen {
26 class PatternDetachCallbackProxyTest : public testing::Test {
27 public:
28 static void SetUpTestCase();
29 static void TearDownTestCase();
30 void SetUp() override;
31 void TearDown() override;
32 sptr<PatternDetachCallbackProxy> proxy_;
33 };
34
SetUpTestCase()35 void PatternDetachCallbackProxyTest::SetUpTestCase() {}
36
TearDownTestCase()37 void PatternDetachCallbackProxyTest::TearDownTestCase() {}
38
SetUp()39 void PatternDetachCallbackProxyTest::SetUp()
40 {
41 sptr<IRemoteObject> iRemoteObjectMocker = new (std::nothrow) IRemoteObjectMocker();
42 proxy_ = new PatternDetachCallbackProxy(iRemoteObjectMocker);
43 }
44
TearDown()45 void PatternDetachCallbackProxyTest::TearDown() {}
46
47 namespace {
48 /**
49 * @tc.name: OnPatternDetach
50 * @tc.desc: OnPatternDetach Test
51 * @tc.type: FUNC
52 */
53 HWTEST_F(PatternDetachCallbackProxyTest, OnPatternDetach, Function | SmallTest | Level2)
54 {
55 int32_t persisitentId = 0;
56 int resultValue = 0;
__anon57110e6b0202() 57 std::function<void()> func = [this, &resultValue, persisitentId]() {
58 proxy_->OnPatternDetach(persisitentId);
59 resultValue = 1;
60 };
61 func();
62 ASSERT_EQ(resultValue, 1);
63 }
64
65 } // namespace
66 } // namespace Rosen
67 } // namespace OHOS