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 "pattern_detach_callback_proxy.h"
19 #include "iremote_object_mocker.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 {
37 }
38
TearDownTestCase()39 void PatternDetachCallbackProxyTest::TearDownTestCase()
40 {
41 }
42
SetUp()43 void PatternDetachCallbackProxyTest::SetUp()
44 {
45 sptr<IRemoteObject> iRemoteObjectMocker = new (std::nothrow) IRemoteObjectMocker();
46 proxy_ = new PatternDetachCallbackProxy(iRemoteObjectMocker);
47 }
48
TearDown()49 void PatternDetachCallbackProxyTest::TearDown()
50 {
51 }
52
53 namespace {
54 /**
55 * @tc.name: OnPatternDetach
56 * @tc.desc: OnPatternDetach Test
57 * @tc.type: FUNC
58 */
59 HWTEST_F(PatternDetachCallbackProxyTest, OnPatternDetach, Function | SmallTest | Level2)
60 {
61 int32_t persisitentId = 0;
62 int resultValue = 0;
__anon5676ea630202() 63 std::function<void()> func = [this, &resultValue, persisitentId]() {
64 proxy_->OnPatternDetach(persisitentId);
65 resultValue = 1;
66 };
67 func();
68 ASSERT_EQ(resultValue, 1);
69 }
70
71 }
72 } // namespace Rosen
73 } // namespace OHOS